← Protocols
Odos
01Description

DEX aggregator with a Smart Order Routing (SOR) engine that supports multi-token-in / multi-token-out swaps in a single transaction across major EVM chains.

02Best for
  • 01multi-input or multi-output swaps
  • 02portfolio rebalancing in one tx
  • 03best-price EVM aggregation
  • 04complex routing across many DEXs
03Install
  • # Odos is REST-first — no official JS SDK. Use fetch/axios.
  • pnpm add axios viem
04Environment variables
VariableScopeDescription
ODOS_API_KEYServerOptional API key for higher rate limits / commercial usage on the Odos API. The public endpoint works keyless for low-volume usage.
05Prompt snippet
Use Odos for multi-token EVM aggregation via REST. Two-step flow: (1) `POST https://api.odos.xyz/sor/quote/v2` with `{ chainId, inputTokens: [{ tokenAddress, amount }], outputTokens: [{ tokenAddress, proportion }], slippageLimitPercent, userAddr }` to get a `pathId` and quote. (2) `POST https://api.odos.xyz/sor/assemble` with `{ userAddr, pathId, simulate: true }` to receive ready-to-send `transaction.{to, data, value, gas}`. Send the calldata as-is via viem/ethers — never modify the returned data. For multi-output swaps, set `proportion` per output token so they sum to 1.0.
06Gotchas
  • Never modify the calldata returned by `/sor/assemble` — the contract verifies an internal hash and any tweak (gas tip, value, calldata bytes) will revert or burn tokens with no recourse.
  • Slippage is set on the quote (`slippageLimitPercent`) and baked into the assembled tx — you cannot raise it later without re-quoting.
  • Multi-output swaps require `proportion` values that sum to exactly 1.0 across all `outputTokens`; rounding errors in float arithmetic will be rejected.
  • Quotes have a short TTL — assemble and submit within the validity window or the path may become stale and the swap reverts.
  • Chain coverage is EVM-only and limited to Odos-supported networks (Ethereum, Arbitrum, Optimism, Base, Polygon, BNB, Avalanche, etc.) — verify `chainId` is supported before quoting.
  • Token approvals must target the Odos Router on each chain (different address per chain) — fetch the router address from `/info/router/v2/{chainId}` rather than hardcoding.
07Alternatives