Use this file to discover all available pages before exploring further.
The Route API is Enso’s crosschain automated pathfinding engine that calculates optimal multi-step paths between any two DeFi positions - tokenIn and tokenOut. Whether you’re swapping tokens, entering yield vaults, or moving assets across chains, the Route API handles the complex routing logic automatically.
Would 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.
Routing vs Bundling: The Route API excels at single-path operations where you want Enso to determine the optimal route automatically. For custom multi-step workflows where you need precise control over each action, use the Bundle API instead.When to use routing: Token swaps with optimal pricing, vault entries/exits, position migrations between protocols, crosschain transfers, and any scenario where you want automated route optimization rather than manually specifying each step.
Specify any tokenIn and tokenOut - ERC20 tokens, LP tokens, vault shares, or yield positions. The Route API automatically finds the optimal path between any two DeFi positions across protocols and chains.
Response
Response contains a complete transaction object ready to sign (tx), amountOut (expected output), gas (estimated), and route (optimized path taken).
Slippage Control
Set slippage in basis points: "50" = 0.5%, "300" = 3%. Higher slippage for complex routes. Cannot use both slippage and minAmountOut - choose one protection method.
Crosschain Operations
Add destinationChainId for crosschain routes. API automatically selects optimal bridges and calculates fees.
The following examples progress from simple token swaps to complex crosschain vault interactions. Each example builds on concepts from previous ones, demonstrating how the Route API handles increasingly sophisticated DeFi operations automatically.
You can interact with the API using Enso SDK or directly via a REST API.You can explore Enso through API Sandbox.To install the SDK run the following command:
npm i @ensofinance/sdkpnpm i @ensofinance/sdkyarn add @ensofinance/sdk
Enter a Yearn vault directly from ETH, automatically handling any intermediate swaps and vault deposits.
SDK
// ETH → yvWETH (Yearn WETH vault) with 1% slippageconst vaultEntry = await ensoClient.getRouteData({ fromAddress, receiver, spender, chainId: 1, amountIn: ["1000000000000000000"], // 1 ETH tokenIn: ["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"], // ETH tokenOut: ["0xa258c4606ca8206d8aa700ce2143d7db854d168c"], // yvWETH slippage: "100", // 1% routingStrategy: "delegate"});console.log('yvWETH shares received:', vaultEntry.amountOut);console.log('Route complexity:', vaultEntry.route.length, 'steps');// Route typically: ETH → WETH → deposit to Yearn vault
What’s happening: The router automatically wraps ETH to WETH, then deposits into the Yearn vault. The amountOut represents vault shares, not underlying tokens.
Complex routing: This involves exiting one protocol (Yearn) and entering another (Aave). The route array will show multiple steps including withdrawal, potential swaps, and final deposit.
Move assets between blockchains using Enso’s integrated bridge routing.
SDK
// USDC from Ethereum → USDC.e on Plume Networkconst crossChain = await ensoClient.getRouteData({ fromAddress, receiver, spender, chainId: 1, // Ethereum destinationChainId: 98866, // Plume Network amountIn: ["1000000000"], // 1,000 USDC tokenIn: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], // USDC on Ethereum tokenOut: ["0x78adD880A697070c1e765Ac44D65323a0DcCE913"], // USDC.e on Plume slippage: "300", // 3% (higher for crosschain) routingStrategy: "delegate"});console.log('USDC.e on Plume:', crossChain.amountOut);console.log('Bridge fee:', crossChain.feeAmount);console.log('Crosschain complexity:', crossChain.route.length, 'steps');
Crosschain considerations: Higher slippage accounts for bridge fees and potential price differences. The feeAmount shows bridge costs, and route reveals pre- and post- bridging steps.
Bundle API: When you need custom multi-step logic or want to orchestrate specific actions in sequence, or you need actions beyond swap, deposit and redeem the route API uses
Nontokenized Positions: For lending positions that don’t issue tokens (like Aave debt positions)
Approval Endpoint: Managing token permissions when using "router" strategy