How to avoid sandwich attacks on Uniswap and Ethereum

Updated 2026-11-06 · 5 min read

A sandwich attack is the most common way swaps on Ethereum lose money to bots. The good news is that most of it is avoidable with a few settings.

What a sandwich attack is

When you press swap, your wallet broadcasts the transaction to the public mempool, where anyone can see it before it is included in a block. A sandwich bot that spots your swap does three things in the same block:

  1. Buys first. It buys the token you are buying, right before you. The price goes up.
  2. Your swap runs at the worse price. You still get filled, as long as the price stays inside your slippage tolerance.
  3. Sells right after. The bot sells into the price you pushed up and keeps the difference.

You do not see an error. You just receive fewer tokens than the quote you saw.

1. Keep slippage tight

Your slippage tolerance is the maximum the bot can take. At 10% slippage a bot can push the price up to 10% against you; at 0.5% it has almost no room. For liquid pairs such as ETH, USDC, USDT or major tokens, 0.5–1% is usually enough. Only raise it for tokens that really need it (tax tokens, very new launches), and set it back afterwards.

2. Check the pool before a big trade

The thinner the pool, the more your trade moves the price, and the more a bot can earn by sandwiching it. Before a large swap on Uniswap, look at the pool's liquidity and the price impact your wallet or DEX shows. If price impact is several percent, split the trade over time or use a deeper pool.

3. Be careful with very large single swaps

Gas on Ethereum is expensive, so bots mostly target larger swaps where the profit covers their gas; small swaps on liquid pairs are rarely worth it. Splitting one large order into a few smaller ones, with tight slippage on each, reduces what any single sandwich can take.

4. Send transactions privately

The root cause is that your swap is visible before it lands. A private RPC sends your signed transaction directly to block builders instead of the public mempool, so sandwich bots never see it in time. Several Ethereum private RPCs keep transactions out of the public mempool; backrun sends your transaction to established ones and to its own builder at the same time, so inclusion stays fast.

Switching is one setting in your wallet. See how to add a private RPC to MetaMask for Ethereum — including the step most people miss.

Send Ethereum swaps privately. backrun keeps your transaction out of the public mempool and pays any backrun profit back to your address.

Add backrun to your wallet

Already traded? Check if you were sandwiched

You can check any past swap on Etherscan in a couple of minutes: how to tell if your Ethereum swap was sandwiched.