← 返回
未分类

polymarket-predictradar-data-layer-skills

Shared Polymarket and prediction-market data access layer. Use this skill whenever another skill or task needs trader positions, trade history, market metada...
共享的Polymarket 与预测市场数据访问层。在其他技能或任务需要交易员持仓、交易历史、市场元数据时使用此技能。
cnica
未分类 clawhub v1.0.0 1 版本 99635 Key: 无需
★ 0
Stars
📥 273
下载
💾 0
安装
1
版本
#latest

概述

Polymarket Data Access Layer

This skill is the shared data layer for the repository. It exists so that individual skills do not need to re-implement MCP session handling, query helpers, market metadata lookups, or local caching logic.


Data Source Priority

1. PredicTradar MCP Server  https://api.predictradar.ai/api/mcp/v2  (primary)
2. polymarket-cli           polymarket <command>                    (service degradation fallback)
3. Polymarket Data API      https://data-api.polymarket.com         (final fallback)

Use the PredicTradar MCP Server by default. It is the canonical shared entry point for this repo.


Current MCP Notes

The live MCP service now requires a full MCP session handshake:

  1. Call initialize
  2. Read the mcp-session-id response header
  3. Send notifications/initialized
  4. Reuse the session header for tools/list and tools/call

The repository wrapper at mcp-client.js already handles this automatically, so skills should call the wrapper instead of implementing raw MCP requests unless they need low-level debugging.

Health endpoint observed on March 31, 2026:

  • service: predictradar-mcp
  • version: 1.0.0
  • protocolVersion: 2025-03-26

MCP Capabilities

The current live tool catalog includes:

ToolPurposeNotes
----------------------
get_tradersTrader list with sorting and paginationSort fields include volume_24h, volume_7d, volume_30d, pnl_24h, pnl_7d, pnl_30d, win_rate
get_trader_detailDetailed trader profileIncludes positions, recent activity, and analysis payloads
get_marketsMarket listSupports status, search, limit, offset
get_market_detailSingle-market detailNewer high-level tool, useful when a skill already has a conditionId
get_leaderboardRanked trader leaderboardperiod: 24h, 7d, 30d, all
get_market_statsAggregate market statisticsIncludes volume, trader counts, active markets, hot markets
search_eventsEvent searchSupports query, category, status, limit
run_query_previewPreferred read-only SQL previewPreview mode only, limited rows
run_queryLegacy alias for preview SQLKeep compatibility, but prefer run_query_preview in new docs
open_query_streamStreamed SQL exportUse for larger result sets instead of overloading preview queries
list_tablesTable catalogSupports category filter: trading, market, user, system, all
describe_tableTable schema inspectionCan include sample rows

Key documentation updates compared with the older version:

  • The handshake requirement must be documented explicitly.
  • get_market_detail should be listed as a first-class tool.
  • run_query_preview should be treated as the preferred preview-query tool.
  • run_query should be described as a compatibility alias.
  • open_query_stream should be documented for larger exports.

Current Table Inventory

Live list_tables currently returns two trading tables:

TableDescriptionApprox. Rows
---------------------------------
tradesHistorical trade records including trade, mint, burn, and redeem actions~296.6M
positionsCurrent and historical positions~30.5M

These row counts are service-side approximations and may grow over time.


Key Schema Notes

trades

Important columns currently exposed by describe_table("trades"):

  • id
  • created_at
  • updated_at
  • platform
  • wallet_address
  • platform_id
  • tx_hash
  • transaction_hash
  • condition_id
  • trader_id
  • market_id
  • token_id
  • side
  • type
  • outcome
  • outcome_side
  • price
  • size
  • amount
  • fee
  • fee_amount
  • outcome_index
  • profit
  • usd_amount
  • chain_id
  • block_number
  • block_timestamp
  • traded_at

Practical takeaways:

  • amount remains the most portable trade-size field for aggregate SQL.
  • usd_amount is available and nullable, which is useful for whale-style filters.
  • type is not just trade; it also includes mint, burn, and redeem.
  • condition_id and market_id are both available directly in the table, so legacy mapping tables should not be required for normal skill flows.

positions

Important columns currently exposed by describe_table("positions"):

  • id
  • created_at
  • updated_at
  • platform
  • wallet_address
  • trader_id
  • market_id
  • token_id
  • condition_id
  • outcome
  • outcome_index
  • outcome_side
  • size
  • size_frozen
  • avg_price
  • avg_entry_price
  • current_price
  • initial_value
  • current_value
  • total_bought
  • realized_pnl
  • unrealized_pnl
  • unrealized_pnl_percent
  • daily_pnl_change
  • is_redeemable
  • is_closed
  • chain_id
  • last_updated_at
  • opened_at
  • closed_at

Practical takeaways:

  • avg_entry_price, current_price, is_redeemable, and lifecycle timestamps should now be reflected in any field documentation.
  • positions is richer than the older docs implied, so skills can describe both PnL state and lifecycle state more precisely.

Quick Start

const mcp = require("../../polymarket-data-layer/scripts/mcp-client");

// health + handshake
const ok = await mcp.ping();
const health = await mcp.health();
const init = await mcp.initialize();

// high-level tools
const leaderboard = await mcp.getLeaderboard({ period: "7d", rankBy: "pnl", limit: 10 });
const traders = await mcp.getTraders({ sortBy: "pnl_7d", order: "desc", limit: 20 });
const markets = await mcp.getMarkets({ status: "active", search: "Fed", limit: 20 });
const market = await mcp.getMarketDetail("0x...");

// preview query
const rows = await mcp.query(`
  SELECT condition_id, SUM(amount) AS volume_24h
  FROM trades
  WHERE traded_at >= now() - INTERVAL 1 DAY
    AND type = 'trade'
  GROUP BY condition_id
  ORDER BY volume_24h DESC
  LIMIT 20
`);

// streamed query export
const stream = await mcp.openQueryStream(`
  SELECT wallet_address, SUM(amount) AS volume_30d
  FROM trades
  WHERE traded_at >= now() - INTERVAL 30 DAY
  GROUP BY wallet_address
`);

Environment Variables

MCP_URL=https://api.predictradar.ai
MCP_API_KEY=pr_public_predictradar

The wrapper already defaults to these values unless overridden.


Shared Scripts

mcp-client.js

Use this for:

  • session-aware MCP calls
  • preview SQL queries
  • streamed query exports
  • health and initialization checks
  • high-level market and trader tools

Highlights:

  • automatic MCP session handshake
  • retry support for transient network issues
  • openQueryStream, consumeQueryStream, cancelQueryStream, and queryStream
  • wrappers for getTraders, getTraderDetail, getLeaderboard, getMarketStats, getMarkets, getMarketDetail, and searchEvents

mcp-examples.js

Run this when you need to inspect:

  • health and handshake behavior
  • current tool inventory
  • table catalog and schema previews
  • example preview queries
  • stream-export behavior
  • trader lookup examples

gamma-client.js

Use this when a skill needs:

  • market metadata by conditionId
  • market-to-domain mapping
  • keyword-based market discovery
  • event URL resolution

queries.js

Use this for reusable repo-level aggregations such as:

  • all addresses
  • base trading metrics
  • ROI metrics
  • address-to-domain volume breakdowns

smartmoney.js

Use this only when a skill explicitly needs the local smart-money classification layer. Prefer read-only cache access when possible unless the workflow truly requires a fresh classification.

cache.js

Use this for local file-backed cache reads and writes inside longer-running scripts.


Query Guidance

Preview Queries

Use preview SQL when:

  • you need a compact result set
  • the skill only needs top rows or aggregate rows
  • a result set comfortably fits within preview limits

Guidance:

  • use mcp.query(...) or mcp.queryWithRetry(...)
  • keep result sizes tight with LIMIT
  • explicitly filter type = 'trade' when you do not want mint, burn, or redeem

Streamed Exports

Use open_query_stream when:

  • you need more rows than a preview call should return
  • a skill needs a larger export for downstream processing
  • you want a preview plus a temporary stream URL

Fallbacks

If MCP is unavailable:

  1. fall back to polymarket-cli when appropriate
  2. fall back to the Polymarket Data API as a final option

Cache Policy

Recommended cache behavior:

  • prefer cached metadata when freshness is not critical
  • bypass cache when the user explicitly asks for the latest or real-time data
  • treat smart-money classification as a separate cacheable enrichment layer
  • avoid over-caching rapidly changing short-window trading snapshots

Important Notes

  1. condition_id is the canonical cross-system market key.
  2. wallet_address should be normalized to lowercase for SQL comparisons.
  3. run_query is no longer the best term for new docs; describe it as a legacy alias and prefer run_query_preview.
  4. open_query_stream should be mentioned anywhere a skill may need larger result sets.
  5. Skills should not document raw MCP session handling unless they are intentionally teaching low-level protocol behavior; ordinary skills should point to mcp-client.js.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 21:08 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

polymarket-predictradar-market-movers-skills

cnica
Polymarket 市场概率波动检测。实时扫描预测市场的概率波动,帮助用户捕捉信息套利...
★ 0 📥 340

polymarket-predictradar-market-discovery-skills

cnica
Polymarket热门市场排名与新市场发现。按24小时交易量/交易者查看热门市场,发现新上市的高动量市场,浏览活跃市场。
★ 0 📥 317

polymarket-predictradar-daily-anomalies-skills

cnica
Polymarket 每日异常报告。扫描三类市场异常:黑天鹅(2小时内概率突变),鲸鱼战(大额对赌...)
★ 0 📥 285