Endpoint should return all available tokens that you support.
Either as pairs or as a list, depending on your implementation (is every combination supported as long as both tokens are supported?)
Tokens should be represented as a combination of chainId
and address
.
Get a quote for a token pair and an specified amount. The below example is from another dex integration we have built, details can be discussed.
Request params:
{
"chainId": required, the chain's id, default Ethereum's chain id,
"fromTokenAddress": required, the address of the source token for the swap,
"toTokenAddress": required, the address of the destination token for the swap,
"fromAmount": required, the swap amount adjusted for the token's decimal places,
"toAddress": required, the recipient of the target token,
"slippage": optional, default 0.005
}
Request example:
{
"chainId": 1,
"fromTokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"toTokenAddress": "0x514910771AF9Ca656af840dff83E8264EcF986CA",
"fromAmount": "200000000",
"toAddress": "0x60Ab6B98CF5702Aaa062b0B0e623D85cf71c2217"
}
Response:
{
"status": "Success",
"chainId": 1,
"fromTokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"toTokenAddress": "0x514910771AF9Ca656af840dff83E8264EcF986CA",
"toAddress": "0x60Ab6B98CF5702Aaa062b0B0e623D85cf71c2217",
"route": {
"fromAmount": "200000000",
"toAmount": "10576286625090965504",
"toAmountMin": "10523405191965510676",
"approveToAddress": "0xe43ca1Dee3F0fc1e2df73A0745674545F11A59F5",
"gasEstimation": 110000,
"transaction": {
"to": "0xe43ca1Dee3F0fc1e2df73A0745674545F11A59F5",
"value": "0",
"callData": "0x2646478b000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000bebc200000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca000000000000000000000000000000000000000000000000920aa544469b0c1400000000000000000000000060ab6b98cf5702aaa062b0b0e623d85cf71c221700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004202A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB4801ffff01FAD57d2039C21811C8F2B5D5B65308aa99D315590060Ab6B98CF5702Aaa062b0B0e623D85cf71c2217000000000000000000000000000000000000000000000000000000000000"
}
}
}