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
| Feature | Fibrous API | StarkFi Command |
|---|---|---|
| Single Swap | getRoute() → getCalldata() | trade |
| Multi-Swap | getRouteBatch() → getCalldataBatch() | multi-swap |
| Batch Swap | getRoute() per pair | batch --swap |
| Health Check | checkFibrousHealth() | status |
API Endpoints
| Endpoint | Function | Purpose |
|---|---|---|
GET /route | getRoute() | Get swap route + expected output for a single pair |
GET /calldata | getCalldata() | Get executable calldata with slippage protection |
GET /routeBatch | getRouteBatch() | Batch routing for up to 3 pairs (same destination token) |
GET /healthCheck | checkFibrousHealth() | API health and availability status |
Base URL: https://api.fibrous.finance/starknet
Configuration
| Setting | Value |
|---|---|
| Base URL | https://api.fibrous.finance/starknet |
| Router Contract | 0x00f6f4CF62E...FDf5a |
| Default Slippage | 1% |
| Max Batch Pairs | 3 |
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 → swapMulti-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
| Error | Cause | Resolution |
|---|---|---|
NO_ROUTE_FOUND | No liquidity path exists | Try a different token pair or smaller amount |
BATCH_LIMIT_EXCEEDED | More than 3 pairs in multi-swap | Split into multiple transactions |
NETWORK_ERROR | Fibrous API unreachable | Check status with starkfi status, retry later |
All requests use automatic retry with exponential backoff for transient network errors.
See Also
- Trading Commands — CLI swap and multi-swap reference
- Trade Tools — MCP tool equivalents for AI agents
- Error Handling — Full error code reference
Last updated on