Skip to main content

What Is MEV and Front-Running?

What Is MEV?​

MEV (Maximal Extractable Value) is the profit that bots, validators, or block builders can make by choosing which transactions go into a block, and in what order.

On many networks, a transaction waits in a public queue, the mempool, before it's added to a block. Bots watch that queue. When they see a swap that will move a price, they can place their own trades around it.

Front-Running and Sandwich Attacks​

  • Front-running: a bot sees your swap and puts its own trade in first, paying a higher fee to go ahead of you. You then trade at a slightly worse price.
  • Sandwich attack: a bot buys just before your swap, which pushes the price up, then sells right after it at that higher price. You pay more, and the bot keeps the difference.

Sandwich attacks mostly target large swaps in small pools with high slippage, because those leave the most room for profit.

How Am I Protected in Gem Wallet?​

Your main protection is the Minimum Received amount. Every swap is signed with a limit based on your slippage setting. If the price moves against you by more than that, whether from the market or from a bot, the swap fails instead of filling at a worse price. See What Does Minimum Received Mean in a Swap?.

A failed swap still costs the network fee, but your tokens stay in your wallet. See Why Was My Crypto Transaction Reverted?.

How to Lower Your Risk​

  • Keep slippage low. Use Auto, or a small custom value. Every extra percent of slippage is room a bot can take. A custom value of 3% or more shows a warning in Gem Wallet.
  • Check price impact. A high price impact means the pool is small for your amount, which makes sandwiching easier. See What is Price Impact?.
  • Split very large swaps into smaller ones.
  • Compare providers. Some providers use routes or order types that bots can't easily sandwich. See How to Select a Swap Provider in Gem Wallet.

Did MEV Cost Me Money?​

If you got less than the quote but at least Minimum Received, the swap went through within the limit you set. That can be normal price movement, price impact, or MEV. See Why Does a Swap Amount Differ from the Original Quote?.

On an explorer, a sandwich shows up as the same address trading the same pair just before and just after your swap, in the same block. See What Is a Block Explorer and How Do I Use It?.