v1

latestOpenAPI 3.0.02026-07-136017.3 KB
swap

generates a swap

By passing in the appropriate options, you can generate a swap transaction

get/swap/v7/{chainId}

Path parameters

chainIdnumber required

chainId

Query parameters

referrerstring

referrer

tokenInstring required

input token address

tokenOutstring required

output token address

senderstring required

sender of transaction

recipientstring

recipient of tokens, defaults to sender

amountinteger required

input token amount

feenumber

amount of the fee, for example 0.0025 (0.25%)

feeReceiverstring

if fee > 0 then receiver of the fee

feeBy'input' | 'output'

if fee > 0 then which token to take fee from input or output

maxPriceImpactnumber

the max price impact for route planning. It's better to set it to a reasonable value, for example 1 (100%)

maxSlippagenumber

the max slippage for route execution, for example 0.005 (0.5%)

source'sender' | 'self'

the source of router liquidity

onlyDEXstring

a list of DEX names separated by comma. If exists in the request then only pools from these DEXes are used in the response route. List of all supported DEXes can be obtained with /liquidity-provider request

onlyPoolsstring

a list of pools addresses separated by comma. If exists in the request then only these pools are used in the response route

excludeDEXstring

a list of DEX names separated by comma. If exists in the request then pools from these DEXes are excluded in the response route. List of all supported DEXes can be obtained with /liquidity-provider request

excludePoolsstring

a list of pools addresses separated by comma. If exists in the request then these pools are excluded in the response route

excludeTokensstring

a list of token addresses separated by comma. If exists in the request then pools with these tokens are excluded in the response route

visualizeboolean

vizulaization

simulateboolean

simulate

overrideboolean

uses state overrides to ensure simulation doesn't fail from sender not having balance and allowance

validateboolean

validate sender has balance & allowance of token if simulation fails

Response

route data

object required

Example response

{
  "status": "Success",
  "tokens": [
    {
      "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
      "symbol": "ETH",
      "name": "Ether",
      "decimals": 18
    },
    {
      "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "symbol": "WETH",
      "name": "Wrapped Ether",
      "decimals": 18
    },
    {
      "address": "0x6B3595068778DD592e39A122f4f5a5cF09C90fE2",
      "symbol": "SUSHI",
      "name": "SushiToken",
      "decimals": 18
    }
  ],
  "tokenFrom": 0,
  "tokenTo": 2,
  "swapPrice": 2837.6709246572527,
  "priceImpact": -0.002204113661183449,
  "amountIn": "10000000000000000",
  "assumedAmountOut": "28376709246572527616",
  "tx": {
    "from": 1.2380129724542482e+48,
    "to": 9.83650862853668e+47,
    "gas": "162561",
    "gasPrice": 682394289,
    "data": "0x5f3bd1c8000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe20000000000000000000000000000000000000000000000018969823f2df6281000000000000000000000000085cd07ea01423b1e937929b44e4ad8c40bbb5e7100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001a4dd9c5f96000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe200000000000000000000000000000000000000000000000189ce52b6a87f80000000000000000000000000000000000000000000000000018969823f2df62810000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700301ffff0201CE84867c3c02B05dc570d0135103d3fB9CC19433C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc204C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc200CE84867c3c02B05dc570d0135103d3fB9CC194330085CD07Ea01423b1E937929B44E4Ad8c40BbB5E71000bb80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "value": "10000000000000000"
  }
}