$npx -y skills add agiprolabs/claude-trading-skills --skill token-holder-analysisToken holder distribution, concentration metrics, insider detection, and supply analysis for Solana tokens
| 1 | # Token Holder Analysis — Concentration, Distribution & Risk |
| 2 | |
| 3 | Analyze who holds a token, how concentrated ownership is, and whether insider patterns suggest risk. This is a critical pre-trade safety check — high concentration means a few wallets can crash the price. |
| 4 | |
| 5 | ## Quick Start |
| 6 | |
| 7 | ```python |
| 8 | import httpx |
| 9 | import math |
| 10 | |
| 11 | # Using Helius DAS API for holder data |
| 12 | HELIUS_KEY = os.getenv("HELIUS_API_KEY", "") |
| 13 | HELIUS = f"https://mainnet.helius-rpc.com/?api-key={HELIUS_KEY}" |
| 14 | |
| 15 | # Or using SolanaTracker for holder + risk data |
| 16 | ST_KEY = os.getenv("SOLANATRACKER_API_KEY", "") |
| 17 | ST = "https://data.solanatracker.io" |
| 18 | |
| 19 | # Get top holders via RPC |
| 20 | def get_top_holders(mint: str) -> list[dict]: |
| 21 | resp = httpx.post(HELIUS, json={ |
| 22 | "jsonrpc": "2.0", "id": 1, |
| 23 | "method": "getTokenLargestAccounts", |
| 24 | "params": [mint], |
| 25 | }) |
| 26 | return resp.json()["result"]["value"] |
| 27 | |
| 28 | holders = get_top_holders("TOKEN_MINT") |
| 29 | ``` |
| 30 | |
| 31 | ## Data Sources |
| 32 | |
| 33 | | Source | What It Provides | Auth | |
| 34 | |--------|-----------------|------| |
| 35 | | **Solana RPC** (`getTokenLargestAccounts`) | Top 20 holders, supply | RPC key | |
| 36 | | **Helius DAS** (`getAsset`, token accounts) | Parsed holder data, metadata | API key | |
| 37 | | **SolanaTracker** (`/tokens/{t}/holders/top`) | Top 100 holders, bundler detection | API key | |
| 38 | | **Birdeye** (`/defi/token_security`) | Top 10 %, creator balance, freeze/mint auth | API key | |
| 39 | |
| 40 | ## Concentration Metrics |
| 41 | |
| 42 | ### Top-N Holder Percentage |
| 43 | |
| 44 | The simplest measure — what % of supply do the top N holders control? |
| 45 | |
| 46 | ```python |
| 47 | def top_n_percentage(holders: list[dict], supply: int, n: int = 10) -> float: |
| 48 | """Calculate percentage held by top N holders. |
| 49 | |
| 50 | Args: |
| 51 | holders: Sorted list of holders (largest first). |
| 52 | supply: Total token supply. |
| 53 | n: Number of top holders. |
| 54 | |
| 55 | Returns: |
| 56 | Percentage (0-100) held by top N. |
| 57 | """ |
| 58 | top_n_amount = sum(int(h.get("amount", 0)) for h in holders[:n]) |
| 59 | return top_n_amount / supply * 100 if supply > 0 else 0 |
| 60 | ``` |
| 61 | |
| 62 | **Risk thresholds**: |
| 63 | - Top 10 < 30%: Well distributed |
| 64 | - Top 10 30-50%: Moderate concentration |
| 65 | - Top 10 50-80%: High concentration — significant dump risk |
| 66 | - Top 10 > 80%: Extreme — likely controlled by a few wallets |
| 67 | |
| 68 | ### Gini Coefficient |
| 69 | |
| 70 | Measures inequality of token distribution (0 = perfectly equal, 1 = one holder owns everything). |
| 71 | |
| 72 | ```python |
| 73 | def gini_coefficient(amounts: list[float]) -> float: |
| 74 | """Calculate Gini coefficient for holder distribution. |
| 75 | |
| 76 | Args: |
| 77 | amounts: List of holder amounts (any order). |
| 78 | |
| 79 | Returns: |
| 80 | Gini coefficient between 0 and 1. |
| 81 | """ |
| 82 | if not amounts or all(a == 0 for a in amounts): |
| 83 | return 0.0 |
| 84 | sorted_amounts = sorted(amounts) |
| 85 | n = len(sorted_amounts) |
| 86 | cumsum = sum((i + 1) * a for i, a in enumerate(sorted_amounts)) |
| 87 | total = sum(sorted_amounts) |
| 88 | return (2 * cumsum) / (n * total) - (n + 1) / n |
| 89 | ``` |
| 90 | |
| 91 | **Interpretation for crypto tokens**: |
| 92 | - Gini < 0.6: Unusual, very well distributed |
| 93 | - Gini 0.6-0.8: Typical for established tokens |
| 94 | - Gini 0.8-0.95: Common for newer tokens |
| 95 | - Gini > 0.95: Extreme concentration, high risk |
| 96 | |
| 97 | ### Herfindahl-Hirschman Index (HHI) |
| 98 | |
| 99 | Measures market concentration — sum of squared market shares. |
| 100 | |
| 101 | ```python |
| 102 | def hhi(amounts: list[float]) -> float: |
| 103 | """Calculate HHI for holder concentration. |
| 104 | |
| 105 | Args: |
| 106 | amounts: List of holder amounts. |
| 107 | |
| 108 | Returns: |
| 109 | HHI value (0-10000). Higher = more concentrated. |
| 110 | """ |
| 111 | total = sum(amounts) |
| 112 | if total == 0: |
| 113 | return 0.0 |
| 114 | shares = [a / total * 100 for a in amounts] |
| 115 | return sum(s ** 2 for s in shares) |
| 116 | ``` |
| 117 | |
| 118 | **Interpretation**: |
| 119 | - HHI < 1500: Competitive (unconcentrated) |
| 120 | - HHI 1500-2500: Moderately concentrated |
| 121 | - HHI > 2500: Highly concentrated |
| 122 | |
| 123 | ### Nakamoto Coefficient |
| 124 | |
| 125 | Minimum number of holders needed to control >50% of supply. |
| 126 | |
| 127 | ```python |
| 128 | def nakamoto_coefficient(amounts: list[float]) -> int: |
| 129 | """Calculate Nakamoto coefficient (holders needed for 51%). |
| 130 | |
| 131 | Args: |
| 132 | amounts: Sorted list of holder amounts (largest first). |
| 133 | |
| 134 | Returns: |
| 135 | Number of holders needed for majority control. |
| 136 | """ |
| 137 | total = sum(amounts) |
| 138 | if total == 0: |
| 139 | return 0 |
| 140 | threshold = total * 0.51 |
| 141 | cumulative = 0 |
| 142 | for i, amount in enumerate(sorted(amounts, reverse=True)): |
| 143 | cumulative += amount |
| 144 | if cumulative >= threshold: |
| 145 | return i + 1 |
| 146 | return len(amounts) |
| 147 | ``` |
| 148 | |
| 149 | ## Insider Detection Patterns |
| 150 | |
| 151 | ### Bundler Detection |
| 152 | |
| 153 | Bundlers use atomic transaction bundles (via Jito) to execute coordinated buys at token launch. Detection signals: |
| 154 | |
| 155 | ```python |
| 156 | def detect_bundler_patterns(holders: list[dict], first_buyers: list[dict]) -> dict: |
| 157 | """Identify potential bundler activity. |
| 158 | |
| 159 | Args: |
| 160 | holders: Current top holders. |
| 161 | first_buyers: Early buyers from SolanaTracker /first-buyers endpoint. |
| 162 | |
| 163 | Returns: |
| 164 | Bundler risk analysis. |
| 165 | """ |