Route Finding

Calculates the optimal swap route between two tokens.

Endpoint: GET /route

Parameters:

Name
Type
Description
Required

tokenA

address

Address of the input token

Yes

tokenB

address

Address of the output token

Yes

amountIn

number

Amount of input token (human readable, e.g., 1.5)

No*

amountOut

number

Desired output amount (for reverse routing)

No*

multiHop

boolean

Set to "true" to enable multi-hop routing

No

excludeDexes

string

Comma-separated list of router indices to exclude

No

* You must provide either amountIn OR amountOut, but not both.

Example Request (Direct Swap):

GET https://api.liqd.ag/route?tokenA=0x47bb061C0204Af921F43DC73C7D7768d2672DdEE&tokenB=0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c&amountIn=1

Example Request (Multi-Hop Swap):

GET https://api.liqd.ag/route?tokenA=0x47bb061C0204Af921F43DC73C7D7768d2672DdEE&tokenB=0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c&amountIn=1&multiHop=true

Example Response:

{
  "success": true,
  "data": {
    "bestPath": {
      "path": ["0x47bb061C0204Af921F43DC73C7D7768d2672DdEE", "0xIntermediate", "0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c"],
      "estimatedAmountOut": "1.05",
      "amountIn": "1",
      "priceImpact": "0.3%",
      "hop": [
        {
          "tokenIn": "0x47bb061C0204Af921F43DC73C7D7768d2672DdEE",
          "tokenOut": "0xIntermediate",
          "hopAmountIn": "1",
          "allocations": [
            {
              "tokenIn": "0x47bb061C0204Af921F43DC73C7D7768d2672DdEE",
              "tokenOut": "0xIntermediate",
              "routerIndex": 1,
              "fee": 0,
              "amountIn": "0.5",
              "stable": true,
              "routerName": "KittenSwap",
              "percentage": 50
            },
            {
              "tokenIn": "0x47bb061C0204Af921F43DC73C7D7768d2672DdEE",
              "tokenOut": "0xIntermediate",
              "routerIndex": 3,
              "fee": 500,
              "amountIn": "0.5",
              "stable": false,
              "routerName": "HyperSwapV3",
              "percentage": 50
            }
          ]
        },
        {
          "tokenIn": "0xIntermediate",
          "tokenOut": "0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c",
          "hopAmountIn": "10.5",
          "allocations": [
            {
              "tokenIn": "0xIntermediate",
              "tokenOut": "0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c",
              "routerIndex": 2,
              "fee": 0,
              "amountIn": "10.5",
              "stable": false,
              "routerName": "HyperSwapV2",
              "percentage": 100
            }
          ]
        }
      ],
      "tokenInfo": {
        "tokenIn": {
          "address": "0x47bb061C0204Af921F43DC73C7D7768d2672DdEE",
          "symbol": "TOKEN1",
          "decimals": 18
        },
        "tokenOut": {
          "address": "0xF26A8ab118f4C46A2D3C0C5cF4bf446008efBf8c",
          "symbol": "TOKEN2",
          "decimals": 18
        },
        "intermediate": {
          "address": "0xIntermediate",
          "symbol": "INTER",
          "decimals": 18
        }
      }
    }
  }
}

Last updated