Get Best Route

Find the most optimal route for swapping tokens across chains. This API determines the best path based on source/destination tokens, chains, amount, and user wallet addresses. Check out the getBestRoute API template script for implementation details.

POST
/vpc/v1/get-best-route

Authorization

x-authorization-secret<token>

Trade Service Secret (set this to the value of TRADE_SERVICE_SECRET from .env)

In: header

Request Body

application/jsonRequired
routeIdstring
fromTokenRequiredstring
fromChainRequiredstring
toTokenRequiredstring
toChainRequiredstring
sameChainFeestring
sameChainFeeCollectorstring
crossChainFeestring
crossChainFeeCollectorstring
fromAmountRequiredstring
slippagestring
permitDeadlinestring
fromUserWalletAddressRequiredstring
toUserWalletAddressRequiredstring
curl -X POST "https://okto-trade-service.oktostage.com//vpc/v1/get-best-route" \
  -H "x-authorization-secret: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "routeId": "80c5a9e7-92a8-49f8-ac55-21f883bf8bc3",
    "fromToken": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
    "fromChain": "eip155:8453",
    "toToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    "toChain": "eip155:42161",
    "sameChainFee": "10",
    "sameChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
    "crossChainFee": "10",
    "crossChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
    "fromAmount": "1000",
    "slippage": "3.0",
    "permitDeadline": "",
    "fromUserWalletAddress": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
    "toUserWalletAddress": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9"
  }'

Fetched

{
  "routeId": "ea95acb6-3b29-49bc-8af5-b9332d5225b4",
  "priceImpact": "0",
  "isPriceImpactCalculated": true,
  "tokenPrices": {
    "fromTokenPriceInUSD": "100",
    "toTokenPriceInUSD": "100"
  },
  "feeCharged": false,
  "outputAmount": "1056",
  "steps": [
    {
      "type": "transaction",
      "metadata": {
        "serviceType": "bridge",
        "transactionType": "approval",
        "protocol": "Okto_ULL",
        "aggregatorName": "Okto_ULL"
      },
      "chainId": "9400de12-efc6-3e69-ab02-0eaf5aaf21e5",
      "txnData": {
        "to": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
        "from": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
        "gasPrice": "3725024",
        "gasLimit": "21000",
        "value": "0x0",
        "data": "0x095ea7b3000000000000000000000000d33a607f1c54e76770c21e40a560e411706ca448ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "chainId": "8453",
        "transactionCost": "535761940224",
        "l1GasCost": "342768446784"
      },
      "intentCalldata": {}
    }
  ],
  "permitDataToSign": "{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"PermitBatchTransferFrom\":[{\"name\":\"permitted\",\"type\":\"TokenPermissions[]\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}],\"TokenPermissions\":[{\"name\":\"token\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}]},\"primaryType\":\"PermitBatchTransferFrom\",\"domain\":{\"name\":\"Permit2\",\"chainId\":8453,\"verifyingContract\":\"0x000000000022D473030F116dDEE9F6B43aC78BA3\"},\"message\":{\"deadline\":\"1740749617\",\"nonce\":\"3250162946\",\"permitted\":[{\"amount\":\"1000\",\"token\":\"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2\"}],\"spender\":\"0xd33a607f1c54e76770C21E40A560E411706ca448\"}}",
  "routeExpiry": "1m0s"
}