diff --git a/docusaurus.config.js b/docusaurus.config.js index 8cc1219e..88114c9f 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -13,7 +13,7 @@ const hasTypesense = /** @type {import('@docusaurus/types').Config} */ const config = { title: "Cadence", - tagline: "The Best Programming Language for Smart Contracts", + tagline: "The Best Programming Language for Consumer DeFi", favicon: "favicon.ico", // Set the production url of your site here diff --git a/src/css/custom.css b/src/css/custom.css index 8c28c6be..2b84b706 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -166,6 +166,7 @@ code { .content-wrapper { max-width: 80rem; + margin: 0 auto; padding-left: max(env(safe-area-inset-left), 1.5rem); padding-right: max(env(safe-area-inset-right), 1.5rem); } @@ -284,8 +285,14 @@ h2 strong { .code { border-radius: 1rem; - font-size: 0.9rem !important; + font-size: 0.73rem !important; box-shadow: 1px 2px 4px rgba(45, 45, 45, 0.4); + margin: 0 !important; +} + +.code pre { + margin: 0 !important; + padding: 1rem !important; } h3 { @@ -477,9 +484,9 @@ footer .license { } .feature { - gap: 6rem; + gap: 3rem; flex-direction: row; - align-items: center; + align-items: flex-start; } .feature.alternate { diff --git a/src/pages/index.js b/src/pages/index.js index f422f142..0385a006 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,11 +1,10 @@ -import React from 'react'; +import React, { useRef, useLayoutEffect, useState } from 'react'; import clsx from 'clsx'; import Head from 'next/head'; import Link from '@docusaurus/Link'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Layout from '@theme/Layout'; import HomepageFeatures from '@site/src/components/HomepageFeatures'; -import { FcLock, FcIdea, FcChargeBattery, FcMindMap } from 'react-icons/fc'; import { HiArrowRight, HiArrowSmDown } from 'react-icons/hi'; import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter'; import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism'; @@ -19,34 +18,107 @@ import learnAnimation from "./learn.json"; import styles from './index.module.css'; import Logo from '@site/static/img/logo.svg'; -const example = `access(all) -resource NFT { +const example = `import "DeFiActions" +import "FlowToken" +import "FlowTransactionScheduler" +import "FlowTransactionSchedulerUtils" +import "IncrementFiStakingConnectors" +import "IncrementFiPoolLiquidityConnectors" +import "SwapConnectors" - access(all) - fun greet(): String { - return "I'm NFT #" - .concat(self.uuid.toString()) - } -} +// Schedule daily yield compounding with Flow Actions +transaction(stakingPoolId: UInt64, executionEffort: UInt64) { + prepare(signer: auth(Storage, Capabilities) &Account) { + + // Compose DeFi actions atomically: Claim → Zap → Restake + let operationID = DeFiActions.createUniqueIdentifier() + + // Source: Claim staking rewards + let rewardsSource = IncrementFiStakingConnectors.PoolRewardsSource( + userCertificate: signer.capabilities.storage + .issue<&StakingPool>(/storage/userCertificate), + pid: stakingPoolId, + uniqueID: operationID + ) + + // Swapper: Convert single reward token → LP tokens + let zapper = IncrementFiPoolLiquidityConnectors.Zapper( + token0Type: Type<@FlowToken.Vault>(), + token1Type: Type<@RewardToken.Vault>(), + stableMode: false, + uniqueID: operationID + ) + + // Compose: Wrap rewards source with zapper + let lpSource = SwapConnectors.SwapSource( + swapper: zapper, + source: rewardsSource, + uniqueID: operationID + ) + + // Sink: Restake LP tokens back into pool + let poolSink = IncrementFiStakingConnectors.PoolSink( + pid: stakingPoolId, + staker: signer.address, + uniqueID: operationID + ) -access(all) -fun main(): String { - let nft <- create NFT() - let greeting = nft.greet() - destroy nft - return greeting + // Setup transaction scheduler manager + if signer.storage.borrow<&AnyResource>( + from: FlowTransactionSchedulerUtils.managerStoragePath) == nil { + let manager <- FlowTransactionSchedulerUtils.createManager() + signer.storage.save(<-manager, to: FlowTransactionSchedulerUtils.managerStoragePath) + } + + let manager = signer.storage.borrow( + from: FlowTransactionSchedulerUtils.managerStoragePath + ) ?? panic("Could not borrow Manager") + + // Estimate and pay fees + let estimate = FlowTransactionScheduler.estimate( + data: nil, + timestamp: nextExecution, + priority: priority, + executionEffort: executionEffort + ) + + let feeVault = signer.storage.borrow(from: /storage/flowTokenVault)! + let fees <- feeVault.withdraw(amount: estimate.flowFee ?? 0.0) as! @FlowToken.Vault + + // Get handler capability + let handlerCap = signer.capabilities.storage + .issue(/storage/RestakeHandler) + + // Schedule recurring execution + manager.schedule( + handlerCap: handlerCap, + data: nil, + timestamp: getCurrentBlock().timestamp + 86400.0, // 24 hours + priority: FlowTransactionScheduler.Priority.Medium, + executionEffort: executionEffort, + fees: <-fees + ) + } }` function cadence(Prism) { Prism.languages.cadence = { + comment: { + pattern: /\/\/.*/, + greedy: true + }, string: { pattern: /"[^"]*"/, greedy: true }, keyword: - /\b(?:access|all|fun|resource|create|let|destroy|return|self)\b/, + /\b(?:access|all|fun|resource|create|let|destroy|return|self|var|init|from|import|transaction|prepare|auth|Storage|Account|true|false)\b/, 'class-name': /\b[A-Z][A-Za-z_\d]*\b/, function: /\b[a-z_]\w*(?=\s*\()/i, + number: /\b\d+\.?\d*\b/, } } @@ -71,66 +143,137 @@ function HomepageHeader() { export default function Home() { const {siteConfig} = useDocusaurusContext(); + const leftColumnRef = useRef(null); + const [codeBoxHeight, setCodeBoxHeight] = useState(null); + + useLayoutEffect(() => { + const updateHeight = () => { + if (leftColumnRef.current) { + // Use requestAnimationFrame to ensure layout is complete + requestAnimationFrame(() => { + if (leftColumnRef.current) { + setCodeBoxHeight(leftColumnRef.current.offsetHeight); + } + }); + } + }; + + // Initial measurement + updateHeight(); + + // Also measure after a small delay to catch any async layout changes + const timeoutId = setTimeout(updateHeight, 0); + + window.addEventListener('resize', updateHeight); + return () => { + clearTimeout(timeoutId); + window.removeEventListener('resize', updateHeight); + }; + }, []); + return ( + title={`${siteConfig.title} - Build the Future of Consumer DeFi`} + description="Ship Consumer DeFi products faster. Cadence delivers the security, automation, and tooling to build financial apps that millions trust.">
-
-
+
+
Cadence

- Forge the future of decentralized apps. + Build the future of Consumer DeFi.
- Unleash utility, composability, + The safest, most composable language
- and safety in smart contracts. + for financial applications that reach millions.

Get started + +
+ +
-
- {example} +
+
+ {example} +
-
+

- Together, we are working to build a programming language to empower everyone to push the boundaries of smart contracts and on-chain logic. + Cadence is powering the next generation of Consumer DeFi, bringing institutional-grade security and consumer-friendly experiences to financial applications that serve millions.

-
- -
+
    +
  • User assets stay in user accounts, delivering better-than-fintech security without centralized risk.
  • +
  • Atomic transactions create seamless, one-click experiences that feel native to everyday users.
  • +
  • Always-on automation runs 24/7/365, enabling recurring payments and strategies that work while you sleep.
  • +
  • Real-time settlement in seconds, not days, making DeFi faster than traditional financial rails.
  • +
  • Open and composable by design, enabling global financial apps that work together seamlessly.
  • +

- Announced in 2020, the Cadence programming language introduced a new paradigm of resource-oriented programming. - By leveraging the power of resources, Cadence brings exciting new ideas to the world of smart contracts. - Cadence makes it easy to write maximally on-chain smart contracts that are secure by design. - Our goals for Cadence are to enable ambitious developers to make daring & complex ideas possible while making them easy, - fun & developer-friendly, as well as safe and secure. + Cadence pioneers resource-oriented programming—designed specifically to handle valuable digital assets. + Unlike traditional smart contract languages where assets are piled in centralized contract storage, Cadence ensures user assets stay in their own accounts. The result is dramatically reduced attack surfaces and the elimination of entire classes of DeFi vulnerabilities.

- Join us in shaping the future of blockchain, one line of code at a time. Get started today! + With features like Flow Actions and Scheduled Transactions, developers can build sophisticated DeFi experiences that feel native to their users. +

+

+ Ready to build the future of finance? Get started today.

@@ -139,103 +282,77 @@ export default function Home() {
-
+
-

Safety by design

+

Complex DeFi Operations, Simple User Experiences

- Cadence provides security and safety guarantees that greatly simplify the development of secure smart contracts. + In Cadence, transactions are first-class citizens. Write customized transactions that interact with multiple contracts atomically, either all succeed or all fail. No need for intermediary contracts or complex multi-call patterns.

- As smart contracts often deal with valuable assets, Cadence provides the resource-oriented programming paradigm, - which guarantees that assets can only exist in one location at a time, cannot be copied, and cannot be accidentally lost or deleted. + Check staking positions, claim rewards, swap tokens, and restake all in one operation by writing a transaction.

- Cadence includes several language features that prevent entire classes of bugs via a strong static type system, design by contract, - and capability-based access control. + Cadence scripts provide native data availability, querying on-chain data directly without external indexers. Build sophisticated analytics and experiences other chains cannot offer.

- These security and safety features allow smart contract developers to focus on the business logic of their contract, - instead of preventing security footguns and attacks. + This flexibility makes Consumer DeFi possible. Complex operations feel simple while maintaining security and atomicity.

- +
-
+
-

Built for permissionless composability

+

Built for DeFi Security

- Resources are stored directly in users' accounts, - and can flow freely between contracts. They can be passed as arguments to functions, returned from functions, or even combined in arbitrary data structures. - This makes implementing business logic easier and promotes the reuse of existing logic. + In DeFi, security isn't optional. The resource-oriented programming paradigm in Cadence fundamentally changes how assets are stored and protected. User assets stay in user accounts, not in contract storage.

- Interfaces enable interoperability of contracts and resources allowing - developers to integrate their applications into existing experiences easily. + Resources guarantee assets can only exist in one location, cannot be copied, and cannot be accidentally lost. Combined with a strong static type system, enforced business logic, and capability-based access control, Cadence eliminates entire classes of DeFi vulnerabilities including reentrancy attacks.

- In addition, the attachments feature - of Cadence allows developers to extend existing types with new functionality and data, - without requiring the original author of the type to plan or account for the intended behavior. + Build financial applications with confidence. Cadence provides safety guarantees that let you focus on creating value, not patching vulnerabilities.

- +
-
+
-

Easy to learn, build and ship

+

Composable DeFi Primitives

- Cadence's syntax is inspired by popular modern general-purpose programming languages like Swift, Kotlin, and Rust, - so developers will find the syntax and the semantics familiar. - Practical tooling, documentation, - and examples enable developers to start creating programs quickly and effectively. + Compose powerful primitives to build sophisticated financial products. Resources stored in users' accounts can flow freely between contracts, which allows seamless integration of lending, swapping, and yield strategies in a single user experience.

-
-
- -
-
- -
-
-

Powerful transactions for mainstream experiences

- In Cadence, a transaction has a lot more flexibility and the power to perform multiple operations with a single transaction, - as opposed to multiple, separate smart contract calls like in other languages. - It allows complex, multi-step interactions to be one-click user experiences. + Flow Actions allow you to bundle complex multi-step DeFi operations into one-click experiences. + {" "}Scheduled Transactions turn on native onchain automation. Recurring payments, DCA strategies, and portfolio rebalancing execute directly from user wallets, no backend servers required.

- Developers can easily batch multiple transactions, turning complicated user journeys into a few clicks. - For example, imagine approving and completing the listing of an NFT from a new collection in the same transaction, - or adding and sending funds with just one approval. + Interfaces and attachments make protocols truly composable. + Build new DeFi functionality on top of any token standard to create composable building blocks that work together seamlessly.

- +
-

🧰 Best-in-class tooling

+

Learn the Best Language for Consumer DeFi

- Cadence comes with great IDE support. Use your favorite editor, - like Visual Studio Code, - Vim or Emacs, to get diagnostics, code completion, refactoring support, and more. + Cadence is purpose-built for consumer DeFi applications. Its intuitive syntax and resource-oriented design make it the ideal language for building financial products that millions of users trust.

- To further enhance the developer experience, there is also a - native testing framework, which allows developers to write - unit & integration tests using Cadence. + Learn a language designed from the ground up by smart contract developers for smart contract developers. With comprehensive documentation, powerful testing frameworks, and a supportive community, you'll be building production-ready consumer DeFi apps faster than with traditional smart contract languages.

- +