Routing and Quotes
A robust router evaluates executable routes rather than choosing a pool by TVL alone. The largest pool is not always the best price, and the best quoted price is not always executable.
Candidate discovery
- Fetch live pools and exclude unsupported or inactive factories.
- Keep pools containing the input token, output token or an approved connector asset.
- Model tokens as graph vertices and pools as edges.
- Support parallel edges, because the same pair can have stable, volatile and multiple concentrated pools.
- Search direct and bounded multi-hop paths; a maximum of three pool hops is a common practical limit.
Quote evaluation
For each candidate path:
- call the compatible quoter with the exact input;
- discard reverting or zero-output quotes;
- estimate gas where practical;
- validate token behaviour;
- compare final output after fees and estimated execution cost;
- select the route that best matches the application's objective.
The pool with the most liquidity can produce a worse quote than a smaller pool with a more appropriate curve, active range or fee setting.
Mixed routes
A mixed route can traverse basic and concentrated pools. Its encoded path must preserve logical token direction even when that direction is opposite to a pool's internal token0/token1 order.
Never copy route-type constants from another deployment without checking Raphael's router and quoter implementation.
Execution
Once a route is selected:
- derive the minimum output from the user's slippage tolerance;
- request only the required token approval;
- set a short, reasonable deadline;
- simulate the exact call;
- submit through the correct Raphael router;
- confirm the receipt and actual output.
Refresh stale quotes. A quote is not a reservation of pool state; it is a snapshot of one block that the next block may contradict.