GET
/
base
/
calldata
curl --location 'https://api.fibrous.finance/base/calldata?amount=100000000000000000&tokenInAddress=0x0000000000000000000000000000000000000000&tokenOutAddress=0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca&slippage=0.1&destination=0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca' \
--header 'Origin: application/javascript'
 

{
    "route": {
        "success": true,
        "routeSwapType": 0,
        "inputToken": {
            "name": "Wrapped Ether",
            "address": "0x4200000000000000000000000000000000000006",
            "decimals": 18,
            "price": 4729.31
        },
        "inputAmount": "100000000000000000",
        "outputToken": {
            "name": "USD Base Coin",
            "address": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "decimals": 6,
            "price": 0.999727
        },
        "outputAmount": "471974940",
        "route": [
            {
                "percent": "100%",
                "swaps": [
                    [
                        {
                            "protocol": 5,
                            "poolName": "Uniswap V3",
                            "poolAddress": "0x4c36388be6f416a29c8d8eee81c771ce6be14b18",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "83%",
                            "extraData": {
                                "fee": 500
                            }
                        },
                        {
                            "protocol": 5,
                            "poolName": "Uniswap V3",
                            "poolAddress": "0x3ddf264ac95d19e81f8c25f4c300c4e59e424d43",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "10%",
                            "extraData": {
                                "fee": 3000
                            }
                        },
                        {
                            "protocol": 9,
                            "poolName": "PancakeSwap V3",
                            "poolAddress": "0xe58b73ff901325b8b2056b29712c50237242f520",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "7%",
                            "extraData": {
                                "fee": 500
                            }
                        }
                    ]
                ]
            }
        ],
        "estimatedGasUsed": "1108171899576",
        "estimatedGasUsedInUsd": 0.010410898218070664,
        "bestQuotesByProtocols": [],
        "time": 0.654,
        "initial": true
    },
    "calldata": {
        "route": {
            "token_in": "0x4200000000000000000000000000000000000006",
            "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "amount_in": "100000000000000000",
            "amount_out": "471974940",
            "min_received": "471502966",
            "destination": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "swap_type": 0
        },
        "swap_parameters": [
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "830000",
                "protocol_id": "5",
                "pool_address": "0x4c36388be6f416a29c8d8eee81c771ce6be14b18",
                "swap_type": 0,
                "extra_data": "0x00000000000000000000000000000000000000000000000000000000000001f4"
            },
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "100000",
                "protocol_id": "5",
                "pool_address": "0x3ddf264ac95d19e81f8c25f4c300c4e59e424d43",
                "swap_type": 0,
                "extra_data": "0x0000000000000000000000000000000000000000000000000000000000000bb8"
            },
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "70000",
                "protocol_id": "9",
                "pool_address": "0xe58b73ff901325b8b2056b29712c50237242f520",
                "swap_type": 0,
                "extra_data": "0x00000000000000000000000000000000000000000000000000000000000001f4"
            }
        ]
    }
}

Endpoint

https://api.fibrous.finance/base/calldata
Generate the calldata required to execute a swap through the Fibrous’ router contract. This endpoint provides the raw transaction data that can be used to execute the swap directly through a Web3 provider.

Request Body Parameters

amount
string
required
The complete response object from the /base/route endpoint. This contains all the necessary information about the optimal route.
tokenInAddress
string
required
The address of the input token.Example: "0x4200000000000000000000000000000000000006" for ETH
tokenOutAddress
string
required
The address of the output token.Example: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" for USDC
reverse
boolean
If true, the amount parameter represents the desired output amount instead of input amount. Default: false
direct
boolean
If true, only direct swaps between the input and output tokens will be considered. Default: false
excludeProtocols
array[string]
Array of protocol names to exclude from routing. Default: []
slippage
number
required
Maximum acceptable slippage in percentage (0.1 to 49). Example: 0.5 for 0.5% slippage tolerance
destination
string
required
The receiver address for the output token.

Response

route
RouteResponse
The complete response object from the /base/route endpoint. This contains all the necessary information about the optimal route.
calldata
CalldataResponse
The hex-encoded calldata to execute the swap through the router contract.

Response Types

export class CalldataResponseDto {
  route: RouteResponse;
  calldata: CalldataResponse;
}

export type RouteResponse =
  | {
      success: false;
      errorMessage: string;
    }
  | {
      success: true;
      inputToken: Token;
      inputAmount: string;
      outputToken: Token;
      outputAmount: string;
      estimatedGasUsed: string;
      estimatedGasUsedInUsd: number;
      route: FormattedRoute[];
      time: number;
      bestQuotesByProtocols: any[];
      initial: boolean;
      routeSwapType: route_swap_type;
};

export type FormattedRoute = {
  percent: Percent;
  swaps: FormattedSwap[][];
};
  
export type FormattedSwap = {
  protocol: Protocol;
  poolName: string;
  poolAddress: string;
  fromTokenAddress: string;
  toTokenAddress: string;
  percent: Percent;
  extraData?: any;
};

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.1 and 49"
}

Invalid Signer

{
  "success": false,
  "error": "Invalid signer",
  "details": "The provided signer address is not valid"
}
curl --location 'https://api.fibrous.finance/base/calldata?amount=100000000000000000&tokenInAddress=0x0000000000000000000000000000000000000000&tokenOutAddress=0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca&slippage=0.1&destination=0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca' \
--header 'Origin: application/javascript'
 

{
    "route": {
        "success": true,
        "routeSwapType": 0,
        "inputToken": {
            "name": "Wrapped Ether",
            "address": "0x4200000000000000000000000000000000000006",
            "decimals": 18,
            "price": 4729.31
        },
        "inputAmount": "100000000000000000",
        "outputToken": {
            "name": "USD Base Coin",
            "address": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "decimals": 6,
            "price": 0.999727
        },
        "outputAmount": "471974940",
        "route": [
            {
                "percent": "100%",
                "swaps": [
                    [
                        {
                            "protocol": 5,
                            "poolName": "Uniswap V3",
                            "poolAddress": "0x4c36388be6f416a29c8d8eee81c771ce6be14b18",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "83%",
                            "extraData": {
                                "fee": 500
                            }
                        },
                        {
                            "protocol": 5,
                            "poolName": "Uniswap V3",
                            "poolAddress": "0x3ddf264ac95d19e81f8c25f4c300c4e59e424d43",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "10%",
                            "extraData": {
                                "fee": 3000
                            }
                        },
                        {
                            "protocol": 9,
                            "poolName": "PancakeSwap V3",
                            "poolAddress": "0xe58b73ff901325b8b2056b29712c50237242f520",
                            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
                            "toTokenAddress": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                            "percent": "7%",
                            "extraData": {
                                "fee": 500
                            }
                        }
                    ]
                ]
            }
        ],
        "estimatedGasUsed": "1108171899576",
        "estimatedGasUsedInUsd": 0.010410898218070664,
        "bestQuotesByProtocols": [],
        "time": 0.654,
        "initial": true
    },
    "calldata": {
        "route": {
            "token_in": "0x4200000000000000000000000000000000000006",
            "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "amount_in": "100000000000000000",
            "amount_out": "471974940",
            "min_received": "471502966",
            "destination": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
            "swap_type": 0
        },
        "swap_parameters": [
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "830000",
                "protocol_id": "5",
                "pool_address": "0x4c36388be6f416a29c8d8eee81c771ce6be14b18",
                "swap_type": 0,
                "extra_data": "0x00000000000000000000000000000000000000000000000000000000000001f4"
            },
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "100000",
                "protocol_id": "5",
                "pool_address": "0x3ddf264ac95d19e81f8c25f4c300c4e59e424d43",
                "swap_type": 0,
                "extra_data": "0x0000000000000000000000000000000000000000000000000000000000000bb8"
            },
            {
                "token_in": "0x4200000000000000000000000000000000000006",
                "token_out": "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca",
                "rate": "70000",
                "protocol_id": "9",
                "pool_address": "0xe58b73ff901325b8b2056b29712c50237242f520",
                "swap_type": 0,
                "extra_data": "0x00000000000000000000000000000000000000000000000000000000000001f4"
            }
        ]
    }
}

Tips

  1. Always verify the min_received amount matches your expectations
  2. Check that the destination address is correct
  3. Consider gas costs when splitting across multiple protocols
  4. Store the route response before requesting calldata

Rate Limits

Please refer to our rate limiting documentation for details about request limits and quotas.