Overview
By default, the Mobula Swap API automatically finds the best route across all available liquidity sources. However, you may want to target a specific pool or restrict routing to certain protocols — for example, to:- Execute a swap directly through a specific Aerodrome CL pool on Base
- Restrict routing to only Uniswap V3 pools
- Avoid certain factory contracts
- Force routing through a specific DEX for compliance or analytics
Key difference:
poolAddress routes the swap directly on-chain through MobulaRouter’s executeRoute function. onlyProtocols passes the restriction to an external aggregator (KyberSwap, Jupiter) which handles the routing.Direct Pool Access (poolAddress)
Use poolAddress when you know the exact pool contract address and want to swap directly through it, without going through an external aggregator. The swap is executed on-chain via MobulaRouter’s internal routing engine.
Basic Example
Route a USDC → WETH swap directly through a specific Aerodrome CL pool on Base:Concrete Example — USDC to TKFG on Aerodrome CL (Base)
This example swaps ~300 USDC (raw units) to TKFG on Base, routed directly through the Aerodrome CL pool:executeRoute selector (0xa564dfa4), executing the swap directly on-chain without any aggregator intermediary.
When to Use poolAddress
- You want zero aggregator fees — the swap goes directly through the pool
- You need deterministic routing — always the exact same pool, no fallback
- You’re building a pool-specific UI (e.g., showing swap for a specific market)
- Multiple pools exist for the same pair (e.g., different fee tiers) and you want a specific one
Filtering by Protocol (onlyProtocols)
Use onlyProtocols to restrict the swap to pools of a specific type. The swap is routed through an external aggregator (KyberSwap on EVM, Jupiter on Solana) which applies the filter.
Single Protocol
Route a swap exclusively through Uniswap V3 pools:Multiple Protocols
Route through either Aerodrome CL or Uniswap V3 pools on Base:Excluding Protocols (excludedProtocols)
Use excludedProtocols to exclude specific factory addresses from routing. Unlike onlyProtocols which takes pool type names, this parameter takes factory contract addresses:
Common Pool Types
EVM Chains
Solana
Only tradable pool types are accepted by
onlyProtocols. Non-tradable types are automatically filtered out. If no valid pool types remain after filtering, the API returns a “No route found” error.