mev-analysis
БесплатноЗапускает вложенные скриптыНе проверенMEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading
от agiprolabs★ 611 звёзд на GitHubОб этом скилле
MEV Analysis for Solana DEX Trading
Maximal Extractable Value (MEV) is the profit that validators and searchers can extract by reordering, inserting, or censoring transactions within a block. On Solana DEXes, MEV primarily manifests as sandwich attacks against swaps, cross-DEX arbitrage, and liquidation extraction. This skill covers detection, estimation, and protection strategies.
What Is MEV on Solana?
MEV occurs when someone with transaction ordering power profits at other traders' expense. On Solana, the MEV supply chain works as follows:
- You submit a swap through an RPC endpoint
- Searchers observe your transaction (via RPC forwarding, block engine access, or leader TPU sniffing)
- Searcher constructs a profitable bundle (e.g., sandwich your swap)
- Bundle submitted to Jito block engine with a tip to the validator
- Validator includes the bundle in the block, earning the tip
- You receive worse execution; the searcher profits the difference
How Solana MEV Differs from Ethereum
| Aspect | Ethereum | Solana |
|---|---|---|
| Block time | 12 seconds | ~400ms slots |
| Mempool | Public mempool | No mempool (but tx visible in transit) |
| Ordering | Proposer-builder separation (PBS) | Jito block engine (~85%+ validators) |
| Bundle system | Flashbots bundles | Jito bundles with tips |
| MEV cost | Gas priority fees | Jito tips (SOL) |
| Latency pressure | Moderate | Extreme (sub-100ms decisions) |
Key Solana-specific factors:
- No public mempool: Transactions flow RPC → TPU → Leader, but searchers tap into this flow via Jito's block engine and modified validators
- Known leader schedule: The leader (block producer) schedule is known ~2 epochs ahead, letting searchers target specific leaders
- Jito dominance: ~85%+ of validators run the Jito-modified client, making Jito bundles the primary MEV vector
- Speed: 400ms slots mean MEV bots must operate in microseconds, favoring co-located infrastructure
MEV Types on Solana
1. Sandwich Attacks
The most common MEV attack against retail traders.
Mechanics:
1. Attacker sees your pending swap: Buy 10 SOL worth of TOKEN_X
2. Front-run: Attacker buys TOKEN_X first → price rises
3. Your swap: You buy TOKEN_X at higher price → worse execution
4. Back-run: Attacker sells TOKEN_X → profits the difference
Your loss = price impact from front-run + attacker's profit margin Attacker profit = your_loss - jito_tip - transaction_fees
Risk factors:
- Trade size: Larger trades = more profitable to sandwich
- Token liquidity: Illiquid tokens = easier price manipulation
- Slippage setting: Wide slippage = more room for the attacker
- Pool type: CPMM pools more vulnerable than CLMM pools at concentrated ranges
2. Arbitrage (Cross-DEX)
Searchers capture price discrepancies between DEXes.
Pool A: TOKEN_X = 1.00 USDC
Pool B: TOKEN_X = 1.02 USDC
→ Buy on A, sell on B, profit 0.02 USDC per token (minus fees)
This is generally beneficial to the market — it equalizes prices across venues. However, your trade may trigger the arbitrage opportunity that the searcher captures.
3. Liquidation Extraction
When DeFi positions (Solend, Marginfi, Kamino) become undercollateralized, searchers race to liquidate them and claim the liquidation bonus (typically 5-10%).
4. JIT (Just-In-Time) Liquidity
Searchers add concentrated liquidity to a CLMM pool just before a large swap and remove it immediately after, earning swap fees without sustained impermanent loss exposure. This is a sophisticated MEV form that can actually improve execution for the swapper.
5. Back-Running
Trading immediately after a large swap that moved the price, capturing the reversion. Less harmful than sandwiching because it does not worsen your execution — it profits from the market response to your trade.
Estimating MEV Exposure
Estimate your MEV risk before executing a trade:
import httpx
def estimate_mev_risk(
trade_size_sol: float,
pool_liquidity_usd: float,
slippage_bps: int,
token_daily_volume_usd: float,
) -> dict:
"""Estimate sandwich attack profitability for a given trade.
Returns risk assessment with estimated cost and recommendations.
"""
# Trade as percentage of pool liquidity
sol_price = 150.0 # approximate; fetch live price in production
trade_usd = trade_size_sol * sol_price
trade_pct_of_pool = (trade_usd / pool_liquidity_usd) * 100
# Estimated price impact from constant-product AMM
# price_impact ≈ trade_size / pool_liquidity (simplified)
price_impact_bps = int(trade_pct_of_pool * 100)
# Sandwich profitability: attacker captures portion of slippage headroom
# Rough model: sandwich_profit ≈ 0.5 * slippage_headroom * trade_size
slippage_headroom_bps = slippage_bps - price_impact_bps
if slippage_headroom_bps < 0:
slippage_headroom_bps = 0
sandwich_pr
Установить mev-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mev-analysis?
MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading
Как установить скилл mev-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mev-analysis запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic