What is MEV?

MEV (Maximal Extractable Value)
MEV (Maximal Extractable Value) refers to the additional value that miners or validators can obtain by reordering transactions. Sandwich attacks are a typical application of MEV, where attackers profit by manipulating the order of transactions.
What is a Sandwich Attack?
A sandwich attack is a Defi market manipulation strategy where attackers exploit the transparency and controllable transaction ordering of blockchains by inserting transactions before and after a victim's transaction to influence market prices and profit from the price movement.
Attack Process
Front-running Transaction: Attackers observe pending transactions, and if they discover someone attempting to buy a specific token, they will purchase it first, paying higher Gas fees to ensure miners prioritize their transaction.
Victim's Transaction Execution: Due to the attacker's buying activity, the price increases, causing the victim to purchase tokens at a higher price.
Back-running Transaction: The attacker immediately sells after the victim's transaction completes, profiting from the price fluctuation.
Why Do Sandwich Attacks Occur?
Blockchain Transaction Transparency: All transactions are publicly visible before confirmation, allowing attackers to monitor the Mempool to predict market movements.
Manipulable Transaction Ordering: Attackers can pay higher Gas fees to prioritize their transactions.
Automated Bots: Attackers use high-frequency trading bots to automatically monitor and execute these transactions at extremely fast speeds, making it difficult for ordinary users to compete.
How to Prevent Sandwich Attacks?
Enable Anti-MEV Mode: Turn on the Anti-MEV mode in BYDFi MoonX trading settings.
Set Slippage Tolerance: Reduce the acceptable price change range to avoid being attacked.
Batch Transactions: Break large transactions into smaller ones to reduce attractiveness to attackers.
Why Doesn’t Low Slippage Prevent Sandwich Attacks?
Slippage Limit ≠ Protection: If attackers keep price changes within your slippage, the sandwich attack still works.
Cannot Prevent Front / Back-Running: Low slippage can’t block order manipulation—attackers use gas to front-/back-run trades.
Low Slippage Can Cause Failures: Setting slippage too low can cause failed trades and wasted gas due to volatility or low liquidity.
Example:
- Original price: $0.01
- User slippage set to 20% → Acceptable range: $0.008 ~ $0.012
- Attacker front-runs, pushes price to $0.015
- Node reads updated expected price: $0.015
- New slippage range becomes: $0.012 ~ $0.018
- If final price is within this range, your transaction still executes
Conclusion: Even with a low slippage setting, sandwich attackers can exploit the system by manipulating prices just enough to fall within your acceptable range — effectively “harvesting” your trade.