@catalyst-team/poly-mcp 0.1.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 (59) hide show
  1. package/README.md +317 -0
  2. package/dist/errors.d.ts +33 -0
  3. package/dist/errors.d.ts.map +1 -0
  4. package/dist/errors.js +86 -0
  5. package/dist/errors.js.map +1 -0
  6. package/dist/index.d.ts +62 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +173 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/server.d.ts +17 -0
  11. package/dist/server.d.ts.map +1 -0
  12. package/dist/server.js +155 -0
  13. package/dist/server.js.map +1 -0
  14. package/dist/tools/guide.d.ts +12 -0
  15. package/dist/tools/guide.d.ts.map +1 -0
  16. package/dist/tools/guide.js +801 -0
  17. package/dist/tools/guide.js.map +1 -0
  18. package/dist/tools/index.d.ts +11 -0
  19. package/dist/tools/index.d.ts.map +1 -0
  20. package/dist/tools/index.js +27 -0
  21. package/dist/tools/index.js.map +1 -0
  22. package/dist/tools/market.d.ts +11 -0
  23. package/dist/tools/market.d.ts.map +1 -0
  24. package/dist/tools/market.js +314 -0
  25. package/dist/tools/market.js.map +1 -0
  26. package/dist/tools/order.d.ts +10 -0
  27. package/dist/tools/order.d.ts.map +1 -0
  28. package/dist/tools/order.js +258 -0
  29. package/dist/tools/order.js.map +1 -0
  30. package/dist/tools/trade.d.ts +38 -0
  31. package/dist/tools/trade.d.ts.map +1 -0
  32. package/dist/tools/trade.js +313 -0
  33. package/dist/tools/trade.js.map +1 -0
  34. package/dist/tools/trader.d.ts +11 -0
  35. package/dist/tools/trader.d.ts.map +1 -0
  36. package/dist/tools/trader.js +277 -0
  37. package/dist/tools/trader.js.map +1 -0
  38. package/dist/tools/wallet.d.ts +274 -0
  39. package/dist/tools/wallet.d.ts.map +1 -0
  40. package/dist/tools/wallet.js +579 -0
  41. package/dist/tools/wallet.js.map +1 -0
  42. package/dist/types.d.ts +413 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +5 -0
  45. package/dist/types.js.map +1 -0
  46. package/docs/01-mcp.md +2075 -0
  47. package/package.json +55 -0
  48. package/src/errors.ts +124 -0
  49. package/src/index.ts +309 -0
  50. package/src/server.ts +183 -0
  51. package/src/tools/guide.ts +821 -0
  52. package/src/tools/index.ts +73 -0
  53. package/src/tools/market.ts +363 -0
  54. package/src/tools/order.ts +326 -0
  55. package/src/tools/trade.ts +417 -0
  56. package/src/tools/trader.ts +322 -0
  57. package/src/tools/wallet.ts +683 -0
  58. package/src/types.ts +472 -0
  59. package/tsconfig.json +20 -0
package/docs/01-mcp.md ADDED
@@ -0,0 +1,2075 @@
1
+ # @catalyst-team/poly-mcp Design
2
+
3
+ > Product-First Thinking: 先验证 API 返回什么,再设计工具
4
+
5
+ **Package**: `@catalyst-team/poly-mcp`
6
+ **Dependency**: `@catalyst-team/poly-sdk`
7
+
8
+ ## 1. 功能本质
9
+
10
+ **用户目标**: AI Agent 能够查询 Polymarket 数据并执行交易
11
+ **一句话**: 这是让 AI 访问预测市场的工具集
12
+ **成功标准**: Agent 能回答 "这个钱包表现如何?" "这个市场什么价?" "帮我下单买 YES"
13
+
14
+ ---
15
+
16
+ ## 2. API 能力验证(真实数据)
17
+
18
+ ### 2.1 Positions API
19
+
20
+ ```bash
21
+ GET https://data-api.polymarket.com/positions?user={address}
22
+ ```
23
+
24
+ **实际返回字段**:
25
+ ```json
26
+ {
27
+ "proxyWallet": "0xc2e7800b...",
28
+ "conditionId": "0x39e493c3...",
29
+ "title": "Spread: Grizzlies (-12.5)",
30
+ "slug": "nba-was-mem-2025-12-20-spread-home-12pt5",
31
+ "outcome": "Wizards",
32
+ "outcomeIndex": 1,
33
+ "size": 1346825.46,
34
+ "avgPrice": 0.520337,
35
+ "curPrice": 1,
36
+ "initialValue": 700803.12,
37
+ "currentValue": 1346825.46,
38
+ "cashPnl": 646022.34,
39
+ "percentPnl": 92.18,
40
+ "realizedPnl": 0,
41
+ "redeemable": true,
42
+ "endDate": "2025-12-21"
43
+ }
44
+ ```
45
+
46
+ ### 2.2 Activity API
47
+
48
+ ```bash
49
+ GET https://data-api.polymarket.com/activity?user={address}&limit=N
50
+ ```
51
+
52
+ **实际返回字段**:
53
+ ```json
54
+ {
55
+ "proxyWallet": "0xc2e7800b...",
56
+ "type": "TRADE",
57
+ "side": "BUY",
58
+ "conditionId": "0x39e493c3...",
59
+ "title": "Spread: Grizzlies (-12.5)",
60
+ "outcome": "Wizards",
61
+ "size": 17307.69,
62
+ "price": 0.52,
63
+ "usdcSize": 9000,
64
+ "timestamp": 1766278645,
65
+ "transactionHash": "0x5fd43582..."
66
+ }
67
+ ```
68
+
69
+ ### 2.3 Leaderboard API
70
+
71
+ ```bash
72
+ GET https://data-api.polymarket.com/v1/leaderboard?limit=N
73
+ ```
74
+
75
+ **实际返回字段**:
76
+ ```json
77
+ {
78
+ "rank": "1",
79
+ "proxyWallet": "0xc2e7800b...",
80
+ "userName": "beachboy4",
81
+ "xUsername": "",
82
+ "verifiedBadge": false,
83
+ "vol": 1346825.46,
84
+ "pnl": 802943.86,
85
+ "profileImage": ""
86
+ }
87
+ ```
88
+
89
+ ### 2.4 Gamma Market API
90
+
91
+ ```bash
92
+ GET https://gamma-api.polymarket.com/markets?slug={slug}
93
+ ```
94
+
95
+ **实际返回字段**:
96
+ ```json
97
+ {
98
+ "conditionId": "0xfa48a993...",
99
+ "question": "US recession in 2025?",
100
+ "slug": "us-recession-in-2025",
101
+ "description": "This market will resolve to...",
102
+ "outcomePrices": "[\"0.0065\", \"0.9935\"]",
103
+ "volume": "11010561.19",
104
+ "liquidity": "110917.70",
105
+ "spread": 0.001,
106
+ "active": true,
107
+ "closed": false,
108
+ "endDate": "2025-12-31T12:00:00Z"
109
+ }
110
+ ```
111
+
112
+ ### 2.5 CLOB Market API
113
+
114
+ ```bash
115
+ GET https://clob.polymarket.com/markets/{conditionId}
116
+ ```
117
+
118
+ **实际返回字段**:
119
+ ```json
120
+ {
121
+ "question": "US recession in 2025?",
122
+ "tokens": [
123
+ { "token_id": "10417...", "outcome": "Yes", "price": 0.0065 },
124
+ { "token_id": "44528...", "outcome": "No", "price": 0.9935 }
125
+ ],
126
+ "active": true,
127
+ "closed": false,
128
+ "minimum_tick_size": 0.001,
129
+ "minimum_order_size": 5
130
+ }
131
+ ```
132
+
133
+ ### 2.6 Orderbook API
134
+
135
+ ```bash
136
+ GET https://clob.polymarket.com/book?token_id={tokenId}
137
+ ```
138
+
139
+ **实际返回字段**:
140
+ ```json
141
+ {
142
+ "market": "0xfa48a993...",
143
+ "asset_id": "10417...",
144
+ "bids": [{ "price": "0.001", "size": "128351" }],
145
+ "asks": [{ "price": "0.999", "size": "3103559" }]
146
+ }
147
+ ```
148
+
149
+ ### 2.7 Trades API
150
+
151
+ ```bash
152
+ GET https://data-api.polymarket.com/trades?market={conditionId}
153
+ ```
154
+
155
+ **实际返回字段**:
156
+ ```json
157
+ {
158
+ "proxyWallet": "0xdb07e53d...",
159
+ "side": "SELL",
160
+ "conditionId": "0xfa48a993...",
161
+ "title": "US recession in 2025?",
162
+ "outcome": "Yes",
163
+ "size": 142.85,
164
+ "price": 0.006,
165
+ "timestamp": 1766318459,
166
+ "transactionHash": "0x85b3dcd4..."
167
+ }
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 3. 工具分类
173
+
174
+ 基于实际 API 能力,分为 **5 类工具**:
175
+
176
+ | 类别 | 核心问题 | 数据来源 |
177
+ |------|----------|----------|
178
+ | **Trader Tools** | "这个交易者怎么样?" | Data API |
179
+ | **Market Tools** | "这个市场什么情况?" | Gamma + CLOB |
180
+ | **Order Tools** | "盘口深度如何?" | CLOB |
181
+ | **Trade Tools** | "帮我交易" | Trading Client |
182
+ | **Wallet Tools** | "如何充值和授权?" | Bridge API + 合约调用 |
183
+
184
+ ### 分类说明
185
+
186
+ - **Trader Tools**: 分析交易者的持仓、交易记录、排名(公开数据)
187
+ - **Wallet Tools**: 管理用户自己钱包的充值和授权(需要私钥)
188
+
189
+ ---
190
+
191
+ ## 4. Trader Tools(交易者分析)
192
+
193
+ ### 工具列表
194
+
195
+ | Tool | 用户问题 | 返回 |
196
+ |------|----------|------|
197
+ | `get_trader_positions` | "他持有什么仓位?" | 持仓列表 + PnL |
198
+ | `get_trader_trades` | "他最近交易了什么?" | 交易历史 |
199
+ | `get_trader_profile` | "他是什么水平?" | 综合分析 |
200
+ | `get_leaderboard` | "谁是顶级交易者?" | 排行榜 |
201
+
202
+ ### 4.1 `get_trader_positions`
203
+
204
+ **用户场景**: "0xc2e7800b 这个钱包持有什么仓位?赚了多少?"
205
+
206
+ **MCP Tool Definition**:
207
+ ```json
208
+ {
209
+ "name": "get_trader_positions",
210
+ "description": "Get all positions held by a trader with PnL breakdown",
211
+ "inputSchema": {
212
+ "type": "object",
213
+ "properties": {
214
+ "address": {
215
+ "type": "string",
216
+ "description": "Trader wallet address (0x...)"
217
+ }
218
+ },
219
+ "required": ["address"]
220
+ }
221
+ }
222
+ ```
223
+
224
+ **Input**:
225
+ ```json
226
+ {
227
+ "address": "0xc2e7800b5af46e6093872b177b7a5e7f0563be51"
228
+ }
229
+ ```
230
+
231
+ **Output** (基于真实 API):
232
+ ```json
233
+ {
234
+ "trader": {
235
+ "address": "0xc2e7800b...",
236
+ "displayName": "beachboy4"
237
+ },
238
+ "positions": [
239
+ {
240
+ "market": {
241
+ "conditionId": "0x39e493c3...",
242
+ "title": "Spread: Grizzlies (-12.5)",
243
+ "slug": "nba-was-mem-2025-12-20-spread-home-12pt5"
244
+ },
245
+ "holding": {
246
+ "outcome": "Wizards",
247
+ "size": 1346825.46,
248
+ "avgPrice": 0.52,
249
+ "curPrice": 1.00
250
+ },
251
+ "pnl": {
252
+ "unrealized": 646022.34,
253
+ "unrealizedPercent": 92.18,
254
+ "realized": 0
255
+ },
256
+ "status": {
257
+ "redeemable": true,
258
+ "endDate": "2025-12-21"
259
+ }
260
+ }
261
+ ],
262
+ "summary": {
263
+ "totalPositions": 5,
264
+ "totalUnrealizedPnl": 1192449.91,
265
+ "totalRealizedPnl": 0,
266
+ "winningPositions": 4,
267
+ "losingPositions": 1
268
+ }
269
+ }
270
+ ```
271
+
272
+ ### 4.2 `get_trader_trades`
273
+
274
+ **用户场景**: "他最近买了什么?卖了什么?"
275
+
276
+ **MCP Tool Definition**:
277
+ ```json
278
+ {
279
+ "name": "get_trader_trades",
280
+ "description": "Get recent trading activity for a trader",
281
+ "inputSchema": {
282
+ "type": "object",
283
+ "properties": {
284
+ "address": {
285
+ "type": "string",
286
+ "description": "Trader wallet address"
287
+ },
288
+ "limit": {
289
+ "type": "number",
290
+ "description": "Maximum number of trades to return",
291
+ "default": 20
292
+ },
293
+ "side": {
294
+ "type": "string",
295
+ "enum": ["BUY", "SELL"],
296
+ "description": "Filter by trade side"
297
+ }
298
+ },
299
+ "required": ["address"]
300
+ }
301
+ }
302
+ ```
303
+
304
+ **Input**:
305
+ ```json
306
+ {
307
+ "address": "0xc2e7800b...",
308
+ "limit": 20,
309
+ "side": "BUY"
310
+ }
311
+ ```
312
+
313
+ **Output**:
314
+ ```json
315
+ {
316
+ "trader": {
317
+ "address": "0xc2e7800b...",
318
+ "displayName": "beachboy4"
319
+ },
320
+ "trades": [
321
+ {
322
+ "type": "TRADE",
323
+ "side": "BUY",
324
+ "market": {
325
+ "conditionId": "0x39e493c3...",
326
+ "title": "Spread: Grizzlies (-12.5)"
327
+ },
328
+ "outcome": "Wizards",
329
+ "execution": {
330
+ "size": 17307.69,
331
+ "price": 0.52,
332
+ "usdcValue": 9000
333
+ },
334
+ "timestamp": "2025-12-20T15:30:45Z",
335
+ "txHash": "0x5fd43582..."
336
+ }
337
+ ],
338
+ "summary": {
339
+ "totalTrades": 20,
340
+ "buyCount": 15,
341
+ "sellCount": 5,
342
+ "buyVolume": 50000,
343
+ "sellVolume": 10000
344
+ }
345
+ }
346
+ ```
347
+
348
+ ### 4.3 `get_trader_profile`
349
+
350
+ **用户场景**: "这个人厉害吗?值得跟单吗?"
351
+
352
+ **MCP Tool Definition**:
353
+ ```json
354
+ {
355
+ "name": "get_trader_profile",
356
+ "description": "Get comprehensive trader profile with performance metrics",
357
+ "inputSchema": {
358
+ "type": "object",
359
+ "properties": {
360
+ "address": {
361
+ "type": "string",
362
+ "description": "Trader wallet address"
363
+ }
364
+ },
365
+ "required": ["address"]
366
+ }
367
+ }
368
+ ```
369
+
370
+ **Input**:
371
+ ```json
372
+ {
373
+ "address": "0xc2e7800b..."
374
+ }
375
+ ```
376
+
377
+ **Output**:
378
+ ```json
379
+ {
380
+ "trader": {
381
+ "address": "0xc2e7800b...",
382
+ "displayName": "beachboy4",
383
+ "xUsername": null,
384
+ "verified": false,
385
+ "profileImage": null
386
+ },
387
+ "ranking": {
388
+ "rank": 1,
389
+ "totalTraders": 10000
390
+ },
391
+ "performance": {
392
+ "officialPnl": 802943.86,
393
+ "totalVolume": 1346825.46,
394
+ "unrealizedPnl": 1192449.91,
395
+ "realizedPnl": 0
396
+ },
397
+ "stats": {
398
+ "positionCount": 5,
399
+ "winRate": 0.80,
400
+ "avgPercentPnl": 92.18,
401
+ "smartScore": 85
402
+ },
403
+ "activity": {
404
+ "lastTradeAt": "2025-12-20T15:30:45Z",
405
+ "isActive": true
406
+ }
407
+ }
408
+ ```
409
+
410
+ ### 4.4 `get_leaderboard`
411
+
412
+ **用户场景**: "谁是最赚钱的交易者?"
413
+
414
+ **MCP Tool Definition**:
415
+ ```json
416
+ {
417
+ "name": "get_leaderboard",
418
+ "description": "Get top traders by PnL",
419
+ "inputSchema": {
420
+ "type": "object",
421
+ "properties": {
422
+ "limit": {
423
+ "type": "number",
424
+ "description": "Number of traders to return",
425
+ "default": 10
426
+ },
427
+ "offset": {
428
+ "type": "number",
429
+ "description": "Pagination offset",
430
+ "default": 0
431
+ }
432
+ }
433
+ }
434
+ }
435
+ ```
436
+
437
+ **Input**:
438
+ ```json
439
+ {
440
+ "limit": 10,
441
+ "offset": 0
442
+ }
443
+ ```
444
+
445
+ **Output**:
446
+ ```json
447
+ {
448
+ "traders": [
449
+ {
450
+ "rank": 1,
451
+ "address": "0xc2e7800b...",
452
+ "displayName": "beachboy4",
453
+ "pnl": 802943.86,
454
+ "volume": 1346825.46,
455
+ "verified": false
456
+ }
457
+ ],
458
+ "pagination": {
459
+ "total": 10000,
460
+ "offset": 0,
461
+ "limit": 10
462
+ }
463
+ }
464
+ ```
465
+
466
+ ---
467
+
468
+ ## 5. Market Tools(市场查询)
469
+
470
+ ### 工具列表
471
+
472
+ | Tool | 用户问题 | 返回 |
473
+ |------|----------|------|
474
+ | `get_market` | "这个市场什么情况?" | 市场详情 |
475
+ | `search_markets` | "有什么关于 XX 的市场?" | 搜索结果 |
476
+ | `get_trending_markets` | "现在什么市场热门?" | 热门列表 |
477
+ | `get_market_trades` | "这个市场最近成交如何?" | 成交记录 |
478
+
479
+ ### 5.1 `get_market`
480
+
481
+ **用户场景**: "US recession 2025 这个市场现在什么价?"
482
+
483
+ **MCP Tool Definition**:
484
+ ```json
485
+ {
486
+ "name": "get_market",
487
+ "description": "Get market details including prices, volume, and status",
488
+ "inputSchema": {
489
+ "type": "object",
490
+ "properties": {
491
+ "identifier": {
492
+ "type": "string",
493
+ "description": "Market slug (e.g., 'us-recession-in-2025') or conditionId (0x...)"
494
+ }
495
+ },
496
+ "required": ["identifier"]
497
+ }
498
+ }
499
+ ```
500
+
501
+ **Input**:
502
+ ```json
503
+ {
504
+ "identifier": "us-recession-in-2025"
505
+ }
506
+ ```
507
+
508
+ **Output**:
509
+ ```json
510
+ {
511
+ "market": {
512
+ "conditionId": "0xfa48a993...",
513
+ "question": "US recession in 2025?",
514
+ "slug": "us-recession-in-2025",
515
+ "description": "This market will resolve to..."
516
+ },
517
+ "prices": {
518
+ "yes": 0.0065,
519
+ "no": 0.9935,
520
+ "spread": 0.001
521
+ },
522
+ "tokens": {
523
+ "yes": { "tokenId": "10417...", "price": 0.0065 },
524
+ "no": { "tokenId": "44528...", "price": 0.9935 }
525
+ },
526
+ "stats": {
527
+ "volume": 11010561.19,
528
+ "liquidity": 110917.70
529
+ },
530
+ "status": {
531
+ "active": true,
532
+ "closed": false,
533
+ "acceptingOrders": true,
534
+ "endDate": "2025-12-31T12:00:00Z"
535
+ },
536
+ "trading": {
537
+ "minTickSize": 0.001,
538
+ "minOrderSize": 5
539
+ }
540
+ }
541
+ ```
542
+
543
+ ### 5.2 `search_markets`
544
+
545
+ **用户场景**: "有什么关于 Trump 的市场?"
546
+
547
+ **实现说明**: Gamma API 不支持服务端文本搜索,所以我们获取活跃市场后在客户端过滤。搜索结果按 24h 交易量排序,精确匹配短语优先。
548
+
549
+ **MCP Tool Definition**:
550
+ ```json
551
+ {
552
+ "name": "search_markets",
553
+ "description": "Search for markets by keyword. Searches in question text and slug. Returns markets sorted by 24h volume.",
554
+ "inputSchema": {
555
+ "type": "object",
556
+ "properties": {
557
+ "query": {
558
+ "type": "string",
559
+ "description": "Search keyword (e.g., 'Trump', 'Bitcoin', 'recession'). Multi-word queries match any word."
560
+ },
561
+ "active": {
562
+ "type": "boolean",
563
+ "description": "Only return active markets",
564
+ "default": true
565
+ },
566
+ "limit": {
567
+ "type": "number",
568
+ "description": "Maximum results",
569
+ "default": 10
570
+ }
571
+ },
572
+ "required": ["query"]
573
+ }
574
+ }
575
+ ```
576
+
577
+ **Input**:
578
+ ```json
579
+ {
580
+ "query": "Trump",
581
+ "active": true,
582
+ "limit": 5
583
+ }
584
+ ```
585
+
586
+ **Output** (真实数据验证 - 2024-12-22):
587
+ ```json
588
+ {
589
+ "markets": [
590
+ {
591
+ "conditionId": "0xac9c6628a5398bb2a06f566854270a9fbc7f2badec4329d3b5fdc1407291c35b",
592
+ "question": "Will Trump release the Epstein files by December 19?",
593
+ "slug": "will-trump-release-the-epstein-files-by-december-19-771",
594
+ "prices": { "yes": 0.9975, "no": 0.0025 },
595
+ "volume": 67321563.56,
596
+ "volume24h": 22684085.39
597
+ },
598
+ {
599
+ "conditionId": "0x8e6ff03d48ea73396ca8c8eac6a8cada2a7507545a78901c4769776be351eaf5",
600
+ "question": "Will Trump release the Epstein files by December 22?",
601
+ "slug": "will-trump-release-the-epstein-files-by-december-22",
602
+ "prices": { "yes": 0.125, "no": 0.875 },
603
+ "volume": 173550.94,
604
+ "volume24h": 123824.96,
605
+ "endDate": "2025-12-26T00:00:00.000Z"
606
+ }
607
+ ],
608
+ "total": 41
609
+ }
610
+ ```
611
+
612
+ ### 5.3 `get_trending_markets`
613
+
614
+ **用户场景**: "现在什么市场交易量大?"
615
+
616
+ **MCP Tool Definition**:
617
+ ```json
618
+ {
619
+ "name": "get_trending_markets",
620
+ "description": "Get trending markets sorted by volume or liquidity",
621
+ "inputSchema": {
622
+ "type": "object",
623
+ "properties": {
624
+ "limit": {
625
+ "type": "number",
626
+ "default": 10
627
+ },
628
+ "sortBy": {
629
+ "type": "string",
630
+ "enum": ["volume", "liquidity", "newest"],
631
+ "default": "volume"
632
+ }
633
+ }
634
+ }
635
+ }
636
+ ```
637
+
638
+ **Input**:
639
+ ```json
640
+ {
641
+ "limit": 10,
642
+ "sortBy": "volume"
643
+ }
644
+ ```
645
+
646
+ **Output**:
647
+ ```json
648
+ {
649
+ "markets": [
650
+ {
651
+ "conditionId": "0x...",
652
+ "question": "...",
653
+ "volume24h": 1000000,
654
+ "priceChange24h": 0.05,
655
+ "prices": { "yes": 0.65, "no": 0.35 }
656
+ }
657
+ ]
658
+ }
659
+ ```
660
+
661
+ ### 5.4 `get_market_trades`
662
+
663
+ **用户场景**: "这个市场最近有什么大单?"
664
+
665
+ **MCP Tool Definition**:
666
+ ```json
667
+ {
668
+ "name": "get_market_trades",
669
+ "description": "Get recent trades for a specific market",
670
+ "inputSchema": {
671
+ "type": "object",
672
+ "properties": {
673
+ "conditionId": {
674
+ "type": "string",
675
+ "description": "Market condition ID"
676
+ },
677
+ "limit": {
678
+ "type": "number",
679
+ "default": 20
680
+ }
681
+ },
682
+ "required": ["conditionId"]
683
+ }
684
+ }
685
+ ```
686
+
687
+ **Input**:
688
+ ```json
689
+ {
690
+ "conditionId": "0xfa48a993...",
691
+ "limit": 20
692
+ }
693
+ ```
694
+
695
+ **Output**:
696
+ ```json
697
+ {
698
+ "market": {
699
+ "conditionId": "0xfa48a993...",
700
+ "question": "US recession in 2025?"
701
+ },
702
+ "trades": [
703
+ {
704
+ "trader": "0xdb07e53d...",
705
+ "traderName": "dontletmecook",
706
+ "side": "SELL",
707
+ "outcome": "Yes",
708
+ "size": 142.85,
709
+ "price": 0.006,
710
+ "timestamp": "2025-12-21T08:20:59Z"
711
+ }
712
+ ],
713
+ "summary": {
714
+ "buyVolume24h": 50000,
715
+ "sellVolume24h": 30000,
716
+ "netFlow": 20000
717
+ }
718
+ }
719
+ ```
720
+
721
+ ---
722
+
723
+ ## 6. Order Tools(订单簿分析)
724
+
725
+ ### 工具列表
726
+
727
+ | Tool | 用户问题 | 返回 |
728
+ |------|----------|------|
729
+ | `get_orderbook` | "盘口深度如何?" | 买卖盘 |
730
+ | `get_best_prices` | "现在最好的价格是?" | 最优价格 |
731
+ | `estimate_execution` | "我买 1000 USDC 会成交在什么价?" | 成交预估 |
732
+
733
+ ### 6.1 `get_orderbook`
734
+
735
+ **用户场景**: "这个市场的盘口深度怎么样?"
736
+
737
+ **MCP Tool Definition**:
738
+ ```json
739
+ {
740
+ "name": "get_orderbook",
741
+ "description": "Get orderbook depth for a market outcome",
742
+ "inputSchema": {
743
+ "type": "object",
744
+ "properties": {
745
+ "conditionId": {
746
+ "type": "string",
747
+ "description": "Market condition ID"
748
+ },
749
+ "outcome": {
750
+ "type": "string",
751
+ "enum": ["Yes", "No"],
752
+ "description": "Which outcome's orderbook to fetch"
753
+ },
754
+ "depth": {
755
+ "type": "number",
756
+ "description": "Number of price levels",
757
+ "default": 10
758
+ }
759
+ },
760
+ "required": ["conditionId", "outcome"]
761
+ }
762
+ }
763
+ ```
764
+
765
+ **Input**:
766
+ ```json
767
+ {
768
+ "conditionId": "0xfa48a993...",
769
+ "outcome": "Yes",
770
+ "depth": 10
771
+ }
772
+ ```
773
+
774
+ **Output**:
775
+ ```json
776
+ {
777
+ "market": {
778
+ "conditionId": "0xfa48a993...",
779
+ "question": "US recession in 2025?"
780
+ },
781
+ "outcome": "Yes",
782
+ "tokenId": "10417...",
783
+ "orderbook": {
784
+ "bids": [
785
+ { "price": 0.006, "size": 128351, "total": 770.11 },
786
+ { "price": 0.005, "size": 51922, "total": 259.61 }
787
+ ],
788
+ "asks": [
789
+ { "price": 0.007, "size": 100000, "total": 700.00 },
790
+ { "price": 0.008, "size": 50000, "total": 400.00 }
791
+ ]
792
+ },
793
+ "summary": {
794
+ "bestBid": 0.006,
795
+ "bestAsk": 0.007,
796
+ "spread": 0.001,
797
+ "spreadPercent": 14.29,
798
+ "bidDepth": 180273,
799
+ "askDepth": 150000
800
+ }
801
+ }
802
+ ```
803
+
804
+ ### 6.2 `get_best_prices`
805
+
806
+ **用户场景**: "YES 现在什么价能买到?"
807
+
808
+ **MCP Tool Definition**:
809
+ ```json
810
+ {
811
+ "name": "get_best_prices",
812
+ "description": "Get best bid/ask prices for both outcomes",
813
+ "inputSchema": {
814
+ "type": "object",
815
+ "properties": {
816
+ "conditionId": {
817
+ "type": "string",
818
+ "description": "Market condition ID"
819
+ }
820
+ },
821
+ "required": ["conditionId"]
822
+ }
823
+ }
824
+ ```
825
+
826
+ **Input**:
827
+ ```json
828
+ {
829
+ "conditionId": "0xfa48a993..."
830
+ }
831
+ ```
832
+
833
+ **Output**:
834
+ ```json
835
+ {
836
+ "market": "US recession in 2025?",
837
+ "yes": {
838
+ "bestBid": 0.006,
839
+ "bestAsk": 0.007,
840
+ "midPrice": 0.0065,
841
+ "spread": 0.001
842
+ },
843
+ "no": {
844
+ "bestBid": 0.993,
845
+ "bestAsk": 0.994,
846
+ "midPrice": 0.9935,
847
+ "spread": 0.001
848
+ }
849
+ }
850
+ ```
851
+
852
+ ### 6.3 `estimate_execution`
853
+
854
+ **用户场景**: "如果我花 1000 USDC 买 YES,平均成交价是多少?"
855
+
856
+ **MCP Tool Definition**:
857
+ ```json
858
+ {
859
+ "name": "estimate_execution",
860
+ "description": "Estimate execution price and slippage for a trade",
861
+ "inputSchema": {
862
+ "type": "object",
863
+ "properties": {
864
+ "conditionId": {
865
+ "type": "string"
866
+ },
867
+ "outcome": {
868
+ "type": "string",
869
+ "enum": ["Yes", "No"]
870
+ },
871
+ "side": {
872
+ "type": "string",
873
+ "enum": ["BUY", "SELL"]
874
+ },
875
+ "amount": {
876
+ "type": "number",
877
+ "description": "Amount in USDC"
878
+ }
879
+ },
880
+ "required": ["conditionId", "outcome", "side", "amount"]
881
+ }
882
+ }
883
+ ```
884
+
885
+ **Input**:
886
+ ```json
887
+ {
888
+ "conditionId": "0xfa48a993...",
889
+ "outcome": "Yes",
890
+ "side": "BUY",
891
+ "amount": 1000
892
+ }
893
+ ```
894
+
895
+ **Output**:
896
+ ```json
897
+ {
898
+ "market": "US recession in 2025?",
899
+ "order": {
900
+ "side": "BUY",
901
+ "outcome": "Yes",
902
+ "usdcAmount": 1000
903
+ },
904
+ "estimate": {
905
+ "avgPrice": 0.0072,
906
+ "sharesReceived": 138889,
907
+ "priceImpact": 0.03,
908
+ "worstPrice": 0.008
909
+ },
910
+ "warning": null
911
+ }
912
+ ```
913
+
914
+ ---
915
+
916
+ ## 7. Trade Tools(交易执行)
917
+
918
+ ### 工具列表
919
+
920
+ | Tool | 用户问题 | 需要 |
921
+ |------|----------|------|
922
+ | `place_limit_order` | "帮我挂单买 YES" | API Key |
923
+ | `place_market_order` | "帮我市价买入" | API Key |
924
+ | `cancel_order` | "取消这个订单" | API Key |
925
+ | `get_my_orders` | "我有什么挂单?" | API Key |
926
+
927
+ ### 7.1 `place_limit_order`
928
+
929
+ **用户场景**: "帮我在 0.50 买入 100 股 YES"
930
+
931
+ **MCP Tool Definition**:
932
+ ```json
933
+ {
934
+ "name": "place_limit_order",
935
+ "description": "Place a limit order on a market",
936
+ "inputSchema": {
937
+ "type": "object",
938
+ "properties": {
939
+ "conditionId": {
940
+ "type": "string"
941
+ },
942
+ "outcome": {
943
+ "type": "string",
944
+ "enum": ["Yes", "No"]
945
+ },
946
+ "side": {
947
+ "type": "string",
948
+ "enum": ["BUY", "SELL"]
949
+ },
950
+ "price": {
951
+ "type": "number",
952
+ "description": "Limit price (0.001 to 0.999)"
953
+ },
954
+ "size": {
955
+ "type": "number",
956
+ "description": "Number of shares"
957
+ },
958
+ "orderType": {
959
+ "type": "string",
960
+ "enum": ["GTC", "GTD"],
961
+ "default": "GTC"
962
+ }
963
+ },
964
+ "required": ["conditionId", "outcome", "side", "price", "size"]
965
+ }
966
+ }
967
+ ```
968
+
969
+ **Input**:
970
+ ```json
971
+ {
972
+ "conditionId": "0xfa48a993...",
973
+ "outcome": "Yes",
974
+ "side": "BUY",
975
+ "price": 0.50,
976
+ "size": 100,
977
+ "orderType": "GTC"
978
+ }
979
+ ```
980
+
981
+ **Output**:
982
+ ```json
983
+ {
984
+ "success": true,
985
+ "order": {
986
+ "orderId": "0x123...",
987
+ "status": "LIVE",
988
+ "tokenId": "10417...",
989
+ "side": "BUY",
990
+ "price": 0.50,
991
+ "size": 100,
992
+ "filled": 0,
993
+ "createdAt": "2025-12-21T10:00:00Z"
994
+ }
995
+ }
996
+ ```
997
+
998
+ ### 7.2 `place_market_order`
999
+
1000
+ **用户场景**: "帮我用 500 USDC 市价买入 YES"
1001
+
1002
+ **MCP Tool Definition**:
1003
+ ```json
1004
+ {
1005
+ "name": "place_market_order",
1006
+ "description": "Place a market order on a market",
1007
+ "inputSchema": {
1008
+ "type": "object",
1009
+ "properties": {
1010
+ "conditionId": {
1011
+ "type": "string"
1012
+ },
1013
+ "outcome": {
1014
+ "type": "string",
1015
+ "enum": ["Yes", "No"]
1016
+ },
1017
+ "side": {
1018
+ "type": "string",
1019
+ "enum": ["BUY", "SELL"]
1020
+ },
1021
+ "amount": {
1022
+ "type": "number",
1023
+ "description": "Amount in USDC"
1024
+ },
1025
+ "maxSlippage": {
1026
+ "type": "number",
1027
+ "description": "Maximum acceptable slippage (e.g., 0.02 for 2%)",
1028
+ "default": 0.02
1029
+ }
1030
+ },
1031
+ "required": ["conditionId", "outcome", "side", "amount"]
1032
+ }
1033
+ }
1034
+ ```
1035
+
1036
+ **Input**:
1037
+ ```json
1038
+ {
1039
+ "conditionId": "0xfa48a993...",
1040
+ "outcome": "Yes",
1041
+ "side": "BUY",
1042
+ "amount": 500,
1043
+ "maxSlippage": 0.02
1044
+ }
1045
+ ```
1046
+
1047
+ **Output**:
1048
+ ```json
1049
+ {
1050
+ "success": true,
1051
+ "execution": {
1052
+ "orderId": "0x456...",
1053
+ "side": "BUY",
1054
+ "usdcSpent": 500,
1055
+ "sharesReceived": 714.29,
1056
+ "avgPrice": 0.70,
1057
+ "fee": 0
1058
+ }
1059
+ }
1060
+ ```
1061
+
1062
+ ### 7.3 `cancel_order`
1063
+
1064
+ **MCP Tool Definition**:
1065
+ ```json
1066
+ {
1067
+ "name": "cancel_order",
1068
+ "description": "Cancel an open order",
1069
+ "inputSchema": {
1070
+ "type": "object",
1071
+ "properties": {
1072
+ "orderId": {
1073
+ "type": "string",
1074
+ "description": "Order ID to cancel"
1075
+ }
1076
+ },
1077
+ "required": ["orderId"]
1078
+ }
1079
+ }
1080
+ ```
1081
+
1082
+ **Input**:
1083
+ ```json
1084
+ {
1085
+ "orderId": "0x123..."
1086
+ }
1087
+ ```
1088
+
1089
+ **Output**:
1090
+ ```json
1091
+ {
1092
+ "success": true,
1093
+ "cancelledOrderId": "0x123..."
1094
+ }
1095
+ ```
1096
+
1097
+ ### 7.4 `get_my_orders`
1098
+
1099
+ **MCP Tool Definition**:
1100
+ ```json
1101
+ {
1102
+ "name": "get_my_orders",
1103
+ "description": "Get your open orders",
1104
+ "inputSchema": {
1105
+ "type": "object",
1106
+ "properties": {
1107
+ "status": {
1108
+ "type": "string",
1109
+ "enum": ["LIVE", "FILLED", "CANCELLED"],
1110
+ "default": "LIVE"
1111
+ }
1112
+ }
1113
+ }
1114
+ }
1115
+ ```
1116
+
1117
+ **Input**:
1118
+ ```json
1119
+ {
1120
+ "status": "LIVE"
1121
+ }
1122
+ ```
1123
+
1124
+ **Output**:
1125
+ ```json
1126
+ {
1127
+ "orders": [
1128
+ {
1129
+ "orderId": "0x123...",
1130
+ "market": "US recession in 2025?",
1131
+ "outcome": "Yes",
1132
+ "side": "BUY",
1133
+ "price": 0.50,
1134
+ "originalSize": 100,
1135
+ "remainingSize": 100,
1136
+ "status": "LIVE",
1137
+ "createdAt": "2025-12-21T10:00:00Z"
1138
+ }
1139
+ ]
1140
+ }
1141
+ ```
1142
+
1143
+ ---
1144
+
1145
+ ## 8. Wallet Tools(钱包管理)
1146
+
1147
+ ### ⚠️ CRITICAL: USDC.e vs Native USDC
1148
+
1149
+ Polymarket CTF **only accepts USDC.e** (bridged USDC), NOT native USDC!
1150
+
1151
+ | Token | Address | CTF Compatible |
1152
+ |-------|---------|----------------|
1153
+ | USDC.e (Bridged) | `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` | ✅ **Required** |
1154
+ | Native USDC | `0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359` | ❌ Not accepted |
1155
+
1156
+ **常见错误**:
1157
+ - 钱包有 100 USDC(Native)→ CTF 操作失败
1158
+ - 原因:CTF 需要 USDC.e,不是 Native USDC
1159
+
1160
+ **解决方案**:
1161
+ - `swap('USDC', 'USDC_E', amount)` - 将 Native USDC 换成 USDC.e
1162
+ - `transferUsdcE(to, amount)` - 给 session 钱包转 USDC.e(用于 CTF)
1163
+ - `CTFClient.checkReadyForCTF(amount)` - 检查钱包是否准备好 CTF 操作
1164
+
1165
+ ### 工具列表
1166
+
1167
+ | Tool | 用户问题 | 需要 |
1168
+ |------|----------|------|
1169
+ | `get_supported_deposit_assets` | "支持哪些资产充值?" | ❌ |
1170
+ | `get_deposit_addresses` | "充值地址是什么?" | 私钥 |
1171
+ | `deposit_usdc` | "帮我充值到交易账户" | 私钥 |
1172
+ | `check_allowances` | "我的授权状态如何?" | 私钥 |
1173
+ | `approve_trading` | "帮我授权所有合约" | 私钥 |
1174
+ | `swap` | "帮我换币" | 私钥 |
1175
+ | `swap_and_deposit` | "帮我换币并充值" | 私钥 |
1176
+ | `get_token_balances` | "我钱包有什么余额?" | 私钥 |
1177
+ | `get_wallet_balances` | "查看某个钱包余额" | ❌ |
1178
+
1179
+ ### 8.1 `get_supported_deposit_assets`
1180
+
1181
+ **用户场景**: "Polymarket 支持从哪些链充值?"
1182
+
1183
+ **MCP Tool Definition**:
1184
+ ```json
1185
+ {
1186
+ "name": "get_supported_deposit_assets",
1187
+ "description": "Get list of supported assets for cross-chain deposits to Polymarket",
1188
+ "inputSchema": {
1189
+ "type": "object",
1190
+ "properties": {
1191
+ "chainId": {
1192
+ "type": "number",
1193
+ "description": "Filter by chain ID (optional)"
1194
+ }
1195
+ }
1196
+ }
1197
+ }
1198
+ ```
1199
+
1200
+ **Input**:
1201
+ ```json
1202
+ {}
1203
+ ```
1204
+
1205
+ **Output** (基于真实 API - 已验证):
1206
+ ```json
1207
+ {
1208
+ "assets": [
1209
+ {
1210
+ "chainId": 1,
1211
+ "chainName": "ethereum",
1212
+ "tokenSymbol": "USDC",
1213
+ "tokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
1214
+ "minDepositUsd": 5
1215
+ },
1216
+ {
1217
+ "chainId": 137,
1218
+ "chainName": "polygon",
1219
+ "tokenSymbol": "USDC",
1220
+ "tokenAddress": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
1221
+ "minDepositUsd": 1
1222
+ }
1223
+ ],
1224
+ "summary": {
1225
+ "totalAssets": 207,
1226
+ "chains": ["ethereum", "polygon", "arbitrum", "optimism", "base", "solana", "bitcoin"]
1227
+ }
1228
+ }
1229
+ ```
1230
+
1231
+ ### 8.2 `get_deposit_addresses`
1232
+
1233
+ **用户场景**: "我的跨链充值地址是什么?"
1234
+
1235
+ **MCP Tool Definition**:
1236
+ ```json
1237
+ {
1238
+ "name": "get_deposit_addresses",
1239
+ "description": "Get deposit addresses for cross-chain deposits",
1240
+ "inputSchema": {
1241
+ "type": "object",
1242
+ "properties": {}
1243
+ }
1244
+ }
1245
+ ```
1246
+
1247
+ **Output** (基于真实 API - 已验证):
1248
+ ```json
1249
+ {
1250
+ "polymarketAddress": "0x1234...your wallet",
1251
+ "depositAddresses": {
1252
+ "evm": "0xabcd...deposit address",
1253
+ "solana": "ABC123...solana address",
1254
+ "bitcoin": "bc1q...bitcoin address"
1255
+ }
1256
+ }
1257
+ ```
1258
+
1259
+ ### 8.3 `deposit_usdc`
1260
+
1261
+ **用户场景**: "帮我把 100 USDC 充值到交易账户"
1262
+
1263
+ **MCP Tool Definition**:
1264
+ ```json
1265
+ {
1266
+ "name": "deposit_usdc",
1267
+ "description": "Deposit USDC from Polygon wallet to Polymarket trading account",
1268
+ "inputSchema": {
1269
+ "type": "object",
1270
+ "properties": {
1271
+ "amount": {
1272
+ "type": "number",
1273
+ "description": "Amount of USDC to deposit"
1274
+ },
1275
+ "token": {
1276
+ "type": "string",
1277
+ "enum": ["NATIVE_USDC", "USDC_E"],
1278
+ "description": "Which USDC token to deposit",
1279
+ "default": "NATIVE_USDC"
1280
+ }
1281
+ },
1282
+ "required": ["amount"]
1283
+ }
1284
+ }
1285
+ ```
1286
+
1287
+ **Input**:
1288
+ ```json
1289
+ {
1290
+ "amount": 100,
1291
+ "token": "NATIVE_USDC"
1292
+ }
1293
+ ```
1294
+
1295
+ **Output**:
1296
+ ```json
1297
+ {
1298
+ "success": true,
1299
+ "transaction": {
1300
+ "hash": "0x5fd43582...",
1301
+ "amount": 100,
1302
+ "token": "NATIVE_USDC",
1303
+ "from": "0x1234...your wallet",
1304
+ "to": "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E"
1305
+ }
1306
+ }
1307
+ ```
1308
+
1309
+ ### 8.4 `check_allowances`
1310
+
1311
+ **用户场景**: "我的钱包授权好了吗?可以交易了吗?"
1312
+
1313
+ **MCP Tool Definition**:
1314
+ ```json
1315
+ {
1316
+ "name": "check_allowances",
1317
+ "description": "Check if wallet has required USDC and ERC1155 approvals for trading",
1318
+ "inputSchema": {
1319
+ "type": "object",
1320
+ "properties": {}
1321
+ }
1322
+ }
1323
+ ```
1324
+
1325
+ **Output** (基于真实合约调用 - 已验证):
1326
+ ```json
1327
+ {
1328
+ "address": "0x1234...your wallet",
1329
+ "usdcBalance": "1000.00",
1330
+ "tradingReady": false,
1331
+ "erc20Allowances": [
1332
+ {
1333
+ "contract": "CTF Exchange",
1334
+ "address": "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
1335
+ "approved": true,
1336
+ "allowance": "unlimited"
1337
+ },
1338
+ {
1339
+ "contract": "Neg Risk CTF Exchange",
1340
+ "address": "0xC5d563A36AE78145C45a50134d48A1215220f80a",
1341
+ "approved": false,
1342
+ "allowance": "0"
1343
+ },
1344
+ {
1345
+ "contract": "Neg Risk Adapter",
1346
+ "address": "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296",
1347
+ "approved": false,
1348
+ "allowance": "0"
1349
+ }
1350
+ ],
1351
+ "erc1155Approvals": [
1352
+ {
1353
+ "contract": "CTF Exchange",
1354
+ "address": "0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
1355
+ "approved": true
1356
+ },
1357
+ {
1358
+ "contract": "Neg Risk CTF Exchange",
1359
+ "address": "0xC5d563A36AE78145C45a50134d48A1215220f80a",
1360
+ "approved": false
1361
+ }
1362
+ ],
1363
+ "issues": [
1364
+ "USDC not approved for Neg Risk CTF Exchange",
1365
+ "USDC not approved for Neg Risk Adapter",
1366
+ "ERC1155 not approved for Neg Risk CTF Exchange"
1367
+ ]
1368
+ }
1369
+ ```
1370
+
1371
+ ### 8.5 `approve_trading`
1372
+
1373
+ **用户场景**: "帮我完成所有授权,让我可以交易"
1374
+
1375
+ **MCP Tool Definition**:
1376
+ ```json
1377
+ {
1378
+ "name": "approve_trading",
1379
+ "description": "Approve all required contracts for trading on Polymarket",
1380
+ "inputSchema": {
1381
+ "type": "object",
1382
+ "properties": {}
1383
+ }
1384
+ }
1385
+ ```
1386
+
1387
+ **Output**:
1388
+ ```json
1389
+ {
1390
+ "success": true,
1391
+ "transactions": [
1392
+ {
1393
+ "type": "ERC20_APPROVAL",
1394
+ "contract": "CTF Exchange",
1395
+ "hash": "0xabc..."
1396
+ },
1397
+ {
1398
+ "type": "ERC20_APPROVAL",
1399
+ "contract": "Neg Risk CTF Exchange",
1400
+ "hash": "0xdef..."
1401
+ },
1402
+ {
1403
+ "type": "ERC20_APPROVAL",
1404
+ "contract": "Neg Risk Adapter",
1405
+ "hash": "0x123..."
1406
+ },
1407
+ {
1408
+ "type": "ERC1155_APPROVAL",
1409
+ "contract": "CTF Exchange",
1410
+ "hash": "0x456..."
1411
+ },
1412
+ {
1413
+ "type": "ERC1155_APPROVAL",
1414
+ "contract": "Neg Risk CTF Exchange",
1415
+ "hash": "0x789..."
1416
+ }
1417
+ ],
1418
+ "message": "All 5 approvals completed. Your wallet is now ready for trading."
1419
+ }
1420
+ ```
1421
+
1422
+ ### 8.6 `swap`
1423
+
1424
+ **用户场景**: "帮我把 100 MATIC 换成 USDC"
1425
+
1426
+ **MCP Tool Definition**:
1427
+ ```json
1428
+ {
1429
+ "name": "swap",
1430
+ "description": "Swap between tokens on Polygon using QuickSwap V3",
1431
+ "inputSchema": {
1432
+ "type": "object",
1433
+ "properties": {
1434
+ "tokenIn": {
1435
+ "type": "string",
1436
+ "description": "Token to swap from (MATIC, WETH, USDC, USDC_E, USDT, DAI)"
1437
+ },
1438
+ "tokenOut": {
1439
+ "type": "string",
1440
+ "description": "Token to swap to (MATIC, WETH, USDC, USDC_E, USDT, DAI)"
1441
+ },
1442
+ "amount": {
1443
+ "type": "string",
1444
+ "description": "Amount to swap in token units"
1445
+ },
1446
+ "slippage": {
1447
+ "type": "number",
1448
+ "description": "Slippage tolerance in percent (default: 0.5)"
1449
+ }
1450
+ },
1451
+ "required": ["tokenIn", "tokenOut", "amount"]
1452
+ }
1453
+ }
1454
+ ```
1455
+
1456
+ **Input**:
1457
+ ```json
1458
+ {
1459
+ "tokenIn": "MATIC",
1460
+ "tokenOut": "USDC",
1461
+ "amount": "100",
1462
+ "slippage": 0.5
1463
+ }
1464
+ ```
1465
+
1466
+ **Output**:
1467
+ ```json
1468
+ {
1469
+ "success": true,
1470
+ "wallet": "0x1234...",
1471
+ "tokenIn": "MATIC",
1472
+ "tokenOut": "USDC",
1473
+ "amountIn": "100",
1474
+ "amountOut": "55.23",
1475
+ "txHash": "0xabc...",
1476
+ "gasUsed": "150000",
1477
+ "explorerUrl": "https://polygonscan.com/tx/0xabc..."
1478
+ }
1479
+ ```
1480
+
1481
+ ### 8.7 `swap_and_deposit`
1482
+
1483
+ **用户场景**: "帮我把 MATIC 换成 USDC 并充值到 Polymarket"
1484
+
1485
+ **MCP Tool Definition**:
1486
+ ```json
1487
+ {
1488
+ "name": "swap_and_deposit",
1489
+ "description": "Swap any token to USDC and deposit to Polymarket in one operation",
1490
+ "inputSchema": {
1491
+ "type": "object",
1492
+ "properties": {
1493
+ "token": {
1494
+ "type": "string",
1495
+ "description": "Token to deposit (MATIC, WETH, USDT, DAI, USDC)"
1496
+ },
1497
+ "amount": {
1498
+ "type": "string",
1499
+ "description": "Amount to deposit in token units"
1500
+ },
1501
+ "slippage": {
1502
+ "type": "number",
1503
+ "description": "Slippage tolerance for swap in percent (default: 0.5)"
1504
+ }
1505
+ },
1506
+ "required": ["token", "amount"]
1507
+ }
1508
+ }
1509
+ ```
1510
+
1511
+ **Input**:
1512
+ ```json
1513
+ {
1514
+ "token": "MATIC",
1515
+ "amount": "100",
1516
+ "slippage": 0.5
1517
+ }
1518
+ ```
1519
+
1520
+ **Output**:
1521
+ ```json
1522
+ {
1523
+ "success": true,
1524
+ "wallet": "0x1234...",
1525
+ "tokenIn": "MATIC",
1526
+ "amountIn": "100",
1527
+ "usdcAmount": "55.23",
1528
+ "swapTxHash": "0xabc...",
1529
+ "depositTxHash": "0xdef...",
1530
+ "depositAddress": "0x4bFb41d5...",
1531
+ "message": "Swapped 100 MATIC to 55.23 USDC, then deposited to Polymarket.",
1532
+ "explorerUrl": "https://polygonscan.com/tx/0xdef..."
1533
+ }
1534
+ ```
1535
+
1536
+ ### 8.8 `get_token_balances`
1537
+
1538
+ **用户场景**: "我的钱包里有什么余额?"(需要私钥配置)
1539
+
1540
+ **MCP Tool Definition**:
1541
+ ```json
1542
+ {
1543
+ "name": "get_token_balances",
1544
+ "description": "Get balances for all supported tokens on Polygon for the configured wallet",
1545
+ "inputSchema": {
1546
+ "type": "object",
1547
+ "properties": {}
1548
+ }
1549
+ }
1550
+ ```
1551
+
1552
+ **Output**:
1553
+ ```json
1554
+ {
1555
+ "wallet": "0x1234...",
1556
+ "balances": [
1557
+ { "token": "MATIC", "symbol": "MATIC", "balance": "150.5", "decimals": 18 },
1558
+ { "token": "USDC", "symbol": "USDC", "balance": "1000.00", "decimals": 6 },
1559
+ { "token": "USDC_E", "symbol": "USDC.e", "balance": "500.00", "decimals": 6 },
1560
+ { "token": "USDT", "symbol": "USDT", "balance": "0", "decimals": 6 },
1561
+ { "token": "DAI", "symbol": "DAI", "balance": "0", "decimals": 18 },
1562
+ { "token": "WETH", "symbol": "WETH", "balance": "0.5", "decimals": 18 }
1563
+ ],
1564
+ "nonZeroBalances": [
1565
+ { "token": "MATIC", "balance": "150.5" },
1566
+ { "token": "USDC", "balance": "1000.00" },
1567
+ { "token": "USDC_E", "balance": "500.00" },
1568
+ { "token": "WETH", "balance": "0.5" }
1569
+ ],
1570
+ "supportedTokens": ["MATIC", "USDC", "USDC_E", "USDT", "DAI", "WETH"]
1571
+ }
1572
+ ```
1573
+
1574
+ ### 8.9 `get_wallet_balances`
1575
+
1576
+ **用户场景**: "查看某个钱包有什么余额?"(不需要私钥)
1577
+
1578
+ **MCP Tool Definition**:
1579
+ ```json
1580
+ {
1581
+ "name": "get_wallet_balances",
1582
+ "description": "Get Polygon token balances for any wallet address (no private key required)",
1583
+ "inputSchema": {
1584
+ "type": "object",
1585
+ "properties": {
1586
+ "address": {
1587
+ "type": "string",
1588
+ "description": "Wallet address to check (0x...)"
1589
+ }
1590
+ },
1591
+ "required": ["address"]
1592
+ }
1593
+ }
1594
+ ```
1595
+
1596
+ **Input**:
1597
+ ```json
1598
+ {
1599
+ "address": "0xc2e7800b5af46e6093872b177b7a5e7f0563be51"
1600
+ }
1601
+ ```
1602
+
1603
+ **Output** (真实数据验证 - 2024-12-22):
1604
+ ```json
1605
+ {
1606
+ "address": "0xc2e7800b5af46e6093872b177b7a5e7f0563be51",
1607
+ "balances": [
1608
+ { "token": "MATIC", "symbol": "MATIC", "balance": "0.0956", "decimals": 18 },
1609
+ { "token": "USDC", "symbol": "USDC", "balance": "0", "decimals": 6 },
1610
+ { "token": "USDC_E", "symbol": "USDC.e", "balance": "2648315.63", "decimals": 6 },
1611
+ { "token": "USDT", "symbol": "USDT", "balance": "0", "decimals": 6 },
1612
+ { "token": "DAI", "symbol": "DAI", "balance": "0", "decimals": 18 },
1613
+ { "token": "WETH", "symbol": "WETH", "balance": "0", "decimals": 18 }
1614
+ ],
1615
+ "nonZeroBalances": [
1616
+ { "token": "MATIC", "balance": "0.0956" },
1617
+ { "token": "USDC_E", "balance": "2648315.63" }
1618
+ ],
1619
+ "summary": {
1620
+ "totalTokens": 2,
1621
+ "stablecoinValue": "2648315.63"
1622
+ },
1623
+ "supportedTokens": ["MATIC", "USDC", "USDC_E", "USDT", "DAI", "WETH"]
1624
+ }
1625
+ ```
1626
+
1627
+ ### 8.10 合约地址参考
1628
+
1629
+ **Polygon Mainnet (chainId: 137)**:
1630
+
1631
+ | Contract | Address | 用途 |
1632
+ |----------|---------|------|
1633
+ | USDC (Native) | `0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359` | ERC20 代币 |
1634
+ | USDC.e (Bridged) | `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` | ERC20 代币 |
1635
+ | USDT | `0xc2132D05D31c914a87C6611C10748AEb04B58e8F` | ERC20 代币 |
1636
+ | DAI | `0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063` | ERC20 代币 |
1637
+ | WMATIC | `0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270` | Wrapped MATIC |
1638
+ | WETH | `0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619` | Wrapped ETH |
1639
+ | Conditional Tokens | `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045` | ERC1155 代币 |
1640
+ | CTF Exchange | `0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E` | 交易合约 |
1641
+ | Neg Risk CTF Exchange | `0xC5d563A36AE78145C45a50134d48A1215220f80a` | Neg Risk 交易 |
1642
+ | Neg Risk Adapter | `0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296` | Neg Risk 适配器 |
1643
+ | QuickSwap V3 Router | `0xf5b509bB0909a69B1c207E495f687a596C168E12` | DEX Swap 路由 |
1644
+
1645
+ ---
1646
+
1647
+ ## 9. 数据字段映射
1648
+
1649
+ ### 9.1 可直接使用的字段
1650
+
1651
+ | 需要 | API | 字段 | 状态 |
1652
+ |------|-----|------|------|
1653
+ | 持仓 | positions | size, avgPrice, curPrice | ✅ |
1654
+ | PnL | positions | cashPnl, realizedPnl, percentPnl | ✅ |
1655
+ | 市场标题 | positions/activity | title, slug | ✅ |
1656
+ | 交易历史 | activity | type, side, size, price, timestamp | ✅ |
1657
+ | 排行榜 | leaderboard | rank, pnl, vol | ✅ |
1658
+ | 市场价格 | gamma | outcomePrices | ✅ |
1659
+ | 订单簿 | clob/book | bids, asks | ✅ |
1660
+
1661
+ ### 9.2 需要计算的字段
1662
+
1663
+ | 需要 | 计算方式 |
1664
+ |------|----------|
1665
+ | winRate | positions.filter(p => p.cashPnl > 0).length / total |
1666
+ | netFlow | buyVolume - sellVolume |
1667
+ | priceImpact | 遍历订单簿计算 |
1668
+ | smartScore | WalletService.calculateSmartScore() |
1669
+
1670
+ ### 9.3 不可用的字段
1671
+
1672
+ | 需要 | 问题 | 解决方案 |
1673
+ |------|------|----------|
1674
+ | 精确 officialPnl 计算方式 | API 黑盒 | 显示两种 PnL |
1675
+ | 历史价格走势 | 需要自己收集 | 后续增加 |
1676
+
1677
+ ---
1678
+
1679
+ ## 10. 实现架构
1680
+
1681
+ ```
1682
+ packages/
1683
+ ├── poly-sdk/ # Core SDK
1684
+ │ ├── src/
1685
+ │ │ ├── index.ts # SDK 入口
1686
+ │ │ ├── clients/
1687
+ │ │ │ ├── bridge-client.ts # Bridge API + depositUsdc
1688
+ │ │ │ ├── trading-client.ts # Trading operations
1689
+ │ │ │ └── ...
1690
+ │ │ └── services/
1691
+ │ │ ├── authorization-service.ts # 授权管理
1692
+ │ │ ├── swap-service.ts # DEX swap 功能
1693
+ │ │ └── ...
1694
+ │ └── package.json
1695
+
1696
+ └── poly-mcp/ # MCP Server (separate package)
1697
+ ├── src/
1698
+ │ ├── index.ts # MCP Handler + exports
1699
+ │ ├── server.ts # Standalone MCP server
1700
+ │ ├── errors.ts # Error handling
1701
+ │ ├── types.ts # Type definitions
1702
+ │ └── tools/
1703
+ │ ├── trader.ts # Trader Tools (4个)
1704
+ │ ├── market.ts # Market Tools (4个)
1705
+ │ ├── order.ts # Order Tools (3个)
1706
+ │ ├── trade.ts # Trade Tools (4个)
1707
+ │ ├── wallet.ts # Wallet Tools (11个)
1708
+ │ └── guide.ts # Usage guide tool
1709
+ ├── docs/
1710
+ │ └── 01-mcp.md # This file
1711
+ └── package.json
1712
+ ```
1713
+
1714
+ ### 10.1 MCP Server 入口
1715
+
1716
+ ```typescript
1717
+ // packages/poly-mcp/src/server.ts
1718
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
1719
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
1720
+ import { PolymarketSDK } from '@catalyst-team/poly-sdk';
1721
+ import { registerTraderTools } from './tools/trader.js';
1722
+ import { registerMarketTools } from './tools/market.js';
1723
+ import { registerOrderTools } from './tools/order.js';
1724
+ import { registerTradeTools } from './tools/trade.js';
1725
+ import { registerWalletTools } from './tools/wallet.js';
1726
+ import { registerGuideTools } from './tools/guide.js';
1727
+
1728
+ const server = new Server(
1729
+ { name: 'poly-mcp', version: '1.0.0' },
1730
+ { capabilities: { tools: {} } }
1731
+ );
1732
+
1733
+ const sdk = new PolymarketSDK();
1734
+
1735
+ // Register all tools
1736
+ registerTraderTools(server, sdk);
1737
+ registerMarketTools(server, sdk);
1738
+ registerOrderTools(server, sdk);
1739
+ registerTradeTools(server, sdk);
1740
+ registerWalletTools(server, sdk);
1741
+ registerGuideTools(server);
1742
+
1743
+ // Start server
1744
+ const transport = new StdioServerTransport();
1745
+ await server.connect(transport);
1746
+ ```
1747
+
1748
+ ### 10.2 工具注册示例
1749
+
1750
+ ```typescript
1751
+ // packages/poly-mcp/src/tools/trader.ts
1752
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
1753
+ import { PolymarketSDK } from '@catalyst-team/poly-sdk';
1754
+ import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
1755
+
1756
+ export function registerTraderTools(server: Server, sdk: PolymarketSDK) {
1757
+ // List available tools
1758
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
1759
+ tools: [
1760
+ {
1761
+ name: 'get_trader_positions',
1762
+ description: 'Get all positions held by a trader with PnL breakdown',
1763
+ inputSchema: {
1764
+ type: 'object',
1765
+ properties: {
1766
+ address: {
1767
+ type: 'string',
1768
+ description: 'Trader wallet address (0x...)'
1769
+ }
1770
+ },
1771
+ required: ['address']
1772
+ }
1773
+ },
1774
+ // ... more tools
1775
+ ]
1776
+ }));
1777
+
1778
+ // Handle tool calls
1779
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1780
+ const { name, arguments: args } = request.params;
1781
+
1782
+ switch (name) {
1783
+ case 'get_trader_positions': {
1784
+ const { address } = args as { address: string };
1785
+ const positions = await sdk.wallets.getWalletPositions(address);
1786
+ const profile = await sdk.wallets.getWalletProfile(address);
1787
+
1788
+ return {
1789
+ content: [{
1790
+ type: 'text',
1791
+ text: JSON.stringify({
1792
+ trader: {
1793
+ address,
1794
+ displayName: profile.displayName || null
1795
+ },
1796
+ positions: positions.map(p => ({
1797
+ market: {
1798
+ conditionId: p.conditionId,
1799
+ title: p.title,
1800
+ slug: p.slug
1801
+ },
1802
+ holding: {
1803
+ outcome: p.outcome,
1804
+ size: p.size,
1805
+ avgPrice: p.avgPrice,
1806
+ curPrice: p.curPrice
1807
+ },
1808
+ pnl: {
1809
+ unrealized: p.cashPnl,
1810
+ unrealizedPercent: p.percentPnl,
1811
+ realized: p.realizedPnl
1812
+ },
1813
+ status: {
1814
+ redeemable: p.redeemable,
1815
+ endDate: p.endDate
1816
+ }
1817
+ })),
1818
+ summary: {
1819
+ totalPositions: positions.length,
1820
+ totalUnrealizedPnl: positions.reduce((s, p) => s + (p.cashPnl || 0), 0),
1821
+ totalRealizedPnl: positions.reduce((s, p) => s + (p.realizedPnl || 0), 0),
1822
+ winningPositions: positions.filter(p => (p.cashPnl || 0) > 0).length,
1823
+ losingPositions: positions.filter(p => (p.cashPnl || 0) < 0).length
1824
+ }
1825
+ }, null, 2)
1826
+ }]
1827
+ };
1828
+ }
1829
+ // ... more cases
1830
+ }
1831
+ });
1832
+ }
1833
+ ```
1834
+
1835
+ ---
1836
+
1837
+ ## 10. 配置与认证
1838
+
1839
+ ### 10.1 环境变量
1840
+
1841
+ ```bash
1842
+ # .env
1843
+ POLY_PRIVATE_KEY=your-private-key # 用于 Trade Tools 和 Wallet Tools
1844
+ POLY_CHAIN_ID=137 # Polygon Mainnet (default)
1845
+ ```
1846
+
1847
+ **Note**: API credentials 会自动从私钥派生,使用 Polymarket 的 `createOrDeriveApiKey()` 方法。
1848
+
1849
+ ### 10.2 MCP 配置
1850
+
1851
+ #### 发布后使用 (推荐)
1852
+
1853
+ ```json
1854
+ // Claude Desktop config: ~/Library/Application Support/Claude/claude_desktop_config.json
1855
+ {
1856
+ "mcpServers": {
1857
+ "polymarket": {
1858
+ "command": "npx",
1859
+ "args": ["@catalyst-team/poly-mcp"],
1860
+ "env": {
1861
+ "POLY_PRIVATE_KEY": "your-wallet-private-key"
1862
+ }
1863
+ }
1864
+ }
1865
+ }
1866
+ ```
1867
+
1868
+ #### 本地开发
1869
+
1870
+ ```json
1871
+ {
1872
+ "mcpServers": {
1873
+ "polymarket": {
1874
+ "command": "node",
1875
+ "args": ["/path/to/PerdictionRouter/packages/poly-mcp/dist/server.js"],
1876
+ "env": {
1877
+ "POLY_PRIVATE_KEY": "your-wallet-private-key"
1878
+ }
1879
+ }
1880
+ }
1881
+ }
1882
+ ```
1883
+
1884
+ ### 10.3 工具权限
1885
+
1886
+ | 工具类别 | 需要认证 | 说明 |
1887
+ |---------|---------|------|
1888
+ | Trader Tools | ❌ | 公开数据查询 |
1889
+ | Market Tools | ❌ | 公开数据查询 |
1890
+ | Order Tools | ❌ | 公开数据查询 |
1891
+ | Trade Tools | ✅ | 需要 API Key |
1892
+ | Wallet Tools | ⚠️ | 部分需要私钥(swap, deposit, allowance),get_wallet_balances 和 get_supported_deposit_assets 不需要 |
1893
+
1894
+ ---
1895
+
1896
+ ## 11. 错误处理
1897
+
1898
+ ### 11.1 统一错误格式
1899
+
1900
+ ```typescript
1901
+ interface McpError {
1902
+ error: {
1903
+ code: string;
1904
+ message: string;
1905
+ details?: Record<string, unknown>;
1906
+ };
1907
+ }
1908
+ ```
1909
+
1910
+ ### 11.2 错误码
1911
+
1912
+ | Code | 说明 | 示例 |
1913
+ |------|------|------|
1914
+ | `INVALID_ADDRESS` | 无效钱包地址 | "Address must start with 0x" |
1915
+ | `MARKET_NOT_FOUND` | 市场不存在 | "Market 0x... not found" |
1916
+ | `INSUFFICIENT_BALANCE` | 余额不足 | "Insufficient USDC balance" |
1917
+ | `ORDER_REJECTED` | 订单被拒绝 | "Price outside valid range" |
1918
+ | `RATE_LIMITED` | 请求过于频繁 | "Rate limit exceeded" |
1919
+ | `AUTH_REQUIRED` | 需要认证 | "Trade tools require API key" |
1920
+ | `INTERNAL_ERROR` | 内部错误 | "Unexpected error occurred" |
1921
+
1922
+ ### 11.3 错误处理实现
1923
+
1924
+ ```typescript
1925
+ // src/utils/errors.ts
1926
+ export class McpToolError extends Error {
1927
+ constructor(
1928
+ public code: string,
1929
+ message: string,
1930
+ public details?: Record<string, unknown>
1931
+ ) {
1932
+ super(message);
1933
+ }
1934
+
1935
+ toResponse() {
1936
+ return {
1937
+ content: [{
1938
+ type: 'text',
1939
+ text: JSON.stringify({
1940
+ error: {
1941
+ code: this.code,
1942
+ message: this.message,
1943
+ details: this.details
1944
+ }
1945
+ })
1946
+ }],
1947
+ isError: true
1948
+ };
1949
+ }
1950
+ }
1951
+
1952
+ // 使用
1953
+ try {
1954
+ const positions = await sdk.wallets.getWalletPositions(address);
1955
+ // ...
1956
+ } catch (err) {
1957
+ if (err instanceof PolymarketError) {
1958
+ throw new McpToolError(
1959
+ err.code,
1960
+ err.message,
1961
+ { originalError: err.details }
1962
+ );
1963
+ }
1964
+ throw new McpToolError('INTERNAL_ERROR', 'Unexpected error occurred');
1965
+ }
1966
+ ```
1967
+
1968
+ ---
1969
+
1970
+ ## 12. 优先级
1971
+
1972
+ | Phase | Tools | 说明 |
1973
+ |-------|-------|------|
1974
+ | **P0** | get_trader_positions, get_market, get_orderbook | 核心查询 |
1975
+ | **P1** | get_trader_trades, get_leaderboard, search_markets, check_allowances, get_supported_deposit_assets, get_deposit_addresses, get_token_balances, get_wallet_balances | 分析 + 钱包状态 |
1976
+ | **P2** | place_limit_order, place_market_order, deposit_usdc, approve_trading, swap, swap_and_deposit | 交易执行 + 钱包操作 |
1977
+ | **P3** | estimate_execution, get_trending_markets | 高级功能 |
1978
+
1979
+ ---
1980
+
1981
+ ## 13. 测试计划
1982
+
1983
+ ### 13.1 单元测试
1984
+
1985
+ ```typescript
1986
+ // tests/tools/trader.test.ts
1987
+ describe('get_trader_positions', () => {
1988
+ it('returns positions for valid address', async () => {
1989
+ const result = await callTool('get_trader_positions', {
1990
+ address: '0xc2e7800b5af46e6093872b177b7a5e7f0563be51'
1991
+ });
1992
+
1993
+ expect(result.trader.address).toBe('0xc2e7800b...');
1994
+ expect(result.positions).toBeInstanceOf(Array);
1995
+ expect(result.summary.totalPositions).toBeGreaterThanOrEqual(0);
1996
+ });
1997
+
1998
+ it('returns error for invalid address', async () => {
1999
+ const result = await callTool('get_trader_positions', {
2000
+ address: 'invalid'
2001
+ });
2002
+
2003
+ expect(result.error.code).toBe('INVALID_ADDRESS');
2004
+ });
2005
+ });
2006
+ ```
2007
+
2008
+ ### 13.2 集成测试
2009
+
2010
+ ```bash
2011
+ # 使用 MCP Inspector 测试
2012
+ npx @anthropic/mcp-inspector poly-mcp
2013
+
2014
+ # 手动测试
2015
+ echo '{"method":"tools/call","params":{"name":"get_trader_positions","arguments":{"address":"0xc2e7800b5af46e6093872b177b7a5e7f0563be51"}}}' | npx poly-mcp
2016
+ ```
2017
+
2018
+ ---
2019
+
2020
+ ## 14. 工具汇总
2021
+
2022
+ | # | Tool | 类别 | 优先级 | 需要私钥 |
2023
+ |---|------|------|--------|----------|
2024
+ | 1 | `get_trader_positions` | Trader | P0 | ❌ |
2025
+ | 2 | `get_trader_trades` | Trader | P1 | ❌ |
2026
+ | 3 | `get_trader_profile` | Trader | P1 | ❌ |
2027
+ | 4 | `get_leaderboard` | Trader | P1 | ❌ |
2028
+ | 5 | `get_market` | Market | P0 | ❌ |
2029
+ | 6 | `search_markets` | Market | P1 | ❌ |
2030
+ | 7 | `get_trending_markets` | Market | P3 | ❌ |
2031
+ | 8 | `get_market_trades` | Market | P1 | ❌ |
2032
+ | 9 | `get_orderbook` | Order | P0 | ❌ |
2033
+ | 10 | `get_best_prices` | Order | P1 | ❌ |
2034
+ | 11 | `estimate_execution` | Order | P3 | ❌ |
2035
+ | 12 | `place_limit_order` | Trade | P2 | ✅ |
2036
+ | 13 | `place_market_order` | Trade | P2 | ✅ |
2037
+ | 14 | `cancel_order` | Trade | P2 | ✅ |
2038
+ | 15 | `get_my_orders` | Trade | P2 | ✅ |
2039
+ | 16 | `get_supported_deposit_assets` | Wallet | P1 | ❌ |
2040
+ | 17 | `get_deposit_addresses` | Wallet | P1 | ✅ |
2041
+ | 18 | `deposit_usdc` | Wallet | P2 | ✅ |
2042
+ | 19 | `check_allowances` | Wallet | P1 | ✅ |
2043
+ | 20 | `approve_trading` | Wallet | P2 | ✅ |
2044
+ | 21 | `swap` | Wallet | P2 | ✅ |
2045
+ | 22 | `swap_and_deposit` | Wallet | P2 | ✅ |
2046
+ | 23 | `get_token_balances` | Wallet | P1 | ✅ |
2047
+ | 24 | `get_wallet_balances` | Wallet | P1 | ❌ |
2048
+ | 25 | `get_swap_quote` | Wallet | P1 | ❌ |
2049
+ | 26 | `get_available_pools` | Wallet | P1 | ❌ |
2050
+ | 27 | `get_usage_guide` | Guide | P0 | ❌ |
2051
+
2052
+ **Total: 27 Tools**
2053
+
2054
+ ---
2055
+
2056
+ ## 15. 后续优化
2057
+
2058
+ ### 15.1 性能优化
2059
+
2060
+ - [ ] 批量查询:合并多个钱包的查询
2061
+ - [ ] 流式响应:对大数据量使用流式传输
2062
+ - [ ] 缓存策略:MCP 层缓存热点数据
2063
+
2064
+ ### 15.2 功能扩展
2065
+
2066
+ - [ ] 历史价格图表数据
2067
+ - [ ] 钱包对比分析
2068
+ - [ ] 市场相关性分析
2069
+ - [ ] 套利机会检测
2070
+
2071
+ ### 15.3 监控与日志
2072
+
2073
+ - [ ] 请求追踪
2074
+ - [ ] 性能指标收集
2075
+ - [ ] 错误报警