mev-protection-guide
Skill8 starsChanged 9 months agoMITView on GitHub
Guide to MEV (Maximal Extractable Value) — sandwich attacks, frontrunning, backrunning, and how to protect transactions. Use when explaining MEV to users, recommending swap protection, or analyzing suspicious transaction patterns.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- sperax-skillsSkill
- agent-wallet-securitySkill
- ai-agent-defi-guideSkill
- airdrop-hunting-guideSkill
- arbitrum-defi-guideSkill
- chainlink-oracle-guideSkill
- cross-chain-bridge-guideSkill
- crypto-governance-guideSkill
- crypto-market-sentimentSkill
- crypto-news-aggregationSkill
- crypto-portfolio-managementSkill
- crypto-price-data-guideSkill
- crypto-tax-basicsSkill
- dca-strategy-guideSkill
- defi-dashboard-buildingSkill
- defi-lending-guideSkill
- defillama-analytics-guideSkill
- defi-risk-assessmentSkill
- defi-yield-strategiesSkill
- erc8004-agent-identitySkill
- gas-optimization-guideSkill
- impermanent-loss-explainedSkill
- nft-analytics-guideSkill
- onchain-analytics-guideSkill
- plutus-plsassets-guideSkill
- plutus-protocol-overviewSkill
- plutus-vaults-guideSkill
- restaking-explainedSkill
- smart-contract-reading-guideSkill
- sperax-ecosystem-overviewSkill
- sperax-farms-guideSkill
- sperax-spa-stakingSkill
- sperax-usds-guideSkill
- stablecoin-mechanicsSkill
- subgraph-development-guideSkill
- token-approval-safetySkill
- token-discovery-guideSkill
- token-swap-best-practicesSkill
- web3-glossarySkill
- whale-watching-guideSkill
- yield-vault-guideSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 37
After large swaps (price impact creates arb opportunity)
- Distinctive: line 85
Place limit orders that execute when conditions are met — no mempool exposure:
- Distinctive: line 87
No frontrunning possible (order isn't in mempool)
- Distinctive: line 97
Look for this pattern around your transaction:
- Distinctive: line 111
If actual slippage significantly exceeds the pool's fee tier, MEV extraction is likely.
- Distinctive: line 128
When helping users with swaps:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MEV Protection Guide
MEV (Maximal Extractable Value) is profit that block builders and searchers extract by reordering, including, or excluding transactions. Understanding MEV helps protect your users' trades.
Types of MEV
1. Sandwich Attacks
The most common MEV attack on DEX swaps:
1. Attacker sees your swap in mempool
2. Attacker buys before you (frontrun) → pushes price up
3. Your swap executes at a worse price
4. Attacker sells after you (backrun) → profits from the price differenceWho gets hurt: Anyone swapping on DEXs with high slippage tolerance Typical loss: 0.3–2% of trade value
2. Frontrunning
A searcher copies your profitable transaction and submits it first with higher gas:
- Arbitrage opportunities
- NFT mints
- Liquidation calls
3. Backrunning
Searcher submits a transaction immediately after yours to capture resulting arbitrage:
- After large swaps (price impact creates arb opportunity)
- After oracle updates
- After liquidations
4. Just-In-Time (JIT) Liquidity
A sophisticated attack on V3 pools:
- Searcher adds concentrated liquidity just before your swap
- Your swap pays fees to the searcher's position
- Searcher removes liquidity immediately after
5. Time-Bandit Attacks
Block proposers reorganize past blocks to capture MEV. Rare but possible with proof-of-stake.
Protection Strategies
For Users
| Strategy | Protection Level | Tradeoff |
| Low slippage (0.5%) | Medium | May fail on volatile tokens |
| Private mempool | High | May have slight delay |
| DEX aggregator | Medium–High | Best price routing |
| Limit orders | High | No immediate execution |
1. Use Low Slippage Tolerance
Set slippage to 0.5% or lower. This limits how much the price can move against you, making sandwich attacks unprofitable.
Caution: Too-low slippage on volatile tokens may cause transactions to fail.
2. Private Transaction Submission
Send transactions through private mempools that hide them from searchers:
| Service | How It Works |
| Flashbots Protect | Sends tx directly to block builders, skipping public mempool |
| MEV Blocker | Private relay by CoW Protocol |
| MEV Shield (Sperax) | Built-in protection in SperaxOS swap tool |
3. Use DEX Aggregators
Aggregators like 1inch, 0x, and Paraswap split trades across pools to minimize price impact and MEV exposure.
4. Gasless Limit Orders
Place limit orders that execute when conditions are met — no mempool exposure:
- 1inch Limit Order Protocol: EIP-712 signed, gasless
- No frontrunning possible (order isn't in mempool)
5. Batch Auctions
Protocols like CoW Swap use batch auctions where all trades in a batch get the same price, preventing sandwich attacks entirely.
Detecting MEV
Signs of a Sandwich Attack
Look for this pattern around your transaction:
- Large buy of the same token (1–2 blocks before yours)
- Your swap (at a worse price than expected)
- Large sell of the same token (same block or next block)
- Same address in steps 1 and 3
Checking Transaction Impact
Expected output (from quote): 1,000 USDC
Actual output (on-chain): 985 USDC
Difference: 15 USDC (1.5% slippage/MEV)If actual slippage significantly exceeds the pool's fee tier, MEV extraction is likely.
MEV by Chain
| Chain | MEV Level | Notes |
| Ethereum | High | Most MEV activity, Flashbots dominant |
| Arbitrum | Low–Medium | Sequencer ordering reduces MEV, but still possible |
| Base | Low–Medium | Similar to Arbitrum |
| Polygon | Medium | Less sophisticated but growing |
| BSC | Medium | MEV searchers active |
| Solana | Medium–High | Jito MEV ecosystem |
Arbitrum advantage: The centralized sequencer orders transactions FIFO (first-in-first-out), which significantly reduces sandwich attack opportunities. This is one reason Sperax chose Arbitrum for USDs.
Agent Tips
When helping users with swaps:
- Always recommend low slippage — 0.5% for standard swaps
- Large swaps (>$10K) should use private mempools or DEX aggregators
- Check if their wallet supports Flashbots Protect — many do now
- On Arbitrum: MEV is lower but not zero — still use reasonable slippage
- If a swap fails: suggest slightly higher slippage but explain the tradeoff
- Limit orders: for non-urgent trades, gasless limit orders eliminate MEV entirely
Links
- Flashbots Protect: https://protect.flashbots.net
- MEV Blocker: https://mevblocker.io
- Sperax (Arbitrum-native, lower MEV): https://app.sperax.io
- EigenPhi (MEV analytics): https://eigenphi.io
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

