$npx -y skills add agiprolabs/claude-trading-skills --skill liquidity-analysisDEX liquidity depth assessment, slippage estimation, and pool composition analysis for Solana tokens
| 1 | # Liquidity Analysis — DEX Depth Assessment for Solana Tokens |
| 2 | |
| 3 | Liquidity analysis answers three critical questions before every trade: **Can I get in at a reasonable price?** **Can I get out when I need to?** and **Is this pool safe?** Without it, you risk excessive slippage, failed exits, and rug pulls. |
| 4 | |
| 5 | ## Why Liquidity Analysis Matters |
| 6 | |
| 7 | **Position sizing**: Maximum position size is bounded by available liquidity. A $10K position in a pool with $20K TVL will move the price significantly. Rule of thumb: keep trade size under 2% of pool depth to limit slippage below 1%. |
| 8 | |
| 9 | **Execution cost**: Slippage is a direct cost. On a 5 SOL buy, the difference between 0.3% and 3% slippage is real money lost on every entry and exit. |
| 10 | |
| 11 | **Rug risk detection**: Thin liquidity, single pools, unlocked LP tokens, and newly created pools are warning signs. Liquidity analysis catches these before you enter. |
| 12 | |
| 13 | **Exit planning**: Entry liquidity may differ from exit liquidity. If LP is unlocked and owned by one wallet, it can be pulled at any time. |
| 14 | |
| 15 | ## Key Concepts |
| 16 | |
| 17 | ### Total Value Locked (TVL) |
| 18 | |
| 19 | Total value of assets deposited in a pool. For a SOL/TOKEN pool with 100 SOL and 1M TOKEN at $0.01 each, TVL = 100 * SOL_price + 1M * $0.01. TVL alone is insufficient — you need depth at the current price range. |
| 20 | |
| 21 | ### Liquidity Depth |
| 22 | |
| 23 | How much can be traded before moving the price X%. In constant-product AMMs, depth is uniform. In concentrated liquidity (CLMM), depth varies by price range — thick near the current price, thin or zero outside active ranges. |
| 24 | |
| 25 | ### Concentration Factor (CLMM) |
| 26 | |
| 27 | Concentrated liquidity pools focus capital in a narrow price range, providing deeper liquidity within that range but nothing outside it. A pool with $50K TVL concentrated in a +/-5% range provides the same depth as a $500K constant-product pool within that range, but zero depth beyond it. |
| 28 | |
| 29 | ### Slippage Curve |
| 30 | |
| 31 | Slippage is not linear. Plotting slippage against trade size produces a curve that's gentle for small trades and steep for large ones. The shape depends on pool type, TVL, and concentration. |
| 32 | |
| 33 | ### Pool Composition |
| 34 | |
| 35 | Who provides liquidity matters. Locked LP tokens cannot be withdrawn (safer). Single-sided liquidity means the pool is imbalanced. Pool age indicates stability — pools older than 7 days with consistent TVL are more reliable. |
| 36 | |
| 37 | ## Data Sources |
| 38 | |
| 39 | Four complementary data sources, from free to comprehensive: |
| 40 | |
| 41 | | Source | Auth Required | Best For | Limitations | |
| 42 | |--------|--------------|----------|-------------| |
| 43 | | DexScreener | None | Quick pool lookup, liquidity.usd | No on-chain pool details | |
| 44 | | Jupiter Quote API | None | Empirical slippage at any size | Aggregate across pools | |
| 45 | | Birdeye | API key | Detailed pool data, trade history | Rate limited on free tier | |
| 46 | | On-chain | RPC only | LP lock status, exact reserves | Requires program knowledge | |
| 47 | |
| 48 | See `references/data_sources.md` for complete endpoint documentation and usage examples. |
| 49 | |
| 50 | ## Core Analysis Pipeline |
| 51 | |
| 52 | ### Step 1: Identify Pools |
| 53 | |
| 54 | Fetch all pools for a token. Most Solana tokens have multiple pools across Raydium, Orca, and Meteora. |
| 55 | |
| 56 | ```python |
| 57 | import httpx |
| 58 | |
| 59 | def get_pools(mint: str) -> list[dict]: |
| 60 | """Fetch all DEX pools for a token from DexScreener.""" |
| 61 | resp = httpx.get(f"https://api.dexscreener.com/tokens/v1/solana/{mint}") |
| 62 | resp.raise_for_status() |
| 63 | pairs = resp.json() |
| 64 | return [p for p in pairs if p.get("liquidity", {}).get("usd", 0) > 0] |
| 65 | ``` |
| 66 | |
| 67 | ### Step 2: Measure Depth |
| 68 | |
| 69 | For each pool, extract liquidity metrics: |
| 70 | |
| 71 | ```python |
| 72 | def extract_depth(pool: dict) -> dict: |
| 73 | """Extract liquidity metrics from a DexScreener pool.""" |
| 74 | return { |
| 75 | "dex": pool.get("dexId", "unknown"), |
| 76 | "liquidity_usd": pool.get("liquidity", {}).get("usd", 0), |
| 77 | "volume_24h": pool.get("volume", {}).get("h24", 0), |
| 78 | "pool_age_hours": _pool_age_hours(pool.get("pairCreatedAt", 0)), |
| 79 | "pair_address": pool.get("pairAddress", ""), |
| 80 | } |
| 81 | ``` |
| 82 | |
| 83 | ### Step 3: Estimate Slippage |
| 84 | |
| 85 | Use Jupiter quotes at multiple sizes to build an empirical slippage curve. This captures real routing across all pools: |
| 86 | |
| 87 | ```python |
| 88 | import httpx |
| 89 | |
| 90 | SOL_MINT = "So11111111111111111111111111111111111111112" |
| 91 | LAMPORTS = 1_000_000_000 |
| 92 | |
| 93 | async def estimate_slippage(token_mint: str, sol_amounts: list[float]) -> list[dict]: |
| 94 | """Query Jupiter for slippage at multiple trade sizes. |
| 95 | |
| 96 | Args: |
| 97 | token_mint: Token mint address to buy. |
| 98 | sol_amounts: List of SOL amounts to test (e.g., [0.1, 0.5, 1, 5, 10]). |
| 99 | |
| 100 | Returns: |
| 101 | List of dicts with sol_amount, output_tokens, price_per_token, slippage_bps. |
| 102 | """ |
| 103 | results = [] |
| 104 | base_price = None |
| 105 | async with httpx.AsyncClient() as client: |
| 106 | for sol in sol_amounts: |
| 107 | lamports = int(sol * LAMPORTS) |
| 108 | resp = await client.get( |
| 109 | "https://api.jup.ag/quote/v1", |
| 110 | para |