Swap API (kX)
Overview
This API allows fetching quotes for token swaps and provides transaction data (calldata
) for execution if the parameters slippageTolerance
, deadline
, and recipient
are specified. This enables direct interaction with smart contracts.
This API is an aggregator of various providers and selects the best ones.
Currently, the following external providers are supported:
Kodiak
Endpoint
URL:
https://backend.kodiak.finance/quote
Method:
GET
Content Type:
application/json
Query Parameters
tokenInAddress
β
Address of the input token for the swap. For native use token = BERA
, ETH
, or address(0) 0x000000000000000000000000000000000000000000
tokenInChainId
β
Chain ID of the input token.
tokenOutAddress
β
Address of the output token for the swap. For native use token = BERA
, ETH
, or address(0) 0x000000000000000000000000000000000000000000
tokenOutChainId
β
Chain ID of the output token.
amount
β
Amount of tokens to swap in human terms
type
β
Type of swap: exactIn
(fixed input amount) or exactOut
(fixed output amount). exactOut
is not supported by most providers, so this is not a recommended method and may show you poor quotes
refCode
β
Your referral code (received from the Kodiak team)
referrerFeeBps
β
Your share of fees. Each referral code has a maximum threshold. Example: 100 = 1%
recipient
β
The address of the recipient of the swapped tokens. Required for generating calldata
slippageTolerance
β
Allowed slippage percentage as an integer (e.g., 1 for 1%).
providers
β
Case insensitive list of providers separated by commas.
Available options: Kodiak
, OpenOcean
,Magpie
,OogaBooga
,Enso
For example: kodiak,openocean,oogabooga
debug
β
Receive additional information on all underlying providers quoted by setting to true
Example Request
GET https://backend.kodiak.finance/quote?protocols=v2%2Cv3%2Cmixed&tokenInAddress=BERA&tokenInChainId=80094&tokenOutAddress=0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce&tokenOutChainId=80094&amount=100000000000000000000&type=exactIn&recipient=0x5a1e747482F8773fe52Cca9951E956F456EFd0Bf&slippageTolerance=1
Example response
{
"id": "b5c7416a",
"amountDecimalsUSD": "225.6878516369463",
"quoteDecimalsUSD": "225.4646160925649",
"tokenInPriceUSD": "2.256878516369463",
"tokenOutPriceUSD": "1",
"priceImpact": "-0.09891340750609146",
"methodParameters":
{
"calldata": "0xd2644d14000000000000000000000000696969696969696969696969696969696969696900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c19a91d0924faf6130000000000000000000000005a1e747482f8773fe52cca9951e956f456efd0bf000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000c38f339c60126deb3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e301e48f77963d3f7dbd2a4796962bd7f3867fb4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003245ae401dc0000000000000000000000000000000000000000000000000000000068823556000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e404e45aaf0000000000000000000000006969696969696969696969696969696969696969000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae00000000000000000000000000000000000000000000000340aad21b3b70000000000000000000000000000000000000000000000000000742bd178e640a419f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae0000000000000000000000000000000000000000000000022b1c8c1227a00000000000000000000000000000000000000000000000000004d73b54569a90d2a100000000000000000000000000000000000000000000000000000000000000426969696969696969696969696969696969696969000bb8549943e04f40284185054145c6e4e9568c1d3241000064fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"value": "0x56bc75e2d63100000",
"to": "0x43Dac637c4383f91B4368041E7A8687da3806Cae",
"decodedArgs":
[
{
"token": "0x6969696969696969696969696969696969696969",
"wrap": true,
"amount": "100000000000000000000",
},
{
"token": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"unwrap": false,
"minAmountOut": "223209969931639256595",
"receiver": "0x5a1e747482F8773fe52Cca9951E956F456EFd0Bf",
},
{
"router": "0xe301E48F77963D3F7DbD2a4796962Bd7f3867Fb4",
"data": "0x5ae401dc0000000000000000000000000000000000000000000000000000000068823556000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e404e45aaf0000000000000000000000006969696969696969696969696969696969696969000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae00000000000000000000000000000000000000000000000340aad21b3b70000000000000000000000000000000000000000000000000000742bd178e640a419f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae0000000000000000000000000000000000000000000000022b1c8c1227a00000000000000000000000000000000000000000000000000004d73b54569a90d2a100000000000000000000000000000000000000000000000000000000000000426969696969696969696969696969696969696969000bb8549943e04f40284185054145c6e4e9568c1d3241000064fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
{
"feeQuote": "225464616092564905651",
"surplusFeeBps": "0",
"refCode": "0",
"referrerFeeBps": "0",
},
],
},
"blockNumber": "8160103",
"amount": "100000000000000000000",
"amountDecimals": "100",
"quote": "225464616092564905651",
"quoteDecimals": "225.464616092564905651",
"gasUseEstimate": "306000",
"gasUseEstimateUSD": "6.920697896398132e-13",
"gasPriceWei": "501981",
"route":
[
[
{
"type": "v3-pool",
"address": "0x1127f801Cb3ab7BDF8923272949AA7Dba94B5805",
"tokenIn":
{
"chainId": 80094,
"decimals": "18",
"address": "0x6969696969696969696969696969696969696969",
"symbol": "WBERA",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "18",
"address": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"symbol": "HONEY",
},
"fee": "3000",
"liquidity": "4493725237081532474168574",
"sqrtRatioX96": "119153151978651141127607820981",
"tickCurrent": "8161",
"amountIn": "60000000000000000000",
"amountOut": "135275596737333603789",
},
],
[
{
"type": "v3-pool",
"address": "0x4866Dd95a3bC4eb40Dd1B659489e3410dAe3287f",
"tokenIn":
{
"chainId": 80094,
"decimals": "18",
"address": "0x6969696969696969696969696969696969696969",
"symbol": "WBERA",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "6",
"address": "0x549943e04f40284185054145c6E4e9568C1D3241",
"symbol": "USDC",
},
"fee": "3000",
"liquidity": "718444640825350202",
"sqrtRatioX96": "52691600443445573726226992633074205",
"tickCurrent": "268166",
"amountIn": "40000000000000000000",
},
{
"type": "v3-pool",
"address": "0xb16fFD445d3c785476F87017b79423eC9057406b",
"tokenIn":
{
"chainId": 80094,
"decimals": "6",
"address": "0x549943e04f40284185054145c6E4e9568C1D3241",
"symbol": "USDC",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "18",
"address": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"symbol": "HONEY",
},
"fee": "100",
"liquidity": "1521993826513687995740",
"sqrtRatioX96": "79246574896778039496813381592642346",
"tickCurrent": "276328",
"amountOut": "90189019355231301862",
},
],
],
"routeString": "[V3] 60.00% = WBERA -- 0.3% [0x1127f801Cb3ab7BDF8923272949AA7Dba94B5805] --> HONEY, [V3] 40.00% = WBERA -- 0.3% [0x4866Dd95a3bC4eb40Dd1B659489e3410dAe3287f] --> USDC -- 0.01% [0xb16fFD445d3c785476F87017b79423eC9057406b] --> HONEY",
"quoteId": "616f5",
"provider": "Kodiak",
"params":
{
"tokenInAddress": "BERA",
"tokenInChainId": 80094,
"tokenOutAddress": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"tokenOutChainId": 80094,
"amount": "100000000000000000000",
"type": "exactIn",
"slippageTolerance": 1,
"recipient": "0x5a1e747482F8773fe52Cca9951E956F456EFd0Bf",
},
"refFee": "0",
"otherQuote":
{
"amountDecimalsUSD": "225.6878516369463",
"quoteDecimalsUSD": "225.4646160925649",
"tokenInPriceUSD": "2.256878516369463",
"tokenOutPriceUSD": "1",
"priceImpact": "-0.09891340750609146",
"methodParameters":
{
"calldata": "0x5ae401dc0000000000000000000000000000000000000000000000000000000068823556000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e404e45aaf0000000000000000000000006969696969696969696969696969696969696969000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000bb80000000000000000000000005a1e747482f8773fe52cca9951e956f456efd0bf00000000000000000000000000000000000000000000000340aad21b3b70000000000000000000000000000000000000000000000000000742bd178e640a419f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124b858183f000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000800000000000000000000000005a1e747482f8773fe52cca9951e956f456efd0bf0000000000000000000000000000000000000000000000022b1c8c1227a00000000000000000000000000000000000000000000000000004d73b54569a90d2a100000000000000000000000000000000000000000000000000000000000000426969696969696969696969696969696969696969000bb8549943e04f40284185054145c6e4e9568c1d3241000064fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"value": "0x00",
"to": "0xe301E48F77963D3F7DbD2a4796962Bd7f3867Fb4",
},
"blockNumber": "8160103",
"amount": "100000000000000000000",
"amountDecimals": "100",
"quote": "225464616092564905651",
"quoteDecimals": "225.464616092564905651",
"gasUseEstimate": "306000",
"gasUseEstimateUSD": "6.920697896398132e-13",
"gasPriceWei": "501981",
"route":
[
[
{
"type": "v3-pool",
"address": "0x1127f801Cb3ab7BDF8923272949AA7Dba94B5805",
"tokenIn":
{
"chainId": 80094,
"decimals": "18",
"address": "0x6969696969696969696969696969696969696969",
"symbol": "WBERA",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "18",
"address": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"symbol": "HONEY",
},
"fee": "3000",
"liquidity": "4493725237081532474168574",
"sqrtRatioX96": "119153151978651141127607820981",
"tickCurrent": "8161",
"amountIn": "60000000000000000000",
"amountOut": "135275596737333603789",
},
],
[
{
"type": "v3-pool",
"address": "0x4866Dd95a3bC4eb40Dd1B659489e3410dAe3287f",
"tokenIn":
{
"chainId": 80094,
"decimals": "18",
"address": "0x6969696969696969696969696969696969696969",
"symbol": "WBERA",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "6",
"address": "0x549943e04f40284185054145c6E4e9568C1D3241",
"symbol": "USDC",
},
"fee": "3000",
"liquidity": "718444640825350202",
"sqrtRatioX96": "52691600443445573726226992633074205",
"tickCurrent": "268166",
"amountIn": "40000000000000000000",
},
{
"type": "v3-pool",
"address": "0xb16fFD445d3c785476F87017b79423eC9057406b",
"tokenIn":
{
"chainId": 80094,
"decimals": "6",
"address": "0x549943e04f40284185054145c6E4e9568C1D3241",
"symbol": "USDC",
},
"tokenOut":
{
"chainId": 80094,
"decimals": "18",
"address": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"symbol": "HONEY",
},
"fee": "100",
"liquidity": "1521993826513687995740",
"sqrtRatioX96": "79246574896778039496813381592642346",
"tickCurrent": "276328",
"amountOut": "90189019355231301862",
},
],
],
"routeString": "[V3] 60.00% = WBERA -- 0.3% [0x1127f801Cb3ab7BDF8923272949AA7Dba94B5805] --> HONEY, [V3] 40.00% = WBERA -- 0.3% [0x4866Dd95a3bC4eb40Dd1B659489e3410dAe3287f] --> USDC -- 0.01% [0xb16fFD445d3c785476F87017b79423eC9057406b] --> HONEY",
"quoteId": "616f5",
"provider": "Kodiak",
"params":
{
"tokenInAddress": "BERA",
"tokenInChainId": 80094,
"tokenOutAddress": "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce",
"tokenOutChainId": 80094,
"amount": "100000000000000000000",
"type": "exactIn",
"slippageTolerance": 1,
"recipient": "0x5a1e747482F8773fe52Cca9951E956F456EFd0Bf",
},
},
"expl":
[
{
"provider": "Magpie",
"status": "success",
"executionTime": "459",
"output": "225.505910668219988287",
"priority": "1.00000000",
"gas": "1977503",
},
{
"provider": "Kodiak",
"status": "success",
"executionTime": "687",
"output": "225.464616092564905651",
"priority": "1.00020000",
"gas": "306000",
},
{
"provider": "OogaBooga",
"status": "success",
"executionTime": "732",
"output": "225.47857060392927232",
"priority": "1.00000000",
"gas": "1665117",
},
{
"provider": "OpenOcean",
"status": "success",
"executionTime": "1110",
"output": "225.480574764869379629",
"priority": "0.99950000",
"gas": "561020",
},
{
"provider": "Enso",
"status": "success",
"executionTime": "1222",
"output": "225.47857060392926899",
"priority": "0.99900000",
"gas": "1141033",
},
],
}
cast send 0x43Dac637c4383f91B4368041E7A8687da3806Cae "0xd2644d14000000000000000000000000696969696969696969696969696969696969696900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c19a91d0924faf6130000000000000000000000005a1e747482f8773fe52cca9951e956f456efd0bf000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000c38f339c60126deb3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e301e48f77963d3f7dbd2a4796962bd7f3867fb4000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003245ae401dc0000000000000000000000000000000000000000000000000000000068823556000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e404e45aaf0000000000000000000000006969696969696969696969696969696969696969000000000000000000000000fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae00000000000000000000000000000000000000000000000340aad21b3b70000000000000000000000000000000000000000000000000000742bd178e640a419f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124b858183f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000043dac637c4383f91b4368041e7a8687da3806cae0000000000000000000000000000000000000000000000022b1c8c1227a00000000000000000000000000000000000000000000000000004d73b54569a90d2a100000000000000000000000000000000000000000000000000000000000000426969696969696969696969696969696969696969000bb8549943e04f40284185054145c6e4e9568c1d3241000064fcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Last updated