Files
vibe-coding-cn/assets/skills/polymarket/SKILL.md
T

142 lines
4.7 KiB
Markdown
Raw Normal View History

2025-12-13 17:00:54 +08:00
---
name: polymarket
2026-04-28 19:14:07 +08:00
description: "Polymarket prediction-market skill: REST/API research, CLOB market data, trading integration boundaries, WebSocket real-time data client, subscriptions, filters, authentication, and LLM-oriented market monitoring."
2025-12-13 17:00:54 +08:00
---
2026-04-28 19:14:07 +08:00
# polymarket Skill
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
Use this skill to build Polymarket research, monitoring, market-data, and integration workflows while keeping trading/authentication risks explicit.
2025-12-13 17:00:54 +08:00
## When to Use This Skill
2026-04-28 19:14:07 +08:00
Trigger when any of these applies:
- Querying Polymarket markets, events, prices, trades, comments, RFQ, or CLOB data.
- Building prediction-market monitors, dashboards, alerts, or LLM market-analysis tools.
- Using the `@polymarket/real-time-data-client` WebSocket client.
- Subscribing to activity, comments, RFQ, crypto price, `clob_market`, or authenticated `clob_user` topics.
- Debugging subscription filters, authentication payloads, reconnect handling, or message processing.
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
## Not For / Boundaries
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- Not financial advice, market-making advice, or a guarantee of trading profitability.
- Do not expose CLOB API keys, secrets, passphrases, wallet keys, or private signing material.
- Private user streams and trading actions require explicit authentication and security review.
- Required inputs: market/event slug or CLOB market id, topic/type, auth need, filter payload, runtime, and expected output.
- For live trading, verify API terms, regional restrictions, auth scheme, and risk controls before implementation.
2025-12-13 17:00:54 +08:00
## Quick Reference
2026-04-28 19:14:07 +08:00
### Common Patterns
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
**Install the real-time data client**
2025-12-13 17:00:54 +08:00
```bash
npm install @polymarket/real-time-data-client
```
2026-04-28 19:14:07 +08:00
**Subscribe to live trades**
2025-12-13 17:00:54 +08:00
```typescript
import { RealTimeDataClient } from "@polymarket/real-time-data-client";
2026-04-28 19:14:07 +08:00
const client = new RealTimeDataClient({
onMessage: (message) => console.log(message.topic, message.type, message.payload),
onConnect: (c) => c.subscribe({
subscriptions: [{ topic: "activity", type: "trades" }],
}),
});
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
client.connect();
2025-12-13 17:00:54 +08:00
```
2026-04-28 19:14:07 +08:00
**Filter activity to one market slug**
2025-12-13 17:00:54 +08:00
```typescript
client.subscribe({
2026-04-28 19:14:07 +08:00
subscriptions: [{
topic: "activity",
type: "trades",
filters: "{\"market_slug\":\"btc-above-100k-2024\"}",
}],
2025-12-13 17:00:54 +08:00
});
```
2026-04-28 19:14:07 +08:00
**Subscribe to CLOB market price changes**
2025-12-13 17:00:54 +08:00
```typescript
client.subscribe({
2026-04-28 19:14:07 +08:00
subscriptions: [{
topic: "clob_market",
type: "price_change",
filters: "[\"100\",\"101\",\"102\"]",
}],
2025-12-13 17:00:54 +08:00
});
```
2026-04-28 19:14:07 +08:00
**Subscribe to comments for an event**
2025-12-13 17:00:54 +08:00
```typescript
client.subscribe({
2026-04-28 19:14:07 +08:00
subscriptions: [{
topic: "comments",
type: "*",
filters: "{\"parentEntityID\":12345,\"parentEntityType\":\"Event\"}",
}],
2025-12-13 17:00:54 +08:00
});
```
2026-04-28 19:14:07 +08:00
**Authenticate a user stream**
2025-12-13 17:00:54 +08:00
```typescript
client.subscribe({
2026-04-28 19:14:07 +08:00
subscriptions: [{
topic: "clob_user",
type: "*",
clob_auth: {
key: "YOUR_API_KEY",
secret: "YOUR_API_SECRET",
passphrase: "YOUR_PASSPHRASE",
},
}],
2025-12-13 17:00:54 +08:00
});
```
2026-04-28 19:14:07 +08:00
## Examples
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
### Example 1: Public Trade Monitor
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- Input: market slug and alert threshold.
- Steps:
1. Subscribe to `activity/trades` with a `market_slug` filter.
2. Normalize messages into timestamp, market, side, price, size.
3. Alert only when trade size or price movement crosses the configured threshold.
- Expected output / acceptance: real-time public trade stream with no private authentication material.
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
### Example 2: CLOB Price Dashboard
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- Input: CLOB market IDs.
- Steps:
1. Subscribe to `clob_market/price_change` with a JSON array filter.
2. Update an in-memory view keyed by market id.
3. Persist snapshots at a controlled interval rather than every message if volume is high.
- Expected output / acceptance: dashboard shows latest market prices and handles reconnects idempotently.
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
### Example 3: Authenticated User Order Feed
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- Input: CLOB API credentials stored in a secret manager.
- Steps:
1. Load credentials at runtime without logging them.
2. Subscribe to `clob_user` order/trade events.
3. Validate message schema and write audit logs without secrets.
- Expected output / acceptance: private user updates are received and secrets never appear in source control or logs.
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
## References
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- `references/index.md`: navigation for local Polymarket references.
- `references/api.md`: platform API documentation.
- `references/getting_started.md`: onboarding and setup notes.
- `references/trading.md`: trading and market operations.
- `references/realtime-client.md`: WebSocket real-time data client.
- `references/README.md`: platform overview.
- `references/llms.md` and `references/llms-full.md`: LLM integration material.
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
## Maintenance
2025-12-13 17:00:54 +08:00
2026-04-28 19:14:07 +08:00
- Sources: local `references/` extracted from Polymarket platform and real-time client documentation.
- Last updated: 2026-04-28
- Known limits: API auth, market availability, and regional/legal constraints must be verified outside this skill before live trading.