Learn · Execution

What is MEV and how does sandwiching work?

MEV — maximal extractable value — is the profit that can be captured by controlling the order of transactions in a block. On public blockchains your pending swap is visible before it confirms, and specialized actors compete to reorder, insert, or front-run transactions for gain. The most common form ordinary traders meet is the sandwich attack. This article explains where MEV comes from, how a sandwich works step by step, and the concrete habits that reduce your exposure.

Where MEV comes from

When you submit a transaction on most EVM chains, it sits in a public mempool waiting to be included in a block. Whoever builds the block decides the order of transactions in it. That ordering power has value: by placing transactions before or after yours, a searcher can profit from the price movement your trade will cause. MEV is the umbrella term for all such value, from benign arbitrage that keeps prices aligned to predatory tactics aimed at your trade.

How a sandwich attack works

A sandwich targets a swap with loose slippage. The attacker sees your pending buy, places their own buy immediately before it (front-run), which pushes the price up. Your trade then executes at the inflated price, pushing it higher still. The attacker immediately sells right after your trade (back-run), pocketing the difference. You are the filling: you paid more than you should have, and the gap you lost is exactly the room your slippage tolerance allowed.

Why slippage settings matter here

A sandwich is only profitable up to the slippage you authorized — that tolerance defines the maximum the attacker can extract. Setting slippage as tight as the pool allows shrinks or eliminates the profit, often making your trade not worth attacking. This is the practical reason the slippage guides warn against maxing out tolerance: a loose setting is an open invitation written in your own transaction.

How to reduce your exposure

Keep slippage tight, especially on large or liquid trades where the dollar profit from a sandwich is highest. Split big orders into smaller clips so no single trade offers an attractive target. Where available, use private transaction routes or MEV-protected submission that keep your trade out of the public mempool until it is included. And re-quote before signing — a fresh, tight quote leaves less room than a stale, loose one.

MEV is not unique to one chain

Although sandwiching is most associated with public-mempool EVM chains, transaction-ordering value exists wherever there is a profit in sequencing trades — Solana included, where it takes different forms. The defenses generalize: minimize the room your own transaction offers, avoid broadcasting large, loose orders into a fully public queue, and prefer execution paths that reduce how visible and exploitable your pending trade is. The goal is never to be the easiest target in the block.

Legal

Risk disclosure

XAUConnect is a non-custodial swap aggregator. Digital assets are volatile and may lose value rapidly. Content on this page is educational and not investment advice. Verify every contract address on the official block explorer before approving a transaction.

Frequently asked questions

What is MEV in simple terms?

The profit available from controlling the order of transactions in a block. It ranges from harmless arbitrage to predatory tactics like sandwich attacks aimed at your trade.

How does a sandwich attack work?

An attacker buys just before your trade to push the price up, lets your trade fill at the worse price, then sells right after — capturing the difference your slippage allowed.

How do I protect myself from sandwiching?

Keep slippage tight, split large trades, use MEV-protected or private submission where available, and re-quote before signing.

Does MEV exist on every chain?

It is most associated with public-mempool EVM chains. Different networks and submission methods change how exposed your trade is, but ordering value exists broadly.

Live execution

Trade on XAUConnect

Open the swap page to compare live routes, set slippage, and sign from your own wallet — fully non-custodial.

Continue exploring

Related markets, guides & networks

Curated next steps based on this topic — deepen your research before you trade.

Build programmatically

Swap via API for bots and AI agents — quotes, builds, and cross-chain routes.

Developer quickstart