Agent skill

Mev Analysis

by agiprolabs in agiprolabs/claude-trading-skills

MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading

MITAuto-check passedBusiness, Finance & HR

Install Mev Analysis

skills CLI
$ npx skills add agiprolabs/claude-trading-skills --skill mev-analysis -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install agiprolabs/claude-trading-skills mev-analysis --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/agiprolabs/claude-trading-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/mev-analysis .claude/skills/mev-analysis && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mev-analysis
GitHub stars
410
Token cost
~3.1k tokens
SKILL.md length
895 words
Files
5 (incl. scripts, references)
Skills in repo
68
Repo updated
First seen
Licence
MIT

At a glance

MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading

  • Works in 5 steps: Sandwich Attacks → Arbitrage (Cross-DEX) → Liquidation Extraction → …
  • Tasks that involve Trading and backtesting
  • SKILL.md covers What Is MEV on Solana?, MEV Types on Solana, Estimating MEV Exposure and MEV Protection Strategies, plus 3 more sections
  • Runs Python scripts from its folder; reaches mainnet.block-engine.jito.wtf

What it does

Mev Analysis is an agent skill from agiprolabs/claude-trading-skills. MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/protection_strategies.md`, `references/solana_mev_mechanics.md` and `scripts/mev_risk_estimator.py`).

It sits in Business, Finance & HR, covering Trading and backtesting. It works with Solana. The repository describes itself as: 68 trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools. The licence is MIT.

When your agent uses it

  • Tasks that involve Trading and backtesting

Example prompts

  • “/mev-analysis”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Sandwich Attacks
  2. Arbitrage (Cross-DEX)
  3. Liquidation Extraction
  4. JIT (Just-In-Time) Liquidity
  5. Back-Running

What it can do on your machine

Read from SKILL.md and the folder at commit 981e1d7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • mainnet.block-engine.jito.wtf

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mev Analysis loads about 3.1k tokens when it runs, and up to ~7.2k if it reads all its reference files. Until then it costs about 28 tokens; SKILL.md has 895 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from agiprolabs/claude-trading-skills at commit 981e1d7, republished under its MIT licence (© agiprolabs). 895 words, ~3,103 tokens.

Download SKILL.mdSave it as .claude/skills/mev-analysis/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
mev-analysis
description
MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading

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:

  1. You submit a swap through an RPC endpoint
  2. Searchers observe your transaction (via RPC forwarding, block engine access, or leader TPU sniffing)
  3. Searcher constructs a profitable bundle (e.g., sandwich your swap)
  4. Bundle submitted to Jito block engine with a tip to the validator
  5. Validator includes the bundle in the block, earning the tip
  6. You receive worse execution; the searcher profits the difference
How Solana MEV Differs from Ethereum
AspectEthereumSolana
Block time12 seconds~400ms slots
MempoolPublic mempoolNo mempool (but tx visible in transit)
OrderingProposer-builder separation (PBS)Jito block engine (~85%+ validators)
Bundle systemFlashbots bundlesJito bundles with tips
MEV costGas priority feesJito tips (SOL)
Latency pressureModerateExtreme (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:

python
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_profit_usd = (slippage_headroom_bps / 10000) * trade_usd * 0.5
    jito_tip_cost = 0.001 * sol_price  # ~0.001 SOL typical tip
    tx_fees = 0.000015 * sol_price * 2  # two transactions for sandwich

    net_mev_profit = sandwich_profit_usd - jito_tip_cost - tx_fees
    is_profitable_to_sandwich = net_mev_profit > 0.10  # $0.10 minimum

    # Volume ratio indicates MEV bot attention level
    volume_ratio = trade_usd / max(token_daily_volume_usd, 1)

    risk_level = "LOW"
    if is_profitable_to_sandwich and trade_pct_of_pool > 1.0:
        risk_level = "HIGH"
    elif is_profitable_to_sandwich or trade_pct_of_pool > 0.5:
        risk_level = "MEDIUM"

    return {
        "risk_level": risk_level,
        "trade_pct_of_pool": round(trade_pct_of_pool, 2),
        "estimated_price_impact_bps": price_impact_bps,
        "slippage_headroom_bps": slippage_headroom_bps,
        "estimated_sandwich_cost_usd": round(max(net_mev_profit, 0), 2),
        "is_profitable_to_sandwich": is_profitable_to_sandwich,
        "recommendations": _get_recommendations(
            risk_level, trade_size_sol, slippage_bps, trade_pct_of_pool
        ),
    }


def _get_recommendations(
    risk_level: str,
    trade_size_sol: float,
    slippage_bps: int,
    trade_pct_of_pool: float,
) -> list[str]:
    """Generate protection recommendations based on risk assessment."""
    recs = []
    if risk_level == "HIGH":
        recs.append("Use Jito bundle with 0.001-0.005 SOL tip")
        recs.append("Use private/protected RPC endpoint")
    if trade_pct_of_pool > 2.0:
        n_splits = max(2, int(trade_pct_of_pool))
        recs.append(f"Split into {n_splits} trades over 2-5 minutes")
    if slippage_bps > 100:
        recs.append(f"Reduce slippage from {slippage_bps}bps to 50-100bps")
    if risk_level in ("MEDIUM", "HIGH"):
        recs.append("Enable Jupiter dynamic slippage / MEV protection")
    if not recs:
        recs.append("Standard execution is likely safe for this trade size")
    return recs

MEV Protection Strategies

Strategy 1: Tight Slippage Settings

Set slippageBps as low as feasible. Sandwich profit is bounded by your slippage tolerance.

Token LiquidityRecommended Slippage
> $5M pool50 bps (0.5%)
$1M - $5M pool100 bps (1%)
$100K - $1M pool150-200 bps
< $100K pool200-500 bps (high risk)

Trade-off: Too-tight slippage causes failed transactions, costing you fees with no execution.

Show full SKILL.md (347 more words)Show less
Strategy 2: Jito Bundles

Submit your swap as a Jito bundle with a priority tip:

python
import httpx

JITO_BLOCK_ENGINE = "https://mainnet.block-engine.jito.wtf"

async def submit_jito_bundle(
    signed_transactions: list[str],
    tip_lamports: int = 1_000_000,  # 0.001 SOL
) -> str:
    """Submit a transaction bundle to Jito block engine.

    Args:
        signed_transactions: Base64-encoded signed transactions.
        tip_lamports: Tip amount in lamports (1 SOL = 1e9 lamports).

    Returns:
        Bundle ID for tracking.
    """
    async with httpx.AsyncClient() as client:
        resp = await client.post(
            f"{JITO_BLOCK_ENGINE}/api/v1/bundles",
            json={
                "jsonrpc": "2.0",
                "id": 1,
                "method": "sendBundle",
                "params": [signed_transactions],
            },
            timeout=10.0,
        )
        resp.raise_for_status()
        result = resp.json()
        return result.get("result", "")

Tip guidelines:

  • Normal priority: 0.0001 - 0.001 SOL
  • High priority: 0.001 - 0.01 SOL
  • Urgent (volatile market): 0.01 - 0.05 SOL
Strategy 3: Private/Protected RPCs

Send transactions through endpoints that do not expose them to searchers:

  • Jito bundles (described above)
  • Helius priority fee API with staked connections
  • QuickNode private transaction submission
  • Direct TPU forwarding (requires infrastructure)
Strategy 4: Trade Splitting

For large trades (> 1% of pool liquidity), split execution:

python
def compute_split_plan(
    total_sol: float,
    pool_liquidity_usd: float,
    sol_price: float = 150.0,
    max_pct_per_trade: float = 0.5,
) -> list[dict]:
    """Compute a trade splitting plan to minimize MEV exposure."""
    total_usd = total_sol * sol_price
    trade_pct = (total_usd / pool_liquidity_usd) * 100

    if trade_pct <= max_pct_per_trade:
        return [{"sol_amount": total_sol, "delay_seconds": 0}]

    n_splits = max(2, int(trade_pct / max_pct_per_trade) + 1)
    per_trade = total_sol / n_splits
    delay = 30  # seconds between trades

    return [
        {"sol_amount": round(per_trade, 4), "delay_seconds": i * delay}
        for i in range(n_splits)
    ]
Strategy 5: Jupiter MEV Protection

Jupiter v6 includes built-in MEV protection features:

  • Dynamic slippage: Automatically adjusts slippage to minimize sandwich window
  • Priority fee estimation: Sets appropriate compute unit price
  • Transaction landing optimization: Retry logic with increasing priority

Enable via Jupiter API:

python
params = {
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": token_mint,
    "amount": str(amount_lamports),
    "slippageBps": "50",
    "dynamicSlippage": "true",        # Auto-adjust slippage
    "prioritizationFeeLamports": "auto",  # Auto priority fee
}

Detecting Sandwich Attacks

After a trade, check whether you were sandwiched:

  1. Fetch your transaction and identify the slot
  2. Fetch all transactions in that slot involving the same token
  3. Look for the pattern:
    • Transaction A: Buy TOKEN_X (before your tx in slot ordering)
    • Your transaction: Buy TOKEN_X (worse price than expected)
    • Transaction B: Sell TOKEN_X (after your tx, same signer as A)
  4. Verify: Signer of A and B is the same wallet (the attacker)
  5. Estimate cost: Difference between your expected and actual execution price

See scripts/sandwich_detector.py for a working implementation.

Known MEV indicators:

  • Transaction signer has thousands of transactions per day
  • Same-slot buy-then-sell of the same token around your swap
  • Signer interacts with Jito tip program frequently
  • Wallet has no token holdings (just in-and-out)

Integration with Other Skills

  • slippage-modeling: Use slippage estimates to set protective limits
  • liquidity-analysis: Pool liquidity determines MEV vulnerability
  • jupiter-api: Jupiter's MEV protection features and swap execution
  • solana-onchain: On-chain transaction analysis for sandwich detection
  • helius-api: Transaction parsing and historical analysis

Files

References
  • references/solana_mev_mechanics.md — Solana block production, Jito block engine, MEV supply chain, and transaction flow paths
  • references/protection_strategies.md — Detailed protection strategies with implementation guidance, cost-benefit analysis, and decision matrix
Scripts
  • scripts/sandwich_detector.py — Detects sandwich attacks around a given transaction signature using on-chain data
  • scripts/mev_risk_estimator.py — Estimates MEV exposure for a planned trade based on token liquidity, trade size, and slippage settings

© agiprolabs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/mev-analysis of agiprolabs/claude-trading-skills.

  • SKILL.md
  • references/protection_strategies.md
  • references/solana_mev_mechanics.md
  • scripts/mev_risk_estimator.py
  • scripts/sandwich_detector.py

Open the folder on GitHubat commit 981e1d7

Compare with similar skills

Mev Analysis next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mev Analysis compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mev Analysis this skillagiprolabs/claude-trading-skills410—~3.1kAutomated safety check: PassMIT
Prismirfndi/prism-liquidity-agent123—~1.5kAutomated safety check: PassMIT
Solana Sniper Botnpc-live/clawfirm156—~913Automated safety check: NotesNone
Solana Payments Wallets Tradingnpc-live/clawfirm1561 repos~4.7kAutomated safety check: PassMIT
Gmgn PortfolioGMGNAI/gmgn-skills607—~5.8kAutomated safety check: NotesMIT
Trading Signalbinance/binance-skills-hub1.1k—~682Automated safety check: PassNone

Similar skills

  • Prism

    irfndi/prism-liquidity-agent

    Operate Prism, an autonomous Solana DLMM liquidity agent for Meteora pools.

    123 GitHub stars~1.5k tokensUpdated 11 days ago
    Business, Finance & HRAuto-check passed
  • Solana Sniper Bot

    npc-live/clawfirm

    Autonomous Solana token sniper and trading bot. An agent skill from npc-live/clawfirm.

    156 GitHub stars~913 tokensUpdated 3 mo ago
    Business, Finance & HRAuto-check: notes
  • Pay people in SOL or USDC, buy and sell tokens, check prices, discover trending and new tokens, create and manage Solana wallets, stake SOL, earn yield through lending and managed vaults, borrow…

    156 GitHub starsUsed in 1 repo~4.7k tokens
    Business, Finance & HRAuto-check passed
  • Gmgn Portfolio

    GMGNAI/gmgn-skills

    Analyze one or many crypto wallets by address — holdings, batch realized/unrealized P&L, win rate, trading history, performance stats, specific token balance, and tokens created by a developer…

    607 GitHub stars~5.8k tokensUpdated 10 days ago
    Business, Finance & HRAuto-check: notes
  • Trading Signal

    binance/binance-skills-hub

    Per-trade smart-money signals — each result is a discrete buy or sell event from a tracked smart-money wallet, with trigger price, current price, max gain since trigger, and exit rate.

    1.1k GitHub stars~682 tokensUpdated 28 days ago
    Business, Finance & HRAuto-check passed
  • Bags

    alsk1992/CloddsBot

    Bags.fm - Complete Solana token launchpad with creator monetization

    2.9k GitHub stars~864 tokensUpdated 6 days ago
    Business, Finance & HRAuto-check passed

More from agiprolabs/claude-trading-skills

All 68 skills in this repo
  • Backtrader

    agiprolabs/claude-trading-skills

    Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Birdeye API

    agiprolabs/claude-trading-skills

    Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity

    410 GitHub stars~1.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Coingecko API

    agiprolabs/claude-trading-skills

    Broad crypto market data from CoinGecko covering 13,000+ tokens.

    410 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Cointegration Analysis

    agiprolabs/claude-trading-skills

    Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis

    410 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Copy Trading

    agiprolabs/claude-trading-skills

    Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Correlation Analysis

    agiprolabs/claude-trading-skills

    Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation

    410 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Mev Analysis

What does Mev Analysis do?

MEV exposure assessment, sandwich attack detection, and protection strategies for Solana DEX trading. Mev Analysis is an agent skill from agiprolabs/claude-trading-skills.

When should I use Mev Analysis?

Mev Analysis fits situations like: tasks that involve Trading and backtesting.

How do I install Mev Analysis in Claude Code?

Run `npx skills add agiprolabs/claude-trading-skills --skill mev-analysis -a claude-code`. Or copy the skill folder (skills/mev-analysis in agiprolabs/claude-trading-skills) into .claude/skills/mev-analysis in your project. Claude Code loads it when a task matches its description.

How do I install Mev Analysis in Codex?

Run `npx skills add agiprolabs/claude-trading-skills --skill mev-analysis -a codex`. Or copy the skill folder (skills/mev-analysis in agiprolabs/claude-trading-skills) into .agents/skills/mev-analysis in your project. Codex loads it when a task matches its description.

Can I use Mev Analysis in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add agiprolabs/claude-trading-skills --skill mev-analysis -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mev-analysis, .gemini/skills/mev-analysis, .github/skills/mev-analysis and .opencode/skills/mev-analysis in your project.

What does Mev Analysis need to run?

Going by SKILL.md and its folder, Mev Analysis needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Mev Analysis access the network?

SKILL.md names 1 domain. In commands or code: mainnet.block-engine.jito.wtf; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Mev Analysis safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Mev Analysis use?

Mev Analysis is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mev Analysis use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.1k tokens, read only when the agent opens those files.

What are the alternatives to Mev Analysis?

Skills that share tags, products or a category with Mev Analysis: Prism (irfndi/prism-liquidity-agent, 123 stars), Solana Sniper Bot (npc-live/clawfirm, 156 stars), Solana Payments Wallets Trading (npc-live/clawfirm, 156 stars) and Gmgn Portfolio (GMGNAI/gmgn-skills, 607 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mev Analysis?

agiprolabs (a GitHub user) maintains it in agiprolabs/claude-trading-skills, which has 410 GitHub stars. The repository holds 68 skills in this directory. The repository was last updated on September 3, 2026.

Source: agiprolabs/claude-trading-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.