EVM Swaps

KyberSwap Aggregator EVM APIs

Download OpenAPI specification:

Note on integrations: clientID

EVM swap APIs

[V1] Get Swap Info with Encoded Data

get

Retrieve the information about a Swap between 2 tokens with encoded data to submit to KyberSwap router contract

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
Query parameters
tokenInstringRequired

Address of the input token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

tokenOutstringRequired

Address of the output token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

amountInstringRequired

Amount of the input token (in wei)

saveGasbooleanOptional

false/0 = route will be based on the maximum output token returned true/1 = route will be based on the lowest gas cost (i.e. the least hops)

slippageTolerancestringOptional

This is the amount of slippage the user can accept for his trade. The unit is bip. The value is in ranges [0, 2000], 10 means 0.1%. Default value is 50/10000 ~ 0.5%.

isInBpsbooleanOptional

if true, fee is taken in BPS

chargeFeeBystring · enumOptional

Indicates whether fee is charged by input token currency_in or output token currency_out Default is empty whereby no fee is charged

Possible values:
feeReceiverstringOptional

Address to receive fee (if chargeFeeBy is not empty)

feeAmountstringOptional

Fee amount to be collected
if isInBps = true, feeAmount is the percentage of fees that we will take with base unit = 10000, i.e feeAmount = 10 and isInBps = true then fee = 0.1% if isInBps = false, feeAmount is the amount of token that we will take as fee, i.e feeAmount = 10 and isInBps = 'false' then fee = 10 token weis

deadlinestringOptional

Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.

Example: 1551036863
tostringRequired

Address to receive the output token

clientDatastringOptional

Json string to present to your client (i.e. clientID)

Example: {"source":"EnterYourClientIdHere"}
Header parameters
Accept-Versionstring · enumRequired

Version of Aggregator

Possible values:
Responses
200
Swap Found
application/json
get
GET /{chain}/route/encode HTTP/1.1
Host: aggregator-api.kyberswap.com
Accept-Version: Latest
Accept: */*
200

Swap Found

{
  "inputAmount": "1000000000000000000",
  "outputAmount": "1667970343",
  "totalGas": 250000,
  "gasPriceGwei": "298.5144176",
  "gasUsd": 0.105226332201885,
  "amountInUsd": 1668.59,
  "amountOutUsd": 1667.970343,
  "receivedUsd": 1667.865116667798,
  "swaps": [
    [
      {
        "pool": "0x45dda9cb7c25131df268515131f647d726f50608",
        "tokenIn": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
        "tokenOut": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
        "swapAmount": "999000000000000000",
        "amountOut": "1667970343",
        "limitReturnAmount": "0",
        "maxPrice": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
        "exchange": "uniswapv3",
        "poolLength": 2,
        "poolType": "univ3"
      }
    ]
  ],
  "tokens": {
    "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": {
      "address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
      "symbol": "USDC",
      "name": "USD Coin",
      "price": 1,
      "decimals": 6
    },
    "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619": {
      "address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
      "symbol": "WETH",
      "name": "Wrapped Ether",
      "price": 1668.59,
      "decimals": 18
    }
  },
  "encodedSwapData": "0xe21fd0e900000000000000000000000000000000000000000000000000000000000000200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000000000062ec95af0000000000000000000000006131b5fae19ea4f9d964eac0408e4408b66337b50000000000000000000000000000000000000000000000000000000063f6f85b00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000409e8aa9350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000045dda9cb7c25131df268515131f647d726f506080000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000ddd2935029d800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000062ec95af0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000ddd2935029d800000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001df7b22536f75726365223a22222c22416d6f756e74496e555344223a22313636382e3539222c22416d6f756e744f7574555344223a22313636372e393730333433222c22526566657272616c223a22222c22466c616773223a332c22496e74656772697479496e666f223a7b224b65794944223a2231222c225369676e6174757265223a225057614f647055363157744e724258424777424f77665434755547674f4e5162597654747273566d30422b626d362b6b58357362722f6b746f554e655a646b4c354378325576674541795a4a5248565349505558627833336a445262773356337549446c41584241687578616e353642524846686f7a492b422b4b396b3961716d4168712b6f4e49696e535939386e4d4a595072504b506c787a457657653043684d32756a4c7264395876474e7143494f6c7644526531426c5259425a552f625936593034454c3149796d6467684b544237316c32637541643274507335347347414f4e3534356e786a58746d6946674668343570754a5a6e6a7876524b3376754861306a71334357384f51444f41416661416261636176544b6774566b42592b4e5058683965495a6c6b4933596f766e44586e6e4236366652747647506175787a374750386a786e735730646164655a344f5a41513d3d227d7d00",
  "routerAddress": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"
}

[V2] Get Swap Route

get

Retrieve the route information about a Swap between 2 tokens. Please use V2 GET API for a more performant route query. The route returned can then be combined with transaction specific params in the POST API payload to get the encoded data for submission to the KyberSwap router contract.

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
Query parameters
tokenInstringRequired

Address of the input token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

tokenOutstringRequired

Address of the output token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

amountInstringRequired

Amount of the input token (in wei)

saveGasbooleanOptional

false/0 = route will be based on the maximum output token returned true/1 = route will be based on the lowest gas cost (i.e. the least hops)

includedSourcesstringOptional

DEX IDs included in the route, separated by comma

excludedSourcesstringOptional

DEX IDs excluded from the route, separated by comma

gasIncludebooleanOptional

Determines whether gas costs are included when searching for route

gasPricestringOptional

Estimated price of gas required for swap, in wei units

feeAmountstringOptional

Fee amount to be collected
if isInBps = true, feeAmount is the percentage of fees that we will take with base unit = 10000, i.e feeAmount = 10 and isInBps = true then fee = 0.1% if isInBps = false, feeAmount is the amount of token that we will take as fee, i.e feeAmount = 10 and isInBps = 'false' then fee = 10 token weis

chargeFeeBystring · enumOptional

Indicates whether fee is charged by input token currency_in or output token currency_out Default is empty whereby no fee is charged

Possible values:
isInBpsbooleanOptional

if true, fee is taken in BPS

feeReceiverstringOptional

Address to receive fee (if chargeFeeBy is not empty)

Responses
200
Swap Found
application/json
get
GET /{chain}/api/v1/routes HTTP/1.1
Host: aggregator-api.kyberswap.com
Accept: */*
200

Swap Found

{
  "code": "0",
  "message": "successfully",
  "data": {
    "routeSummary": {
      "tokenIn": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
      "amountIn": "1000000000000000000",
      "amountInUsd": "1668.95",
      "tokenOut": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
      "amountOut": "1666243758",
      "amountOutUsd": "1665.9071767608839",
      "gas": "253000",
      "gasPrice": "181968304449",
      "gasUsd": "0.06491355324609177",
      "extraFee": {
        "feeAmount": "10",
        "chargeFeeBy": "currency_out",
        "isInBps": "true,",
        "feeReceiver": "0x0513c794bC2c65C6f374a86D6ad04425e32Df22e"
      },
      "route": [
        [
          {
            "pool": "0x4b543e89351faa242cb0172b2da0cdb52db699b4",
            "tokenIn": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
            "tokenOut": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
            "limitReturnAmount": "0",
            "swapAmount": "1000000000000000000",
            "amountOut": "1667911669",
            "exchange": "dodo",
            "poolLength": 2,
            "poolType": "dodo",
            "extra": {
              "type": "DPP",
              "dodoV1SellHelper": "0xdfaf9584f5d229a9dbe5978523317820a8897c5a",
              "baseToken": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
              "quoteToken": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"
            }
          }
        ]
      ]
    },
    "routerAddress": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"
  }
}

[V2] Post Swap Route For Encoded Data

post

Get the encoded swap route to be forwarded to the KyberSwap router contract. For simplicity, the request body should contain the routeSummary returned by [V2] Get Swap Route appended with the additional tx parameters.

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
Body
deadlineintegerOptional

Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.

slippageToleranceintegerOptional

This is the amount of slippage the user can accept for his trade. The unit is bip. The value is in ranges [0, 2000], 10 means 0.1%. Default value is 50/10000 ~ 0.5%.

senderstringRequired

Address which the swap input tokens will be debited from

recipientstringRequired

Address which the swap output tokens will be sent to

sourcestringOptional

String to present to your client (i.e. clientID)

skipSimulateTxbooleanOptional

Returns the encoded data without price impact checks. For advanced trades.

Responses
200
Successfully encoded
application/json
post
POST /{chain}/api/v1/route/build HTTP/1.1
Host: aggregator-api.kyberswap.com
Content-Type: application/json
Accept: */*
Content-Length: 581

{
  "routeSummary": {
    "tokenIn": "text",
    "amountIn": "text",
    "amountInUsd": "text",
    "tokenOut": "text",
    "amountOut": "text",
    "amountOutUsd": "text",
    "gas": "text",
    "gasPrice": "text",
    "gasUsd": "text",
    "extraFee": {
      "feeAmount": "text",
      "chargeFeeBy": "currency_in",
      "isInBps": "text",
      "feeReceiver": "text"
    },
    "route": [
      [
        {
          "pool": "text",
          "tokenIn": "text",
          "tokenOut": "text",
          "limitReturnAmount": "text",
          "swapAmount": "text",
          "amountOut": "text",
          "exchange": "text",
          "poolLength": 1,
          "poolType": "text",
          "extra": "text"
        }
      ]
    ]
  },
  "deadline": 1,
  "slippageTolerance": 1,
  "sender": "text",
  "recipient": "text",
  "source": "text",
  "skipSimulateTx": true
}
200

Successfully encoded

{
  "code": 0,
  "message": "successfully",
  "data": {
    "amountIn": "1000000000000000000",
    "amountInUsd": "1668.5",
    "amountOut": "1666243758",
    "amountOutUsd": "1666.243758",
    "gas": "253000",
    "gasUsd": "0.06491355324609177",
    "outputChange": {
      "amount\"": "0",
      "percent\"": 0,
      "level\"": 0
    },
    "data": "0xe21fd0e900000000000000000000000000000000000000000000000000000000000000200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000006600000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000006350dcae0000000000000000000000006131b5fae19ea4f9d964eac0408e4408b66337b50000000000000000000000000000000000000000000000000000000063f6fe9c00000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000408a5da90f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd0000000000000000000000004b543e89351faa242cb0172b2da0cdb52db699b40000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfaf9584f5d229a9dbe5978523317820a8897c5a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000006350dcae00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001de7b22536f75726365223a22222c22416d6f756e74496e555344223a22313636382e35222c22416d6f756e744f7574555344223a22313636362e323433373538222c22526566657272616c223a22222c22466c616773223a332c22496e74656772697479496e666f223a7b224b65794944223a2231222c225369676e6174757265223a22435558755770383248546b6148425659454b574f784a7a76367a2b4f4d7952302f51324558726e41773863646e753474755344534744347a454367504f35374c626b6e366d5054344d5647726f30515a6f497750486c4a50615935426e4f347a416c6f5876532f4a4b31467066776553516b79726d555834793478624f554341655474497477546c726c4d64694e5474544852764c76555255436443443875362b6f4c68766f782b6e5336483378672f7453693566327673744471666166506864524b45496b432f7841584c4a3279764769567361564542722b55483943774e455a53756f7765424f4c4d386f4d7a3047306a4b7470395768756a50796171757832694b674f625271347974625976586935744f6d734d486935654574782b54705539546f694a5957317252456a447170426c486d5849526738714d734a6b46495361314e352f31374b447957482f48366f466e39513d3d227d7d0000",
    "routerAddress": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"
  }
}

Last updated

Was this helpful?

#477: Elastic fee tier and token launches

Change request updated