Maximal Extractable Value (MEV) is one of the most important concepts for serious DeFi traders to understand. It represents the profit that can be extracted from blockchain users by reordering, inserting, or censoring transactions within a block. If you’ve ever wondered why your DEX trade executed at a worse price than expected, MEV might be the culprit.
What Exactly is MEV?
Originally called “Miner Extractable Value” (before Ethereum’s move to Proof of Stake), MEV now stands for Maximal Extractable Value. It refers to the maximum value that can be extracted from block production beyond the standard block reward and gas fees.
Block producers (validators on PoS chains, miners on PoW chains) have the power to:
- Reorder transactions within a block
- Insert their own transactions before or after yours
- Exclude transactions entirely
This power creates opportunities for profit extraction—often at your expense.
Common Types of MEV Attacks
Sandwich Attacks
The most common MEV attack targeting DEX traders. Here’s how it works:
- You Submit a Trade: You want to swap 10 ETH for USDC on Uniswap. Your transaction enters the mempool.
- Attacker Spots Your Transaction: MEV bots constantly scan the mempool. They see your large trade and calculate the price impact.
- Front-Run Transaction: The attacker places a buy order BEFORE yours, pushing the price up.
- Your Trade Executes: Your trade goes through at a worse price than expected.
- Back-Run Transaction: The attacker immediately sells after your trade, pocketing the difference.
Sandwich Attack Example:
Initial ETH price: $2,000
1. Attacker buys ETH → Price rises to $2,010
2. Your 10 ETH swap → You get $2,010/ETH (expected $2,000)
3. Attacker sells ETH → Price returns to $2,000
Your loss: ~$100
Attacker profit: ~$100 (minus gas fees)
Frontrunning
Similar to sandwich attacks but without the back-run. Attackers simply place their transaction ahead of yours to capture an opportunity you’ve revealed:
- Arbitrage frontrunning: You find an arbitrage opportunity, attacker takes it first
- Liquidation frontrunning: You spot an undercollateralized loan, attacker liquidates it before you
- NFT sniping: You try to buy an underpriced NFT, attacker buys it first
JIT (Just-In-Time) Liquidity
A more sophisticated form of MEV targeting liquidity providers:
- Attacker sees a large pending swap
- Adds concentrated liquidity right at the current price
- Captures most of the swap fees
- Removes liquidity immediately after
How to Protect Yourself from MEV
For Traders
1. Use MEV-Protected RPC Endpoints
Services like Flashbots Protect or MEV Blocker send your transactions directly to block builders, bypassing the public mempool.
- Flashbots Protect: Add RPC: https://rpc.flashbots.net
- MEV Blocker: Add RPC: https://rpc.mevblocker.io
2. Set Tight Slippage Tolerance
Lower slippage tolerance makes sandwich attacks unprofitable. For stablecoin swaps, use 0.1-0.5%. For volatile pairs, 1-3% maximum.
3. Use DEX Aggregators with MEV Protection
Aggregators like CoW Swap batch orders and use batch auctions to prevent MEV. 1inch Fusion uses a similar approach with professional market makers.
Key Takeaways
- MEV is value extracted by reordering/inserting transactions—often at your expense
- Sandwich attacks are the most common threat to DEX traders
- LPs face JIT liquidity and adverse selection from arbitrageurs
- Use private RPCs (Flashbots, MEV Blocker) to protect transactions
- DEX aggregators like CoW Swap offer built-in MEV protection
- The ecosystem is evolving—encrypted mempools and intent-based trading are the future