How Sandwich Attacks Drain Crypto Traders (And How to Block Them)

Sandwich attacks are bots exploiting your visible DeFi trades to make you buy at worse prices. They happen because transactions are public before confirmation, enabling front-running and profit extraction.

A sandwich attack is one of the most common ways DeFi traders lose money without realizing it. A bot sees your trade before it confirms, jumps in front of it, and exits immediately after, leaving you with fewer tokens than your transaction was supposed to deliver. You did not make a mistake. The trade executed exactly as designed. The problem is structural, and it costs the DeFi ecosystem hundreds of millions of dollars every year.

If you have ever swapped tokens on a DEX and received noticeably less than the quoted amount, a sandwich attack may be the reason. Understanding how they work, and what actually stops them, is the difference between trading on your terms and handing money to a bot every time you enter a position.

What a Sandwich Attack Is

A sandwich attack is a specific type of MEV exploit (Maximal Extractable Value). The mechanics follow a predictable three-step sequence. First, a bot monitors the public mempool and spots your pending swap. Second, it submits a buy order with a higher gas fee so it processes immediately before yours, pushing the token price up. Third, once your trade confirms at that inflated price, the bot sells into your position and exits with the spread as profit. You end up in the middle, hence the name.

A concrete example makes this clear. You submit a swap to buy $5,000 worth of a token using ETH. Before your transaction confirms, a bot buys a large amount of that same token, moving the price up by 1 to 3 percent. Your swap executes at that higher price, so you receive fewer tokens than the quote showed. The bot immediately sells everything it bought, collecting the difference. Your trade effectively subsidized the bot profit. The bot did not hack you. It used public information you provided by broadcasting to a public mempool.

The slippage tolerance you set is what makes this possible at the trade level. If your slippage is set to 2 percent, a sandwich bot has 2 percent of your trade value to work with. On a $5,000 swap, that is $100 available for extraction. Across thousands of transactions per day, that adds up quickly for a bot running at scale.

How Much Sandwich Attacks Cost Traders

The numbers are not hypothetical. HoudiniSwap documented over $500 million extracted through sandwich attacks across a defined recent period. On Solana specifically, sandwich bots pulled between $370 million and $500 million from users spanning billions of transactions. These are not concentrated losses from a handful of whale trades. They accumulate across millions of ordinary swaps, often a few dollars per transaction, invisibly.

What makes the loss especially frustrating is that most traders never identify it. The trade settles. You received tokens. The transaction succeeded. Nothing in your wallet tells you that you received 1.8 percent fewer tokens than you should have. The money did not vanish; it transferred directly to the bot operator. This happens on every major chain, on every major DEX, to traders of every size. Anyone broadcasting a transaction to a public mempool with any meaningful slippage tolerance is a valid target.

The frequency compounds the damage. A trader doing ten swaps a week at modest sizes can bleed several hundred dollars per year purely through this type of extraction, without ever making a bad trade decision.

Why Sandwich Attacks Happen on Public Mempools

When you submit a transaction on Ethereum or most other chains, it enters the public mempool before confirmation. Think of the mempool as a public waiting room where every participant can read every pending transaction. Block producers select which transactions to include and in what order, which creates the opportunity for value extraction based on transaction ordering.

MEV bots run continuously, scanning the mempool for transactions that meet their profitability thresholds. They calculate whether the size of your trade, combined with your slippage tolerance and the token liquidity depth, leaves enough room to sandwich profitably. If yes, they act. The whole cycle, from detection to execution, takes milliseconds. No human can respond faster than a well-optimized bot watching the same data.

This is not a bug that will be patched. It is a consequence of how public blockchains work. The mempool is public by design, because transparency is part of what makes decentralized systems trustworthy. The structural answer is not to fix the mempool. It is to route around it entirely. To understand the related mechanic in more depth, see how front-running works in crypto, since front-running is the first half of every sandwich sequence.

How Private Transaction Routing Blocks Sandwich Attacks

The logic is simple: if the bot cannot see your transaction, it cannot sandwich you. Private mempool routing removes your transaction from the public waiting room and sends it directly to block producers through a private channel. The transaction goes from your wallet to the block without ever being visible to scanning bots.

Banana Gun routes every transaction through a private mempool by default on Ethereum. This is not an optional toggle or a premium feature. Every trade, every user, automatically. You do not need to think about it or configure anything to get this protection.

On Solana, Banana Gun uses Jito infrastructure for block inclusion. Jito routes transactions for optimized delivery while preventing the front-running and back-running that make a sandwich attack possible. The mechanism differs from Ethereum because Solana architecture differs, but the outcome is the same: your transaction does not sit in a public queue where bots can act on it.

On MegaETH, the team rebuilt the routing engine specifically for that chain. MegaETH runs at 100,000 transactions per second with sub-100ms execution, which changes the attack surface considerably. The custom routing engine delivers MEV resistance at that throughput level, making sandwich attacks structurally harder to execute against users on that chain.

Across Base and BNB Chain, MEV-aware execution logic applies the same core principle: route transactions so that bot operators cannot front-run or back-run them profitably. The protection runs on all five chains, as the default behavior, with no extra steps required from you. For a broader look at how the platform handles MEV across all five chains, the Banana Gun blog covers each chain's execution infrastructure in detail.

Beyond Routing: Pre-Flight Simulation as a Second Layer

Private routing addresses the sandwich attack threat. It does not address the token itself. A malicious contract can drain your position through mechanics that have nothing to do with mempool ordering. Honeypots let you buy but block you from selling. Hidden minting functions dilute your holdings after purchase. Blacklisting functions can prevent your wallet from transferring tokens at all.

Banana Simulator adds a second layer of protection before your funds move. Every transaction is simulated against live chain state prior to execution. The simulation checks whether you can actually sell the token after buying it. If the sell check fails, the trade is blocked automatically. No override, no warning you can click past. The trade does not happen.

This runs on every trade across all five chains supported by Banana Gun. It is not a scan of a token database that might be outdated. It is a live simulation against current chain state, which means it catches newly deployed malicious contracts that no database has catalogued yet. Combined with private routing, you get protection against two distinct attack vectors: bots extracting value from your public transaction, and contracts designed to take your funds on execution.

What You Can Do Right Now

Choose a platform where MEV protection is on by default, not something you enable manually. If you have to remember to activate it, you will eventually forget, and that is the trade that costs you. Default-on protection removes the human error variable entirely.

Tighten your slippage settings. The slippage tolerance you set is the profit ceiling for any sandwich bot targeting your trade. Lower slippage means less room for extraction. A reasonable starting point for most liquid tokens is 0.5 to 1 percent. For newer tokens with thinner liquidity you may need higher tolerance, but be aware that higher tolerance is also higher exposure.

Verify that your trading platform simulates transactions before sending them on-chain. Routing protects you from bots. Pre-flight simulation protects you from the token itself. You want both, running automatically, before any funds move.

If you are currently using a DEX interface that routes through the public mempool with no MEV protection, every swap you make is potentially exposed. Switching to Banana Pro gives you private routing and pre-flight simulation across five chains, with no configuration changes required to get started.

Frequently Asked Questions

What is a sandwich attack in crypto?

A sandwich attack is a type of MEV exploit where a bot spots your pending transaction in the public mempool and places one trade immediately before yours and another immediately after. Your swap executes in the middle at a worse price, and the bot collects the price difference as profit. The attack works because public mempools let anyone see pending transactions before they are confirmed on-chain.

How do you prevent sandwich attacks?

The most effective method is private mempool routing, which sends your transaction directly to block producers without exposing it to the public queue that bots monitor. Banana Gun routes every transaction this way by default on Ethereum, uses Jito infrastructure on Solana, and runs a custom routing engine on MegaETH. Keeping your slippage tolerance tight also limits how much a bot can extract, because slippage tolerance sets the maximum profit available to any attacker targeting your trade.

How much do sandwich attacks cost traders?

HoudiniSwap documented over $500 million extracted through sandwich attacks across a defined recent period. On Solana alone, sandwich bots pulled between $370 million and $500 million from users across billions of transactions. The losses accumulate across millions of individual trades, often just a few dollars per swap, which is why most traders never notice the drain until they calculate it across a full trading history.

Written by
Bananagun
published on
May 5, 2026