Your swap

ComponentAmount (USD)

Slippage tolerance sweep

Same trade size — how the attacker's extractable value scales with your slippage setting.

Slippage toleranceExtractable (gross)Attacker net profit

How a sandwich attack works

Your swap sits in the public mempool for a few seconds before it's mined. A bot sees it, and does three things in the same block:

This calculator uses the standard heuristic: the attacker's gross extractable value ≈ trade size × slippage tolerance, since that's the exact ceiling your transaction will accept before reverting. Net profit subtracts two gas transactions and two DEX fee legs. It's a simplified model — real extraction also depends on pool depth and exact AMM curve — but it's the right order of magnitude for deciding how tight to set your slippage.

Minimum profitable trade size for the attacker

Below a certain trade size, gas costs eat the entire extractable value and the attack isn't worth running. That break-even point is exactly what the table above shows flip from "not profitable" to "profitable" as slippage tolerance rises.

Related: Slippage calculator · Network fees · Impermanent loss · Triangular arbitrage

Frequently asked questions

What is a sandwich attack?

A sandwich attack is when a bot sees your pending DEX swap in the mempool, buys the token right before your trade (pushing the price up), lets your trade execute at the worse price, then sells immediately after (pocketing the difference). You still get your tokens, but at a worse rate than you would have without the attack — the extra cost is called MEV (maximal extractable value).

How much can a sandwich attacker extract from my trade?

As a rule of thumb, the attacker can extract up to your slippage tolerance, since that is the worst price your transaction will still accept before reverting. A 1% slippage tolerance on a $10,000 swap gives an attacker roughly $100 of extractable value before their own costs (gas and DEX fees on both legs). Tighter slippage tolerance directly caps the attacker's ceiling.

Why does slippage tolerance matter so much for MEV?

Slippage tolerance is the exact number the attacker targets: they push the price up just enough that your trade still executes (doesn't revert) but at the worst price you'll accept. Wallets that default to 1-3% slippage tolerance on volatile pairs are handing sandwich bots a wide, predictable margin. Tightening it to 0.1-0.5% on liquid pairs shrinks the attack's ceiling directly.

How do I protect my trade from sandwich attacks?

Three practical defenses: (1) set the tightest slippage tolerance your trade can tolerate without reverting, (2) route through a private RPC / mempool (Flashbots Protect, MEV Blocker, or your wallet's built-in private transaction option) so the trade never appears in the public mempool for bots to see, (3) split large trades into smaller chunks or use a DEX aggregator with built-in MEV protection.

Does sandwich MEV happen on every chain?

It is most common and most profitable on Ethereum mainnet, where gas costs enough that attackers need meaningful trade sizes to profit, but block building is centralized enough (via relays) that sandwich bots operate at scale. It exists on L2s and other chains too, but lower gas costs lower the attacker's break-even trade size while faster, more fragmented block building can make consistent sandwiching harder to run profitably.

Share: 𝕏 Post Reddit