executionrouting

How to Design Anti-Sandwich Order Routing

Anti-sandwich routing is not a single trick — it is an execution system that detects MEV conditions, chooses protected venues, shapes orders, and adaptively re-prices to maximize inclusion probability while minimizing toxic flow exposure.

T
TradeBlocks
How to Design Anti-Sandwich Order Routing

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:

  1. Sees your intent (public mempool / predictable route)
  2. Gets in front (priority fee, builder preference, faster propagation)
  3. Moves the price against you (front-run)
  4. Lets you execute at worse terms
  5. 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 ProtectionExecution-Grade Protection
Lower slippageSlippage budgets per venue + volatility regime
Single routeRoute randomization + venue selection
Public broadcastPrivate-first propagation with fallbacks
Static feesAdaptive priority & rebid triggers
Blind to mempoolToxicity 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

50–80%Preventable
Public Visibility30%
Route Predictability20%
Fee Mispricing15%
Liquidity Thinness15%
Mempool Pressure10%
Latency10%

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:

  1. Private path (relay / builder / bundle / solver)
  2. Private + fee bump (if inclusion probability drops)
  3. Hybrid (multiple private endpoints, multi-region)
  4. 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.

EnvironmentPrimary RiskRouting Defense
Ethereum (builder markets)Mempool visibility + builder selectionPrivate relays, bundles, adaptive tips
Solana (high throughput)Latency + bundle competitionBundle markets, fast propagation, clip sizing
BSC (fast + noisy)Mempool searcher densityPrivate paths where possible + strict guards
L2s (sequencers)Sequencer ordering policiesSequencer-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:

  1. Risk Scoring Module
    Sandwich probability estimator + toxicity labels.

  2. Route Generator
    K routes, path diversity constraints, entropy selection.

  3. Venue Selector
    Private relays / bundles / RFQs prioritized by risk.

  4. Fee & Inclusion Model
    Percentiles, rebid triggers, inclusion SLA.

  5. Order Shaper
    Clip sizing, slippage budgets, deadlines, price guards.

  6. Propagation Orchestrator
    Multi-region endpoints, private-first ladder, telemetry.

  7. 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.


Read More Infrastructure Insights →
Explore TradeBlocks →