The Bundle API is Enso’s multi-action orchestration engine that executes complex DeFi workflows atomically. While the Route API automatically finds optimal paths between positions, the Bundle API gives you precise control over each action in your sequence - perfect for custom strategies, multi-protocol operations, and advanced DeFi automation.
Bundle vs Route: Choose Bundle when you need specific execution order, multi-protocol interactions, or actions beyond simple swaps and deposits. Use Route when you want Enso to handle the optimization automatically.
Atomic execution: All actions in a bundle succeed together or revert entirely - no partial executions or stuck funds.
The Bundle API accepts an array of actions that execute sequentially. Each action can use outputs from previous actions, enabling complex workflows impossible with separate transactions.
Bundle supports 15+ action types across 50+ protocols. Common actions include swap, deposit, borrow, harvest, and bridge. See our Actions Reference for the complete list.
Each action requires: protocol (where to execute), action (what to do), and args (action-specific parameters). Actions execute in array order.
Dynamic Outputs
Use useOutputOfCallAt to reference previous action outputs. This enables chaining without knowing amounts in advance - critical for harvesting, compounding, and multi-step strategies.
Atomic Safety
All actions succeed or all revert. No partial executions, no stuck funds. Failed actions revert the entire bundle, protecting against incomplete workflows.
Gas Efficiency
One transaction instead of many. Bundle saves 20-40% on gas compared to separate transactions, plus reduced MEV exposure.
Not all actions work for every protocol! To check which actions are supported per protocol, use the SDK’s getActionsBySlug (GET /v1/actions/{protocol}) method.
Start with a simple two-action bundle that swaps ETH for USDC, then deposits into Aave.
The first action (route) will invoke Enso’s automatic routing engine and optimize ETH → USDC path,
This simple example is completely achievable with DeFi Swap and Routing. This is for illustrative purposes only.
What’s happening: This bundle swaps 1 ETH for USDC, then deposits exactly 2000 USDC to Aave. Note the fixed amount in the second action - we’ll make this dynamic next.
Key concept: useOutputOfCallAt: 0 references the output from the first action (index 0). This enables compound strategies without knowing reward amounts in advance.
Bridge assets and execute actions on the destination chain - all atomically.
What’s happening: The callback array executes atomically on the destination chain. If any callback action fails, the entire operation (including the bridge) reverts - true cross-chain atomicity!
Copy
Ask AI
const bundle = await ensoClient.getBundleData( { chainId: 1, // Ethereum fromAddress: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", routingStrategy: "delegate" }, [ // Convert USDC to ETH for bridge fee { protocol: "enso", action: "route", args: { tokenIn: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC tokenOut: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH amountIn: "3000000000", // 3000 USDC slippage: "100" } }, // Bridge ETH to Base with callback actions { protocol: "stargate", action: "bridge", args: { primaryAddress: "0x77b2043768d28e9c9ab44e1abfc95944bce57931", destinationChainId: 8453, // Base tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", amountIn: { useOutputOfCallAt: 0 }, receiver: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", // These actions execute on Base after bridging! callback: [ { protocol: "enso", action: "route", args: { tokenIn: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", tokenOut: "0x2Ae3F1Ec7F328C4243D5eE", // cbETH on Base amountIn: { useOutputOfCallAt: 0 }, // Use bridged ETH slippage: "200" } }, { protocol: "aave-v3", action: "deposit", args: { tokenIn: "0x2Ae3F1Ec7F328C4243D5eE", // cbETH tokenOut: "0x078f358208685046a11C85e8ad32895DED33A249", // acbETH amountIn: { useOutputOfCallAt: 0 }, // From the swap above primaryAddress: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5" } } ] } } ]);console.log('Cross-chain deposit ready:', bundle.tx);
Advanced patterns: See our Cross-chain Examples for complex multi-step callbacks, including LP positions and yield strategies.