skills-ws 1.5.4 → 1.5.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skills-ws",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "83 agent skills for AI coding assistants \u2014 marketing, growth, web3, dev, design & operations. Built for OpenClaw, Claude Code, Cursor, and Codex.",
5
5
  "scripts": {
6
6
  "test": "node test/cli.test.mjs"
@@ -0,0 +1,411 @@
1
+ ---
2
+ name: polymarket-trading
3
+ description: Polymarket prediction market trading — market analysis, edge calculation, bookmaker cross-referencing, order placement via CLOB API, position management, and redemption. Covers sports betting strategy, risk management, and the full Polymarket SDK workflow.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Polymarket Trading
8
+
9
+ Complete framework for analyzing, trading, and managing positions on Polymarket — the world's largest prediction market.
10
+
11
+ ## Table of Contents
12
+
13
+ 1. [Market Analysis Framework](#market-analysis-framework)
14
+ 2. [Edge Calculation](#edge-calculation)
15
+ 3. [Bookmaker Cross-Referencing](#bookmaker-cross-referencing)
16
+ 4. [Risk Management Rules](#risk-management-rules)
17
+ 5. [APIs & Data Sources](#apis--data-sources)
18
+ 6. [Trading via CLOB](#trading-via-clob)
19
+ 7. [Position Management & Redemption](#position-management--redemption)
20
+ 8. [Understanding Polymarket Mechanics](#understanding-polymarket-mechanics)
21
+ 9. [Common Pitfalls](#common-pitfalls)
22
+
23
+ ---
24
+
25
+ ## Market Analysis Framework
26
+
27
+ ### The Scan Pipeline
28
+
29
+ For every potential bet, follow this pipeline in order:
30
+
31
+ ```
32
+ 1. Polymarket prices → identify markets with volume > $10K
33
+ 2. Filter → bookmaker favorites > 65% implied probability
34
+ 3. Injury/news check → any material changes not priced in?
35
+ 4. Form & H2H analysis → recent performance, matchup history
36
+ 5. Cross-reference 3+ bookmaker sources → calculate true probability
37
+ 6. Calculate edge → only bet if edge > 10% vs Polymarket price
38
+ 7. Size the bet → based on edge magnitude and bankroll
39
+ ```
40
+
41
+ ### Market Selection Criteria
42
+
43
+ **Good markets:**
44
+ - High volume (> $10K) — ensures liquidity for entry and exit
45
+ - Near-term resolution (days, not months) — capital efficiency
46
+ - Binary outcomes with clear resolution criteria
47
+ - Markets where bookmaker odds exist for cross-referencing
48
+
49
+ **Bad markets:**
50
+ - Low liquidity (< $5K volume) — wide spreads eat your edge
51
+ - Subjective resolution criteria — dispute risk
52
+ - Markets with insider information advantage (crypto governance, company decisions)
53
+ - Long-dated futures that tie up capital for months
54
+
55
+ ---
56
+
57
+ ## Edge Calculation
58
+
59
+ ### The Math
60
+
61
+ ```
62
+ Bookmaker Implied Probability = 1 / Decimal Odds
63
+ Edge = (True Probability - Polymarket Price) / Polymarket Price × 100
64
+
65
+ Example:
66
+ Bookmaker odds: -225 (decimal 1.44) → Implied probability: 69.4%
67
+ Polymarket price: $0.645 (64.5%)
68
+ Edge = (69.4 - 64.5) / 64.5 × 100 = 7.6%
69
+ ```
70
+
71
+ ### American Odds to Probability
72
+
73
+ ```
74
+ Negative odds (favorites): Probability = |odds| / (|odds| + 100)
75
+ -225 → 225 / 325 = 69.2%
76
+
77
+ Positive odds (underdogs): Probability = 100 / (odds + 100)
78
+ +150 → 100 / 250 = 40.0%
79
+ ```
80
+
81
+ ### Removing the Vig
82
+
83
+ Bookmaker odds include a margin (vig). To get true probabilities:
84
+
85
+ ```
86
+ 1. Convert both sides to implied probabilities
87
+ 2. Sum them (will be > 100%, e.g., 105%)
88
+ 3. Divide each by the sum to normalize to 100%
89
+
90
+ Example:
91
+ Team A: -200 → 66.7% Team B: +170 → 37.0%
92
+ Sum: 103.7%
93
+ True A: 66.7 / 103.7 = 64.3%
94
+ True B: 37.0 / 103.7 = 35.7%
95
+ ```
96
+
97
+ ### Edge Thresholds
98
+
99
+ | Edge | Action |
100
+ |------|--------|
101
+ | < 5% | Skip — too thin, transaction costs eat it |
102
+ | 5-10% | Marginal — only if very high conviction + multiple sources agree |
103
+ | **> 10%** | **Target zone — place the bet** |
104
+ | > 20% | Strong edge — size up, but verify it's not a trap (news you missed?) |
105
+
106
+ ---
107
+
108
+ ## Bookmaker Cross-Referencing
109
+
110
+ ### Why Cross-Reference?
111
+
112
+ Polymarket prices are set by traders, not oddsmakers. They systematically:
113
+ - **Overvalue favorites** by 3-7% in major sports markets
114
+ - **Undervalue underdogs/draws** in 3-way football markets
115
+ - **Lag behind** sharp bookmaker lines by hours
116
+
117
+ ### Sources to Cross-Reference
118
+
119
+ | Source | Use | Notes |
120
+ |--------|-----|-------|
121
+ | **Pinnacle** | Sharpest lines globally | Gold standard, lowest vig |
122
+ | **Bet365** | Popular, liquid markets | Good for mainstream sports |
123
+ | **DraftKings/FanDuel** | US sports | NFL, NBA, MLB, NHL |
124
+ | **Betfair Exchange** | True market prices | No vig, just commission |
125
+ | **OddsPortal/OddsChecker** | Aggregators | Compare across 20+ books |
126
+ | **Action Network** | Analysis + odds | Good injury/form context |
127
+
128
+ ### The 3-Source Rule
129
+
130
+ Never bet based on a single bookmaker. Always confirm with **3+ independent sources**:
131
+
132
+ ```
133
+ ✅ Good: Pinnacle -220, Bet365 -225, DraftKings -215 → consensus ~69%
134
+ Polymarket at 60¢ → 15% edge → BET
135
+
136
+ ❌ Bad: Only one bookmaker has odds, others don't list the market
137
+ → Information asymmetry, you might be wrong
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Risk Management Rules
143
+
144
+ ### Bankroll Management
145
+
146
+ ```
147
+ Max single bet: 10% of bankroll
148
+ Typical bet size: 2-5% of bankroll
149
+ Max daily exposure: 25% of bankroll
150
+ ```
151
+
152
+ ### Hard Rules
153
+
154
+ 1. **Sport only** — No crypto, politics, or geopolitics bets. Crypto markets are manipulated by insiders.
155
+ 2. **Only heavy favorites** — Bookmaker implied probability > 65%
156
+ 3. **Edge > 10%** — No exceptions for "gut feelings"
157
+ 4. **3+ sources minimum** — Cross-reference before every bet
158
+ 5. **No long shots** — Underdogs and parlays are money pits
159
+ 6. **The best trade is sometimes no trade** — Don't force action
160
+
161
+ ### When NOT to Bet
162
+
163
+ - Market is illiquid (< $5K volume, wide spreads)
164
+ - News is breaking and odds haven't settled
165
+ - You can't find 3 bookmakers listing the event
166
+ - The edge comes from a single outlier source
167
+ - You're chasing losses from a previous bet
168
+ - Resolution criteria are ambiguous
169
+
170
+ ### Track Record Requirements
171
+
172
+ - Target **80%+ win rate** on individual bets
173
+ - If below 60% over 10+ bets, stop and re-evaluate strategy
174
+ - Log every bet: market, entry price, bookmaker consensus, edge, result
175
+
176
+ ---
177
+
178
+ ## APIs & Data Sources
179
+
180
+ ### Gamma API (Public, No Auth)
181
+
182
+ Market discovery and search. Base: `https://gamma-api.polymarket.com`
183
+
184
+ ```
185
+ GET /public-search?q=<query> — Search markets/events
186
+ GET /events?active=true&closed=false — List active events
187
+ GET /events?tag_slug=<slug> — Events by category (sports, politics, crypto)
188
+ GET /markets?slug=<slug> — Market details by slug
189
+ GET /tags — All available categories
190
+ ```
191
+
192
+ **Key response fields:**
193
+ - `outcomePrices` — Current Yes/No prices (JSON string, parse it)
194
+ - `clobTokenIds` — Token IDs needed for CLOB trading (JSON string)
195
+ - `volume` — Total dollar volume traded
196
+ - `negRisk` — If true, uses negRisk contract (multi-outcome markets)
197
+ - `groupItemTitle` — The outcome name in grouped markets
198
+
199
+ ### CLOB API (Public reads, Auth for trading)
200
+
201
+ Order book and trading. Base: `https://clob.polymarket.com`
202
+
203
+ ```
204
+ # Public (no auth)
205
+ GET /midpoint?token_id=<id> — Midpoint price
206
+ GET /book?token_id=<id> — Full order book
207
+ GET /spread?token_id=<id> — Bid-ask spread
208
+ GET /price?token_id=<id>&side=buy|sell — Best available price
209
+ GET /tick-size?token_id=<id> — Min price increment
210
+
211
+ # Authenticated (requires L2 API key)
212
+ POST /order — Place order
213
+ DELETE /order/<id> — Cancel order
214
+ GET /orders — Open orders
215
+ GET /balances — CLOB balances
216
+ ```
217
+
218
+ ### Data API (Public, No Auth)
219
+
220
+ Positions and history. Base: `https://data-api.polymarket.com`
221
+
222
+ ```
223
+ GET /positions?user=<wallet_address> — All positions for a wallet
224
+ GET /trades?user=<wallet_address> — Trade history
225
+ ```
226
+
227
+ ### Authentication Model
228
+
229
+ Two-layer auth system:
230
+ - **L1 (Wallet Signature)**: EIP-712 signature from your Polygon wallet — used to derive API credentials
231
+ - **L2 (API Key)**: HMAC-SHA256 headers for all trading operations
232
+
233
+ **Headers for authenticated requests:**
234
+ ```
235
+ POLY_ADDRESS — Wallet address
236
+ POLY_SIGNATURE — HMAC signature of request
237
+ POLY_TIMESTAMP — Unix timestamp
238
+ POLY_NONCE — Request nonce
239
+ POLY_API_KEY — Your API key
240
+ POLY_PASSPHRASE — Your passphrase
241
+ POLY_SECRET — Your API secret (used for HMAC)
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Trading via CLOB
247
+
248
+ ### Using the TypeScript SDK
249
+
250
+ ```javascript
251
+ const { ClobClient, Side } = require('@polymarket/clob-client');
252
+ const { Wallet } = require('ethers');
253
+
254
+ // Initialize client
255
+ const wallet = new Wallet(PRIVATE_KEY);
256
+ const client = new ClobClient(
257
+ 'https://clob.polymarket.com',
258
+ 137, // Polygon chainId
259
+ wallet,
260
+ creds // { apiKey, secret, passphrase }
261
+ );
262
+
263
+ // Derive API credentials (first time)
264
+ const creds = await client.createOrDeriveApiKey();
265
+
266
+ // Place a limit buy order
267
+ const order = await client.createAndPostOrder({
268
+ tokenID: '<token_id>', // From Gamma API clobTokenIds
269
+ price: 0.65, // Max price willing to pay
270
+ size: 10, // Dollar amount
271
+ side: Side.BUY,
272
+ }, { tickSize: '0.01' }); // Check tick-size endpoint first
273
+
274
+ // Cancel an order
275
+ await client.cancelOrder(orderId);
276
+
277
+ // Get open orders
278
+ const orders = await client.getOpenOrders();
279
+ ```
280
+
281
+ ### Order Flow
282
+
283
+ ```
284
+ 1. Search market on Gamma → get slug
285
+ 2. Get market details → extract clobTokenIds and outcomePrices
286
+ 3. Identify the outcome you want (Yes token ID vs No token ID)
287
+ 4. Check tick-size for that token
288
+ 5. Check current best price: GET /price?token_id=X&side=buy
289
+ 6. Place limit order at your target price
290
+ 7. Monitor: GET /orders to check if filled
291
+ ```
292
+
293
+ ### Token ID Selection
294
+
295
+ Grouped markets (like "Who wins UFC 326?") have multiple outcomes. Each outcome has a Yes and No token:
296
+
297
+ ```
298
+ Market: "UFC 326 Main Event"
299
+ Outcome: "Max Holloway"
300
+ → Yes Token ID: 7068099725... (buy this if you think Holloway wins)
301
+ → No Token ID: 1293847561... (buy this if you think Holloway loses)
302
+ Outcome: "Charles Oliveira"
303
+ → Yes Token ID: 8843920183...
304
+ → No Token ID: 5567382910...
305
+ ```
306
+
307
+ The Gamma API returns `clobTokenIds` as a JSON string with `[NoTokenId, YesTokenId]` — **index 1 is Yes**.
308
+
309
+ ---
310
+
311
+ ## Position Management & Redemption
312
+
313
+ ### Checking Positions
314
+
315
+ ```
316
+ GET https://data-api.polymarket.com/positions?user=<wallet_address>
317
+ ```
318
+
319
+ Returns all current positions with:
320
+ - `asset` — Token ID
321
+ - `size` — Number of shares
322
+ - `avgPrice` — Average entry price
323
+ - `currentPrice` — Current market price
324
+ - `pnl` — Unrealized P&L
325
+
326
+ ### Redeeming Resolved Positions
327
+
328
+ When a market resolves, winning shares are worth $1.00. You need to call the contract to redeem:
329
+
330
+ **Standard markets** (2-outcome, `negRisk: false`):
331
+ ```javascript
332
+ // Call ConditionalTokens contract: redeemPositions()
333
+ const CTF_ADDRESS = '0x4D97DCd97eC945f40cF65F87097ACe5EA0476045';
334
+ ```
335
+
336
+ **NegRisk markets** (multi-outcome, `negRisk: true`):
337
+ ```javascript
338
+ // Call NegRiskAdapter: redeemPositions()
339
+ const NEG_RISK_ADAPTER = '0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296';
340
+ // Also call NegRiskCTFExchange for conversion
341
+ const NEG_RISK_EXCHANGE = '0xC5d563A36AE78145C45a50134d48A1215220f80a';
342
+ ```
343
+
344
+ ### Exit Strategies
345
+
346
+ - **Winner**: Hold until resolution → redeem at $1.00
347
+ - **Cut losses**: Sell on the CLOB if the market moves against you
348
+ - **Take profit**: If price moved significantly in your favor before resolution, consider selling early to lock in gains and free capital
349
+
350
+ ---
351
+
352
+ ## Understanding Polymarket Mechanics
353
+
354
+ ### How Prices Work
355
+
356
+ - Prices = probabilities ($0.65 = market says 65% chance of Yes)
357
+ - Markets resolve to $1.00 (correct outcome) or $0.00 (incorrect)
358
+ - Your profit = $1.00 - entry price (per share, if you win)
359
+ - Your loss = entry price (per share, if you lose)
360
+
361
+ ### Where Polymarket Misprices
362
+
363
+ | Pattern | Why | How to Exploit |
364
+ |---------|-----|----------------|
365
+ | Favorites overvalued by 3-7% | Retail bias toward "safe" bets | Compare vs sharp bookmaker lines |
366
+ | Underdogs/draws undervalued | People avoid complexity | 3-way football markets (win/draw/lose) |
367
+ | Slow to react to news | Traders aren't 24/7 | Fast reaction to injury reports, lineups |
368
+ | Low-volume markets inefficient | Not enough informed traders | Small edges in niche markets |
369
+
370
+ ### Polymarket vs Bookmakers
371
+
372
+ | Feature | Polymarket | Traditional Bookmaker |
373
+ |---------|-----------|----------------------|
374
+ | Vig/margin | 0% (peer-to-peer) | 3-10% |
375
+ | Liquidity | Variable | Guaranteed |
376
+ | Resolution | Smart contract | Bookmaker decides |
377
+ | Settlement | USDC on Polygon | Fiat |
378
+ | Edge | Retail-driven inefficiencies | Sharp lines, hard to beat |
379
+
380
+ ### Chain Details
381
+
382
+ - **Chain**: Polygon (MATIC for gas, USDC.e for trading)
383
+ - **USDC.e contract**: `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174`
384
+ - **Note**: Polymarket uses USDC.e (bridged), NOT native USDC
385
+ - **Geo**: Restricted in some countries (US blocked, most of EU is fine)
386
+
387
+ ---
388
+
389
+ ## Common Pitfalls
390
+
391
+ ### ❌ Mistakes to Avoid
392
+
393
+ 1. **Betting on crypto/politics markets** — Insider manipulation is rampant (project teams, whale wallets, political operatives)
394
+ 2. **Chasing long shots** — A 5¢ token that could pay $1 sounds amazing; it almost never hits
395
+ 3. **Ignoring liquidity** — A "great price" means nothing if you can't exit
396
+ 4. **Single-source analysis** — One bookmaker can be wrong; always cross-reference
397
+ 5. **Overexposure** — Never have > 25% of bankroll in active bets
398
+ 6. **Ignoring the vig** — Bookmaker odds include margin; remove it before comparing
399
+ 7. **Trading illiquid markets** — Wide spreads (> 5¢) silently destroy your edge
400
+ 8. **Holding long-dated positions** — Capital is locked; shorter resolution = better capital efficiency
401
+ 9. **Not tracking results** — Without a log, you can't evaluate if your strategy works
402
+ 10. **Emotional trading** — If you just lost, don't immediately place another bet
403
+
404
+ ### ✅ Habits of Profitable Traders
405
+
406
+ 1. Systematic scan pipeline for every bet (not ad-hoc)
407
+ 2. Spreadsheet tracking all bets with entry, target, result, edge
408
+ 3. Walk away when there's no edge — most days have no good bets
409
+ 4. Focus on 1-2 sports you know deeply rather than spreading thin
410
+ 5. Check injury reports, team news, and lineup confirmations before betting
411
+ 6. Review win/loss ratio monthly and adjust thresholds if needed