Token to Token Swaps
Important: Token swapping requires approval (if not already approved). This is shown in additionalTransactions
. Always check for additional transactions and execute them first, then execute transactionData
Returns transaction data for swapping directly between tokens. Uses the quoteData from a previous quote API call to generate executable transaction data. Always includes token approval transaction data when needed.
Body
quoteDatastringRequiredExample:
Encoded quote data from a previous call to the quotes/token API
eyJ0b2tlbkluIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwIiwidG9rZW5PdXQiOiIweGFiY2RlZjEyMzQ1Njc4OTBhYmNkZWYxMjM0NTY3ODkwYWJjZGVmMTIiLCJhbW91bnRJblRva2VuSW4iOiIxMDAwMDAwMDAwMDAwMDAwMDAwIiwiYW1vdW50T3V0VG9rZW5PdXQiOiI5ODUwMDAwMDAwMDAwMDAwMDAiLCJ0b2tlbkRlY2ltYWxzSW4iOjE4LCJ0b2tlbkRlY2ltYWxzT3V0IjoxOCwiZXhjaGFuZ2UiOjAsInBhcmFtcyI6eyJzdGFibGUiOmZhbHNlLCJ0aWNrU3BhY2luZyI6MCwiZmVlIjowLCJiaW5TdGVwIjoiMCIsInJldmVyc2VkIjpmYWxzZX19
slippagenumber · max: 100OptionalDefault:
Slippage tolerance percentage (0-100)
0.5
Example: 1
toAddressstringOptionalExample:
Address to receive tokens (defaults to sender)
0xabcdef1234567890abcdef1234567890abcdef12
Pattern: ^0x[a-fA-F0-9]{40}$
feeBpsinteger · max: 10000OptionalExample:
Partner fee in basis points (0-10000)
25
feeRecipientstringOptionalExample:
Address to receive the partner fee
0xabcdef1234567890abcdef1234567890abcdef12
Pattern: ^0x[a-fA-F0-9]{40}$
Responses
200
Transaction data for executing the swap
application/json
400
Invalid request parameters
application/json
500
Internal server error
application/json
post
POST /api/v1/swap/token HTTP/1.1
Host: api.coal.ag
Content-Type: application/json
Accept: */*
Content-Length: 598
{
"quoteData": "eyJ0b2tlbkluIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwIiwidG9rZW5PdXQiOiIweGFiY2RlZjEyMzQ1Njc4OTBhYmNkZWYxMjM0NTY3ODkwYWJjZGVmMTIiLCJhbW91bnRJblRva2VuSW4iOiIxMDAwMDAwMDAwMDAwMDAwMDAwIiwiYW1vdW50T3V0VG9rZW5PdXQiOiI5ODUwMDAwMDAwMDAwMDAwMDAiLCJ0b2tlbkRlY2ltYWxzSW4iOjE4LCJ0b2tlbkRlY2ltYWxzT3V0IjoxOCwiZXhjaGFuZ2UiOjAsInBhcmFtcyI6eyJzdGFibGUiOmZhbHNlLCJ0aWNrU3BhY2luZyI6MCwiZmVlIjowLCJiaW5TdGVwIjoiMCIsInJldmVyc2VkIjpmYWxzZX19",
"slippage": 1,
"toAddress": "0xabcdef1234567890abcdef1234567890abcdef12",
"feeBps": 25,
"feeRecipient": "0xabcdef1234567890abcdef1234567890abcdef12"
}
{
"transactionData": {
"to": "0x1234567890123456789012345678901234567890",
"data": "0x38ed17390000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000008c8339dafed480000",
"value": "0"
},
"additionalTransactions": [
{
"to": "0xabcdef1234567890abcdef1234567890abcdef12",
"data": "0x095ea7b300000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000000de0b6b3a7640000",
"value": "0"
}
]
}
Last updated