Skip to content
NFTVenue Ledger
Directory

Amm Clob Intent Dex Settlement

Sandwich MEV Attacks: Closed-Form Optimal Frontrun Sizing & Slippage Tolerance Exploitation

Every basis point of excess amountOutMinimum slippage tolerance on a public-mempool AMM swap acts as a deterministic limit order inviting atomic frontrun-backrun sandwich extraction.

By Dr. Devon Kurosawa, PhDReview not recorded
Sandwich MEV Attacks: Closed-Form Optimal Frontrun Sizing & Slippage Tolerance Exploitation — NFTVenue Ledger 2026 quantitative & supervisory data card
NFTVenue Ledger (Concentrated Liquidity AMMs, On-Chain CLOBs, Intent Solvers & MEV): Closed-form frontrun quadratic roots, 2*f fee hurdles, club sandwiches, and OFA shields.Source: NFTVenue Ledger Institutional Research DeskLicense: CC-BY-4.0

When a swapper broadcasts exactInputSingle({ amountIn, amountOutMinimum }) to a public P2P mempool with a careless 1.00% or 2.00% UI slippage tolerance on a deep pool whose true price impact is only 0.08%, that unused 92–192 bps buffer does not remain an idle safety cushion. Searchers operating across the MEV-Boost PBS framework compute the exact closed-form *Optimal Frontrun Input (`DeltaxF)** that pushes the AMM marginal price upward until the victim's transaction executes **within 1 wei of amountOutMinimum**—followed immediately in the next transaction index by an atomic backrun selling DeltaxF*` into the victim's artificially inflated post-trade reserve!

Anchored in our concentrated AMM, CLOB & intent DEX master guide, auditing slippage bounds and RPC transport security is mandatory across every public EVM and Solana AMM tracked in our marketplaces directory (from Apeswap and Auraswap to 9mm Pro).

Three-Step Atomic Sandwich Invariant & Why Zero Capital Is Needed#

Unlike JIT liquidity, a pure constant-product or Concentrated Liquidity AMM sandwich requires zero upfront searcher inventory beyond flash-swap fees:

  1. Tx_1 (Frontrun Buy): Searcher flash-borrows USDC from Balancer (0 bps flash fee!) or Uniswap v4 unlock, buying ETH on the target pool and driving spot price from P_0 up to P_1.
  2. Tx_2 (Victim Swap): Unaware of Tx_1, the victim's USDC -> ETH swap executes at degraded price P_1 -> P_2, landing at amountOut == amountOutMinimum (preventing EVM revert!).
  3. Tx_3 (Backrun Sell): Searcher sells the exact ETH bought in Tx_1 back into the pool at elevated price P_2 -> P_3, repays the Balancer flash loan in the same callback, and sweeps 90% of net profit Pi_sandwich to the block builder via block.coinbase.transfer.
Atomic 3-step flash-loaned sandwich MEV attack pushing victim AMM swap to amountOutMinimum
Atomic 3-step flash-loaned sandwich MEV attack pushing victim AMM swap to amountOutMinimumVerified Exhibit

Why Swap Fees 2 * f Bound Small-Trade Sandwiches (Until Multi-Victim Batching!)#

Notice that the sandwich bot must pay the pool swap fee f twice (once on Tx_1 frontrun and once on Tx_3 backrun) plus ~190,000 gas for two swaps. Consequently, if a victim sets slippage slack s_slack <= 2 * f (for instance, s_slack = 8 bps on a 5 bps pool where 2 * f = 10 bps), a single-victim sandwich is mathematically unprofitable regardless of trade size!

However, sophisticated builders execute Multi-Meat ("Club") Sandwiches: bundling K = 3..8 retail swaps heading in the same direction inside a single outer frontrun/backrun pair, paying 2 * f and gas only once across the combined orderflow!

Sandwich Vulnerability & Protection Matrix Across Routing Channels#

Quantitative Distribution · Public Mempool Visibility
Public Mempool VisibilitySlippage Slack Exploitation Risk
01Default Public RPC + 1.0% U…100% Cleartext …02Public RPC + Dynamic Tight …100% Cleartext …
Order Submission ChannelPublic Mempool VisibilitySlippage Slack Exploitation RiskBackrun Rebate Captured by User
Default Public RPC + 1.0% UI Slippage100% Cleartext P2P BroadcastNear-100% Sandwiched once profit > gas + 2f0% (100% lost to searcher/validator)
Public RPC + Dynamic Tight Slippage (<= 1.5 * f)100% Cleartext P2P BroadcastImmune to 1-victim sandwich; higher legitimate revert rate0%
Private Builder RPC (Flashbots Protect)Hidden (Sent only to builders)Zero frontrun; unbundled only on rare uncle/reorgOptional fast-mode or refund
Orderflow Auction RPC (MEV-Blocker)Stripped simulation to searchersZero frontrun (contractually & technically barred)90% of harmless backrun refunded!
Off-Chain Signed Intent (CoW Batch)Off-chain API onlyZero frontrun + Uniform Clearing Price100% CoW + solver competition surplus
Realized sandwich MEV loss in USD for a $250,000 ETH/USDC swap across progressive slippage settings
Realized sandwich MEV loss in USD for a $250,000 ETH/USDC swap across progressive slippage settingsVerified Exhibit

Closed-Form Optimal Frontrun Sizing (Delta_x_F*) on x * y = k#

Given pool reserves (x_0, y_0), swap retention factor gamma = 1 - f (e.g., 0.997 for a 30-bps pool), victim input Delta_x_V, and victim minimum output y_min, the post-frontrun reserve x_1 = x_0 + gamma * Delta_x_F that leaves the victim exact output y_min satisfies a quadratic equation with exact positive root:

Formula or model from the articleNot independently verified
Exact Sandwich Maximum Extractable Frontrun & Net Profit:
  • Victim Output Condition:
  • yout(x1) = (y1 * gamma * DeltaxV) / (x1 + gamma * DeltaxV) = ymin, where y1 approx (x0 * y0) / x_1
  • Solving for Post-Frontrun Reserve x_1*:
  • x1* = ( -gamma * DeltaxV + sqrt( (gamma * DeltaxV)^2 + (4 * x0 * y0 * gamma * DeltaxV) / ymin ) ) / 2
  • Optimal Frontrun Input: DeltaxF* = max(0, (x1* - x0) / gamma)
  • Worked Public Mempool Audit (Pool: x0 = 10,000,000 USDC, y0 = 3,333.33 ETH, f = 5 bps => gamma = 0.9995):
  • Victim swaps DeltaxV = 200,000 USDC (un-sandwiched output = 65.327 ETH) with 1.00% slippage => y_min = 64.674 ETH:
  • => Solved post-frontrun reserve x_1* = 10,050,410 USDC (+0.504% reserve => +1.01% spot price shift):
  • => Optimal flash-borrowed frontrun DeltaxF* = (10,050,410 - 10,000,000) / 0.9995 = 50,435 USDC
  • => Victim loses 0.653 ETH ($1,959); Searcher pays 2 * 5 bps on $50.4k ($50.44) + $18 gas => Net MEV Profit = ~$1,890!

Hardening Frontend Routers & Smart-Contract Vaults#

Production aggregators and yield vaults eliminate sandwich risk through three mandatory engineering rules: never set deadline = block.timestamp inside on-chain contracts (which passes every block forever!), dynamically bound amountOutMinimum via off-chain tick simulation, and transmit exclusively via MEV-Blocker or CoW Protocol batch auctions—or migrate execution onto app-chain CLOB price-time books inside our AMM, CLOB & Intent DEX hub.

Frequently asked questions

Why does setting 2% slippage guarantee a ~2% loss on large public Ethereum swaps?

Public mempool searchers treat amountOutMinimum as a limit price; as long as your excess slippage slack exceeds twice the pool fee plus ~190k gas, a flash-loaned frontrun-backrun bundle extracts virtually 100% of that slack.

Why is deadline = block.timestamp a critical vulnerability in Solidity DEX integrations?

Inside an EVM contract, block.timestamp evaluates to the exact timestamp of whichever future block includes the transaction—meaning a stalled or censored transaction never expires and can be sandwiched hours later after prices move.

Can a transaction sent through Flashbots Protect or MEV-Blocker still get sandwiched?

Private builder RPCs withhold pending calldata from the public P2P mempool so searchers cannot frontrun; the sole residual edge case (~0.1%–0.2%) is an uncle/reorg block leaking txs, mitigated by tight 1-to-2-slot deadlines.

What is a multi-victim ("club") sandwich in block building?

When several small swaps in the same block each have too little slippage slack to cover 2*f + gas individually, a builder wraps one frontrun before all of them and one backrun after all of them to amortize fixed costs.

Publication record

Published
November 14, 2026
Updated
November 14, 2026
Author
Dr. Devon Kurosawa, PhD
Review
Review not recorded
Automated fact check
Passed in the stored pipeline record
Source URLs
3 recorded

AI assistance recorded: anthropic/claude-opus-4.6. This field does not establish human review or source verification.

Academic & Institutional Attribution

Cite This Research & Embed Live Data Card

Open Attribution License (CC BY 4.0)

Standard academic & institutional research paper citation format.

Dr. Devon Kurosawa, PhD. (2026, November 14). Sandwich MEV Attacks: Closed-Form Optimal Frontrun Sizing & Slippage Tolerance Exploitation. NFTVenue Ledger. https://nftvenueledger.com/protocols/sandwich-mev-slippage-tolerance-optimal-frontrun-sizing

Regulatory Directory Cross-Reference

Referenced Institutions & Regulatory Registries

Primary Tier-1 Supervisory Registries

Explore Amm Clob Intent Dex Settlement Hub (20) →

NFTVenue Ledger Data, Benchmarks & Contributor Records

Sandwich MEV Attacks: Optimal Frontrun & Slippage Math | NFTVenue Ledger