nonceDocumentation

How MEV Works

MEV (Maximal Extractable Value) is the profit that can be captured by strategically ordering, inserting, or front-running transactions within a blockchain block. It exists on every blockchain with a public mempool — and it represents billions of dollars in annual value.

The mempool: where opportunities live

When you submit a transaction on Ethereum, Solana, or any other blockchain, it doesn't get confirmed instantly. It first enters the mempool — a public waiting room of pending transactions. Every transaction in this pool is visible to anyone watching.

MEV bots continuously scan the mempool at millisecond intervals, analyzing each pending transaction for exploitable patterns. When a bot spots an opportunity — say, a large swap that will move a token's price — it can construct its own transaction to profit from that price movement.

MEV strategies explained

DEX Arbitrage

When the same token trades at different prices on different decentralized exchanges, arbitrage bots buy on the cheaper exchange and sell on the more expensive one — capturing the spread as pure profit.

Example

Token ABC trades at $1.00 on Uniswap and $1.03 on SushiSwap. The bot buys on Uniswap and sells on SushiSwap in a single atomic transaction, netting $0.03 per token minus gas fees.

Sandwich trades

When a large swap is detected in the mempool, the bot places a buy order just before it (front-running) and a sell order just after (back-running). The large swap pushes the price up; the bot profits from the difference.

Example

A user submits a $50K swap of ETH→USDC. The bot buys ETH before this swap executes (at the lower price), then sells after the large swap has pushed the price up — capturing the price impact as profit.

Liquidations

In DeFi lending protocols like Aave or Compound, positions become liquidatable when collateral value drops below a threshold. Bots monitor these positions and execute liquidations to earn the liquidation bonus — typically 5-10% of the repaid amount.

Example

A borrower's health factor drops below 1.0 on Aave. The bot repays part of their debt and receives the collateral at a 5% discount, instantly selling it for profit.

Token sniping

When a new token is listed on a DEX — whether through a fair launch, Pump.fun, or a fresh liquidity addition — sniping bots buy in the same block as the listing, before the wider market reacts. Early entry often means buying at the lowest possible price.

Example

A new memecoin launches on Pump.fun. The bot detects the liquidity addition transaction in the mempool and submits a buy order in the same block — entering at launch price before retail buyers drive it up.

Atomic transactions: the safety net

The key innovation that makes MEV extraction safe is atomic execution. An atomic transaction either completes entirely (all steps succeed and profit is captured) or reverts entirely (all steps are undone and nothing happens). There is no middle ground — you cannot lose your principal in an atomic trade.

What does 'atomic' actually mean?

Think of it like an all-or-nothing bet with a guaranteed refund if you lose. The smart contract checks profitability before committing the trade. If the expected profit isn't there — due to someone else getting there first, or the price moving — the entire transaction reverts. The only cost is the gas fee for the attempt.

Why is MEV consistently profitable?

MEV isn't speculation — it's structural. As long as decentralized exchanges exist and people trade on them, price discrepancies and ordering opportunities will continue to appear in every single block. This makes MEV one of the most consistent sources of yield in DeFi:

  • Market inefficiencies are constant — DEX prices lag behind each other on every block, creating arbitrage opportunities hundreds of times per minute
  • Volume-dependent, not price-dependent — MEV profits come from trading activity, not from whether crypto goes up or down
  • Compounding at scale — hundreds of small, low-risk trades compound into meaningful daily returns over time