How to avoid sandwich attacks on PancakeSwap and BNB Chain
A sandwich attack is the most common way swaps on BNB Chain 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:
- Buys first. It buys the token you are buying, right before you. The price goes up.
- Your swap runs at the worse price. You still get filled, as long as the price stays inside your slippage tolerance.
- 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 BNB, 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 PancakeSwap, 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
A sandwich needs a profit bigger than its gas cost. Small swaps on liquid pairs are rarely worth it; large swaps on thin pools are the main targets. 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 BNB Chain block builders run private RPCs; backrun sends your transaction to them 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 BNB Chain — including the step most people miss.
Send BNB Chain swaps privately. backrun keeps your transaction out of the public mempool and pays any backrun profit back to your address.
Add backrun to your walletAlready traded? Check if you were sandwiched
You can check any past swap on BscScan in a couple of minutes: how to tell if your BNB Chain swap was sandwiched.