Logo

Sandwich Attack: What It Is in Crypto and How Bots Eat Your Trade

by Noti Bird9 min read
Sandwich Attack: What It Is in Crypto and How Bots Eat Your Trade image

A sandwich attack is what happens when a bot spots your pending swap, buys just before you, and sells just after you, leaving you with the worst price in the block and itself with the profit. You are the filling, and nobody asked whether you wanted to be lunch.

Most traders never notice it happening, since the swap still "works" and the loss hides inside a worse fill. Once one can read a block explorer, though, the pattern is hard to unsee.

What Is a Sandwich Attack?

A sandwich attack is a form of front-running aimed at trades on decentralized exchanges. An automated searcher, usually called a MEV bot, watches pending transactions, picks a juicy one, and places one transaction directly in front of it and another directly behind it. The first pushes the price up, the victim buys at that inflated price, and the second sells into the move the victim just created.

It works because of how automated market makers price tokens (no order book, no human market maker, just a formula). A pool like Uniswap's holds two assets and sets the price from the ratio between them, so every buy makes the next buy more expensive. A few terms make the rest of this guide easier to follow:

  • Mempool: the public waiting room where signed transactions sit before a block builder picks them up.
  • AMM pool: a smart contract holding two tokens, pricing them by the ratio of its reserves rather than an order book.
  • Front-run: the attacker's buy, placed just ahead of the victim in the same block.
  • Back-run: the attacker's sell, placed just after the victim, closing the position at a profit.
  • Slippage tolerance: the worst price the victim agreed to accept, and therefore the attacker's budget.

How a Sandwich Attack Works, Step by Step

The mechanics are almost boringly mechanical, which is exactly why bots run them around the clock. Here is a simplified run (round, illustrative numbers rather than real data), assuming one trader wants to buy a token on a mid-sized pool:

  1. 1
    The victim broadcasts

    A trader signs a swap of 10 ETH for a token, with a 5% tolerance, and it lands in the public mempool.

  2. 2
    The bot simulates

    A MEV bot reads the pending swap, calculates how far the price can move before the trade would fail, and finds the most profitable buy size.

  3. 3
    The front-run lands first

    The bot buys the token with a higher priority fee, so its transaction sits directly ahead of the victim's.

  4. 4
    The victim fills at a worse price

    The swap still executes, since the new price is just inside the 5% limit, but the trader receives noticeably fewer tokens.

  5. 5
    The back-run closes the loop

    The bot sells right after the victim, at the price the victim's own buy just pushed up.

All three transactions sit in the same block, often in consecutive positions, so the bot never carries any real market risk. If the victim's limit is too tight to leave room for profit, the bot simply skips the sandwich attack, which is why the size of that limit matters so much. The attacker isn't predicting anything; it's reading a public order and collecting the gap between what you asked for and what you were willing to accept.

Why Your Slippage Setting Is the Menu

How much can a bot take? Exactly as much as you allowed it to, and not a cent more. The tolerance you set is the maximum price impact you agreed to swallow, and a sandwich attack is the business of pushing your fill right up against that edge without crossing it. Set 1% and the bot's room is small. Set 30% on a hyped launch and you've effectively written the attacker a cheque with the amount left blank.

This is the cruel bit for snipers. Fresh launches move fast and pools are thin, so traders raise their tolerance to stop transactions failing, and wide limits on thin pools are precisely what sandwich attack crypto bots look for. It's a trade-off with no free lunch (pun fully intended): too tight and the snipe reverts, too loose and the snipe gets eaten. One way out is to stop broadcasting to the public mempool at all, which is why the Noti sniper bot sends transactions directly to block builders instead.

Pool size matters just as much as the limit. A 10 ETH buy barely moves a deep ETH/USDC pool, but on a pool holding 20 ETH of liquidity the same order moves the price dramatically, so the potential profit for the bot grows with every ETH of thinness.

Who Profits From a Sandwich Attack?

Sandwiching is a business, and it has a supply chain. Searchers run the bots that scan the mempool and build the bundles, while block builders decide the order of transactions in a block and get paid for including a profitable bundle in the right spot. So who actually ends up with the victim's money? In a competitive race, searchers bid away much of their profit to builders as tips, so a large chunk of what the victim loses can end up with whoever builds the block.

The bots themselves are relentless. A single MEV bot can monitor every pending swap on a chain at once, simulate each one in milliseconds and attack only the trades that clear its profit threshold. They don't sleep, they don't get bored, and they never fat-finger a trade — which makes them a far better business than the average memecoin portfolio.

Fresh launches are their favorite hunting ground. Thin pools, wide tolerances and a crowd of buyers all arriving in the same few blocks give a bot several fillings in a row, and an early sniper who broadcasts publicly is often the first one on the plate. Being early is the name of the game, but being early and visible is just being early for someone else's profit.

Sandwiches are one flavor of a much older idea. Our explainer on front running in crypto traces it back to stock-market floor brokers and through the legal grey areas that still surround it today.

How to Tell You've Been Sandwiched

Suspect it already happened to you? Checking takes about two minutes, and no special software is needed (a block explorer is enough). Open your swap on Etherscan, note the block number, and look at the transactions directly above and below yours in that block. If the same address bought the same token just before you and sold it just after, you were the filling. One should also glance at the other swaps in that block, since a bot that found one tasty order often finds a few more.

Other signs are subtler but just as telling:

  • Fill near your limit: you received close to your minimum output rather than the quoted amount.
  • Same token, same block: two trades by one address bracket yours, usually with very different priority fees.
  • A wrapping contract: the attacker's transactions often go through an unverified contract rather than a normal wallet.

Analytics tools such as EigenPhi label sandwich attack crypto transactions automatically, so pasting a transaction hash there is the quickest way to confirm a hunch.

Pros and Cons of Tight Slippage Against a Sandwich Attack

### Pros

  • Smaller menu: a low tolerance shrinks the gap a bot can exploit, often below the point where an attack pays.
  • Free to use: it's a setting, not a service, and every DEX interface offers it.
  • Predictable fills: you know the worst case before you sign.

### Cons

  • Failed trades: on volatile launches, tight limits mean a lot of reverts and wasted gas.
  • Still visible: your trade sits in the public mempool for any bot to inspect.
  • No help with thin pools: if liquidity is tiny, even a small limit can leave room for a profitable sandwich.

Case Study: The $215,000 Stablecoin Sandwich

On 12 March 2025, a trader swapped about $220,764 of USDC for USDT on Uniswap v3's USDC-USDT pool, a trade that should have returned roughly the same dollar amount. Instead it returned about $5,271, a loss of over $215,000 in a few seconds, Cointelegraph reported on 13 March 2025, citing Etherscan data and an analysis by The DeFi Report's Michael Nadeau.

The MEV bot front-ran the swap by pulling the USDC liquidity out of the pool, let the victim trade into the emptied pool, then put the liquidity back afterwards. Most of the haul didn't stay with the attacker either, since roughly $200,000 went as a tip to the block builder "bob-the-builder.eth", while Nadeau put the bot's own profit at about $8,000. Nadeau later noted that the trade did not come through Uniswap's own front end, which applies MEV protection and default limits.

Stablecoins are supposed to be the boring part of crypto, which is what makes this such an instructive sandwich attack crypto case. Whatever route the order took, it was signed with a minimum output loose enough to accept a 98% loss, and a sandwich attack only needs that one mistake. The lesson is simple: the limit you sign is the most a bot can take, whether you're trading $PEPE or dollars.

How to Avoid a Sandwich Attack With Noti

Tight limits help, but they fight the symptom. The cleaner fix is to keep your trade out of the public mempool in the first place, so no bot ever sees it coming. That is the approach the Noti sniping platform takes, and setting up a protected snipe looks like this:

  1. 1
    Open Noti

    Use the Noti web app or Noti's Telegram bot, paste the contract address and generate or connect a wallet.

  2. 2
    Set the snipe

    Choose the amount, price limit, gas and slippage that suit the launch.

  3. 3
    Add a selling strategy

    Set your exit point with the snipe, so the sell is planned before the buy lands.

  4. 4
    Let Noti route it privately

    The Noti sniping service skips the public mempool and sends your transaction straight to block builders, invisible to MEV bots.

Private routing doesn't make a bad trade good, and you still need a sensible limit and position size. What it removes is the public preview that every sandwich relies on. For a deeper look at private RPCs, builders and other defenses, see our guide to MEV protection. Noti is live on Ethereum today, with more chains listed as coming soon.

Frequently Asked Questions

Can a sandwich attack happen on a centralized exchange?

No. A sandwich needs a public queue of pending transactions and an AMM pool, both features of DEX trading, while centralized exchanges match orders internally, so the classic sandwich attack crypto traders worry about is a DEX problem.

Is a sandwich attack illegal?

It's a grey area. Regulators haven't drawn a clear line on sandwiching public DEX trades, so treat it as a risk to manage rather than something the law will fix for you.

Does a smaller trade avoid sandwich attacks?

Partly, since small trades on deep pools often aren't worth attacking after fees. On thin memecoin pools, however, even modest orders can be profitable targets.

Does Noti protect against sandwich attacks?

Yes. Noti sends transactions directly to block builders instead of the public mempool, so sandwich bots can't see your trade before it lands, though you should still set a sensible limit.

Conclusion

To sum it up:

  • Know the recipe: a sandwich attack is a front-run, your trade, and a back-run in the same block.
  • Your limit is their budget: the looser your tolerance, the more a bot can take.
  • Hide the order: private routing removes the public preview every sandwich depends on.

Money still doesn't grow on trees, and it certainly doesn't grow on the public mempool. Keep your limits honest, keep your trades out of sight, and let the Noti sniper bot route your next snipe where no sandwich bot can see it.

Share this article

Recent Articles

All articles

Subscribe
to Our Newsletter

Get exclusive bonuses, free tips,
snipe tutorials, and project updates