arrows-rotateDeFi and Swap Routing

Find optimal paths for crosschain entering/exiting DeFi positions or swapping ERC20 tokens.

Getting Started with Route API

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.

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.

The route API produces an gas-optimized, atomic transaction between the two given positions, combining swap, deposit, and redeem operations.

Use the Bundle APIarrow-up-right if you need other actions Enso supportsarrow-up-right, such as harvest, borrow, repay.

arrow-up-rightSample requests

  • Token Swap

  • Vault Entry (Zap)

  • Crosschain swap

  • Crosschain Vault Zap

CopyAsk AI

const route = await ensoClient.getRouteData({
  fromAddress: "0x...",
  chainId: 1,
  tokenIn: ["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"], // ETH
  tokenOut: ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], // USDC
  amountIn: ["1000000000000000000"], // 1 ETH
  slippage: "50", // 0.5%
  routingStrategy: "delegate"
});

await wallet.sendTransaction(route.tx);

Last updated