# MEV (Miner Extractable Value)

* the profit can be extracted from a transaction
* happen when miners prioritizing or re-ordering transactions in a block
  * traders paying higher gas fee to miners to prioritize their profitable arbitrage
  * miners make extra profit by executing TXs (transactions) with extra gas fee
* Benefit: DEX arbitrage maintain correct price over different DEXs
* Drawback: MEV incentive triggers bot gas war that makes normal users pay more gas/slippage

### MEV examples

* **front running:** putting a higher gas in a TX to win the gas auction, so blockchain finalise your TX before others to get a better deal , such as selling higher price/buying lower price, liquidators liquidating borrowers loans (selling borrowers’ collaterals) before they can repay the debt to extract profits
* **back running:** putting a lower gas to proceed after a known pending target, such as queuing for token initial liquidity to be the first to trade
* **sandwiching:** mix tactic of front & back running. When victim is queuing a TX on chain, attacker places one TX before & another right after a victim's pending TX. This allows attacker to buy before victim to push price up, then sell the token straight after the victim at a higher price, where the price gap is attacker's profit
* **DEX arbitrage:** buy from DEX A at lower price and sell in DEX B at high price to make profit from price difference

### Flashbots

A private network layer mitigates negative externalities of MEV to the Ethereum network

* **Flashbots Auction**
  * private transaction pool with a blind auction mechanism
  * block producers to trustlessly outsource the work of finding optimal block construction
  * users can privately communicate their bid and not require to pay for fail bid
* **Flashbots Data**
  * MEV inspector to find miner payments + tokens transfers and profit + swaps and arbitrages in a block
* **Flashbots Protect**
  * Flashbots RPC endpoint can be easily add to users' wallet
  * TXs are masked by flashbots and not visible on public mempool
  * provide frontrunning protection and no fail transaction (drop if not executable)&#x20;
