v1

latestOpenAPI 3.0.02026-07-26278284.4 KB
DeFi Shortcuts

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. <Tip>To enter a non-tokenized position, use the GET /shortcuts/route/nontokenized.</Tip>

post/api/v1/shortcuts/route

Request body

chainIdnumber

Chain ID of the network to execute the transaction on

fromAddressstring required

Ethereum address of the wallet to send the transaction from

amountInstring[] required

Amount of tokenIn to swap in wei

tokenInstring[] required

Ethereum address of the token to swap from. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

tokenOutstring[] required

Ethereum address of the token to swap to. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

routingStrategy'router' | 'delegate' | 'router-legacy' | 'delegate-legacy' | 'ensowallet' nullable

Routing strategy to use. In majority of cases you can use router. Use delegate with EOA when you want to specify a spender

toEoaboolean nullable

Flag that indicates if gained tokenOut should be sent to EOA

receiverstring

Ethereum address of the receiver of the tokenOut

spenderstring

Ethereum address of the spender of the tokenOut. Note: you must use the delegate strategy when specifying a spender, otherwise it will be ignored.

minAmountOutstring[]

Minimum amount out in wei. If specified, slippage should not be specified

slippagestring

Slippage in basis points (1/10000), e.g. 50 = 0.50%. Takes precedence over minAmountOut argument.

feestring[]

Fee in basis points (1/10000) for each amountIn value, e.g. 50 = 0.50%. Must be in range 0-100. If specified, this percentage of each amountIn value will be sent to feeReceiver

feeReceiverstring

The Ethereum address that will receive the collected fee. Required if fee is provided

ignoreAggregatorsstring[] nullable

A list of swap aggregators to be ignored from consideration

ignoreStandardsstring[] nullable

A list of standards to be ignored from consideration

ignoreBridgesstring[] nullable

A list of bridges to be ignored from consideration for crosschain routes. Supported values: relay, stargate, ccip, cctp

variableEstimatesobject required
referralCodestring

Referral code that will be included in an on-chain event.

destinationChainIdnumber

Chain ID of the network to bridge to and receive tokenOut

refundReceiverstring

Ethereum address of the receiver of any dust tokens that might be produced during the execution of actions

Example request

{
  "fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  "amountIn": [
    "1000000000000000000"
  ],
  "tokenIn": [
    "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
  ],
  "tokenOut": [
    "0x6b175474e89094c44da98b954eedeac495271d0f"
  ],
  "receiver": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  "spender": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  "slippage": "300",
  "fee": [
    "100"
  ],
  "feeReceiver": "0x220866B1A2219f40e72f5c628B65D54268cA3A9D",
  "refundReceiver": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
}

Response

gasstring required
amountOutstring required
priceImpactnumber nullable required

Price impact in basis points, null if USD price not found

feeAmountstring[] required

An array of the fee amount collected for each tokenIn

minAmountOutstring required

The minimum allowable amount out after slippage

createdAtnumber required

Block number the transaction was created on

ensoFeeAmountstring[] required