← All posts
USTX
What Is a Sandwich Attack?

A sandwich attack is a form of MEV that can make your swap execute at a worse price. Here's how it works and how to protect yourself.
How the "sandwich" works
A bot spots your pending buy in the mempool. It:
- Buys just before you (front-run), pushing the price up.
- Lets your trade execute at that higher price.
- Sells just after you (back-run), pocketing the difference.
You're the "filling" — you get a worse rate so the bot profits.
How to reduce the risk
- Set reasonable slippage — high slippage gives bots more room.
- Use MEV-protection / private transaction features if your wallet or DEX offers them.
- Avoid very large swaps in thin pools; split them up.
FAQ
Does this happen to every trade?
No — mainly larger or high-slippage trades in busy markets are targeted.
Is it a hack?
No — it exploits public pending transactions and slippage, not a vulnerability in your wallet.