Optimal route between two tokens
Calculates optimal transaction with the best route between two tokens, which may involve several actions that interact with various DeFi protocols. This single call already quotes internally and returns executable calldata along with amountOut and gas, so there is no separate quote step to call beforehand.
Body
Chain ID of the network to execute the transaction on
Ethereum address of the wallet to send the transaction from
Amount of tokenIn to swap in wei
Ethereum address of the token to swap from. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Destination token addresses. Solana mints are case-sensitive; native SOL uses 11111111111111111111111111111111.
Routing strategy to use
ensowallet-v2, router, delegate, router-legacy, delegate-legacy Controls how quote is built based on execution mode
user, backend Flag that indicates if gained tokenOut should be sent to EOA
Include point-in-time source-chain transaction cost estimates in native units and USD, plus USD values for reported bridge fees
Route a cross-chain request through an intent address on the destination chain. The bridge delivers to that address, then a keeper runs the destination route and sends tokenOut to the receiver. When omitted, intents are used if both chains support them. Set to false to use a bridge callback instead. Ignored for same-chain routes.
Ethereum address of the spender of the tokenIn
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Ethereum address of the receiver of any dust tokens produced during execution. Required for routes to Solana.
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Minimum amount out in wei. If specified, slippage should not be specified
Slippage in basis points (1/10000). e.g. 50 = 0.50%. If specified, minAmountOut should not be specified
"300"
A list of swap aggregators to be ignored from consideration
0x, 1inch, openocean, kyberswap, native, paraswap, bebop, barter, sushiswap-router, ooga-booga, renegade, uniswap, rooster, wowmax, grapher, hyperbloom, hyperswap, hyperflow, fly, eisen, nordstern, everlong, bitget, akka A list of standards to be ignored from consideration
A list of bridges to be ignored from consideration
cctp, stargate, ccip, relay, layerzero-teller, arbitrum-native, mayan Controls cross-chain route complexity. direct uses only a bridge, source allows routing before the bridge, destination allows routing after the bridge, sourceOrDestination allows routing on either chain but not both, and full allows routing on both chains
direct, source, destination, sourceOrDestination, full Latency/quality trade-off for pathfinding and aggregator querying. light returns fastest over a reduced search space (short aggregator wait with early return once two usable quotes arrive, fewer candidate paths, no destination-side bridge routing), medium waits the full short window over the full search space, high is the default balanced behavior, and max queries all aggregators in parallel with an extended wait for best execution (higher CU cost)
light, medium, high, max Referral code that will be included in an on-chain event.
16"0123456789ABCDEF"
Destination recipient. Required for cross-chain routes; Solana uses a case-sensitive Base58 address.
Chain ID of the network to bridge to and receive tokenOut
Allow async redeems, where tokenOut is paid after the transaction. An async route returns amountOut, minAmountOut and priceImpact as null and describes the payout in async. Cannot be combined with minAmountOut or useIntentAddress, intents do not support async redeems.
Response
Null for async routes, see async.estimatedAmountOut
Block number the transaction was created on
The tx object to use in ethers
The route the shortcut will use
Block number the quote was simulated against
Price impact in basis points, null if USD price not found
An array of the fee amount collected for each tokenIn
Present when the route is an async redeem (allowAsync=true). amountOut, minAmountOut and priceImpact are null because nothing is delivered in the transaction, the estimates are in async
The minimum allowable amount out after slippage
Ordered route segments with the underlying standard actions. For inspection only; do not use it to build the transaction.
The ERC-4337 user operation object
Transactions that may need to be executed before the main shortcut transaction. Token approvals should be skipped when the current allowance is already sufficient.
Estimated bridging durations when applicable
Unix timestamp (seconds) after which this quote expires. Transactions submitted after this time may revert. On an intent route a late transaction still bridges, but the bridged token is refunded on the destination chain instead of being swapped.
Point-in-time lower-bound estimate of mandatory source-chain transaction fees in the native token smallest unit. Excludes priority fees, transaction value, bridge fees, and destination execution.
Decimal string USD value of transactionCost. Null when the native-token price or source-chain fee estimate is unavailable.
