route
and bundle
API operate in crosschain mode. For custom bundles, use the bridge
action to facilitate cross-chain token transfers using Stargate.
For example: bridge assets to chains where protocols exist, execute operations such as minting, then optionally bridge results back to your origin chain and deposit them in a yield-bearing position.
Quick Start
Simple cross-chain token transfer Try this route → To simply bridge an asset, use theroute
API with automatic route optimization from input and output token/chain pairs.
SDK
Core Concepts
Bridging
Crosschain routing uses Stargate and LayerZero for bridging assets.
The
bridge
action’s parameter primaryAddress
must reference an appropriate pool contract, exposed by the layerZero/pool
API.Native Drop
Parent bridge calls calculate gas fees required for all child bridge operations and include these costs in the initial transaction fee using LayerZero’s native drop feature.
Post-Bridge Execution
Callback arrays of Enso Actions execute on the destination chain after bridge completion. All actions execute atomically.
When to use Route vs Bundle API?
Use Route API for: Limitations: Cannot handle custom post-bridge logic or multi-step protocols interactions Use Bundle API for:- crosschain position minting
- crosschain yield strategies
- Limitations: Single callback sequence with up to 10 chained actions
Examples
1. Simple Cross-Chain Swap
Use Route API for basic cross-chain operations with automatic pathfinding.SDK
2. Crosschain Vault Zap
In this example, we’ll bridge ETH from Ethereum to zap it to a Ether.fiweETH
vault on Base.
Try this route →
3. Cross-Chain Position Minting
Crosschain routing enables you to mint positions on different chains and bridge them back. In this example, we’ll bridge USDC from Berachain to Ethereum, mint e-rUSD using Reservoir protocol, then bridge rUSD back to Berachain. About Reservoir: Reservoir is a stablecoin protocol that mints rUSD (a USD-pegged stablecoin) by accepting USDC as collateral on Ethereum mainnet.Use the GET
layerzero/pool
API to find the correct pool address and use it as the primaryAddress
for stargate.bridge
operation.Understanding callbacks executionCallbacks execute on the destination chain after the bridge completes, but they’re not separate transactions. The bridge operation includes encoded instructions that execute atomically using Enso’s crosschain execution engine. This means:
- Atomic Safety: If any callback action fails, the entire bridge operation reverts. Your funds never get stuck in an intermediate state between chains.
- Gas Management: The initial transaction on the source chain calculates and pays for all destination chain gas costs using LayerZero’s native drop feature. You don’t need to hold native tokens on every destination chain.
- Output Chaining: Callbacks can reference outputs from previous callback actions using useOutputOfCallAt, enabling complex multi-step workflows that adapt to actual bridged amounts rather than fixed values.
mintOnBeraFromMainnet.ts
4. Crosschain Yield Strategy
Nested callbacks enable multi-hop workflows, allowing operations that span multiple chains where different protocols exist. In this example, we’ll do an Euler deposit of rUSD tokens minted on a different chain. The user starts with USDC on Berachain and ends with yield-generating vault shares in a single transaction. Bridge USDC from Berachain to Ethereum, mint e-rUSD using Reservoir protocol, bridge e-rUSD back to Berachain, then deposit into Euler vault.mintOnBeraDepositOnMainnet.ts
Reference
Bridge Action Parameters
Parameter | Description | Required |
---|---|---|
primaryAddress | Stargate pool contract address for the source chain | Yes |
destinationChainId | Target blockchain network ID | Yes |
tokenIn | Token address to bridge from source chain | Yes |
amountIn | Amount to bridge (with full decimals) or reference to previous action output | Yes |
receiver | Address to receive bridged tokens on destination chain | Yes |
callback | Array of actions to execute on destination chain after bridging | No |
Callback Requirements
Critical: All callback sequences must begin with a balance check action to verify the bridged token amount on the destination chain.
- First action must be:
{ protocol: "enso", action: "balance", args: { token: "bridged_token_address" } }
- Reference previous outputs: Use
{ useOutputOfCallAt: index }
to chain callback actions - Atomic execution: All callback actions succeed or the entire bridge operation reverts
- Nested callbacks: Bridge actions within callbacks enable multi-hop workflows
Supported Chains and Tokens
Use the GETlayerzero/pool
API to find the correct pool address and use it as the primaryAddress
for stargate.bridge
operation.
Updated