MEV, sandwiching, and how to avoid getting rekt when swapping
Let's say you've spotted a good trade. You paste in your token, hit swap, and a few seconds later you're staring at a final price that's noticeably worse than what you were quoted. You didn't fat-finger anything. The market didn't move. So what happened? There's a good chance you just met MEV.
MEV - maximal extractable value - is one of the most pervasive, least understood dynamics in DeFi. It costs everyday traders over a billion dollars a year. It operates invisibly, at the infrastructure layer, and most of the time you'll never know it happened.
This article explains what MEV is, how it works, and - crucially - what you can actually do about it.
What is MEV?
MEV stands for maximal extractable value. In simple terms, it's the profit that can be extracted from you by manipulating the order of transactions on the blockchain - before, during, or after your trade executes.
To understand how this is even possible, you need to understand the mempool.
The mempool problem
When you submit a transaction on Ethereum, it doesn't land in the next block instantly. It first enters a waiting area called the mempool - a public, visible queue of all pending transactions.
That word 'public' is doing a lot of work here. Anyone can see what's waiting in the mempool. Including bots. Including very sophisticated, very fast bots whose entire job is to find transactions they can exploit and pay validators to reorder them for profit.
"You post your transaction. The bot sees it. The bot pays to jump ahead of you - or position itself right behind you - and takes the value you were about to receive."
That's MEV in a nutshell. And there are several flavours of it.
The three types of MEV attack
1. Frontrunning
Frontrunning is the most brazen form. You submit a buy order for a token. A bot sees it in the mempool, identifies that your large purchase is about to push the price up, and buys the same token first. Now you're buying at the inflated price the bot just helped create. The bot then sells into your order and pockets the difference.
Think of it like someone jumping the queue at a bakery, buying all the bread, and then selling them back to you at a mark-up.
2. Sandwich attacks
A sandwich attack is frontrunning and backrunning together. The bot places a trade just before yours to push the price in the direction of your order, waits for your transaction to clear (at a worse price than you expected), and then immediately places an opposing trade to capture the price difference your transaction just created.
You're the filling in the sandwich. The bot made money on the way in and on the way out. You got squeezed in the middle.
This is the most common and damaging type of MEV for everyday traders. Sandwich bots on AMMs and aggregators generate close to $1 million in profit every single week.
3. Backrunning
Backrunning is a little different. Rather than attacking your trade directly, a backrunner positions its transaction right behind yours to capture the price movement and arbitrage opportunities that your trade creates in the liquidity pool.
It's generally considered less harmful than sandwich attacks - your trade still executes as expected - but it does mean that value created by your transaction gets captured by someone else. (You'll recall this is exactly what happened in the much-discussed $50M AAVE swap recently, where an MEV bot backran the trade and extracted around $37.6M from the pool imbalance the transaction created.)
Why slippage tolerance is your enemy here
Most DeFi interfaces ask you to set a slippage tolerance when you trade. This is meant to protect you from price movements between the time you submit your order and when it executes. A 1% slippage tolerance means you'll accept a final price up to 1% worse than quoted.
The problem? MEV bots read your slippage tolerance like a menu. If you've set 1% slippage on a large order, a sandwich bot knows exactly how bad a price you'll accept - and will engineer exactly that outcome, to the penny, while keeping the rest.
Set your slippage too high and you're inviting sandwich attacks. Set it too low and your transaction fails entirely. There's no perfect number, because the problem isn't the number - it's the exposure.
The deeper issue is that on a standard DEX, every trade you make is a public announcement of your intentions. The mempool is effectively an open book. And the bots have very good reading skills.
Public mempool vs. MEV-protected trading: the difference in plain English
Here's a direct comparison of what happens to your trade on a traditional DEX vs. CoW Swap.
On a traditional DEX (Uniswap, etc.)
• You submit a swap transaction
• It enters the public mempool, visible to all
• MEV bots scan it, assess it, and decide whether to exploit it
• If it's worth it, they pay to reorder transactions around yours
• Your trade executes - at a worse price than you expected
• The bot profits. You've effectively subsidised them
On CoW Swap (intent-based, MEV-protected)
• You sign an 'intent to trade' - not a transaction
• That intent goes to CoW's solver network, not the public mempool
• Competing solvers find the best possible execution path for you
• The winning solver executes the trade on your behalf
• You never touch the public mempool. MEV bots can't see you. They can't touch you
• Whatever price you were quoted is the worst price you'll get - it may complete at a better price if a superior execution path is found
The key insight: when solvers execute on your behalf, all MEV risk transfers to them - not you. CoW's solver network competes to give you the best outcome. Your exposure to the public mempool is zero.
How CoW Swap's MEV protection actually works
CoW Swap has three structural defences against MEV built into the protocol itself. This isn't a setting you turn on - it's how the system was designed from day one.
1. Delegated trade execution
When you trade on CoW Swap, you're not submitting a blockchain transaction - you're signing an intent. A decentralised network of solvers (independent algorithms competing in an auction) picks that up and figures out the optimal execution path on your behalf.
Because the solvers are the ones going on-chain, not you, your order never appears in the public mempool. You're invisible to MEV bots. The risk of extraction is entirely on the solver, which has strong financial incentives to find the best possible outcome for you.
2. Coincidence of Wants (CoW)
Before touching any on-chain liquidity pool, CoW Protocol's solvers check whether your trade can be matched directly with another trader who wants the opposite. If you want to sell ETH for USDC, and someone else in the same batch wants to sell USDC for ETH, you can be matched peer-to-peer.
This is called a Coincidence of Wants - and it's the cleanest possible trade. No liquidity pool fees. No price impact from pool dynamics. No MEV exposure whatsoever, because there's no on-chain liquidity interaction for a bot to exploit.
(It's also why the protocol is called CoW.)
3. Uniform Clearing Price (UCP)
Even when trades do need to settle on-chain, CoW Swap batches multiple orders together and settles them all at the same price - the Uniform Clearing Price.
On a traditional DEX, if eight people are all buying ETH in the same block, each gets a slightly different price depending on where their transaction falls in the ordering. That ordering difference is what MEV bots exploit.
On CoW Swap, all eight trades in a batch clear at the same price. Transaction ordering becomes irrelevant. There's nothing to exploit, because the outcome is the same regardless of order.
Your practical checklist: trading smarter and safer
Even with MEV protection, good trading habits matter - especially for larger orders. Here's what to keep in mind.
Trade size
✓ For large trades, consider splitting into smaller chunks over time. A single massive market order creates price impact regardless of the platform - splitting reduces it.
✓ Use limit orders where possible. CoW Swap is one of the only DEXs that offers surplus on limit orders - meaning you may get a better price than the one you set. Limit orders also remove the urgency that makes large market orders risky.
✓ If the quoted price impact looks alarming, stop. A 99% price impact warning is not a suggestion. It's a stop sign.
Slippage
✓ On CoW Swap, slippage is dynamically adjusted by the solver network - you don't need to set it manually in most cases.
✓ On other platforms: tighter slippage (0.1-0.5%) reduces MEV exposure but increases the chance of transaction failure. Looser slippage increases fill rate but increases sandwich attack risk. There's no free lunch.
✓ For stablecoins, tighter slippage is almost always appropriate. For volatile assets in fast-moving markets, slightly looser tolerances may be necessary - but be aware of the trade-off.
Timing
✓ Gas prices and mempool congestion vary significantly throughout the day. High congestion periods increase competition between bots and can worsen MEV exposure on unprotected platforms.
✓ If you're not in a rush, trading during quieter periods can reduce your exposure. On CoW Swap, this matters less - but it's still worth knowing.
Platform choice
✓ Use an intent-based, MEV-protected platform for any trade where execution quality matters. CoW Swap routes your order off-chain by default - no configuration required.
✓ For any trade you're making outside of CoW Swap, consider using MEV Blocker - a free RPC endpoint from CoW DAO that hides your transactions from the public mempool and even shares a portion of backrunning profits back with you.
✓ Never use a 'fast' or default public RPC for large trades without MEV protection. You are broadcasting your intentions to a room full of sophisticated bots.
Why this matters now
MEV isn't a theoretical problem. It has extracted more than $1.3 billion from ordinary Ethereum users since tracking began. Sandwich bots alone generate close to $1 million in weekly profit - all of it taken from traders who didn't know they were targets.
The recent $50M AAVE swap that circulated across crypto Twitter is a stark illustration of what happens when a massive trade meets shallow liquidity and an alert MEV bot. The user's $50M swap created a pool imbalance that a backrunning bot exploited within the same block, extracting $37.6M - $27.5M of which went to a block builder as a bribe, $10M kept as profit.
The event is a useful reminder of just how predatory the on-chain environment can be, and why architecture-level MEV protection isn't a luxury feature. It's a baseline requirement for anyone trading at scale.
The bottom line
MEV is real, it's expensive, and it's happening to traders on unprotected platforms every day. Frontrunning, sandwich attacks, and backrunning are not edge cases - they're systematic, automated, and profitable enough to sustain entire bot operations.
The solution isn't to trade less or accept worse outcomes. It's to trade on infrastructure that was designed with the problem in mind.
CoW Swap's intent-based model, delegated execution, Coincidence of Wants matching, and Uniform Clearing Price mechanism work together to eliminate your mempool exposure entirely. You sign an intent. The solver network does the rest. The worst price you can get is the price you were quoted - and it may well be better.
Ready to trade without MEV exposure?
Try CoW Swap at swap.cow.fi.


