Skip to main content
GET
/
{network}
/
route
{
  "success": true,
  "routeSwapType": 123,
  "inputToken": {
    "name": "<string>",
    "address": "<string>",
    "decimals": 123,
    "price": 123
  },
  "outputToken": {},
  "inputAmount": "<string>",
  "outputAmount": "<string>",
  "time": 123,
  "estimatedGasUsed": "<string>",
  "estimatedGasUsedInUsd": 123,
  "route": [
    {
      "percent": "<string>",
      "swaps": [
        {
          "protocol": 123,
          "poolName": "<string>",
          "poolAddress": "<string>",
          "fromTokenAddress": "<string>",
          "toTokenAddress": "<string>",
          "percent": "<string>",
          "extraData": {}
        }
      ]
    }
  ],
  "initial": true
}

Overview

The Route endpoint finds the optimal trading path through Fibrous Finance’s liquidity pools to maximize output and minimize slippage. This endpoint is available across all supported networks.

Supported Networks

  • Base
  • HyperEVM
  • Scroll
  • Monad
  • Starknet
https://api.fibrous.finance/base/route

Request Parameters

amount
string
required
The amount of input tokens in wei format (for EVM chains) or the smallest unit for the token.Example: "1000000000000000000" for 1 token with 18 decimals
tokenInAddress
string
required
The contract address of the input token.
  • Base/HyperEVM/Scroll/Monad
  • Starknet
Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE or 0x0000000000000000000000000000000000000000 for native tokens
tokenOutAddress
string
required
The contract address of the output token.
slippage
number
default:"0.5"
Maximum acceptable slippage in percentage (0.1 to 100).Example: 0.5 for 0.5% slippage tolerance
destination
string
The destination address to receive the output tokens. If not provided, defaults to the sender address.
excludeProtocols
string[]
Array of protocol IDs to exclude from routing.
direct
boolean
default:"false"
If true, only direct swaps will be considered (no multi-hop routes).

Response

success
boolean
Indicates if the route was successfully found
routeSwapType
number
Type of swap route (0 = standard)
inputToken
object
Information about the input token
outputToken
object
Information about the output token (same structure as inputToken)
inputAmount
string
The amount of input tokens in wei format
outputAmount
string
The expected amount of output tokens in wei format
time
number
Time taken to calculate the route (in seconds)
estimatedGasUsed
string
Estimated gas units for the transaction
estimatedGasUsedInUsd
number
Estimated gas cost in USD
route
object[]
Array of route segments showing how the swap is split
initial
boolean
Indicates if this is an initial route calculation

Example Request

curl "https://api.fibrous.finance/base/route?amount=1000000000000000000&tokenInAddress=0x0000000000000000000000000000000000000000&tokenOutAddress=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&slippage=0.5"

Example Response

{
  "success": true,
  "routeSwapType": 0,
  "inputToken": {
    "name": "Wrapped Ether",
    "address": "0x4200000000000000000000000000000000000006",
    "decimals": 18,
    "price": 3171.37
  },
  "inputAmount": "1000000000000000000",
  "outputToken": {
    "name": "USD Coin",
    "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "decimals": 6,
    "price": 0.99971
  },
  "outputAmount": "3165007379",
  "time": 0.495,
  "estimatedGasUsed": "0",
  "estimatedGasUsedInUsd": 0,
  "route": [
    {
      "percent": "51%",
      "swaps": [
        [
          {
            "protocol": 9,
            "poolName": "PancakeSwap V3",
            "poolAddress": "0x72ab388e2e2f6facef59e3c3fa2c4e29011c2d38",
            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
            "toTokenAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "percent": "100.00%",
            "extraData": {
              "fee": 100
            }
          }
        ]
      ]
    },
    {
      "percent": "49%",
      "swaps": [
        [
          {
            "protocol": 9,
            "poolName": "PancakeSwap V3",
            "poolAddress": "0xc211e1f853a898bd1302385ccde55f33a8c4b3f3",
            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
            "toTokenAddress": "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
            "percent": "100.00%",
            "extraData": {
              "fee": 100
            }
          }
        ],
        [
          {
            "protocol": 3,
            "poolName": "Aerodrome Slipstream",
            "poolAddress": "0x4e962bb3889bf030368f56810a9c96b83cb3e778",
            "fromTokenAddress": "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
            "toTokenAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "percent": "61.00%",
            "extraData": {
              "tickSpacing": 100
            }
          },
          {
            "protocol": 3,
            "poolName": "Aerodrome Slipstream",
            "poolAddress": "0x3e66e55e97ce60096f74b7c475e8249f2d31a9fb",
            "fromTokenAddress": "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
            "toTokenAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "percent": "39.00%",
            "extraData": {
              "tickSpacing": 2000
            }
          }
        ]
      ]
    }
  ],
  "initial": false
}

Best Practices

  1. Fresh Routes
    • Always fetch a new route before executing a swap
    • Routes can become stale due to market movements
    • Typical validity: 30-60 seconds depending on market volatility
  2. Slippage Settings
    • Stable pairs: 0.1% - 0.5%
    • Volatile pairs: 1% - 3%
    • Low liquidity tokens: 3% - 5%
  3. Gas Optimization
    • Use direct: true for major token pairs
    • Consider gas costs vs. price improvement for small amounts
    • Exclude high-gas protocols when optimizing for speed
  4. Error Handling
    • Implement retry logic with exponential backoff
    • Check for insufficient liquidity errors
    • Validate token addresses before calling

Network-Specific Notes

  • Native token: ETH
  • Common tokens: USDC, USDbC, WETH, DAI
  • Average block time: ~2 seconds
  • Native token: HYPE
  • Common tokens: USDC, WHYPE
  • Average block time: ~2 seconds
  • Native token: ETH
  • Common tokens: USDC, WETH
  • Average block time: ~3 seconds