Agent skill

Impermanent Loss

by agiprolabs in agiprolabs/claude-trading-skills

Impermanent loss calculation, modeling, and breakeven analysis for AMM liquidity provision across pool types

MITAuto-check passed

Install Impermanent Loss

skills CLI
$ npx skills add agiprolabs/claude-trading-skills --skill impermanent-loss -a claude-code

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

GitHub CLI
$ gh skill install agiprolabs/claude-trading-skills impermanent-loss --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/impermanent-loss .claude/skills/impermanent-loss && 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
impermanent-loss
GitHub stars
410
Token cost
~1.9k tokens
SKILL.md length
852 words
Files
5 (incl. scripts, references)
Skills in repo
68
Repo updated
First seen
Licence
MIT

At a glance

Impermanent loss calculation, modeling, and breakeven analysis for AMM liquidity provision across pool types

  • Works in 5 steps: Stablecoin Pairs → Correlated Pairs → Wider CLMM Ranges → …
  • SKILL.md covers Why "Impermanent"?, Key Insight, Constant-Product IL Formula and Concentrated Liquidity (CLMM)…, plus 7 more sections
  • Runs Python scripts from its folder

What it does

Impermanent Loss is an agent skill from agiprolabs/claude-trading-skills. Impermanent loss calculation, modeling, and breakeven analysis for AMM liquidity provision across pool types

Its SKILL.md is about 1.9k 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/breakeven_analysis.md`, `references/il_formulas.md` and `scripts/il_calculator.py`).

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.

Example prompts

  • “/impermanent-loss”

Requirements

  • Python 3

Workflow steps

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

  1. Stablecoin Pairs
  2. Correlated Pairs
  3. Wider CLMM Ranges
  4. Active Range Management
  5. Fee Tier Selection

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

    No URLs in SKILL.md.

    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

Impermanent Loss loads about 1.9k tokens when it runs, and up to ~5.4k if it reads all its reference files. Until then it costs about 31 tokens; SKILL.md has 852 words of instructions outside code blocks.

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

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). 852 words, ~1,914 tokens.

Download SKILL.mdSave it as .claude/skills/impermanent-loss/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
impermanent-loss
description
Impermanent loss calculation, modeling, and breakeven analysis for AMM liquidity provision across pool types

Impermanent Loss — Calculation, Modeling & Breakeven Analysis

Impermanent loss (IL) is the cost of providing liquidity to an automated market maker (AMM) relative to simply holding the tokens. When you deposit tokens into a liquidity pool, the AMM continuously rebalances your position as prices move. This rebalancing always works against you — selling winners and buying losers — resulting in less value than if you had just held the original tokens.

Why "Impermanent"?

IL is called "impermanent" because it only crystallizes when you withdraw. If prices return to their original ratio, IL reverts to zero. However, in practice, prices rarely return exactly, so IL is usually quite real.

Key Insight

IL is a function of the price ratio change, not the absolute price. A token moving from $1 to $2 produces the same IL as a token moving from $100 to $200 — both are a 2x ratio change. Direction does not matter either: a 2x increase and a 0.5x decrease produce the same IL magnitude.

Constant-Product IL Formula

For a standard x * y = k AMM (Raydium standard, Orca legacy):

IL = 2 * sqrt(r) / (1 + r) - 1

Where r = P_new / P_initial (the price ratio).

IL at Key Price Ratios
Price ChangeRatio (r)IL
-75%0.25-5.72%
-50%0.50-5.72%
-25%0.75-0.60%
0%1.000.00%
+25%1.25-0.60%
+50%1.50-2.02%
+100% (2x)2.00-5.72%
+200% (3x)3.00-13.40%
+400% (5x)5.00-25.46%
+900% (10x)10.00-42.54%

Note the symmetry: a 2x increase (r=2.0) and a 2x decrease (r=0.5) both produce -5.72% IL.

Concentrated Liquidity (CLMM) Amplified IL

Concentrated liquidity market makers (Orca Whirlpools, Raydium CLMM, Meteora DLMM) allow LPs to concentrate liquidity within a price range [P_lower, P_upper]. This amplifies both fee income and IL.

Concentration Factor
concentration_factor = 1 / (1 - sqrt(P_lower / P_upper))

For a ±10% range around current price: concentration_factor ≈ 10x.

CLMM IL Behavior
  • Price within range: IL is amplified by the concentration factor relative to constant-product IL.
  • Price exits range: The position becomes 100% of the losing asset. This is the maximum possible IL for that direction — you hold only the depreciating token.
IL_clmm ≈ IL_constant_product * concentration_factor

This approximation holds for small moves. For large moves or prices near range boundaries, use the full CLMM formula (see references/il_formulas.md).

Example: CLMM vs Constant-Product

SOL at $150, LP with ±20% range ($120–$180):

ScenarioConstant-Product ILCLMM IL (±20%)
SOL → $180-0.62%~-3.1%
SOL → $200-1.03%100% SOL (exit)
SOL → $120-1.80%~-9.0%
SOL → $100-3.42%100% USDC (exit)

IL vs Fees: Breakeven Analysis

The core question for any LP is: Do fees earned exceed IL incurred?

Net Position = LP_value + accrued_fees - hold_value

Profitable when accrued_fees > IL.

Breakeven Fee Rate

For constant-product pools, the expected IL per period is approximately:

expected_IL ≈ σ² / 8

Where σ is the standard deviation of log returns for that period. This means:

Daily Volatility (σ)Expected Daily ILMin Daily Fee Rate to Break Even
1%0.001%0.001%
3%0.011%0.011%
5%0.031%0.031%
10%0.125%0.125%
20%0.500%0.500%

Daily fee income for an LP:

daily_fee_income = (deposit / TVL) * daily_volume * fee_rate

For a full breakeven framework, see references/breakeven_analysis.md.

Modeling IL Over Time

Monte Carlo Simulation

Simulate many random price paths using geometric Brownian motion (GBM):

python
import numpy as np

def simulate_price_path(
    initial_price: float,
    daily_vol: float,
    days: int,
    drift: float = 0.0,
) -> np.ndarray:
    """Simulate a price path using geometric Brownian motion."""
    dt = 1.0  # daily steps
    log_returns = np.random.normal(
        (drift - 0.5 * daily_vol**2) * dt,
        daily_vol * np.sqrt(dt),
        days,
    )
    prices = initial_price * np.exp(np.cumsum(log_returns))
    return np.insert(prices, 0, initial_price)

For each path, compute the IL at each timestep and the cumulative fees earned. After N simulations, analyze the distribution of outcomes.

See scripts/il_scenario_modeler.py for a complete Monte Carlo simulation.

Show full SKILL.md (326 more words)Show less
Historical Analysis

Use actual OHLCV price data to compute what IL would have been for a historical period. This gives a more realistic (but backward-looking) estimate.

IL Mitigation Strategies

1. Stablecoin Pairs

Pairs like USDC/USDT have near-zero IL because the price ratio barely moves. Fee income is almost pure profit.

2. Correlated Pairs

Pairs like SOL/mSOL or ETH/stETH move together, so the price ratio stays close to 1.0. IL is minimal.

3. Wider CLMM Ranges

A wider range reduces concentration factor, reducing IL at the cost of less fee income per unit of capital.

4. Active Range Management

Monitor price and rebalance your CLMM range when price approaches boundaries. This reduces the risk of price exiting your range entirely.

5. Fee Tier Selection

Higher fee tiers (e.g., 1% vs 0.3%) compensate for higher IL in volatile pairs. Match fee tier to expected volatility.

When IL Is Acceptable

  • High volume pools: Fee income significantly exceeds expected IL.
  • Stable or correlated pairs: IL is structurally minimal.
  • Token accumulation strategy: You want to accumulate the cheaper token anyway.
  • Short time horizons with active management: Fees compound, and you rebalance before large moves.

When to Avoid LPing

  • Low volume, high volatility: IL dominates, fees are insufficient.
  • Trending markets: Strong directional moves create large, sustained IL.
  • Illiquid new tokens: Price can move 10x+ in hours, causing catastrophic IL.
  • Wide-spread pools: Low volume means fees don't compensate for any IL at all.
  • lp-math: AMM mechanics and reserve calculations that underpin IL formulas.
  • yield-analysis: Compare LP yields net of IL against other DeFi opportunities.
  • liquidity-analysis: Assess pool depth and volume to estimate fee income.
  • volatility-modeling: Forecast volatility inputs for IL modeling.

Files

References
  • references/il_formulas.md — Full IL derivations for constant-product, CLMM, and multi-asset pools
  • references/breakeven_analysis.md — Fee vs IL breakeven framework with practical tools
Scripts
  • scripts/il_calculator.py — Calculate IL for any price change across pool types, with tables and comparisons
  • scripts/il_scenario_modeler.py — Monte Carlo simulation of LP positions over time with fee and IL modeling

© 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/impermanent-loss of agiprolabs/claude-trading-skills.

  • SKILL.md
  • references/breakeven_analysis.md
  • references/il_formulas.md
  • scripts/il_calculator.py
  • scripts/il_scenario_modeler.py

Open the folder on GitHubat commit 981e1d7

Compare with similar skills

Impermanent Loss 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.

Impermanent Loss compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Impermanent Loss this skillagiprolabs/claude-trading-skills410—~1.9kAutomated safety check: PassMIT
OmniRoute Model Catalogdiegosouzapw/OmniRoute75k—~589Automated safety check: PassMIT
Model Bank Metadatalobehub/lobehub83k—~2kAutomated safety check: PassCustom licence
Harness Threat Modelruvnet/ruflo74k—~363Automated safety check: NotesMIT
OmniRoute Model Catalog CLIdiegosouzapw/OmniRoute75k—~554Automated safety check: PassMIT
Defi Amm Securityaffaan-m/ECC276k1 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • OmniRoute Model Catalog

    diegosouzapw/OmniRoute

    Looks up which AI models an OmniRoute gateway can reach, creates or updates model aliases and tests whether individual models respond.

    75k GitHub stars~589 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Model Bank Metadata

    lobehub/lobehub

    Fills and maintains the knowledgeCutoff, family and generation fields on model cards in LobeHub's model bank, from a single new model up to repo-wide backfills.

    83k GitHub stars~2k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Enterprise-review-grade threat model from harness threat-model {path}.

    74k GitHub stars~363 tokensUpdated today
    SecurityAuto-check: notes
  • OmniRoute Model Catalog CLI

    diegosouzapw/OmniRoute

    Lists and manages AI models from the OmniRoute command line: browse a provider's catalog, search it, and add, edit, remove or test-add models.

    75k GitHub stars~554 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Defi Amm Security

    affaan-m/ECC

    Security checklist for Solidity AMM contracts, liquidity pools, and swap flows.

    276k GitHub starsUsed in 1 repo~1.3k tokens
    Business, Finance & HRAuto-check passed
  • Model Usage

    openclaw/openclaw

    Summarize CodexBar local cost logs by model for Codex or Claude, including current or full breakdowns.

    392k GitHub starsUsed in 1 repo~637 tokens
    Auto-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

Questions about Impermanent Loss

What does Impermanent Loss do?

Impermanent loss calculation, modeling, and breakeven analysis for AMM liquidity provision across pool types. Impermanent Loss is an agent skill from agiprolabs/claude-trading-skills.

How do I install Impermanent Loss in Claude Code?

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

How do I install Impermanent Loss in Codex?

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

Can I use Impermanent Loss 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 impermanent-loss -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/impermanent-loss, .gemini/skills/impermanent-loss, .github/skills/impermanent-loss and .opencode/skills/impermanent-loss in your project.

What does Impermanent Loss need to run?

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

Does Impermanent Loss access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Impermanent Loss 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 Impermanent Loss use?

Impermanent Loss 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 Impermanent Loss use?

About 1.9k tokens (SKILL.md is roughly 7.7k 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 3.4k tokens, read only when the agent opens those files.

What are the alternatives to Impermanent Loss?

Skills that share tags, products or a category with Impermanent Loss: OmniRoute Model Catalog (diegosouzapw/OmniRoute, 75k stars), Model Bank Metadata (lobehub/lobehub, 83k stars), Harness Threat Model (ruvnet/ruflo, 74k stars) and OmniRoute Model Catalog CLI (diegosouzapw/OmniRoute, 75k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Impermanent Loss?

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.