DeFi

What Is MEV? Sandwich Attacks and How to Protect Swaps

What Is MEV? Sandwich Attacks and How to Protect Swaps

Your swap quoted 10.0 ETH and you received 9.75. If that has happened to you, you may have met MEV. So what is MEV? Maximal extractable value is the profit someone can make by choosing which transactions go into a block and in what order. Some of it is harmless, like arbitrage that keeps prices aligned. Some of it comes straight out of your trade, most often through a sandwich attack. This guide explains who extracts MEV, how to check whether your swap was sandwiched, and the settings that make it much harder.

Key takeaways

  • MEV is value captured by reordering, inserting or excluding transactions in a block.
  • Arbitrage and liquidations are “neutral” MEV; sandwich attacks and front-running take value from users.
  • A high slippage tolerance is effectively a budget you hand to sandwich bots.
  • Private transaction routes (such as Flashbots Protect, MEV Blocker or MetaMask Smart Transactions) and intent-based swaps (CoW Swap, UniswapX) keep your order out of the public mempool.
  • “MEV bot” money-making tutorials are a known scam that drains anyone who deploys the code.

What is MEV in plain terms

When you submit a transaction on Ethereum, it usually waits in a public waiting area called the mempool before being included in a block. Anyone can read it there. Whoever builds the block decides the order of transactions, and order matters: a trade placed just before yours can change the price you get.

MEV crypto discussions use “maximal extractable value” (originally “miner extractable value”) for the total profit available from these ordering choices. It falls into rough categories:

  • Arbitrage: buying on one DEX and selling on another after a large trade moves the price. This keeps markets in line and doesn’t directly harm a specific user.
  • Liquidations: racing to repay undercollateralised loans on lending protocols in exchange for a bonus. It keeps lending markets solvent.
  • Front-running: copying or pre-empting a profitable pending transaction with a higher priority fee.
  • Sandwich attacks: placing one trade before yours and one after, profiting from the price impact your trade causes.

The first two are part of how DeFi functions. The last two are a hidden cost for users, and they’re what the rest of this guide is about.

The MEV supply chain: searchers, builders, validators

On Ethereum today, MEV runs through a chain of specialised roles, a setup known as proposer-builder separation (PBS):

Role What it does
Searchers Run bots that scan the mempool and blockchain state for profitable opportunities, then submit bundles of transactions in a precise order
Builders Assemble full blocks from public transactions and searchers’ bundles, aiming to produce the most valuable block
Relays Pass sealed blocks from builders to validators so neither side can cheat the other
Validators (proposers) Pick the highest-paying block, typically through software called MEV-Boost, and propose it to the network

Most of the value flows back to validators as payment for including the most profitable block. That arrangement relies on trusted relays outside the protocol. Ethereum developers plan to move it inside the protocol through enshrined PBS (ePBS, EIP-7732), the headline change of the upcoming Glamsterdam upgrade, and to add fork-choice inclusion lists (FOCIL, EIP-7805) in a later upgrade to make it harder for builders to censor transactions. As of October 2026, Glamsterdam’s mainnet date was still being finalised; check ethereum.org for the current status.

Sandwich attacks, step by step

Here’s how a sandwich attack in crypto works, with simplified, illustrative numbers. You submit a swap of 30,000 USDC for ETH on a DEX pool, with a quote of 10 ETH and a 3% slippage tolerance. That means you’ll accept as little as 9.7 ETH.

  1. Spot. A searcher’s bot sees your pending swap in the public mempool and calculates how far it can push the price without exceeding your 3% limit.
  2. Front-run. The bot buys ETH from the same pool just before you, pushing the price up.
  3. Your trade. Your swap executes at the worse price. You receive about 9.75 ETH, which is within your tolerance, so it doesn’t fail.
  4. Back-run. The bot immediately sells its ETH back into the pool at the higher price your trade created.

The bot keeps the difference, minus fees and what it pays the builder for that ordering. You lost about 0.25 ETH relative to your quote, and nothing looked wrong in your wallet: the transaction succeeded.

The key variable is slippage tolerance. Bots extract up to the limit you set. A 0.5% setting on a liquid pair leaves almost nothing to take; a 5% or “auto” setting on a thin memecoin pool can hand over most of it. Our slippage guide explains how to choose a sensible tolerance for different pairs.

Was my swap sandwiched? How to check

If a swap came out noticeably worse than quoted, you can usually prove whether it was sandwiched in a few minutes:

  1. Open your transaction on a block explorer. Search the transaction hash on Etherscan (or the explorer for your chain). If you’re new to explorers, see our guide to blockchain explorers.
  2. Click through to the block. Note your transaction’s position in the block.
  3. Look at the transactions immediately before and after yours. A sandwich shows the same address or contract swapping the same pair just before you (buying what you bought) and just after you (selling it).
  4. Compare amounts. The “Tokens Transferred” or logs section shows what each trade received. If the bot’s sell returned more than its buy cost, and your received amount was near your minimum, you were sandwiched.
  5. Use an MEV analytics site. Tools such as EigenPhi let you paste a transaction hash and label it if it was part of a sandwich, showing the attacker’s profit.

There is no way to reverse it. The value of checking is learning which settings to change before your next trade.

How to protect swaps from MEV

MEV protection works by keeping your trade out of the public mempool, or by changing how it’s filled. As of October 2026, these are the main options:

1. Use a private transaction route

  • MetaMask Smart Transactions: MetaMask’s support documentation says the feature is turned on automatically and is available on networks including Ethereum, Linea, Base, Arbitrum, BNB Smart Chain and Polygon. Check it under Settings, then Transactions (extension) or Settings, then Advanced (mobile). Using a custom RPC on those networks overrides it.
  • Flashbots Protect and MEV Blocker (built by the CoW Protocol team and partners): add their RPC endpoint to your wallet as a network, using the address published in their official docs. Transactions go to builders privately instead of to the public mempool, and some MEV that searchers do capture by back-running can be refunded to you.

2. Use intent-based swaps

With CoW Swap and UniswapX you sign an order (an “intent”) rather than broadcasting a swap. Solvers or fillers compete to fill it, and your order isn’t exposed in the mempool for bots to sandwich. Note that signing an order is still an authorisation; read what you’re signing, and check token approvals afterwards. For how routing across many pools fits in, see our guide to DEX aggregators.

3. Tighten slippage and split large trades

Set slippage as low as the pair allows, typically well under 1% for major tokens. For large orders in thin pools, split the trade or use a limit order so there’s less price impact for a bot to exploit.

Layer 2 networks also reduce sandwiching because a centralised sequencer orders transactions, often first-come-first-served, and there is usually no public mempool. That depends on the sequencer’s policies, so it’s a reduction in risk, not a guarantee.

MEV on Solana

Solana has no traditional public mempool, but MEV exists there too. Much of it flows through Jito, whose modified validator client lets searchers send bundles with tips to validators running it. Our Jito explainer covers that infrastructure in depth.

Sandwiching became a serious problem for Solana traders, especially those using Telegram trading bots with high slippage settings. On 8 March 2024, Jito Labs suspended the mempool feature in its block engine, citing the harm sandwich attacks were doing to users. Sandwiching didn’t stop: private mempools and some validators kept doing it directly. Research presented at a Solana conference in 2025 estimated that sandwich bots extracted several hundred million dollars between early 2024 and mid-2025. During 2025, the Marinade stake pool and Jito both removed validators found to be sandwiching, though critics noted that operators can return under new identities.

The practical defences on Solana are the same in spirit: keep slippage low, be wary of trading bots that default to high tolerances, and use wallet or aggregator options that route transactions with MEV protection where offered.

MEV bot scams

Because MEV sounds like a money machine, it attracts scams. A common one is a video tutorial promising easy profits from an “MEV bot” or “arbitrage bot” smart contract. You’re told to paste code into Remix, deploy it, and send ETH to it to “start trading”. The code hides an address that lets the scammer withdraw everything. SentinelLABS documented one such campaign in August 2025 that had taken more than $900,000, using aged YouTube accounts, AI-generated narration and heavily moderated comment sections.

Real MEV searching is a highly competitive, capital-intensive engineering business. Nobody gives away a profitable bot in a YouTube video. If you’ve lost funds this way, report it to the FBI’s IC3 (ic3.gov) in the US or your national fraud agency, and ignore anyone offering to recover your money for a fee. More DeFi explainers are collected in the DeFi hub.

FAQ

Is MEV illegal?

Most MEV, such as arbitrage and liquidations, is a normal part of how public blockchains work. Sandwich attacks occupy a grey area and are widely seen as harmful to users. In the US, prosecutors charged two brothers with fraud over a 2023 exploit of other traders’ MEV bots, and their 2025 trial ended in a mistrial after the jury deadlocked, so the legal lines remain unsettled. This is not legal advice.

What is the best MEV protection for a normal wallet?

For most users, the simplest MEV protection is to keep slippage low and route transactions privately. In MetaMask, check that Smart Transactions is on for supported networks. In other wallets, you can add a protected RPC such as Flashbots Protect or MEV Blocker. For larger swaps, intent-based platforms like CoW Swap or UniswapX avoid the public mempool entirely.

What does a private RPC do?

A private RPC is a network endpoint that sends your transaction directly to block builders instead of broadcasting it to the public mempool. Bots can’t see your pending swap, so they can’t sandwich it. Some private RPCs also share back-running profits with you. You add one in your wallet’s network settings using the official address from the provider’s documentation.

How does Jito relate to MEV on Solana?

Jito runs a widely used validator client and block engine on Solana that lets searchers submit transaction bundles with tips to validators. That makes MEV more orderly and pays validators and stakers, but it also provided infrastructure that sandwich bots used. Jito shut its mempool feature in March 2024 because of sandwich attacks, and it has since removed validators caught sandwiching.

Crypto is volatile and risky; this is education, not financial advice. Do your own research.

Related Articles