💱Quotes

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.

Endpoint

URL: https://api.kodiak.finance/quote

Method: GET

Content Type: application/json

Query Parameters

Parameter
Required
Description

protocols

✅

The protocols used for the swap. Possible values: v2, v3, mixed.

tokenInAddress

✅

Address of the input token for the swap.

tokenInChainId

✅

Chain ID of the input token.

tokenOutAddress

✅

Address of the output token for the swap.

tokenOutChainId

✅

Chain ID of the output token.

amount

✅

Amount of tokens to swap in humman terms

type

✅

Type of swap: exactIn (fixed input amount) or exactOut (fixed output amount).

recipient

❌

The address of the recipient of the swapped tokens. Required for generating calldata.

deadline

❌

Time in seconds until the transaction expires.

slippageTolerance

❌

Allowed slippage percentage as an integer (e.g., 1 for 1%).

Example Request

GET https://api.kodiak.finance/quote?protocols=v2,v3,mixed&tokenInAddress=0x7507c1dc16935B82698e4C63f2746A2fCf994dF8&tokenInChainId=80084&tokenOutAddress=0x1740F679325ef3686B2f574e392007A92e4BeD41&tokenOutChainId=80084&amount=40862354775778842528071&type=exactIn&recipient=0xA54e745BFf14816Ec6D323d894E7861b6Ef3F2aE&deadline=1000&slippageTolerance=1

Example response

{
  "blockNumber": "7067071",
  "amount": "1000000000000000000000",
  "amountDecimals": "1000",
  "quote": "55837913683147237796",
  "quoteDecimals": "55.837913683147237796",
  "quoteGasAdjusted": "55840267836750092796",
  "quoteGasAdjustedDecimals": "55.840267836750092796",
  "gasUseEstimateQuote": "2354153602855000",
  "gasUseEstimateQuoteDecimals": "0.002354153602855",
  "gasUseEstimate": "443000",
  "gasUseEstimateUSD": "0.041844",
  "gasPriceWei": "5314116485",
  "route": [
    [
      {
        "type": "v3-pool",
        "address": "0x8a960A6e5f224D0a88BaD10463bDAD161b68C144",
        "tokenIn": {
          "chainId": 80084,
          "decimals": "18",
          "address": "0x7507c1dc16935B82698e4C63f2746A2fCf994dF8",
          "symbol": "WBERA"
        },
        "tokenOut": {
          "chainId": 80084,
          "decimals": "18",
          "address": "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03",
          "symbol": "HONEY"
        },
        "fee": "3000",
        "liquidity": "2436507486332335185500775",
        "sqrtRatioX96": "18720675063184587718540484748",
        "tickCurrent": "-28856",
        "amountIn": "53049022487390937786",
        "amountOut": "950000000000000000000"
      }
    ],
    [
      {
        "type": "v3-pool",
        "address": "0xe49E094fe1679624C3981EB821fA6aB46c99E18E",
        "tokenIn": {
          "chainId": 80084,
          "decimals": "18",
          "address": "0x7507c1dc16935B82698e4C63f2746A2fCf994dF8",
          "symbol": "WBERA"
        },
        "tokenOut": {
          "chainId": 80084,
          "decimals": "18",
          "address": "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03",
          "symbol": "HONEY"
        },
        "fee": "500",
        "liquidity": "1785423513716355823391",
        "sqrtRatioX96": "18718672899386852222700719036",
        "tickCurrent": "-28858",
        "amountIn": "2788891195756300010",
        "amountOut": "50000000000000000000"
      }
    ]
  ],
  "routeString": "[V3] 95.00% = WBERA -- 0.3% [0x8a960A6e5f224D0a88BaD10463bDAD161b68C144] --\u003E HONEY, [V3] 5.00% = WBERA -- 0.05% [0xe49E094fe1679624C3981EB821fA6aB46c99E18E] --\u003E HONEY",
  "quoteId": "a6d10"
}

Execution of swap

If you specified the parameters a, b, c then the answer will return the calldata property. To perform this swap you just need to use our SwapRouter02

SwapRouter02 address: 0x496e305C03909ae382974cAcA4c580E1BF32afBE

Make sure you do the approve before the action in the example

 cast send 0x496e305C03909ae382974cAcA4c580E1BF32afBE "0x5ae401dc0000000000000000000000000000000000000000000000000000000067479f3a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e404e45aaf0000000000000000000000007507c1dc16935b82698e4c63f2746a2fcf994df80000000000000000000000001740f679325ef3686b2f574e392007a92e4bed410000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000a54e745bff14816ec6d323d894e7861b6ef3f2ae0000000000000000000000000000000000000000000008a72716c2895c8a4947000000000000000000000000000000000000000000005f726aca12c4ec97acd7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

Last updated