LogoLogo
App
  • Overview
  • Partner Fees
  • Base URL
  • Quoting
    • Native Quote
    • Token to Token Quote
  • Swaps
    • Native Swaps
    • Token to Token Swaps
Powered by GitBook
On this page
  1. Swaps

Native Swaps

PreviousToken to Token QuoteNextToken to Token Swaps

Last updated 3 months ago

Important: Sells require approval (if not already approved). This is shown in additionalTransactions. Always check for additional transactions and execute them first, then execute transactionData

Buy = $S to Token Sell = Token To $S

Get transaction data for native currency swaps

post

Returns transaction data for swapping between native currency and tokens. Uses the quoteData from a previous quote API call to generate executable transaction data.

Body
quoteDatastringRequired

Encoded quote data from a previous call to the quotes/native API

Example: eyJ0b2tlbk91dCI6IjB4MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MCIsImFtb3VudEluTmF0aXZlIjoiMTAwMDAwMDAwMDAwMDAwMDAwMCIsImFtb3VudE91dEluVG9rZW5zIjoiOTg1MDAwMDAwMDAwMDAwMDAwIiwidG9rZW5PdXREZWNpbWFscyI6MTgsImV4Y2hhbmdlIjowLCJwYXJhbXMiOnsic3RhYmxlIjpmYWxzZSwidGlja1NwYWNpbmciOjAsImZlZSI6MCwiYmluU3RlcCI6IjAiLCJyZXZlcnNlZCI6ZmFsc2V9fQ==
slippagenumber · max: 100Optional

Slippage tolerance percentage (0-100)

Default: 0.5Example: 1
toAddressstringOptional

Address to receive tokens (defaults to sender)

Example: 0xabcdef1234567890abcdef1234567890abcdef12Pattern: ^0x[a-fA-F0-9]{40}$
feeBpsinteger · max: 10000Optional

Partner fee in basis points (0-10000)

Example: 25
feeRecipientstringOptional

Address to receive the partner fee

Example: 0xabcdef1234567890abcdef1234567890abcdef12Pattern: ^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/native HTTP/1.1
Host: api.coal.ag
Content-Type: application/json
Accept: */*
Content-Length: 498

{
  "quoteData": "eyJ0b2tlbk91dCI6IjB4MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MCIsImFtb3VudEluTmF0aXZlIjoiMTAwMDAwMDAwMDAwMDAwMDAwMCIsImFtb3VudE91dEluVG9rZW5zIjoiOTg1MDAwMDAwMDAwMDAwMDAwIiwidG9rZW5PdXREZWNpbWFscyI6MTgsImV4Y2hhbmdlIjowLCJwYXJhbXMiOnsic3RhYmxlIjpmYWxzZSwidGlja1NwYWNpbmciOjAsImZlZSI6MCwiYmluU3RlcCI6IjAiLCJyZXZlcnNlZCI6ZmFsc2V9fQ==",
  "slippage": 1,
  "toAddress": "0xabcdef1234567890abcdef1234567890abcdef12",
  "feeBps": 25,
  "feeRecipient": "0xabcdef1234567890abcdef1234567890abcdef12"
}
{
  "transactionData": {
    "to": "0x1234567890123456789012345678901234567890",
    "data": "0x7325e69100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0",
    "value": "1000000000000000000"
  },
  "additionalTransactions": [
    {
      "to": "0xabcdef1234567890abcdef1234567890abcdef12",
      "data": "0x095ea7b300000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000000de0b6b3a7640000",
      "value": "0"
    }
  ]
}