@0xprotovox/deficlaw 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +115 -41
  2. package/dist/analysis/formatOutput.d.ts +113 -2
  3. package/dist/analysis/formatOutput.js +135 -100
  4. package/dist/analysis/formatOutput.js.map +1 -1
  5. package/dist/analysis/riskScorer.d.ts +24 -2
  6. package/dist/analysis/riskScorer.js +146 -48
  7. package/dist/analysis/riskScorer.js.map +1 -1
  8. package/dist/analysis/summaryGenerator.d.ts +3 -2
  9. package/dist/analysis/summaryGenerator.js +204 -42
  10. package/dist/analysis/summaryGenerator.js.map +1 -1
  11. package/dist/cache/memoryCache.d.ts +12 -3
  12. package/dist/cache/memoryCache.js +43 -2
  13. package/dist/cache/memoryCache.js.map +1 -1
  14. package/dist/server.d.ts +3 -2
  15. package/dist/server.js +66 -16
  16. package/dist/server.js.map +1 -1
  17. package/dist/sources/dexscreener.d.ts +8 -17
  18. package/dist/sources/dexscreener.js +123 -29
  19. package/dist/sources/dexscreener.js.map +1 -1
  20. package/dist/sources/gmgn.d.ts +11 -4
  21. package/dist/sources/gmgn.js +207 -115
  22. package/dist/sources/gmgn.js.map +1 -1
  23. package/dist/sources/solanaRpc.d.ts +4 -4
  24. package/dist/sources/solanaRpc.js +60 -29
  25. package/dist/sources/solanaRpc.js.map +1 -1
  26. package/dist/tools/analyzeToken.d.ts +1 -2
  27. package/dist/tools/analyzeToken.js +114 -100
  28. package/dist/tools/analyzeToken.js.map +1 -1
  29. package/dist/tools/getNewLaunches.d.ts +30 -0
  30. package/dist/tools/getNewLaunches.js +63 -0
  31. package/dist/tools/getNewLaunches.js.map +1 -0
  32. package/dist/tools/getPrice.d.ts +2 -12
  33. package/dist/tools/getPrice.js +23 -4
  34. package/dist/tools/getPrice.js.map +1 -1
  35. package/dist/tools/getTopTraders.d.ts +30 -24
  36. package/dist/tools/getTopTraders.js +36 -21
  37. package/dist/tools/getTopTraders.js.map +1 -1
  38. package/dist/tools/getTrending.d.ts +8 -1
  39. package/dist/tools/getTrending.js +12 -2
  40. package/dist/tools/getTrending.js.map +1 -1
  41. package/dist/tools/searchToken.d.ts +24 -0
  42. package/dist/tools/searchToken.js +43 -0
  43. package/dist/tools/searchToken.js.map +1 -0
  44. package/dist/types/index.d.ts +34 -0
  45. package/dist/utils/debug.d.ts +7 -0
  46. package/dist/utils/debug.js +27 -0
  47. package/dist/utils/debug.js.map +1 -0
  48. package/package.json +18 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # DefiClaw
1
+ # deficlaw
2
2
 
3
3
  **The first open-source DeFi MCP server for Claude Code.**
4
4
 
@@ -7,13 +7,13 @@ Analyze any Solana token in seconds. Holder intelligence, risk scoring, smart mo
7
7
  ```
8
8
  > "analyze token 3oQwNvAfZMuPWjVPC12ukY7RPA9JiGwLod6Pr4Lkpump"
9
9
 
10
- ═══ SUMMARY ═══
10
+ === SUMMARY ===
11
11
  POKE6900 is a 9mo old PumpSwap token with $25.9K liquidity and $34.5K market cap.
12
12
  53 diamond hands (53.0%), strong holder conviction.
13
13
  Only 18.0% of holders are in profit, most are underwater with avg loss of $844 per wallet.
14
14
  Buy pressure is strong at 3.3:1 ratio (1093 buys vs 395 sells), accumulation phase.
15
15
  Contract looks safe: mint and freeze authorities revoked.
16
- 🟢 Lower risk profile based on available data.
16
+ Lower risk profile based on available data.
17
17
  ```
18
18
 
19
19
  ## Why deficlaw?
@@ -23,22 +23,31 @@ Claude Code can write code, fix bugs, deploy apps. But ask it "what's the price
23
23
  **deficlaw fixes that.** It gives Claude Code real-time access to DeFi data across Solana and 10+ chains.
24
24
 
25
25
  - **Token Analysis** with holder intelligence, risk scoring, KOL tracking
26
+ - **Token Search** by name or symbol across all chains
27
+ - **New Launches** detection with age, mcap, liquidity data
26
28
  - **Real-time Prices** from DexScreener across all major chains
27
29
  - **Trending Tokens** with volume, liquidity, and boost data
28
30
  - **Top Traders** showing who made and lost money on any token
29
31
  - **Contract Security** checking mint/freeze authority on Solana
30
- - **1.5 second** full analysis (not 11 seconds like browser-based scrapers)
32
+ - **Actionable Verdicts** (BUY/SELL/NEUTRAL/AVOID) based on combined data signals
33
+ - **~1.5 second** full analysis (not 11 seconds like browser-based scrapers)
31
34
  - **Zero config** - no API keys, no wallets, no accounts needed
32
35
 
33
- ## Quick Start
36
+ ## Install
37
+
38
+ ### Option A: npm (recommended)
39
+
40
+ ```bash
41
+ npm install -g @0xprotovox/deficlaw
42
+ claude mcp add defi -- deficlaw
43
+ ```
44
+
45
+ ### Option B: From source
34
46
 
35
47
  ```bash
36
- # Clone and build
37
48
  git clone https://github.com/0xprotovox/deficlaw.git
38
49
  cd deficlaw
39
50
  npm install && npm run build
40
-
41
- # Add to Claude Code
42
51
  claude mcp add defi -- node /path/to/deficlaw/dist/index.js
43
52
  ```
44
53
 
@@ -47,6 +56,8 @@ Then just ask Claude naturally:
47
56
  ```
48
57
  > "analyze this token: 3oQw...pump"
49
58
  > "what's the price of BONK?"
59
+ > "search for BONK token"
60
+ > "show me new launches on solana in the last 30 minutes"
50
61
  > "show me trending tokens on solana"
51
62
  > "who made money on JUP token?"
52
63
  ```
@@ -79,14 +90,51 @@ Full token analysis with holder intelligence, risk scoring, and human-readable s
79
90
  - KOL list with Twitter handles
80
91
  - Human-readable summary with actionable insights
81
92
 
93
+ ### `search_token`
94
+
95
+ Search for tokens by name or symbol. Returns top matches across all chains.
96
+
97
+ ```
98
+ > "search for BONK"
99
+
100
+ Results:
101
+ 1. Bonk (BONK) -- solana -- $0.000024 -- $1.8B mcap
102
+ 2. BonkBot (BONK) -- ethereum -- $0.00001 -- $2M mcap
103
+ ```
104
+
105
+ **Input:**
106
+ | Parameter | Type | Default | Description |
107
+ |-----------|------|---------|-------------|
108
+ | `query` | string | required | Token name or symbol |
109
+ | `chain` | string | all | Filter by chain |
110
+ | `limit` | number | `10` | Results to return (1-20) |
111
+
112
+ ### `get_new_launches`
113
+
114
+ Get recently created tokens on a blockchain, sorted by creation time.
115
+
116
+ ```
117
+ > "new launches on solana last 30 minutes"
118
+
119
+ 1. NEWTOKEN -- 12m old -- $0.001 -- $50K mcap -- $15K liq
120
+ 2. LAUNCH2 -- 25m old -- $0.0005 -- $20K mcap -- $8K liq
121
+ ```
122
+
123
+ **Input:**
124
+ | Parameter | Type | Default | Description |
125
+ |-----------|------|---------|-------------|
126
+ | `chain` | string | `"solana"` | Blockchain |
127
+ | `max_age_minutes` | number | `60` | Max token age in minutes (5-1440) |
128
+ | `limit` | number | `20` | Tokens to return (1-50) |
129
+
82
130
  ### `get_price`
83
131
 
84
- Quick price lookup. Sub-second response.
132
+ Quick price lookup. Sub-second response. Supports both token addresses and name/symbol search.
85
133
 
86
134
  ```
87
135
  > "price of So11111112222..."
88
136
 
89
- BONK $0.000024 (+5.2% 24h)
137
+ BONK -- $0.000024 (+5.2% 24h)
90
138
  Volume: $142M | Liquidity: $12M | MCap: $1.8B
91
139
  ```
92
140
 
@@ -97,9 +145,9 @@ Trending and boosted tokens on any chain.
97
145
  ```
98
146
  > "trending tokens on solana"
99
147
 
100
- 1. BONK $0.000024 (+12%) $142M volume
101
- 2. WIF $0.89 (-2.1%) $89M volume
102
- 3. JUP $0.94 (+3.5%) $45M volume
148
+ 1. BONK -- $0.000024 (+12%) -- $142M volume
149
+ 2. WIF -- $0.89 (-2.1%) -- $89M volume
150
+ 3. JUP -- $0.94 (+3.5%) -- $45M volume
103
151
  ...
104
152
  ```
105
153
 
@@ -110,13 +158,13 @@ Who made and lost money on a token. Winners, losers, PnL, tags.
110
158
  ```
111
159
  > "who profited on this token?"
112
160
 
113
- 🏆 Top Winners:
114
- 1. CR5N... +$680 (+124%) 🟢 still holding
115
- 2. EsRB... +$166 (+16%) 💎 diamond hands
161
+ Top Winners:
162
+ 1. CR5N... -- +$680 (+124%) still holding
163
+ 2. EsRB... -- +$166 (+16%) diamond hands
116
164
 
117
- 💀 Top Losers:
118
- 1. BgeeV... -$7,548 (-65%) 💎 diamond hands (!)
119
- 2. 5vqid... -$5,420 (-50%) gmgn user
165
+ Top Losers:
166
+ 1. BgeeV... -- -$7,548 (-65%) diamond hands (!)
167
+ 2. 5vqid... -- -$5,420 (-50%) gmgn user
120
168
  ```
121
169
 
122
170
  ## Data Sources
@@ -141,34 +189,36 @@ Holder analysis (GMGN) currently supports **Solana** tokens.
141
189
 
142
190
  ## Risk Scoring
143
191
 
144
- The risk scorer analyzes 6 dimensions to produce a 0-100 score:
192
+ The risk scorer analyzes 8 dimensions to produce a 0-100 score:
145
193
 
146
- | Dimension | Weight | What it checks |
147
- |-----------|--------|----------------|
148
- | Liquidity | 25% | Pool depth in USD |
149
- | Token Age | 10% | Time since creation |
150
- | Holder Concentration | 20% | Top 10 holder % |
151
- | Dev Wallet | 20% | Dev holdings and selling behavior |
152
- | Fresh Wallets | 15% | New wallet % (possible wash/bundle) |
153
- | Sniper Activity | 10% | Bot/sniper wallets in top holders |
194
+ | Dimension | Max Points | What it checks |
195
+ |-----------|-----------|----------------|
196
+ | Liquidity | 22 | Pool depth in USD |
197
+ | Token Age | 10 | Time since creation |
198
+ | Volume Anomalies | 8 | Wash trading signals, vol/mcap ratio |
199
+ | Holder Concentration | 18 | Top 10 holder % |
200
+ | Dev Wallet | 15 | Dev holdings and selling behavior |
201
+ | Fresh Wallets | 12 | New wallet % (possible wash/bundle) |
202
+ | Sniper Activity | 10 | Bot/sniper wallets in top holders |
203
+ | Contract Security | 5 | Mint/freeze authority status |
154
204
 
155
- **Levels:** 🟢 LOW (0-19) | 🟡 MEDIUM (20-44) | 🟠 HIGH (45-69) | 🔴 CRITICAL (70-100)
205
+ **Levels:** LOW (0-19) | MEDIUM (20-44) | HIGH (45-69) | CRITICAL (70-100)
156
206
 
157
207
  ## Architecture
158
208
 
159
209
  ```
160
- Claude Code ←→ MCP stdio ←→ deficlaw server
161
-
162
- ┌────────────┼────────────┐
163
-
210
+ Claude Code <-> MCP stdio <-> deficlaw server
211
+ |
212
+ +------------+------------+
213
+ | | |
164
214
  DexScreener GMGN API Solana RPC
165
215
  (prices) (holders) (security)
166
216
  ```
167
217
 
168
218
  - **MCP SDK** for Claude Code integration
169
219
  - **curl-based GMGN fetcher** bypasses Cloudflare (Playwright fallback if needed)
170
- - **In-memory TTL cache** prevents rate limiting
171
- - **Rate limiter** for DexScreener (150 req/min)
220
+ - **In-memory TTL cache** with automatic cleanup prevents rate limiting
221
+ - **Rate limiter** with retry logic for DexScreener (150 req/min)
172
222
  - **TypeScript** with full type safety
173
223
 
174
224
  ## Configuration
@@ -178,6 +228,9 @@ Claude Code ←→ MCP stdio ←→ deficlaw server
178
228
  | Variable | Default | Description |
179
229
  |----------|---------|-------------|
180
230
  | `SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Custom Solana RPC endpoint |
231
+ | `DEFICLAW_CACHE_TTL` | `120000` (2 min) | GMGN holder cache TTL in milliseconds |
232
+ | `DEFICLAW_PRICE_CACHE_TTL` | `30000` (30s) | Price cache TTL in milliseconds |
233
+ | `DEBUG` | (unset) | Set to `deficlaw` to enable debug logging to stderr |
181
234
 
182
235
  ### Claude Code Config
183
236
 
@@ -187,29 +240,50 @@ Add to your project's `.mcp.json`:
187
240
  {
188
241
  "mcpServers": {
189
242
  "defi": {
190
- "command": "node",
191
- "args": ["/path/to/deficlaw/dist/index.js"],
243
+ "command": "npx",
244
+ "args": ["-y", "@0xprotovox/deficlaw"],
192
245
  "env": {
193
- "SOLANA_RPC_URL": "https://your-rpc.com"
246
+ "SOLANA_RPC_URL": "https://your-rpc.com",
247
+ "DEFICLAW_CACHE_TTL": "120000",
248
+ "DEFICLAW_PRICE_CACHE_TTL": "30000",
249
+ "DEBUG": "deficlaw"
194
250
  }
195
251
  }
196
252
  }
197
253
  }
198
254
  ```
199
255
 
256
+ Or if installed from source:
257
+
258
+ ```json
259
+ {
260
+ "mcpServers": {
261
+ "defi": {
262
+ "command": "node",
263
+ "args": ["/path/to/deficlaw/dist/index.js"]
264
+ }
265
+ }
266
+ }
267
+ ```
268
+
200
269
  ## Roadmap
201
270
 
202
271
  - [x] Token analysis with holder intelligence
203
- - [x] Risk scoring (6 dimensions)
272
+ - [x] Risk scoring (8 dimensions)
204
273
  - [x] Contract security checks
205
274
  - [x] KOL detection with Twitter handles
206
275
  - [x] Human-readable AI summary
207
276
  - [x] Top traders (winners/losers)
208
- - [ ] Token search by name/symbol
277
+ - [x] npm package (`npm install -g @0xprotovox/deficlaw`)
278
+ - [x] Token search by name/symbol
279
+ - [x] New launches detection
280
+ - [x] Actionable verdict (BUY/SELL/NEUTRAL/AVOID)
281
+ - [x] Configurable cache TTL via env vars
282
+ - [x] Debug logging (DEBUG=deficlaw)
283
+ - [x] Non-blocking async GMGN fetches
209
284
  - [ ] Slippage estimation (Jupiter quotes)
210
285
  - [ ] Token comparison (side by side)
211
286
  - [ ] Multi-chain holder analysis
212
- - [ ] npm package (`npm install -g deficlaw`)
213
287
  - [ ] Price alerts via MCP resources
214
288
 
215
289
  ## Built With
@@ -1,4 +1,115 @@
1
1
  /**
2
- * Format analysis output clean, readable, both summary + detailed numbers
2
+ * Format analysis output as clean, readable plain text.
3
+ * Both human-readable summary and detailed numbers.
3
4
  */
4
- export declare function formatAnalysis(data: any): string;
5
+ interface AnalysisData {
6
+ summary?: string;
7
+ token: {
8
+ name: string;
9
+ symbol: string;
10
+ chain: string;
11
+ address: string;
12
+ age?: string;
13
+ createdAt?: string;
14
+ };
15
+ price: {
16
+ usd: number;
17
+ change5m?: number;
18
+ change1h: number;
19
+ change6h?: number;
20
+ change24h: number;
21
+ };
22
+ market: {
23
+ marketCap: number;
24
+ fdv: number;
25
+ liquidity: number;
26
+ volume24h: number;
27
+ volume6h?: number;
28
+ volume1h: number;
29
+ volume5m?: number;
30
+ volumeLiquidityRatio?: number;
31
+ dex: string;
32
+ pairAddress: string;
33
+ };
34
+ security?: {
35
+ mintAuthority: string;
36
+ freezeAuthority: string;
37
+ supply: number;
38
+ decimals: number;
39
+ };
40
+ risk: {
41
+ score: number;
42
+ level: string;
43
+ flags?: {
44
+ severity: string;
45
+ message: string;
46
+ }[];
47
+ };
48
+ holders?: {
49
+ total: number;
50
+ concentration: {
51
+ top5Pct: number;
52
+ top10Pct: number;
53
+ top20Pct: number;
54
+ };
55
+ categories: Record<string, number>;
56
+ sentiment: {
57
+ profitableHolders: number;
58
+ losingHolders: number;
59
+ profitRatio: number;
60
+ totalPnlUsd: number;
61
+ totalCostUsd: number;
62
+ avgPnlPerHolder: number;
63
+ };
64
+ pressure: {
65
+ totalBuyTx: number;
66
+ totalSellTx: number;
67
+ buySellRatio: number;
68
+ };
69
+ devWallet?: {
70
+ address: string;
71
+ holdingPercent: number;
72
+ pnl: number;
73
+ status: string;
74
+ } | null;
75
+ topHolders: {
76
+ address: string;
77
+ tags: string[];
78
+ supplyPercent: number;
79
+ valueUsd: number;
80
+ pnl: number;
81
+ profitMultiple?: number;
82
+ buyTx?: number;
83
+ sellTx?: number;
84
+ isDeployer?: boolean;
85
+ isFreshWallet?: boolean;
86
+ twitterHandle?: string | null;
87
+ }[];
88
+ };
89
+ lpDetection?: {
90
+ lpAddress: string;
91
+ lpPercent: number;
92
+ realTopHolder?: {
93
+ address: string;
94
+ percent: number;
95
+ } | null;
96
+ };
97
+ kols?: {
98
+ address?: string;
99
+ twitterHandle?: string | null;
100
+ pnl: number;
101
+ status: string;
102
+ tags: string[];
103
+ }[];
104
+ socials?: {
105
+ websites?: string[];
106
+ twitter?: string | null;
107
+ telegram?: string | null;
108
+ };
109
+ meta: {
110
+ sources: string[];
111
+ fetchTimeMs: number;
112
+ };
113
+ }
114
+ export declare function formatAnalysis(data: AnalysisData): string;
115
+ export {};