The Slippage Desk

Home › Basics › What Is a Sandwich Attack in Crypto? A Clear Explanation

What Is a Sandwich Attack in Crypto? A Clear Explanation

Editorial team · Updated 2026-10-14 · 5 min read

A sandwich attack is a trading tactic where a bot places one transaction immediately before your swap and another immediately after it. Your trade moves the price, the bot profits from that move, and you receive fewer tokens than you expected. It does not drain your wallet; it widens your price impact within your slippage limit.

The mechanics in four steps

Decentralised exchanges such as Uniswap-style pools price tokens with a formula based on the pool’s reserves. When you buy, you shift the reserves and the price rises a little; the bigger your trade relative to the pool, the larger the move. That predictable shift is what a sandwich exploits.

  1. You submit a swap. It sits in a queue of pending transactions, often called the mempool, waiting for a block producer to include it.
  2. A bot sees it. The bot simulates your trade and works out how far the price will move, given the amount and the slippage tolerance you attached.
  3. The bot front-runs. It buys the same token first, paying a priority fee or a tip so that its transaction is ordered ahead of yours.
  4. You execute at a worse price, then the bot back-runs. Your swap fills at the inflated price. The bot immediately sells into the price your trade created and keeps the spread, less fees.

The two bot transactions are the bread; yours is the filling. That is where the name comes from.

Key takeaway: the bot does not need to predict the market. It only needs to know your trade is coming and how much room your slippage setting leaves it.

Why slippage tolerance is the lever

Every swap carries a minimum amount you will accept. If the price moves past that floor, the transaction reverts instead of filling. A sandwich only works while your trade still clears, so the bot sizes its front-run to push the price right up to your limit, no further. A 5% tolerance gives it far more room than a 0.3% one.

This is why the setting matters more than almost anything else a trader controls. We cover the details in slippage tolerance explained.

Factor Raises exposure Lowers exposure
Slippage tolerance High (several percent) Tight (a fraction of a percent)
Trade size vs pool depth Large share of a thin pool Small share of a deep pool
Transaction path Public mempool Private or protected routing
Token liquidity Illiquid or new tokens Major pairs with deep liquidity

A simplified illustration

The numbers below are hypothetical and chosen only to show the shape of the trade; they are not market data. Imagine a pool where you plan to swap a sum that would normally move the price by 1%, and you have set a 3% tolerance. The bot sees that headroom. It buys first and pushes the price up by roughly the 2% of extra room, your swap fills near your floor, and the bot sells straight after into the price your order just lifted. Your result lands close to the worst case you allowed, not the best case you hoped for. Had you set 0.5%, the same bot would have had no room, the simulation would have failed its profit check, and the attack would not have happened.

Notice that the bot never needed to be right about direction. It needed visibility of your order, an ordering advantage and enough slippage headroom to cover its own fees.

Who is on the other side

Sandwich bots are run by searchers: independent operators who look for profitable orderings of transactions. The background concept is MEV, short for maximal extractable value, which ethereum.org describes as the value that can be extracted by including, excluding or reordering transactions in a block. Sandwiching is one of several MEV strategies, alongside arbitrage and liquidations, and it is the one that most directly costs another user money.

Product pages describe the tooling in similar terms. CryptoMEV Bot’s sandwich bot page, for example, says its software monitors the mempool for large swaps with high slippage tolerance and simulates whether the expected profit covers the gas for both of its transactions before it acts. That simulation step is the standard gate: if the numbers do not clear, a careful bot does nothing.

What it costs the victim

The loss is the gap between the price you would have received and the price you did receive. For a small trade in a deep pool the difference is trivial and often smaller than the gas fee. For a large trade in a shallow pool with loose slippage it can be material. We deliberately do not quote an average loss, because published figures depend on the period, chain and methodology, and a single number would mislead.

Two other costs are easy to miss:

  • Fee competition. Bots bid against each other for ordering, which raises priority fees in busy periods.
  • Failed trades. If a sandwich pushes the price past your limit, your transaction reverts and you still pay the gas.

Is it “an attack”?

The word is contested. Operators often describe sandwiching as a market-making or arbitrage-like activity that exploits permitted settings. Many traders and researchers see it as value extraction from users who did not consent to it. Regulators have not settled the question uniformly, and we look at the legal side in is sandwich trading legal. What is not contested is the mechanism: it works only because the victim’s order is visible and the ordering can be influenced.

If you are a trader, go to how to avoid sandwich attacks. If you are trying to understand the tooling, how a sandwich bot works goes inside the logic, and sandwich attack vs front-running separates the two terms. For a broader look at bot families, the explainer on what an MEV bot is is a reasonable primer from a vendor’s point of view; read it as such.

Two practical points to close. First, nothing about a sandwich requires access to your keys, so wallet hygiene is unrelated to it; the defence is in how you route and size trades. Second, the effect varies by chain: ordering rules differ between Ethereum-style networks and Solana, which is why we treat Ethereum and Solana separately.

Where to see the vendor’s description

If you want to compare this explanation with how a commercial product describes the same mechanism, the sandwich bot crypto page at CryptoMEV Bot sets out its three-step user flow and its simulation check. Read it with the caveats above in mind: it describes capability and gives no performance data.

This article is educational and not financial or legal advice.

Frequently asked questions

What is a sandwich attack in simple terms?

A bot buys a token just before your swap, your swap pushes the price up, and the bot sells right after. You get a worse price and the bot keeps the difference, minus fees.

Can a sandwich attack steal my tokens?

No. It does not take funds from your wallet. It worsens the price you receive within the slippage limit you set, so the cost shows up as fewer tokens out.

Which trades are most exposed?

Larger swaps in thin pools with a generous slippage tolerance, sent through the public mempool, are the easiest targets.

Is a sandwich attack the same as front-running?

It includes front-running but adds a back-run. Front-running alone only trades ahead of you.

Sources