POST
/
v1
/
route
/
multi
curl --request POST \
  --url https://backend.swap.coffee/v1/route/multi \
  --header 'Content-Type: application/json' \
  --data '{
  "input_assets": [
    {
      "token": {
        "blockchain": "ton",
        "address": "native"
      },
      "amount": 1
    }
  ],
  "output_asset": {
    "blockchain": "ton",
    "address": "native"
  },
  "max_splits": 4,
  "max_length": 3,
  "pool_selector": {
    "blockchains": [
      "ton"
    ],
    "dexes": [
      "dedust"
    ],
    "max_volatility": 1
  },
  "mev_protection": true,
  "additional_data": {
    "sender_address": "UQCNTO0Nh0Z7QNyRW1BLWfk08f2dAOw4izrx9sO6OUPg4DoV",
    "referral_name": "tonkeeper"
  }
}'
{
  "routes": [
    {
      "input_token": {
        "address": {
          "blockchain": "ton",
          "address": "native"
        },
        "metadata": {
          "name": "ARBUZ",
          "symbol": "ARBUZ",
          "decimals": 123,
          "image_url": "<string>",
          "listed": true
        }
      },
      "output_token": {
        "address": {
          "blockchain": "ton",
          "address": "native"
        },
        "metadata": {
          "name": "ARBUZ",
          "symbol": "ARBUZ",
          "decimals": 123,
          "image_url": "<string>",
          "listed": true
        }
      },
      "input_amount": 123,
      "output_amount": 123,
      "input_usd": 123,
      "output_usd": 123,
      "savings": 123,
      "left_amount": 123,
      "recommended_gas": 123,
      "price_impact": 123,
      "estimated_cashback_usd": 123,
      "partner_commission_ton": 123,
      "mev_protection_fee": 123,
      "paths": [
        {
          "blockchain": "ton",
          "dex": "stonfi",
          "pool_address": "<string>",
          "input_token": {
            "address": {
              "blockchain": "ton",
              "address": "native"
            },
            "metadata": {
              "name": "ARBUZ",
              "symbol": "ARBUZ",
              "decimals": 123,
              "image_url": "<string>",
              "listed": true
            }
          },
          "output_token": {
            "address": {
              "blockchain": "ton",
              "address": "native"
            },
            "metadata": {
              "name": "ARBUZ",
              "symbol": "ARBUZ",
              "decimals": 123,
              "image_url": "<string>",
              "listed": true
            }
          },
          "swap": {
            "result": "fully_fulfilled",
            "input_amount": 123,
            "output_amount": 123,
            "before_reserves": [
              123
            ],
            "after_reserves": [
              123
            ],
            "reason": "<string>",
            "left_amount": 123
          },
          "recommended_gas": 123,
          "average_gas": 123,
          "next": [
            {}
          ]
        }
      ]
    }
  ],
  "output_token": {
    "address": {
      "blockchain": "ton",
      "address": "native"
    },
    "metadata": {
      "name": "ARBUZ",
      "symbol": "ARBUZ",
      "decimals": 123,
      "image_url": "<string>",
      "listed": true
    }
  },
  "total_output_amount": 123,
  "total_savings": 123,
  "total_estimated_cashback_usd": 123,
  "total_partner_commission_ton": 123,
  "total_mev_protection_fee": 123
}

Authorizations

X-Api-Key
string
header
required

Body

application/json
input_assets
object[]
required
output_asset
object
required
max_splits
integer
default:4

Defines the maximum number of independent paths (i.e., transactions) . For v4 wallets, you can omit this or set it to 4; for v5 wallets, you can set it to 100 (this is our internal upper limit, and we may reduce it later). No more than 20 splits will be used for single input_asset.

Required range: 1 <= x <= 50
max_length
integer
default:3

Defines the maximum length of each path in tokens. It accepts values from [2; 5]. If it's 2, only direct swaps A -> B without multihops are possible. If it's 3, there can be a maximum of 1 intermediate token, i.e., A -> X -> B. If it's 4/5, there can be 2/3 intermediate tokens. A value of 2 deprives you of more profitable exchanges by finding market inefficiencies and does not allow you to exchange tokens without a direct pair (since there can be no intermediate tokens). The higher the value, the more profitable routes can be built, but the higher the likelihood that the user ends up with an intermediate token (since our blockchain is asynchronous, and some swap in the middle of the route may fail due to slippage).

Required range: 2 <= x <= 5
pool_selector
object

Configures the DEX pools that can appear in the generated route. By setting blockchains = ["ton"] inside it, you can remove the dexes field; max_volatility allows you to exclude pools whose volatility has been above a certain percentage in the last 15 minutes. This makes sense when you allow 2-3 intermediate tokens or a large number of splits to smooth out potential issues.

mev_protection
boolean

Whether a MEV protection should be enabled

Example:

true

additional_data
object

Response

200
application/json
resulting route
routes
object[]
required
output_token
object
required
total_output_amount
number
required
total_savings
number
total_estimated_cashback_usd
number
total_partner_commission_ton
number
total_mev_protection_fee
number

Fees for the usage of MEV protection.