DexLadder Open the app

How to avoid getting sandwiched on a DEX swap

Your pending transaction is public before it is final, and your slippage tolerance tells anyone watching exactly how much they are allowed to take from you.

Last verified 13 September 2026 · written by the DexLadder team

The mechanism, in order

  1. You submit a swap. It enters a public mempool, where its size, the pool it targets and its slippage tolerance are all readable.
  2. A bot computes how far it can push the pool price and still leave your swap executable inside your tolerance.
  3. It buys ahead of you, paying for priority in the block.
  4. Your swap fills at the worse price you authorised.
  5. It sells immediately after, into the impact you just created. The profit is bounded by your tolerance.

Nothing here is a bug. It follows from public ordering and from the fact that block space is auctioned.

What actually reduces it

What does not help

Raising gas alone does not protect you — the attacker is bidding in the same auction with better information and better latency. Nor does an extremely tight tolerance on a volatile pool: the swap simply reverts, and you pay gas for nothing. The working setting is the one derived from actual pool arithmetic, not a default and not a guess.

Practise it without paying for the lesson

In DexLadder's pool desk you can size a swap against real pool reserves and watch impact, fee and final fill before anything is submitted. Run the same trade at ten times the size and the curve becomes obvious in a way no explanation achieves.

Related reading

Calculators for this

Terms used here

Questions people actually ask

What slippage tolerance should I set?

Slightly above the computed price impact for your size in that specific pool — not a habitual 1% or 5%. Compute it per trade; a fixed default is either too tight to execute or too wide to be safe.

Does a private relay guarantee safety?

It removes public mempool exposure, which eliminates the easiest attack. It does not remove every form of ordering advantage.

Why did my swap revert and still cost gas?

Execution is attempted on-chain. If the price moved beyond your tolerance the transaction fails, and you still pay for the computation attempted.

Open the free Web3 desk — no account, nothing to install