Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin Chain SAFU CryptoTax DeFAI AGI Claude Me Claude Skill Claude Design Claude Cowork
Independent Media
Not affiliated with any project
The Deepest Crypto Knowledge Base
crypto-bible.com
LATEST
A Complete Stablecoin Guide: How USDT and USDC Work, Three Types and Their Risks  ·  DeFi 101: What Decentralized Finance Is and What It Lets You Do  ·  What Is a Smart Contract? Why It Auto-Executes and Why It Carries Risk  ·  What Is Layer 2? Why Ethereum Needs It and How Rollups Work  ·  Why a Low-Priced Coin Isn't Necessarily Cheap: Market Cap and Supply Explained  ·  How to Read a Crypto Coin's Info Page: Market Cap, FDV, Supply, and 24h Volume
security

What Are MEV and Sandwich Attacks? How Your On-Chain Trade Gets Squeezed, and How to Protect Yourself

30-Second Version · For the impatient
On a DEX your pending trade is public, so a bot can buy ahead to push the price up and sell behind you — your trade becomes the sandwich filling. Setting slippage tight is the simplest defense.

Full Explanation +
01 · Why did this happen?

What exactly is MEV? MEV stands for "maximal extractable value," the extra profit that those with the power to decide "in what order this batch of transactions is arranged" — miners, validators, or searcher bots watching pending transactions — can extract before a block is finalized and written on-chain, by reordering, inserting, or piggybacking their own transactions. Its root: transactions waiting to be processed on a blockchain are publicly visible before confirmation, and whoever can decide the ordering holds the power to manipulate. For ordinary users, MEV most often shows up as "your trade inexplicably filling at a worse price."

02 · What is the mechanism?

How exactly does a sandwich attack squeeze you? Imagine you're buying a coin on a DEX. Step one, you submit a buy order, and it enters the public pending area, where everyone (including attacker bots) can see you're "about to buy." Step two, the attacker's bot buys the same coin ahead of you, pushing the price up. Step three, your buy fills, but since the price is already pushed up, you buy at a worse price than expected. Step four, the attacker immediately sells what they just bought behind you, pocketing the spread created by their push and your taking it. Your trade is sandwiched between the attacker's "buy first" and "sell after," like the filling in a sandwich — hence the name, and the reason you inexplicably overpaid.

03 · How does it affect me?

Why do I get targeted by sandwich attacks, and what kind of trades are most dangerous? Two root causes. First, publicity: on most public chains, the trade you submit enters a public pending area before confirmation, and attacker bots can scan in real time and see the trade you're about to make. Second, and the key you can control — slippage tolerance. When you set slippage loose (allowing a large gap between fill price and the price you saw), you're proactively telling the attacker "I'll accept up to this price," so they can comfortably push the price to your tolerance ceiling before letting you fill. So the most dangerous trades are: large amounts (more juice to squeeze), shallow-liquidity pairs (price easily moved), and loose slippage (lots of room for the attacker). All three together is nearly inviting a bot to sandwich you.

04 · What should I do?

How do I protect myself and minimize the squeeze risk? A few practical measures, simple to advanced. First, and simplest: set slippage tolerance tight (within a reasonable range that still fills). The tighter the slippage, the less room the attacker has to move the price, and the less they can extract; but too tight and the trade may fail on minor price moves, so calibrate. Second, use a wallet, aggregator, or route supporting "private transactions" or built-in MEV protection, so your trade bypasses the public pending area, the attacker can't see it, and naturally can't sandwich it. Third, split large trades into batches to reduce the value exposed in a single one. Fourth, avoid extremely shallow-liquidity small-coin pairs as much as possible — they're the high-risk zone for sandwiching. Combine these and an ordinary user can actually push this risk quite low.

Diagram
Sandwich Attack: How Your Swap Gets SqueezedYouAttacker botDEX pool1. submit swap (visible in mempool)2. front-run: buy first → price up3. your swap fills at a worse price4. back-run: sell → pockets the spreadYour trade is the filling — bought high between the attacker's buy and sell.
Feel free to share. Please credit the source.
Ask a Question
Please enter at least 10 characters
Related Articles
What Is a Multisig Wallet? How It Works and Who It's For
security · Jun 05
Asset Security and Inheritance Planning for Long-Term Holders: Cold Storage, Distributed Backups, and the Coins-Outlive-You Problem
security · Jun 03
How to Avoid Approval Phishing: Read Wallet Signatures, Revoke Approvals, and Dodge the Most Common Theft
security · Jun 03
What Is a Smart Contract? Why It Auto-Executes and Why It Carries Risk
blockchain · Jun 05
More Related Topics