Smart Routing & Aggregator
AchSwap's smart routing system automatically finds the best swap rate across V2, V3, and V4 pools. The aggregator takes this further by splitting trades across multiple protocols for optimal execution.
How Smart Routing Works
Multi-Protocol Quotes
When you request a swap, the system queries all enabled protocols in parallel:
- V2 Pools — Direct pair and hop-through-wrapped routes
- V3 Pools — All 5 fee tiers (single-hop) plus 25 multi-hop combinations
- V4 Pools — All registered V4 pools with hooks
- Aggregator — Optimal split across V2, V3, and V4 adapters
The best quote is selected by output amount, and you can manually override to use any available route.
Route Selection
USDC → ACHS
V2: 2,480 ACHS (direct)
V3: 2,495 ACHS (0.05% fee tier) ← Selected (best)
V4: 2,490 ACHS (0.30% pool)
Agg: 2,501 ACHS (60% V3 + 40% V4)
The Aggregator
The AchSwap aggregator splits your trade across multiple protocols to minimize price impact and maximize output.
How Aggregator Splitting Works
- Probe each adapter — Get quotes from V2, V3, and V4 adapters for the full amount
- Coarse search — Test 10% increment splits across adapter pairs
- Fine search — Refine the top candidates with 1% increments
- Select best — Choose the split with highest net output
Example Split
Trade: 10,000 USDC → ACHS
Single V3 route: 24,800 ACHS
Aggregator split:
├─ 60% via V3: 14,940 ACHS
└─ 40% via V4: 10,020 ACHS
Total: 24,960 ACHS (+0.6% better)
Source Mask
The aggregator uses a bitmask to select which protocols to include:
| Protocol | Bit Value |
|---|---|
| V2 | 1 |
| V3 | 2 |
| V4 | 4 |
For example, source mask 7 (1+2+4) enables all three protocols.
Aggregator Fee
The aggregator charges a 0.1% fee (10 basis points) on the gross output. This is deducted before displaying the net output.
Protocol-Specific Routing
V2 Routing
- Queries direct path and hop-through-wrapped path
- Uses
getAmountsOuton the V2 Router - Best for: Simple pairs, stablecoins
V3 Routing
- Tests all 5 fee tiers in parallel
- Multi-hop through wrapped token (25 fee-tier combinations)
- Uses
QuoterV2for accurate quotes with gas estimates - Best for: Concentrated liquidity, volatile pairs
V4 Routing
- Queries all registered V4 pools
- Supports hook-enabled pools
- Uses the V4 Router's
quoteExactInputSingle - Best for: Custom hook logic, new pool types
Configuration
Protocol Toggles
In swap settings, you can enable/disable each protocol:
- V2 — Classic constant product AMM
- V3 — Concentrated liquidity pools
- V4 — Hook-enabled singleton pools
- Aggregator — Split routing across all protocols
Aggregator Sub-Source Toggles
When the aggregator is enabled, you can also toggle which sub-sources it uses:
- Aggregator V2 — Route splits through V2 adapter
- Aggregator V3 — Route splits through V3 adapter
- Aggregator V4 — Route splits through V4 adapter
Default Settings
All protocols and aggregator sources are enabled by default for maximum rate optimization.
Price Impact
Impact Calculation
Price impact is measured by comparing the spot price to the execution price:
Impact = (Spot Output - Actual Output) / Spot Output × 100
Impact Thresholds
| Impact | UI Warning |
|---|---|
| < 1% | None |
| 1% - 5% | Yellow warning |
| > 15% | Red warning + confirmation required |
Multi-Protocol Impact
The aggregator reduces price impact by splitting large trades across deeper pools.
Troubleshooting
"No route found"
- No pools exist for this token pair
- Try enabling more protocols in settings
- For V4, ensure the pool is registered on-chain
"Aggregator has no route"
- The V4 adapter may not be registered in the aggregator
- Enable V2 or V3 as fallback sources
- Try a smaller amount
Quote takes a while
- V3 queries 5+25 fee-tier combinations in parallel
- Aggregator probes multiple adapters and split combinations
- Large amounts trigger coarse + fine split search
- Results are cached for 5 seconds
Best Practices
- Trust smart routing — It finds the best path automatically
- Check the route — Review which protocol/split was selected
- Use aggregator for large trades — Splits reduce price impact
- Enable all protocols — More options = better rates