Garden Finance
website·Indexed 34 days ago
https://docs.garden.financeA cross-chain atomic swap protocol and API for integrating Bitcoin bridging and asset swaps into wallets, aggregators, and dApps. Garden utilizes Hashed Time Lock Contracts (HTLCs) to support secure swaps across Bitcoin, EVM, Solana, Starknet, Sui, Tron, and HyperEVM. The platform provides a comprehensive API for quotes and order management, a TypeScript SDK for React and Node.js, and specialized contract architectures for various blockchain networks.
What's inside Garden
- The Garden SDK is a collection of TypeScript packages designed to enable developers to bridge Bitcoin to EVM or non-EVM chains and vice versa. It serves as an abstraction layer over the Garden APIs, simplifying the integration of Bitcoin bridging components into decentralized applications (dApps). The SDK provides specialized support for both React (via providers and hooks) and Node.js (for server-side environments).
Overview of Garden Governance
Garden is a decentralized system governed entirely by Garden token holders. Governance involves managing tokenomics, following established decision-making processes, and participating in voting via Snapshot. Key components of the governance ecosystem include the SEED token distribution and the Gardener Pass NFT program.Overview of Garden Finance benefits
Garden provides an alternative to traditional bridge solutions with four primary advantages:
- No custody risk: Users maintain complete control of their assets throughout the process.
- Broad chain coverage: Supports trading any asset across any chain using flexible intent expression.
- Better prices: Offers competitive pricing with the potential for price improvement.
- Free option protection: Includes built-in safeguards to prevent exploitation by malicious actors.
Overview of Garden Bitcoin rails protocol
Garden is an intent-based Bitcoin rails protocol that enables trustless Bitcoin swaps in as little as 30 seconds. It operates by allowing users to express a swap intent, which is then filled by a competitive network of solvers. Settlement is handled on-chain via Hashed Time-Lock Contracts (HTLCs), ensuring that either both sides of the trade complete or neither does, maintaining user custody of funds throughout the process.Overview of HyperCore Atomic Swaps on HyperEVM
HyperCore supports atomic swaps via a modified Hashed Time Lock Contract (HTLC) deployed on HyperEVM. Unlike standard HTLCs, this implementation uses the CoreWriter precompile to automatically settle funds directly into a user's HyperCore spot account upon redemption or refund, removing the need for a separate bridge or withdrawal step.
Critical Architecture Note: The HTLC contract lives entirely on HyperEVM, not on HyperCore. HyperCore is supported as a chain through Garden's integration with HyperEVM.
Overview of Tron Atomic Swap Architecture
Garden implements atomic swaps on Tron using EVM-compatible Hashed Time Lock Contracts (HTLCs). The implementation is identical to the EVM guide but is currently restricted to TRC20 tokens; native TRX is not supported. The swap lifecycle is managed through four primary operations: Initiate, Redeem, Refund, and Instant Refund.Understand Garden's intent-based cross-chain interactions
Garden utilizes an intent-based approach for on-chain interactions. Unlike traditional transactions—which require users to sign a rigid sequence of machine-readable instructions—intents allow users to define a desired outcome (an 'intent') in a structured message. For Garden, this involves specifying parameters such as assets, chains, and amounts for a swap, abstracting away the granular execution steps to make the process more intuitive and efficient.Understand Cross-chain Coincidence of Wants (xCoW) in Garden
Garden's xCoW mechanism matches complementary user intents to optimize cross-chain trades. By connecting users with opposing needs, it reduces reliance on external liquidity providers, improves pricing, and increases transaction efficiency. Notably, Garden extends this capability to include Proof-of-Work (PoW) chains like Bitcoin, enabling trustless interoperability across diverse network types.Implement Bitcoin Atomic Swaps using HTLCs
Atomic swaps on Bitcoin are implemented using scripts executed when UTXOs are spent, rather than traditional contract functions. The logic is centered around a Hashed Time-Lock Contract (HTLC) which ensures funds are locked until specific conditions (secret revelation or time expiry) are met.type HTLC struct { // X-only pubkey of the initiator InitiatorPubkey []byte // X-only pubkey of the redeemer RedeemerPubkey []byte // sha256(preimage) SecretHash []byte // expiry in blocks Timelock uint32 }Scale chain coverage using intents-based liquidity
Garden supports a wide range of blockchains by utilizing an intents-based model instead of traditional liquidity pools. Unlike traditional bridges that require maintaining idle capital in pools on every supported chain, Garden provides liquidity on demand at the moment of execution. This removes capital constraints and reduces the operational overhead required to add support for new chains.Retrieve a specific order by its ID
Use theGET /orders/{order}endpoint to retrieve detailed information about a specific order. You must provide the unique order ID as a path parameter.curl -X GET "https://garden.finance/orders/{order}"Understand Garden affiliate fee structure
Garden allows partners to charge an affiliate fee for swaps initiated via SDK or API. These fees are charged in addition to protocol and solver fees. Fees are expressed in basis points (bps), where 1 bps = 0.01% (e.g., 30 bps = 0.3% of the source asset value). Rewards can be earned in USDC or cbBTC on supported chains. Fees can be sent to a single address or split across multiple addresses and assets. Collected fees are distributed to specified addresses at the end of each week.