StarkFiStarkFi

Fibrous DEX Aggregator

Optimal swap routing, batch routing, and USD pricing

Overview

Fibrous is a DEX aggregator on Starknet that finds optimal swap routes across multiple liquidity sources. StarkFi uses Fibrous for all swap operations — single trades, multi-swaps, and batch operations.

Mainnet only: The Fibrous API operates exclusively on Starknet mainnet. Swap-related commands (trade, multi-swap, batch --swap, portfolio-rebalance) are not available on Sepolia testnet. All other StarkFi features (lending, staking, batch supply/stake/send, portfolio) are fully network-aware and work on both mainnet and Sepolia.

How StarkFi Uses Fibrous

FeatureFibrous APIStarkFi Command
Single SwapgetRoute()getCalldata()trade
Multi-SwapgetRouteBatch()getCalldataBatch()multi-swap
Batch SwapgetRoute() per pairbatch --swap
Health CheckcheckFibrousHealth()status

API Endpoints

EndpointFunctionPurpose
GET /routegetRoute()Get swap route + expected output for a single pair
GET /calldatagetCalldata()Get executable calldata with slippage protection
GET /routeBatchgetRouteBatch()Batch routing for up to 3 pairs (same destination token)
GET /healthCheckcheckFibrousHealth()API health and availability status

Base URL: https://api.fibrous.finance/starknet

Configuration

SettingValue
Base URLhttps://api.fibrous.finance/starknet
Router Contract0x00f6f4CF62E...FDf5a
Default Slippage1%
Max Batch Pairs3

How Routing Works

Single Swap

1. getRoute(tokenIn, tokenOut, amount)    →  Find optimal route + expected output
2. getCalldata(tokenIn, tokenOut, amount) →  Generate executable calldata with slippage
3. Execute via TxBuilder:  approve → swap

Multi-Swap (Batch)

When all pairs share the same output token, Fibrous uses the native routeBatch endpoint for more efficient routing. Otherwise, StarkFi falls back to parallel individual getRoute() calls:

1. getRouteBatch(pairs)       →  Get routes for 2-3 pairs simultaneously
2. getCalldataBatch(pairs)    →  Generate calldata for each pair
3. Execute via TxBuilder:  approve₁ → swap₁ → approve₂ → swap₂ → ...

Error Handling

ErrorCauseResolution
NO_ROUTE_FOUNDNo liquidity path existsTry a different token pair or smaller amount
BATCH_LIMIT_EXCEEDEDMore than 3 pairs in multi-swapSplit into multiple transactions
NETWORK_ERRORFibrous API unreachableCheck status with starkfi status, retry later

All requests use automatic retry with exponential backoff for transient network errors.


See Also

Edit on GitHub

Last updated on

On this page