Find optimal paths for crosschain entering/exiting DeFi positions or swapping ERC20 tokens.
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.
route
do the job? route
API might be the simpler way to route your assets.
Before using the bundle API, check if route
would work using happypath.route
API produces an gas-optimized, atomic transaction between the two given positions, combining swap
, deposit
, and redeem
operations.
harvest
, borrow
, repay
.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.tx
), amountOut
(expected output), gas
(estimated), and route
(optimized path taken)."50"
= 0.5%, "300"
= 3%. Higher slippage for complex routes. Cannot use both slippage
and minAmountOut
- choose one protection method.destinationChainId
for crosschain routes. API automatically selects optimal bridges and calculates fees.route
response consists of the following fields:
tx
: Complete transaction object ready for submission. Contains the correct to
address, data
, value
, and gas
fields.amountOut
: Simulated output amount - display this to users as expected returns. This is calculated through onchain simulation.gas
: Estimated gas usage from simulation. Use this value to prevent out-of-gas failures.route
: Array showing the optimization path Enso constructed. Shows the DEX(s) Enso selected for optimal pricing.tx
object returned by the API, and use the gas
value for your transaction.to
address varies based on routing strategy, and other fields like value
and data
are precisely calculated for your specific route.gas
value estimate comes from actual simulation, out-of-gas transaction failures.amountOut
represents vault shares, not underlying tokens.
feeAmount
shows bridge costs, and route
reveals pre- and post- bridging steps.
swap
, deposit
and redeem
the route API uses"router"
strategyUpdated