Crypto glossary

Sandwich Attack

A sandwich attack is a form of MEV in which a bot spots your pending swap on a decentralized exchange, trades just before it to move the price against you, and trades just after it to lock in a profit. Your trade ends up in the middle, at a worse price.

Auf Deutsch lesen

How a sandwich attack works

When you swap on an automated market maker, your transaction is often visible in the public mempool before it is confirmed. A bot can see how much you are trading and what slippage tolerance you allowed, meaning the worst price you are willing to accept.

If you are buying a token, the bot buys the same token first, pushing its price up. Your swap then executes at that higher price, pushing it up further. The bot immediately sells into the price you created. If you are selling, the attack works in reverse: the bot sells first and buys back after you. The bot pays for its transactions to be placed in exactly this order in the block.

An example

Say you swap 10,000 USDC for a token in a small pool and set a 5% slippage tolerance. A bot buys first, raising the price by about 4%. Your swap still goes through because it stays within your 5% limit, but you receive roughly 4% fewer tokens. The bot then sells and keeps a few hundred dollars after fees, money that came out of your trade.

Who is most at risk

Sandwich attacks are most profitable on large trades in pools with little liquidity, and when users set high slippage tolerances. Small trades in deep pools are usually not worth attacking, because the bot's own costs would exceed the profit.

How to reduce the risk

Set slippage as low as practical; if the trade fails, you can retry. Split large orders, prefer deep pools, and consider services or wallets that send transactions through private channels instead of the public mempool. Some trading interfaces also use auctions or batch trades so that orders cannot be front-run in the same way. These steps reduce the risk but do not remove it entirely.

Ask Coach about it

Coach is the AI on AtenaCrypto. It explains crypto with live market data, in plain words.

What slippage settings make sense for different trade sizes to limit sandwich attacks?Ask Coach →

Frequently asked questions

How do I know if I was sandwiched?

Look up your transaction on a block explorer. If a bot bought the same token just before your swap and sold it just after, in the same block, you were likely sandwiched.

Does a low slippage setting prevent sandwich attacks?

It limits how much a bot can take, because a large price move would make your transaction fail instead. Set too low, however, your trades may fail often in volatile markets.

Are sandwich attacks the same as front-running?

Front-running is the first half: trading ahead of a known order. A sandwich adds a second trade after yours to complete the profit.

Related terms

MEV (Maximal Extractable Value)SlippageMempoolDEX (Decentralized Exchange)AMM (Automated Market Maker)Liquidity Pool

Learn it step by step

AC Learning explains these ideas in interactive lessons — the first eight sections are free.

Open AC Learning → Create a free account

All glossary terms · Educational reference only — not investment, legal, tax or financial advice.