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
Ethereum address of the wallet to send the transaction from
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Amount of tokenIn to swap in wei
Ethereum address of the token to swap from. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Ethereum address of the token to swap to. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Chain ID of the network to execute the transaction on
Routing strategy to use. In majority of cases you can use router. Use delegate with EOA when you want to specify a spender
router, delegate, router-legacy, delegate-legacy, ensowallet Flag that indicates if gained tokenOut should be sent to EOA
Ethereum address of the receiver of the tokenOut
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Ethereum address of the spender of the tokenOut. Note: you must use the delegate strategy when specifying a spender, otherwise it will be ignored.
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Minimum amount out in wei. If specified, slippage should not be specified
Slippage in basis points (1/10000), e.g. 50 = 0.50%. Takes precedence over minAmountOut argument.
"300"
Fee in basis points (1/10000) for each amountIn value. Must be in range 1-100. By default the fee is collected from amountIn on the source chain. When destinationFeeReceiver is selected for destination execution, it is collected from the delivered bridge asset instead.
The Ethereum address that receives the source-chain fee and remains the fallback when destination collection does not apply. Required if fee is provided.
"0x220866B1A2219f40e72f5c628B65D54268cA3A9D"
Optional destination-chain fee receiver. For a cross-chain route with destination execution, the requested fee is collected atomically from the delivered bridge asset on the destination chain. Otherwise feeReceiver remains the source-chain receiver.
"0x220866B1A2219f40e72f5c628B65D54268cA3A9D"
A list of swap aggregators to be ignored from consideration
A list of standards to be ignored from consideration
A list of bridges to be ignored from consideration for crosschain routes. Supported values: relay, stargate, ccip, cctp
Referral code that will be included in an on-chain event.
16^.{0,16}$Chain ID of the network to bridge to and receive tokenOut
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 Ethereum address of the receiver of any dust tokens that might be produced during the execution of actions
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
Response
Price impact in basis points, null if USD price not found
An array of the fee amount collected for each tokenIn
The minimum allowable amount out after slippage
Block number the transaction was created on
The tx object to use in ethers
The route the shortcut will use
