Skip to main content

Swap params

Generate data for calling the 1inch router for exchange: /api/swap#

Description of query parameters#

Parameter nameTypeDescription
fromTokenAddress *stringcontract address of a token to sell
e.g.: 0x6b175474e89094c44da98b954eedeac495271d0f
toTokenAddress *stringcontract address of a token to buy
e.g.: 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
amount *integeramount of a token to sell, set in minimal divisible units e.g.:
1.00 DAI set as 1000000000000000000
51.03 USDC set as 51030000
fromAddress *stringaddress of a seller, make sure that this address has approved to spend fromTokenAddress in needed amount
e.g.: 0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5
slippage *numberlimit of price slippage you are willing to accept in percentage, may be set with decimals. &slippage=0.5 means 0.5% slippage is acceptable. Low values increase chances that transaction will fail, high values increase chances of front running. Set values in the range from 0 to 50
protocolsstringspecify liquidity protocols. If not set, all liquidity protocols will be used; you can disable any protocol by listing all protocols except those you don't need
e.g.: &protocols=WETH,CURVE,BALANCER,...,ZRX
default: all protocols can be used
destReceiverstringrecipient address of a purchased token
if not set, fromAddress will receive a purchased token
referrerAddressstringreferrer's address
feenumberthis percentage of fromTokenAddress token amount will be sent to referrerAddress, the rest will be used as input for a swap
min: 0; max: 3; default: 0
example to set a fee to 1.5%: &fee=1.5
gasPricestring1inch takes in account gas expenses to determine exchange route. It is important to use the same gas price on the quote and swap methods.
Gas price set in wei: 12.5 GWEI set as 12500000000
default: "fast" from network
permitstringhttps://eips.ethereum.org/EIPS/eip-2612
burnChibooleanIf true, CHI will be burned from fromAddress to compensate gas. Check CHI balance and allowance before turning that on. CHI should be approved for the spender address
default: false
complexityLevelstringmaximum number of token-connectors to be used in a transaction. The more is used — the longer route estimation will take, the more complex route might be as a result. If not set, two token-connectors may be used
min: 0; max: 3; default: 2
connectorTokensstringtoken-connectors can be specified via this parameter. The more is set — the longer route estimation will take. If not set, default token-connectors will be used. If a token you want to exchange doesn't have a pool with one of the default token-connectors this parameter will help find the route; should be the same for a quote and swap max: 5;
e.g.: &connectorTokens=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, 0x6b175474e89094c44da98b954eedeac495271d0f
default: list of default token-connectors
allowPartialFillbooleanif true, the algorithm can cancel part of the route, if the rate has become less attractive. Unswapped tokens will return to the fromAddress
default: true
disableEstimatebooleanif true, disable most of the checks
default: false
gasLimitintegermaximum amount of gas for a swap;
should be the same for a quote and swap
default: 11500000; max: 11500000
mainRoutePartsintegerlimit maximum number of main route parts;
should be the same for a quote and swap
default: 20; max: 50
partsintegerlimit maximum number of parts each main route parts can be split into; should be the same for a quote and swap
default: 20; max: 100

Description of response parameters#

Parameter nameTypeDescription
fromTokenstringparameters of a token to sell
toTokenstringparameters of a token to buy
fromTokenAmountstringinput amount of fromToken in minimal divisible units
toTokenAmountstringresult amount of toToken in minimal divisible units
protocolsstringroute of the trade
fromstringtransactions will be sent from this address
tostringtransactions will be sent to our contract address
datastringbytes of call data
valuestringamount of ETH (in wei) will be sent to the contract address
gasPricestringgas price in wei
gasstringestimated amount of the gas limit, increase this value by 25%