TheCryptoNist
Loading live crypto prices…
Blockchain

MEV Sandwich Attacks: How Slippage and Transaction Routing Matter

A sandwich attack can worsen a decentralized-exchange swap by placing trades around it. Learn what slippage controls, what they cannot stop and how routing choices change risk.

12 min read
ETH/BTC order-book depth chart showing bid and ask liquidity.
Photo: Kjerish · CC BY-SA 4.0

What MEV means for an everyday swap

Maximal extractable value, or MEV, describes value that can be gained by choosing which transactions are included in a block and in what order. The term began in research on miners and is now used across proof-of-stake systems, where validators, builders, searchers and other infrastructure participants can influence ordering. MEV is not one single attack. It includes arbitrage that can bring prices across venues closer together, liquidations that help lending markets remain solvent, and strategies that may impose costs on ordinary users.

For someone swapping tokens on a decentralized exchange, the most visible concern is a sandwich attack. A searcher sees a pending trade, places a transaction before it that moves the pool price, lets the user’s trade execute at a worse rate, then places a transaction after it to unwind the position. The user receives less of the output token than expected, while the searcher attempts to capture the difference after fees and execution costs. The details depend on the pool, transaction size, slippage setting and ordering rules.

A simplified example of a sandwich

Imagine a user submits a large order to buy Token B with Token A from a pool. Because the pool’s reserves determine the exchange rate, the user’s own order moves the price. If the transaction is visible before it is included, a bot may buy Token B first, making the pool more expensive. The user’s swap then executes against the altered reserves. Once the user’s purchase raises the price further, the bot sells some Token B back into the pool.

The example is simplified: real transactions can involve routing through multiple pools, competing searchers, builder auctions and changing market prices. A bot may fail to profit, a transaction can revert, or ordinary market activity can move the price at the same time. The important point is that a public pending transaction can reveal information about a user’s intended trade, while automated actors can react faster and submit transactions with different fees or through specialized routes.

Price impact is not the same as slippage

Price impact is the change in a pool’s quoted price caused by the size of a trade relative to available liquidity. A large order in a shallow pool usually has more price impact than the same order in a deep pool. Slippage is the difference between the expected execution and the amount actually received, often because the pool state changed while the transaction was waiting. A user interface may show a quoted output and let the user specify a minimum acceptable output.

These ideas are related but not identical. A trade can have high price impact even if it executes exactly as quoted. Slippage can occur because of market movement, competing transactions or MEV. The minimum-output check is designed to make the transaction revert if the received amount falls below the user’s chosen threshold. That can limit the worst execution the user accepts, but it does not make the transaction immune to being sandwiched within the selected range.

What a slippage setting really controls

Slippage tolerance is a boundary, not a guarantee of a fair price. If the tolerance is too tight for current volatility or pool depth, the swap may fail. If it is too wide, the trade may execute at a materially worse rate than the user expected. Some interfaces suggest a default based on token volatility or network conditions. Users should understand whether that value is a percentage, how the minimum output is calculated and whether the interface adjusts it automatically.

Setting a low tolerance can reduce the amount of adverse movement accepted, but it may also increase failed transactions or require resubmission. Repeatedly resubmitting a large trade can reveal more information and incur additional costs. The right choice depends on the asset, pool liquidity, trade size and urgency. A volatile token with limited liquidity behaves differently from a stable pair in a deep pool. There is no universal percentage that guarantees protection.

Public mempools and transaction visibility

In many networks, a signed transaction is shared with nodes before it is included in a block. A public mempool provides transparency and supports open participation, but it can also expose pending trade details. Searchers can simulate the transaction against current pool state and decide whether an ordering strategy is profitable. Some systems use private transaction routes, encrypted mempools or auction mechanisms to reduce public exposure.

Private routing can reduce the chance that a trade is copied by actors watching the public mempool, but it introduces other assumptions. A user must trust the route’s operator or rely on a specific privacy design. The transaction may be delayed, rejected or handled differently from a public submission. Some protected routes share partial information with searchers under rules intended to return value to users or reduce harmful ordering. Read the product’s own documentation; “MEV protected” is not a single technical standard that means the same thing everywhere.

Practical ways to reduce avoidable exposure

Start by checking the pool and route. A swap aggregator may compare several pools, but each additional hop can add contract and fee considerations. Review the estimated price impact and minimum output before signing. For a large trade, consider whether splitting the order over time or using a limit order is more appropriate; both have trade-offs, including exposure to changing market prices and execution uncertainty.

Use wallet and protocol features that you understand. Some wallets allow users to route transactions through a protected RPC or private relay. Some decentralized exchanges use intents or auctions, where specialized fillers compete to satisfy a user’s signed order. Those designs can reduce public-mempool exposure or improve execution in certain cases, but they do not eliminate smart-contract, counterparty, routing or market risk. Confirm the official endpoint and understand what information the service can see.

Do not increase slippage simply because a swap keeps failing unless you understand why. Check whether the pool is shallow, the token is unusually volatile, the route is congested or the token has transfer restrictions. A very high tolerance can turn a failed trade into a completed trade at an unfavorable price. If a wallet prompt requests permissions unrelated to the swap, pause and inspect the spender, token and allowance before approving it.

How to evaluate a protected swap product

Ask where the transaction is sent, whether it enters a public mempool, who can inspect it and how it is included. Learn whether the service uses a single operator, a network of builders or an auction among fillers. Check whether the service charges a fee, how failed transactions are handled, and whether users can verify the final execution on-chain. If refunds or MEV sharing are advertised, read the calculation method and eligibility rules.

It is also important to distinguish prevention from redistribution. A system may attempt to prevent harmful front-running, or it may permit certain forms of back-running and share part of the value with a user. Those are different goals. Some forms of MEV can improve market efficiency by closing price gaps or liquidating undercollateralized positions. The policy question is whether the user understands the ordering and receives the outcome they authorized, not whether every form of value extraction can be removed from an open network.

Common misconceptions

“A hardware wallet stops MEV” is not accurate. Hardware wallets protect keys from some online threats and let users review transaction details on a trusted screen. MEV is about transaction ordering and execution, so the hardware device does not by itself hide a pending swap or control the pool’s price. “Slippage protection prevents every sandwich” is also too strong. A sandwich can sometimes remain within a user’s tolerated range, while a tighter limit may simply cause a revert.

Another misconception is that any price difference proves a sandwich. Market prices move naturally, and route execution can differ because of latency, price impact, volatility or competing trades. On-chain analysis can reveal transaction ordering, but interpreting intent requires care. A professional review separates observable facts—the order of transactions, pool state and token amounts—from conclusions about why an actor submitted them.

A pre-swap checklist

Before confirming, verify the token contracts, network, route, trade size, estimated price impact, minimum received amount and slippage tolerance. Check whether the transaction will be sent through a public or protected route and understand any extra service. Confirm that the wallet prompt matches the action you intended. For unfamiliar tokens, review transfer restrictions and liquidity rather than relying on a price shown in a promotional post.

After execution, compare the transaction receipt with the quote. Look at the pool route, actual output, gas cost and any additional fee. If the result is materially different, investigate the transaction order and interface settings before repeating it. Keep records if you need to report a problem to a wallet, aggregator or exchange. A transaction hash is public information; your seed phrase and private key are not.

The takeaway

MEV is a feature of transaction ordering in open blockchains, with both useful and harmful forms. Sandwich attacks exploit the visibility and price impact of pending swaps. Slippage limits can cap the result a user accepts, but they cannot remove every ordering risk. Private routes and protected swap products may help, yet each has its own assumptions.

The practical defense is informed signing: understand the quote, liquidity, minimum output, route and permissions. Use tools from verified sources, avoid setting a tolerance you cannot explain and remember that a low fee or fast confirmation does not automatically mean a better execution. Security improves when users know what the transaction authorizes and how its path through the network works.

Sources and further reading

Ethereum.org: MEV and transaction ordering · Flashbots Protect: private transaction routing · Uniswap: swap safety checks and slippage

How did this story make you feel?

Comments

Loading comments…

Related stories

The best of the news, in your inbox

Subscribe for free. Unsubscribe any time.

What would you like to receive?

By subscribing you agree to receive emails. We will first send a confirmation email.

Cookie settings

Choose which cookies to allow. You can change this any time from the footer.

Needed to run the site, keep it secure and remember your preferences. Cannot be turned off.

Helps us understand which stories are read so we can improve the site.

Used to show relevant ads and measure their performance.