DEX Routing
Understand DEX routing, aggregators, split orders, gas, slippage, MEV and why the best displayed route is not always the best realised execution.
Reading progress — saved on this device
DEX routing chooses one or more pools and paths to exchange tokens, often splitting an order across venues to minimise total execution cost rather than simply selecting the pool with the lowest quoted price.
Learning objectives
- Explain why a router may split one swap across several pools.
- Evaluate execution using all-in output after fees, gas and price impact.
- Identify slippage, approval, MEV and route-complexity risks.
What it is
A token pair can trade across many AMMs, fee tiers and intermediate assets. An aggregator queries possible paths and estimates which combination should maximise output for an exact-input trade or minimise input for an exact-output trade.
A direct A→B swap is not always optimal. Routing A→USDC→B, or splitting 60% through one AMM and 40% through another, can reduce price impact when no single pool has enough depth.
How it works
Routers optimise estimates based on current on-chain state. Between simulation and block inclusion, other transactions can change reserves, so realised output can differ.
Gas and network fees matter especially for smaller trades. A complex three-hop route that saves £4 in price impact but costs £10 more in gas is economically inferior.
Slippage tolerance determines how much adverse movement a transaction will accept before reverting. Very loose settings increase execution uncertainty and can make a swap more attractive to sandwich attackers; very tight settings can increase failed transactions in volatile markets.
Token-specific mechanics can break route assumptions. Transfer taxes, rebasing, blacklists or non-standard token behaviour may cause a route to fail or produce less output than an ordinary ERC-20-style model predicts.
How to analyse it
Judge routers by realised all-in execution and failure rate over comparable conditions, not by the headline “best price” badge.
| Check | Why it matters | What to verify |
|---|---|---|
| Depth by route | Different pools support different trade sizes. | Compare executable quotes at the intended notional. |
| Gas cost | More hops and contracts can cost more. | Convert gas to the same currency as expected price improvement. |
| Slippage settings | Tolerance affects both fill probability and adverse execution risk. | Set limits based on volatility and depth rather than a fixed default. |
| Contract/approval surface | Routers interact with multiple contracts and allowances. | Review trusted contracts and minimise unnecessary approvals. |
For large orders, route quality can change non-linearly with size. Test several notionals rather than assuming the same route remains optimal.
If execution is sensitive, consider private transaction channels or other MEV-aware methods where available, while recognising that these add their own counterparties or trust assumptions.
Worked example and thought exercise
A £100,000 swap has three options: Pool A alone would cost an estimated 0.70% including price impact; Pool B alone 0.80%; a split route estimates 0.48% but adds £70 of gas. The split still wins if the saved impact exceeds the extra network cost and the route executes as simulated.
For a £500 swap, the same complex split may be worse because fixed gas is large relative to order value.
Thought exercise: if a route shows 0.2% more output but has a materially higher revert rate, how should expected execution cost incorporate failed gas and delay?
Common mistakes and practical workflow
- Choosing the route with the best quoted token price but ignoring gas.
- Using excessively loose slippage settings.
- Assuming simulated output is guaranteed at block inclusion.
- Granting unlimited approvals to unfamiliar routing contracts without review.
Practical workflow
- Define exact-input or exact-output requirements.
- Compare all-in quotes at the intended size.
- Inspect route hops, pools, gas and contract addresses.
- Set a deliberate minimum-received or maximum-input tolerance.
- Review the actual receipt and realised execution after the trade.
✅ Knowledge checkpoint
- Why can a split route outperform a direct swap?
- How can a “better price” route be worse after gas?
- What trade-off does slippage tolerance control?
- Why should route quality be evaluated at the actual order size?
FAQs
❓ What does a DEX aggregator do?
It searches across pools and paths to estimate a route that improves all-in execution for the requested trade.
❓ Is the quoted output guaranteed?
No. On-chain state can change before execution, and slippage rules determine whether the trade fills or reverts.
❓ Why use intermediate tokens?
A liquid intermediate asset can provide deeper combined liquidity than a direct pair.
❓ Are multi-hop routes riskier?
They can add gas, contracts, approvals and failure points, so the price improvement should justify the complexity.
📋 Summary
DEX routing is an optimisation problem across price impact, fees, gas, liquidity and execution risk. The best route is the one with the best expected realised outcome, not necessarily the most attractive pre-trade quote.
Want this in a personalised order?
Take the crypto assessment and get a custom path of 10 modules matched to what you already know. Free, no card required.
Build my path →