GET
/
base
/
execute
curl -X POST "https://api.fibrous.finance/base/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "route": {
      "inputToken": {
        "address": "0x4200000000000000000000000000000000000006",
        "symbol": "ETH",
        "decimals": 18
      },
      "inputAmount": "1000000000000000000",
      "outputToken": {
        "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "symbol": "USDC",
        "decimals": 6
      },
      "outputAmount": "1650230000",
      "route": [
        {
          "protocol": "uniswap",
          "poolAddress": "0x...",
          "tokenIn": "0x4200000000000000000000000000000000000006",
          "tokenOut": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        }
      ]
    },
    "slippageTolerance": 0.5,
    "deadline": 1703980800
  }'
{
  "success": true,
  "data": {
    "to": "0x1234...",
    "data": "0x...",
    "value": "0"
  }
}

https://api.fibrous.finance/base

Execute a token swap using the optimal route previously found through the route endpoint. This endpoint handles the actual transaction execution and ensures the swap is performed with the best possible outcome.

Request Body Parameters

route
object
required

The route object returned from the /base/route endpoint. This contains all necessary information about the swap path and expected outcomes.

slippageTolerance
number
default:"0.5"

Maximum acceptable slippage in percentage (0.1 to 100). Example: 0.5 for 0.5% slippage tolerance

deadline
number

Unix timestamp (in seconds) after which the transaction will revert. Defaults to 20 minutes from the current time if not specified.

recipient
string

The address that will receive the output tokens. If not specified, tokens will be sent to the transaction sender.

Response

success
boolean

Indicates if the execution request was successful.

transactionHash
string

The hash of the executed transaction.

route
object

The executed route details.

execution
object

Execution details.

Error Responses

Route Expired

{
  "success": false,
  "error": "Route expired",
  "details": "The provided route has expired. Please fetch a new route."
}

Slippage Exceeded

{
  "success": false,
  "error": "Slippage exceeded",
  "details": "The swap would result in more slippage than allowed"
}

Insufficient Balance

{
  "success": false,
  "error": "Insufficient balance",
  "details": "Wallet does not have enough tokens for the swap"
}

Invalid Deadline

{
  "success": false,
  "error": "Invalid deadline",
  "details": "Deadline must be a future timestamp"
}
curl -X POST "https://api.fibrous.finance/base/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "route": {
      "inputToken": {
        "address": "0x4200000000000000000000000000000000000006",
        "symbol": "ETH",
        "decimals": 18
      },
      "inputAmount": "1000000000000000000",
      "outputToken": {
        "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "symbol": "USDC",
        "decimals": 6
      },
      "outputAmount": "1650230000",
      "route": [
        {
          "protocol": "uniswap",
          "poolAddress": "0x...",
          "tokenIn": "0x4200000000000000000000000000000000000006",
          "tokenOut": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
        }
      ]
    },
    "slippageTolerance": 0.5,
    "deadline": 1703980800
  }'
{
  "success": true,
  "data": {
    "to": "0x1234...",
    "data": "0x...",
    "value": "0"
  }
}

Best Practices

  1. Route Freshness

    • Always use a fresh route from the /base/route endpoint
    • Routes can become stale due to market movements
    • Implement retry logic with fresh routes if execution fails
  2. Slippage Management

    • Set appropriate slippage tolerance based on:
      • Token pair volatility
      • Trade size
      • Market conditions
    • Higher values increase success rate but may result in worse prices
    • Lower values ensure better prices but may cause more failed transactions
  3. Deadline Setting

    • Set reasonable deadlines to prevent stale transactions
    • Consider network congestion when setting deadlines
    • Default of 20 minutes is suitable for most cases
  4. Gas Optimization

    • Monitor gasUsed in responses to optimize future transactions
    • Consider using direct routes for major pairs
    • Bundle multiple swaps if possible

See Also