Learn · Advanced

What Is MEV? Sandwich Attacks on DEX Swaps Explained

Published August 12, 2026 · 7 min read

Sometimes a swap executes noticeably worse than quoted, with no obvious market move to explain it. Often the explanation is that a bot saw your trade coming and arranged to profit from it. That's MEV, and it's more avoidable than most people realise.

MEV stands for Maximal Extractable Value — the profit available to whoever decides the order transactions go into a block. Ordering matters enormously in trading, and on a public blockchain, pending trades are visible to anyone before they're final.

The gap that makes it possible

When you sign a swap, it doesn't settle instantly. It goes to the mempool, a public waiting room of unconfirmed transactions, until a validator picks it up. That window is short — but it's long enough to read your trade, calculate its effect, and act.

Everything about your trade is public in that window: which tokens, how much, and critically, the slippage tolerance you set.

How a sandwich attack works

The most common form against ordinary traders is the sandwich. Three steps:

Your loss and the bot's profit are the same money. Nothing was hacked, and no rule was broken — the bot simply used information you published by broadcasting your trade.

Your slippage tolerance is a public statement of the worst price you'll accept. A bot reads it and takes as much of that room as it profitably can.

Why loose slippage is the main mistake

This is the practical takeaway. If you set 5% tolerance because a trade kept failing, you've told every bot watching that you'll tolerate a 5% worse price. That's the budget a sandwich has to work with.

Tighten to 0.3% and the same attack has far less room. Often it stops being worth the bot's gas — and if it tries anyway and overshoots, your trade simply reverts and you keep your tokens.

Practical defences

Set slippage deliberately

Not by nudging it upward until something works. Match it to the pair: fractions of a percent for deep, liquid pairs; more only where liquidity genuinely demands it.

Trade where liquidity is deep

Sandwiching a thin pool is cheap because small trades move the price a lot. In a deep pool, a bot must commit far more capital for the same effect, which frequently makes the attempt uneconomic.

Split large orders

One conspicuous trade is a better target than several ordinary ones. Routing that splits an order across multiple pools helps here too — it's harder to sandwich a trade that isn't concentrated in one place. That's a side benefit of how aggregators route.

Consider a private RPC

The most direct fix is not broadcasting to the public mempool at all. Several wallets now let you point at a private or protected RPC endpoint, which forwards your transaction to block builders without exposing it publicly first. No mempool visibility, no sandwich. Check your wallet's network settings to see what it offers.

Mind the chain

MEV exists wherever ordering can be influenced, but conditions differ by network. Fast, cheap chains change the economics of an attack without eliminating the concept. Don't assume any chain is immune.

Keeping it in proportion

If you're swapping $50 of a liquid token with sane slippage, you are rarely worth a bot's attention — the gas costs more than the extractable profit. MEV matters most for larger trades, thin liquidity, and wide slippage settings.

The habits that protect you are the same ones that get you a better price anyway: understand what you're being quoted, keep slippage tight, and route through depth rather than whichever pool you happened to open.

Route through depth, not luck

Kryllex compares 100+ DEXs across 16 chains and shows expected output and price impact before you sign — non-custodial, no account.

Launch Kryllex →

Keep reading: What is slippage? · The cheapest way to swap crypto