The price was visible.
The slippage looked safe.
The transaction was signed.
But the block was hostile.
And the route was predictable.
The trader blames the DEX.
The real issue?
MEV-aware routing.
Routing Is Defense
MEV Reality
If your route is public, deterministic, and slow, you are advertising your trade to adversarial actors.
Sandwiching Is a Routing Problem (Not a Wallet Problem)
A sandwich happens when an adversary:
- Sees your intent (public mempool / predictable route)
- Gets in front (priority fee, builder preference, faster propagation)
- Moves the price against you (front-run)
- Lets you execute at worse terms
- Extracts back-run profit (closing trade)
This is not just “someone paid more gas.”
It is orderflow exploitation driven by:
- public visibility
- deterministic routing
- slow propagation
- naïve slippage rules
- lack of private paths
Anti-sandwich routing means:
make your intent harder to see, harder to predict, and harder to exploit. 🛡️
What “Anti-Sandwich” Actually Means
Most teams define anti-sandwich as:
- “use lower slippage”
- “set a tighter minOut”
- “use a private RPC sometimes”
That is partial. Real anti-sandwich routing is a policy engine.
| Naive Protection | Execution-Grade Protection |
|---|---|
| Lower slippage | Slippage budgets per venue + volatility regime |
| Single route | Route randomization + venue selection |
| Public broadcast | Private-first propagation with fallbacks |
| Static fees | Adaptive priority & rebid triggers |
| Blind to mempool | Toxicity scoring + sandwich risk model |
Layer 1: Detect Sandwich Risk Before You Route
You can’t defend what you don’t measure.
A practical sandwich risk score can be built from:
- Trade size vs pool depth (impact potential)
- Volatility regime (fast price movement increases capture)
- Mempool pressure (pending density & competing swaps)
- Route predictability (standard routers are easily mirrored)
- Known toxic venues / pools (historical extraction hotspots)
- Time-to-inclusion estimate (latency + fee positioning)
Sandwich Risk Drivers
Where routing decisions should focus
If your router doesn’t compute these signals, it is routing blind.
Layer 2: Venue Selection — Prefer Protected Execution Paths
Anti-sandwich routing starts with where you send the order.
Protected execution venues include:
- Private relays / builders (Ethereum-style private orderflow)
- Bundle markets (Solana Jito-style bundles, builder auctions)
- RFQ / intent solvers (quote-based fills, less mempool exposure)
- MEV-protected AMMs (where applicable; still not magic)
Public First = Advertising
If your default is public mempool broadcast, your router is a signal generator for searchers.
Private First = Policy
A serious router defaults to private propagation and escalates only when inclusion probability drops below threshold.
Layer 3: Route Design — Reduce Predictability
Deterministic routing is exploitable because it is easy to mirror.
Anti-sandwich routing uses:
- Multi-route sampling (generate K candidate routes)
- Entropy injection (choose among near-optimal routes probabilistically)
- Split execution (break large swaps into smaller clips when feasible)
- Path diversity (avoid the single “obvious” pool every time)
- Time jitter (micro-delays to avoid being a consistent target, but only when inclusion probability remains strong)
This is not randomness for fun.
It is making the adversary’s problem harder.
Layer 4: Order Shaping — Make the Trade Harder to Extract
Even with private paths, you still need shaping controls.
Core shaping primitives
-
Dynamic slippage budget
Slippage should be a function of volatility + pool depth + risk score, not a fixed UI setting. -
Price guards & minimum output
Tight minOut is good, but not sufficient if you’re still public + slow. -
Partial fills / clip sizes
A 1-shot fat order is a clean target. -
Deadline discipline
Longer deadlines increase exposure window. -
Revert-aware retries
If a protection path fails, retry with a new route and updated fees — not the same transaction again.
Shape The Order
Extraction Resistance
Anti-sandwich is partly cryptography, partly market microstructure, and mostly execution policy.
Layer 5: Propagation Strategy — Multi-Path, Escalating, Measurable
A robust router uses a propagation ladder:
- Private path (relay / builder / bundle / solver)
- Private + fee bump (if inclusion probability drops)
- Hybrid (multiple private endpoints, multi-region)
- Public fallback (only if user policy allows and the trade is low risk)
Key concept: inclusion probability is the control knob.
If your transaction is not landing, your router must respond fast.
Layer 6: Chain-Specific Anti-Sandwich Tactics
Different chains mean different attack surfaces.
| Environment | Primary Risk | Routing Defense |
|---|---|---|
| Ethereum (builder markets) | Mempool visibility + builder selection | Private relays, bundles, adaptive tips |
| Solana (high throughput) | Latency + bundle competition | Bundle markets, fast propagation, clip sizing |
| BSC (fast + noisy) | Mempool searcher density | Private paths where possible + strict guards |
| L2s (sequencers) | Sequencer ordering policies | Sequencer-aware routing + solver/RFQ when available |
Anti-sandwich routing must be chain-native.
Generic routing is how you get farmed.
The Practical Architecture
Here is an execution-grade blueprint:
-
Risk Scoring Module
Sandwich probability estimator + toxicity labels. -
Route Generator
K routes, path diversity constraints, entropy selection. -
Venue Selector
Private relays / bundles / RFQs prioritized by risk. -
Fee & Inclusion Model
Percentiles, rebid triggers, inclusion SLA. -
Order Shaper
Clip sizing, slippage budgets, deadlines, price guards. -
Propagation Orchestrator
Multi-region endpoints, private-first ladder, telemetry. -
Feedback Loop
Post-trade attribution: where did slippage come from, did we detect pressure, did we escalate correctly?
Execution is not a router function call.
It is an adversarial control system. 🎯
Final Principle
A sandwich is not “bad luck.”
It is a predictable outcome when:
- the trade is visible
- the route is obvious
- the propagation is slow
- the execution policy is naive
Anti-sandwich routing means designing for:
- privacy-by-default
- route unpredictability
- adaptive fees
- state-aware venue selection
- measurable inclusion probability
Because in modern markets:
the block is the battlefield.