v3

latestOpenAPI 3.0.32026-07-21128192192.7 KB
Routing

Returns the best route for the given trade pair

post/v1/route

Request body

input_amountnumber double

Input amount in tokens (not nano!) to be swapped

output_amountnumber double

If specified, the route will be built to get the specified output amount. If not specified, the route will be built to get the maximum output amount for the given input amount.

max_splitsinteger

Defines the maximum number of independent paths (i.e., transactions) the route can split into. For v4 wallets, you can omit this or set it to 4; for v5 wallets, you can set it to 20 (this is our internal upper limit, and we may reduce it later to something like 10).

max_lengthinteger

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).

mev_protectionboolean

Whether a MEV protection should be enabled

Example request

{
  "input_token": {
    "blockchain": "ton",
    "address": "native"
  },
  "output_token": {
    "blockchain": "ton",
    "address": "native"
  },
  "pool_selector": {
    "blockchains": [
      "ton"
    ],
    "dexes": [
      "dedust"
    ]
  },
  "mev_protection": true,
  "additional_data": {
    "sender_address": "UQCNTO0Nh0Z7QNyRW1BLWfk08f2dAOw4izrx9sO6OUPg4DoV",
    "referral_name": "tonkeeper"
  }
}

Response

resulting route

input_amountnumber double required
output_amountnumber double required
input_usdnumber double required
output_usdnumber double required
savingsnumber double
left_amountnumber double
recommended_gasnumber double required
price_impactnumber double required
estimated_cashback_usdnumber double
partner_commission_tonnumber double
mev_protection_feenumber double

Fees for the usage of MEV protection.