MEV, Flash Loans & On-Chain Arbitrage
Explore the hidden economy of Maximal Extractable Value - how bots front-run transactions, exploit flash loans, and what it means for everyday users.
MEV, Flash Loans & On-Chain Arbitrage
The blockchain mempool is a battleground. Bots scan every pending transaction to extract profit - this is MEV (Maximal Extractable Value), and understanding it is essential for advanced DeFi users.
MEV is the profit a block producer (validator/miner) can extract by reordering, inserting, or censoring transactions within a block.
Total MEV extracted on Ethereum has exceeded $1 billion since DeFi Summer 2020.
A bot sees your large DEX trade in the mempool and inserts its own buy order before yours, then sells into your transaction's price impact.
You: Buy 100 ETH of TOKEN at market Bot: [sees your tx] → Buy TOKEN first → YOUR tx executes → Bot sells at higher price Result: You get worse price, bot profits
A variant of front-running. The bot places a buy before and a sell after your transaction:
Block order: 1. Bot buy (front-run) 2. YOUR trade (victim) 3. Bot sell (back-run)
Protection: Use high slippage only when necessary, consider private RPCs (Flashbots Protect, MEV Blocker).
When a borrower's collateral falls below the liquidation threshold, bots race to liquidate and claim the liquidation bonus (typically 5-15%).
Prices diverge between Uniswap and Sushiswap. Bots simultaneously buy on the cheaper exchange and sell on the more expensive one - all in one transaction.
Flash loans let you borrow millions with zero collateral - as long as you repay within the same transaction block.
Why is this possible? Smart contracts execute atomically. If repayment fails, the entire transaction reverts as if it never happened.
Transaction flow: 1. Borrow 1,000,000 USDC from Aave 2. Buy ETH on Exchange A (cheap) 3. Sell ETH on Exchange B (expensive) 4. Repay 1,000,000 USDC + 0.09% fee 5. Keep the arbitrage profit If any step fails → entire tx reverts, loan never happened
Flash Loan Providers:
- Aave: 0.09% fee
- dYdX: 0% fee (for some assets)
- Balancer: 0% fee
- Uniswap v3: 0.05% fee
| Protocol | Year | Loss | Method | |---|---|---|---| | bZx | 2020 | $1M | Oracle manipulation | | Harvest Finance | 2020 | $34M | Stablecoin depeg | | Cream Finance | 2021 | $130M | Reentrancy + flash loan | | Euler Finance | 2023 | $197M | Donation attack |
Flashbots created an off-chain auction for MEV:
- MEV-Boost: Validators earn more by accepting MEV-optimised blocks
- Flashbots Protect RPC: Hides your transaction from the mempool
- MEV Share: Users share MEV with the searcher capturing it
At a high level, an arbitrage bot:
- Monitors price feeds from multiple DEXes (using WebSocket streams)
- Calculates profitability after gas costs and fees
- Submits a bundle via Flashbots if profitable
- Uses flash loans to avoid needing capital
Key considerations:
- Gas costs: Ethereum gas can be $50-$500 per tx
- Competition: Thousands of bots compete for the same opportunity
- Latency: You need to be within milliseconds of competitors
- Capital: Even with flash loans, you need ETH for gas
- Use private RPCs: Flashbots Protect, MEV Blocker, 1inch Fusion
- Set tight slippage: Max 0.5% for stablecoins, 1-2% for volatile assets
- Trade during off-peak hours: Less competition in mempool
- Use DEX aggregators: 1inch, Paraswap route orders to minimise impact
- Avoid on-chain limit orders unless the protocol protects against front-running
MEV is a fundamental property of transparent blockchains. Understanding it helps you protect your trades and, potentially, profit from it.
Found this guide helpful? Share it with others


