Skip to main content
POST
/
{network}
/
v2
/
calldata
{
  "route": {
    "token_in": "<string>",
    "token_out": "<string>",
    "amount_in": "<string>",
    "amount_out": "<string>",
    "min_received": "<string>",
    "destination": "<string>",
    "swap_type": 123
  },
  "swap_parameters": [
    {
      "token_in": "<string>",
      "token_out": "<string>",
      "rate": "<string>",
      "protocol_id": "<string>",
      "pool_address": "<string>",
      "swap_type": 123,
      "extra_data": "<string>"
    }
  ],
  "router_address": "<string>",
  "meta": {
    "apiVersion": "<string>",
    "timestamp": "<string>"
  }
}

Overview

The Calldata V2 endpoint generates transaction calldata for executing a swap using a pre-calculated route. This endpoint is useful when you already have a route from the /v2/route endpoint and want to generate the execution calldata with specific slippage and destination parameters. Currently available on Evm networks.
V2 API is currently available on Evm networks. V1 endpoints remain available for backward compatibility.

Endpoint

  • Evm networks
https://api.fibrous.finance/{network}/v2/calldata
Generate transaction calldata for executing a swap using a pre-calculated route. This endpoint is useful when you already have a route and want to generate calldata with different slippage or destination parameters.

Request Body Parameters

route
object
required
The complete route response object from the /v2/route endpoint. This contains all the necessary information about the optimal route.
slippage
number
required
Maximum acceptable slippage percentage (0-49, e.g., 0.5 for 0.5%).
destination
string
required
Recipient address for the output tokens.
API Key Required: Integrator features (integratorAddress, integratorFeePercentageBps, integratorSurplusPercentageBps) require an API key. Partners must obtain an API key from Fibrous Finance to use these monetization features. Include the API key in the request headers as X-API-Key.

Response

route
object
Route information for the calldata.
swap_parameters
array
Array of swap parameters for each hop in the route.
router_address
string
Router contract address for executing the swap.
meta
object
required
API metadata including version and timestamp.

Example Request

curl -X POST "https://api.fibrous.finance/{network}/v2/calldata" \
  -H "Content-Type: application/json" \
  -d '{
    "route": {
      "success": true,
      "routeSwapType": 0,
      "inputToken": {
        "name": "Monad",
        "address": "0x0000000000000000000000000000000000000000",
        "decimals": 18,
        "price": 0
      },
      "inputAmount": "1000000000000000000",
      "outputToken": {
        "name": "Wrapped Monad",
        "address": "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
        "decimals": 18,
        "price": 0
      },
      "outputAmount": "1000000000000000000",
      "estimatedGasUsed": "0",
      "estimatedGasUsedInUsd": 0,
      "route": [],
      "time": 0,
      "bestQuotesByProtocols": [],
      "initial": false
    },
    "slippage": 0.5,
    "destination": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
  }'

Example Response

{
  "route": {
    "token_in": "0x0000000000000000000000000000000000000000",
    "token_out": "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
    "amount_in": "1000000000000000000",
    "amount_out": "1000000000000000000",
    "min_received": "995000000000000000",
    "destination": "0x742d35cc6634c0532925a3b844bc9e7595f0beb",
    "swap_type": 0
  },
  "swap_parameters": [],
  "router_address": "0x274602a953847d807231d2370072f5f4e4594b44",
  "meta": {
    "apiVersion": "2.0",
    "timestamp": "2024-01-15T10:30:00.000Z"
  }
}

Differences from V1

FeatureV1V2
HTTP MethodGETPOST
Meta field✅ Always present
Integrator support✅ With API key
Request formatQuery paramsRequest body

Best Practices

  1. Use fresh routes - Routes can become stale within 30-60 seconds
  2. Verify min_received - Always check that the minimum received amount matches your expectations
  3. Check destination - Ensure the destination address is correct
  4. Monitor meta.timestamp - Track when the calldata was generated

Error Responses

Invalid Route

{
  "success": false,
  "error": "Invalid route",
  "details": "The provided route is invalid or expired"
}

Invalid Slippage

{
  "success": false,
  "error": "Invalid slippage",
  "details": "Slippage must be between 0 and 49"
}