Would
The
route
do the job? The
route
API might be the simpler way to route your assets.
Before using the bundle API, check if route
would work using happypath.
Quick Start
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.Core Concepts
Action Structure
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.Sample Workflows
Request Structure
Each action in the bundle array follows this structure:primaryAddress
: Protocol’s main contract (pool, vault, router)useOutputOfCallAt
: Reference output from action at index Nreceiver
: Optional override for output recipientslippage
: Basis points for price protection (100 = 1%)
Examples
0. Install & Authenticate
You can interact with the API using Enso SDK or directly via REST API.npm
SDK
1. Basic Bundle: Swap and Deposit
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.
SDK
2. Dynamic Chaining: Harvest and Compound
UseuseOutputOfCallAt
to chain actions dynamically.
SDK
useOutputOfCallAt: 0
references the output from the first action (index 0). This enables compound strategies without knowing reward amounts in advance.
4. Leveraged Position
Create a 2x leveraged position by borrowing against deposited collateral.SDK
5. Cross-chain Bundle with Callbacks
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!SDK
Utility Actions
Bundle API includes helper actions for safety and flow control:Balance Check
Get token balance mid-bundle:
Slippage Protection
Apply slippage to any output:
Minimum Output
Enforce minimum amounts:
Fee Collection
Take protocol fees:
Next Steps
From here, you can explore other resources:- Actions Reference: Complete list of supported actions and protocols
- Routing Strategies: Overview of
delegate
androuter
strategies for action execution**.** - Shortcuts Library: 20+ production-ready bundle examples
- Route API: When automatic routing is better than custom bundles