How MEV Bots Steal Your Money: The Sandwich Attack Guide
Have you noticed receiving fewer tokens than expected after a DEX swap? You likely fell victim to a "Sandwich Attack." This guide explains how these bots exploit your trades and how to stop them.
The Core Mechanism: Transaction Ordering
On blockchains like Ethereum or Solana, transactions aren't processed the instant you click "Swap." Instead, they are grouped into blocks.
- The Mempool: Your pending trade sits in a public "waiting room" (Mempool) where anyone can see it.
- The Power of Order: Validators can choose the execution order. MEV bots pay higher fees to jump in front of your trade, manipulating the price before your transaction completes.
Anatomy of a Sandwich Attack
A bot "sandwiches" your trade between two of its own to extract profit:
- Front-run: The bot sees your pending buy order and buys the token before you by paying a higher gas fee. This pushes the price up.
- Your Trade: Your transaction executes at the inflated price. You get fewer tokens for your money.
- Back-run: Immediately after your trade pushes the price even higher, the bot sells its tokens, pocketing the difference as risk-free profit.
When Are You a Target?
MEV bots prioritize "high-efficiency" targets. You are at risk if:
- High Slippage: Setting slippage to 5%–10% or higher tells the bot exactly how much profit it can squeeze from you.
- Low Liquidity: In small pools, even a modest trade causes a massive price swing, making it easy to attack.
- Large Orders: The bigger your trade relative to the pool size, the more "juice" there is for the bot to extract.
How to Protect Your Assets
Don't let bots eat your profits. Use these defense strategies:
- Use Private RPCs: Route your trades through private lanes like Flashbots Protect (Ethereum) or Jito (Solana). This hides your transaction from public bots.
- Tighten Your Slippage: Keep slippage between 0.5% and 1.0%. If a bot tries to push the price further than your limit, the trade will simply fail instead of being exploited.
- Split Your Trades: Break large swaps into several smaller chunks. This reduces your price impact and makes your trade less attractive to bots.
- Check Pool TVL: Always verify the Total Value Locked (TVL) on DEXScreener before swapping. Avoid low-liquidity pools where price manipulation is cheap.
- Use Pump.Fun Bundler: If you are launching your own memecoin, using a Pump.Fun Bundler is an effective way to protect your token from external sniping bot attacks.
Summary
A sandwich attack isn't just "bad luck"—it's a calculated theft enabled by public mempools. By using MEV-protected routing and strict slippage limits, you can keep your trading capital where it belongs: in your wallet.
Tip: You can check if you've been attacked in the past by entering your wallet address at sandwiched.me.
