The short version: a sandwich attack needs two things: a visible pending swap, and a slippage tolerance that pre-authorizes a worse price. The attacker buys before you, lets your trade move the price, and sells after you, pocketing up to your tolerance. Offchain orders and uniform clearing prices per token pair reduce this exposure. Signed limits constrain execution, but external-pool settlement can still be public and adversarial.

What is a sandwich attack?

A sandwich attack brackets your swap between two attacker trades: a buy placed just before yours pushes the price up, your swap executes at that worse price, and a sell placed just after captures the difference. You still receive tokens, just fewer of them, which is why many victims never notice. The attacker's profit comes out of your execution price.

How does the attacker see my trade before it executes?

Through the public mempool. A normal swap is a transaction that sits visible and pending before it is mined, carrying the pool it will trade against and the worst price it will accept. Bots scan pending transactions for exactly this and can pay for the ordering they need around yours.

How much can a sandwich cost me?

Up to your slippage tolerance. The tolerance is the worst price you pre-authorized, so it is precisely the budget an attacker can harvest: a 1% tolerance on a large swap hands over up to 1% of it. Tightening the tolerance shrinks the budget but starts failing your trades in volatile markets, which is the uncomfortable trade-off tolerance-based execution forces.

How do batch auctions mitigate sandwich attacks?

Orders are submitted offchain and each token pair clears at a uniform batch price, reducing common ordering advantages. The settlement transaction can still be visible and use external pools. Signed limits remain enforced, but batch auctions do not guarantee immunity from every sandwich scenario.

Does a tight slippage setting protect me on a regular DEX?

Only partially. A tighter tolerance limits adverse execution but can increase failed transactions. Router minimum-output bounds and signed-order limits are both contract-enforced. Private submission and batch auctions add different protections; neither makes all execution inside the permitted price band risk-free.

Go deeper

The full protection picture, including exactly what is and is not guaranteed, is in MEV-protected swaps, explained. How orders work with signed limits: what is an intent-based DEX aggregator. The role of the parties who settle your trade: what is a solver.