Swap safety guards
Guards that stop swaps from routing into dust pools or stranding tokens.
- Stack
- TypeScriptUniswap V4eth_simulateV1
On new chains, liquidity is thin and fragmented, and aggregators don't always see it. A route can look fine on paper and still sell into a nearly empty pool, or partially fill and leave tokens stuck in a settlement contract.
I traced two of these failures end to end onchain, then designed and shipped the guards that stop them, now live in production.
What I built
- A reference-price check that fails closed when a quote drifts too far from onchain prices, including Uniswap V4 pools that indexers miss.
- A floor that aborts the request when filtering has thrown away every good quote, instead of serving the bad one that's left.
- Simulation that tolerates harmless dust like hook fees but rejects real stranding.
- A post-trade watcher that compares what was quoted with what was actually received.