What is front-running and MEV?
Front-running is when someone sees a pending transaction and gets their own transaction executed first to profit from it. MEV (maximal extractable value) is the wider profit available from choosing which transactions go into a block and in what order. Sandwich attacks, back-running and liquidation races are all forms of it, and protocols that ignore ordering can leak value to whoever controls it.
Common forms
- Sandwich attacks. An attacker buys before a large swap and sells after it, profiting from the price movement the victim causes.
- Front-running. Copying a profitable transaction, such as a liquidation, an arbitrage or a claim, and paying to have it executed first.
- Back-running. Placing a transaction immediately after one that moves a price, to capture the arbitrage.
- Griefing. Front-running to make a user’s transaction fail, such as taking a name or slot they were about to claim.
Where protocols leak value
- Swaps with no slippage limit or a deadline that never expires.
- Functions that reward whoever calls them first, without commitment.
- Initialisation functions that anyone can call before the deployer does.
- On-chain reveals of information others can act on.
Reducing exposure
- Require minimum output amounts and deadlines on trades.
- Use commit-reveal for actions where seeing the transaction gives an advantage.
- Make sure deployment and initialisation happen atomically.
- Consider private transaction submission for sensitive operations.
HYDN’s audits look at ordering risk in every function that moves value. See our Ethereum audit page.
Frequently asked questions
Can MEV be eliminated?
Not entirely. It can be reduced by design: slippage limits, commit-reveal schemes, batch auctions, private transaction submission and avoiding functions whose outcome depends on ordering.
Is front-running a smart contract bug?
It is often a design flaw. If a function's result depends on who calls it first, or a user's trade can be worsened by a transaction placed before it, someone will exploit that ordering.
Published Updated
