Sandwich Attacks

A sandwich attack places two transactions around yours: one before (frontrun) that moves the price up, and one after (backrun) that sells at the inflated price. You get a worse price; the bot profits from the difference.

Anatomy of a Sandwich

1
Frontrun
Bot buys ETH, pushing price up
2
Your Swap
You buy ETH at a worse price
3
Backrun
Bot sells ETH at the inflated price
4
Profit
Bot keeps the price difference

Your Loss Calculator

Price Impact (no attack)
0.50%
Your Extra Loss
$125
Bot Profit
~$120

Protection Methods

  • Flashbots Protect — Send txs through private mempools
  • Low slippage — Reduce max slippage tolerance
  • MEV-blocker — OFA (Order Flow Auctions) that rebate MEV to you
  • Smaller swaps — Split large trades across multiple txs
  • CoW Swap — Batch auctions with MEV protection built in