Skip to content
Back to search

polyclaw

Trading-enabled Polymarket skill for OpenClaw - browse markets, execute trades, track positions, discover hedges

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/chainstacklabs--polyclaw/badge.svg)](/listings/chainstacklabs--polyclaw)

HTML

<a href="/listings/chainstacklabs--polyclaw"><img src="/api/listings/chainstacklabs--polyclaw/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Install skill

**Option A: Install from ClawHub (recommended)**

clawhub install polyclaw
cd ~/.openclaw/skills/polyclaw
uv sync

**Option B: Manual install**

cp -r polyclaw ~/.openclaw/skills/
cd ~/.openclaw/skills/polyclaw
uv sync

2. Configure environment variables

Add the following to your `openclaw.json` under `skills.entries.polyclaw.env`:

"polyclaw": {
  "enabled": true,
  "env": {
    "CHAINSTACK_NODE": "https://polygon-mainnet.core.chainstack.com/YOUR_KEY",
    "POLYCLAW_PRIVATE_KEY": "0x...",
    "OPENROUTER_API_KEY": "sk-or-v1-..."
  }
}

**Where to get the keys:** - **Chainstack node** — [Sign up at Chainstack](https://console.chainstack.com) (free tier available, sign up with GitHub, X, or Google) - **OpenRouter API key** — [Create key at OpenRouter](https://openrouter.ai/settings/keys)

**Security warning:** Keep only small amounts in this wallet. Withdraw regularly to a secure wallet.

> **Looking for standalone CLI usage?** This skill is designed for OpenClaw. For standalone CLI usage without OpenClaw, see [polymarket-alpha-bot](https://github.com/chainstacklabs/polymarket-alpha-bot).

3. First-time setup (required for trading)

Before your first trade, set Polymarket contract approvals (one-time, costs ~0.01 POL in gas):

uv run python scripts/polyclaw.py wallet approve

This submits 6 approval transactions to Polygon. You only need to do this once per wallet.

4. Run commands

# Browse markets
uv run python scripts/polyclaw.py markets trending
uv run python scripts/polyclaw.py markets search "election"

# Find hedging opportunities
uv run python scripts/polyclaw.py hedge scan --limit 10

# Check wallet and trade
uv run python scripts/polyclaw.py wallet status
uv run python scripts/polyclaw.py buy <market_id> YES 50

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 215 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: polyclaw
  3. description: "Trade on Polymarket via split + CLOB execution. Browse markets, track positions with P&L, discover hedges via LLM. Polygon/Web3."
  4. metadata: {"openclaw":{"emoji":"🦞","homepage":"https://polymarket.com","primaryEnv":"POLYCLAW_PRIVATE_KEY","requires":{"bins":["uv"],"env":["CHAINSTACK_NODE","POLYCLAW_PRIVATE_KEY"]},"install":[{"id":"uv-brew","kind":"brew","formula":"uv","bins":["uv"],"label":"Install uv (brew)"}]},"clawdbot":{"emoji":"🦞","homepage":"https://polymarket.com","primaryEnv":"POLYCLAW_PRIVATE_KEY","requires":{"bins":["uv"],"env":["CHAINSTACK_NODE","POLYCLAW_PRIVATE_KEY"]},"install":[{"id":"uv-brew","kind":"brew","formula":"uv","bins":["uv"],"label":"Install uv (brew)"}]}}
  5. ---
  6. # PolyClaw
  7. Trading-enabled Polymarket skill for OpenClaw. Browse markets, manage wallets, execute trades, and track positions.
  8. ## Features
  9. - **Market Browsing** - Search and browse Polymarket prediction markets
  10. - **Wallet Management** - Env-var based wallet configuration
  11. - **Trading** - Buy YES/NO positions via split + CLOB execution
  12. - **Position Tracking** - Track entry prices, current prices, and P&L
  13. - **Hedge Discovery** - LLM-powered covering portfolio discovery via logical implications
  14. ## Quick Start
  15. First, install dependencies (from skill directory):
  16. ```bash
  17. cd {baseDir}
  18. uv sync
  19. ```
  20. ### First-Time Setup (Required for Trading)
  21. Before your first trade, set Polymarket contract approvals (one-time, costs ~0.01 POL in gas):
  22. ```bash
  23. uv run python scripts/polyclaw.py wallet approve
  24. ```
  25. This submits 6 approval transactions to Polygon. You only need to do this once per wallet.
  26. ### Browse Markets
  27. ```bash
  28. # Trending markets by volume
  29. uv run python scripts/polyclaw.py markets trending
  30. # Search markets
  31. uv run python scripts/polyclaw.py markets search "election"
  32. # Market details (returns full JSON with all fields)
  33. uv run python scripts/polyclaw.py market <market_id>
  34. ```
  35. **Output options:**
  36. - Default output is a formatted table (good for display)
  37. - Use `--full` flag for full question text without truncation
  38. - Use `--json` flag via `scripts/markets.py --json trending` for structured JSON output
  39. ### Wallet Management
  40. ```bash
  41. # Check wallet status (address, balances)
  42. uv run python scripts/polyclaw.py wallet status
  43. # Set contract approvals (one-time)
  44. uv run python scripts/polyclaw.py wallet approve
  45. ```
  46. The wallet is configured via the `POLYCLAW_PRIVATE_KEY` environment variable.
  47. ### Trading
  48. ```bash
  49. # Buy YES position for $50
  50. uv run python scripts/polyclaw.py buy <market_id> YES 50
  51. # Buy NO position for $25
  52. uv run python scripts/polyclaw.py buy <market_id> NO 25
  53. ```
  54. ### Positions
  55. ```bash
  56. # List all positions with P&L
  57. uv run python scripts/polyclaw.py positions
  58. ```
  59. ### Hedge Discovery
  60. Find covering portfolios - pairs of market positions that hedge each other via contrapositive logic.
  61. ```bash
  62. # Scan trending markets for hedges
  63. uv run python scripts/polyclaw.py hedge scan
  64. # Scan markets matching a query
  65. uv run python scripts/polyclaw.py hedge scan --query "election"
  66. # Analyze specific markets for hedging relationship
  67. uv run python scripts/polyclaw.py hedge analyze <market_id_1> <market_id_2>
  68. ```
  69. **Output options:**
  70. - Default output is a formatted table showing Tier, Coverage, Cost, Target, and Cover
  71. - Use `--json` flag for structured JSON output
  72. - Use `--min-coverage 0.90` to filter by minimum coverage (default 0.85)
  73. - Use `--tier 1` to filter by tier (1=best, default 2)
  74. **Coverage tiers:**
  75. - **Tier 1 (HIGH):** >=95% coverage - near-arbitrage opportunities
  76. - **Tier 2 (GOOD):** 90-95% - strong hedges
  77. - **Tier 3 (MODERATE):** 85-90% - decent but noticeable risk
  78. - **Tier 4 (LOW):** <85% - speculative (filtered by default)
  79. **LLM model:** Uses `nvidia/nemotron-nano-9b-v2:free` via OpenRouter. Model selection matters — some models find spurious correlations while others (like DeepSeek R1) have output format issues. Override with `--model <model_id>` if needed.
  80. ## Security
  81. For the MVP, the private key is stored in an environment variable for simplicity and Claude Code compatibility.
  82. **Security Warning:** Keep only small amounts in this wallet. Withdraw regularly to a secure wallet.
  83. ## Environment Variables
  84. | Variable | Required | Description |
  85. |----------|----------|-------------|
  86. | `CHAINSTACK_NODE` | Yes (trading) | Polygon RPC URL |
  87. | `OPENROUTER_API_KEY` | Yes (hedge) | OpenRouter API key for LLM hedge discovery |
  88. | `POLYCLAW_PRIVATE_KEY` | Yes (trading) | EVM private key (hex, with or without 0x prefix) |
  89. | `HTTPS_PROXY` | Recommended | Rotating residential proxy for CLOB (e.g., IPRoyal) |
  90. | `CLOB_MAX_RETRIES` | No | Max CLOB retries with IP rotation (default: 5) |
  91. | `POLY_BUILDER_CODE` | No | Bytes32 builder code for attribution (from polymarket.com/settings?tab=builder). Attached to every order when set. |
  92. **Security Warning:** Keep only small amounts in this wallet. Withdraw regularly to a secure wallet. The private key in an env var is convenient for automation but less secure than encrypted storage.
  93. ## Trading Flow
  94. 1. **Split Position** - pUSD is split into YES + NO tokens via CTF contract
  95. 2. **Sell Unwanted** - The unwanted side is sold via CLOB order book (V2)
  96. 3. **Result** - You hold the wanted position, recovered partial cost from selling unwanted
  97. Example: Buy YES at $0.70
  98. - Split $100 pUSD → 100 YES + 100 NO tokens
  99. - Sell 100 NO tokens at ~$0.30 → recover ~$27 pUSD
  100. - Net cost: ~$73 for 100 YES tokens (entry: $0.73)
  101. If you only have USDC.e, wrap it 1:1 into pUSD via the Collateral Onramp's `wrap()` function before trading.
  102. ## Polymarket Contracts (Polygon Mainnet, CLOB V2)
  103. - **pUSD (collateral):** `0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB`
  104. - **USDC.e (onramp input):** `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174`
  105. - **Collateral Onramp:** `0x93070a847efEf7F70739046A929D47a521F5B8ee`
  106. - **CTF (Conditional Tokens):** `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045`
  107. - **CTF Exchange (V2):** `0xE111180000d2663C0091e4f400237545B87B996B`
  108. - **Neg Risk CTF Exchange (V2):** `0xe2222d279d744050d28e00520010520000310F59`
  109. ## Dependencies
  110. Install with uv (from skill directory):
  111. ```bash
  112. cd {baseDir}
  113. uv sync
  114. ```
  115. ## Limitations
  116. - Trading requires wallet approval setup (one-time)
  117. - CLOB sells may fail if liquidity is insufficient
  118. ### CLOB Cloudflare Blocking
  119. Polymarket's CLOB API uses Cloudflare protection that blocks POST requests from many IPs, including datacenter IPs and some residential ISPs. This affects the "sell unwanted tokens" step.
  120. **Solution: Residential proxy with retry logic**
  121. The recommended setup uses a rotating residential proxy (e.g., IPRoyal, BrightData). The CLOB client automatically retries with new IPs until one works:
  122. ```bash
  123. export HTTPS_PROXY="http://user:pass@geo.iproyal.com:12321"
  124. export CLOB_MAX_RETRIES=10 # Default is 5
  125. ```
  126. With this setup, CLOB orders typically succeed within 5-10 retries as the proxy rotates through IPs until finding an unblocked one.
  127. **Alternative workarounds:**
  128. 1. **Use `--skip-sell`** — Keep both YES and NO tokens, sell manually on polymarket.com
  129. 2. **No proxy** — Split still works; only CLOB sell is affected
  130. If CLOB fails after all retries, your split still succeeded. The output tells you how many tokens to sell manually.
  131. ## Troubleshooting
  132. ### "No wallet available"
  133. Set the `POLYCLAW_PRIVATE_KEY` environment variable:
  134. ```bash
  135. export POLYCLAW_PRIVATE_KEY="0x..."
  136. ```
  137. ### "Insufficient pUSD"
  138. Check balance with `uv run python scripts/polyclaw.py wallet status`. Trades require pUSD (Polymarket USD). If you have USDC.e, wrap it 1:1 via the Collateral Onramp (`0x9307...B8ee`) — the polymarket.com UI does this automatically; API users wrap manually.
  139. ### "CLOB order failed"
  140. The CLOB sell may fail due to:
  141. - Insufficient liquidity at the sell price
  142. - IP blocked by Cloudflare (try proxy)
  143. Your split still succeeded - you have the tokens, just couldn't sell unwanted side.
  144. ### "Approvals not set"
  145. First trade requires contract approvals. Run:
  146. ```bash
  147. uv run python scripts/polyclaw.py wallet approve
  148. ```
  149. ## License
  150. Apache 2.0
README.md · README · 357 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # PolyClaw
  2. **Trading-enabled Polymarket skill for OpenClaw.**
  3. Browse prediction markets, execute trades on-chain, and discover hedging opportunities using LLM-powered analysis. Full trading capability via split + CLOB execution on Polygon.
  4. > **Disclaimer:** This software is provided as-is for educational and experimental purposes. It is not financial advice. Trading prediction markets involves risk of loss. This code has not been audited. Use at your own risk and only with funds you can afford to lose.
  5. 📺 **[Watch the video explainer](https://www.youtube.com/watch?v=s_uP802NVTE)**
  6. ## Features
  7. ### Market browsing
  8. - `polyclaw markets trending` — Top markets by 24h volume
  9. - `polyclaw markets search "query"` — Search markets by keyword
  10. - `polyclaw market <id>` — Market details with prices
  11. ### Trading
  12. - `polyclaw buy <market_id> YES <amount>` — Buy YES position
  13. - `polyclaw buy <market_id> NO <amount>` — Buy NO position
  14. - Split + CLOB execution (split pUSD → YES+NO, sell unwanted side)
  15. ### Position tracking
  16. - `polyclaw positions` — List open positions with live P&L
  17. - `polyclaw position <id>` — Detailed position view
  18. - Positions tracked locally in `~/.openclaw/polyclaw/positions.json`
  19. ### Wallet management
  20. - `polyclaw wallet status` — Show address, POL / pUSD / USDC.e balances
  21. - `polyclaw wallet approve` — Set Polymarket contract approvals (one-time)
  22. ### Hedge discovery
  23. - `polyclaw hedge scan` — Scan trending markets for hedging opportunities
  24. - `polyclaw hedge scan --query "topic"` — Scan markets matching a query
  25. - `polyclaw hedge analyze <id1> <id2>` — Analyze specific market pair
  26. Uses LLM-powered contrapositive logic to find covering portfolios. Only logically necessary implications are accepted — correlations and "likely" relationships are rejected.
  27. **Coverage tiers:** T1 (≥95%), T2 (90-95%), T3 (85-90%)
  28. ## Quick start
  29. ### 1. Install skill
  30. **Option A: Install from ClawHub (recommended)**
  31. ```bash
  32. clawhub install polyclaw
  33. cd ~/.openclaw/skills/polyclaw
  34. uv sync
  35. ```
  36. **Option B: Manual install**
  37. ```bash
  38. cp -r polyclaw ~/.openclaw/skills/
  39. cd ~/.openclaw/skills/polyclaw
  40. uv sync
  41. ```
  42. ### 2. Configure environment variables
  43. Add the following to your `openclaw.json` under `skills.entries.polyclaw.env`:
  44. ```json
  45. "polyclaw": {
  46. "enabled": true,
  47. "env": {
  48. "CHAINSTACK_NODE": "https://polygon-mainnet.core.chainstack.com/YOUR_KEY",
  49. "POLYCLAW_PRIVATE_KEY": "0x...",
  50. "OPENROUTER_API_KEY": "sk-or-v1-..."
  51. }
  52. }
  53. ```
  54. **Where to get the keys:**
  55. - **Chainstack node** — [Sign up at Chainstack](https://console.chainstack.com) (free tier available, sign up with GitHub, X, or Google)
  56. - **OpenRouter API key** — [Create key at OpenRouter](https://openrouter.ai/settings/keys)
  57. **Security warning:** Keep only small amounts in this wallet. Withdraw regularly to a secure wallet.
  58. > **Looking for standalone CLI usage?** This skill is designed for OpenClaw. For standalone CLI usage without OpenClaw, see [polymarket-alpha-bot](https://github.com/chainstacklabs/polymarket-alpha-bot).
  59. ### 3. First-time setup (required for trading)
  60. Before your first trade, set Polymarket contract approvals (one-time, costs ~0.01 POL in gas):
  61. ```bash
  62. uv run python scripts/polyclaw.py wallet approve
  63. ```
  64. This submits 6 approval transactions to Polygon. You only need to do this once per wallet.
  65. ### 4. Run commands
  66. ```bash
  67. # Browse markets
  68. uv run python scripts/polyclaw.py markets trending
  69. uv run python scripts/polyclaw.py markets search "election"
  70. # Find hedging opportunities
  71. uv run python scripts/polyclaw.py hedge scan --limit 10
  72. # Check wallet and trade
  73. uv run python scripts/polyclaw.py wallet status
  74. uv run python scripts/polyclaw.py buy <market_id> YES 50
  75. ```
  76. ## Example prompts
  77. Natural language prompts you can use with OpenClaw:
  78. ### 1. Browse trending markets
  79. ```
  80. What's trending on Polymarket?
  81. ```
  82. Returns market IDs, questions, prices, and volume.
  83. ### 2. Get market details
  84. ```
  85. Show me details for market <market_id>
  86. ```
  87. Use the market ID from Polymarket URL or from the trending markets response above.
  88. Returns full market info with link to Polymarket.
  89. ### 3. Check wallet status
  90. ```
  91. What's my PolyClaw wallet balance?
  92. ```
  93. Shows address, POL balance (for gas), pUSD balance (collateral), and USDC.e balance (wrap into pUSD via the Collateral Onramp if you need it).
  94. ### 4. Direct trading
  95. If you have your own conviction on a market:
  96. ```
  97. Buy $50 YES on market <market_id>
  98. ```
  99. Executes split + CLOB flow and records position.
  100. ### 5. Hedge discovery flow
  101. Find LLM-analyzed arbitrage opportunities:
  102. ```
  103. Find me some hedging opportunities on Polymarket
  104. ```
  105. or more specifically:
  106. ```
  107. Run hedge scan limit 10
  108. ```
  109. > **Note:** This takes a few minutes. The skill fetches open markets and sends pairs to the LLM for logical implication analysis.
  110. Review the results — you'll see coverage tiers (T1 = 95%+, T2 = 90-95%, T3 = 85-90%) and the market pairs where you can take hedged positions.
  111. ### 6. Check positions
  112. ```
  113. Show my PolyClaw positions
  114. ```
  115. Lists open positions with entry price, current price, and P&L.
  116. ### 7. Sell early
  117. To exit a position before the market resolves:
  118. ```
  119. Sell my YES position on market <market_id>
  120. ```
  121. Sells your tokens on the CLOB order book at current market price.
  122. ### Full flow example
  123. 1. **"What's trending on Polymarket?"** → Get market IDs
  124. 2. **"Run hedge scan limit 10"** → Wait for LLM analysis
  125. 3. Review hedge opportunities with coverage tiers
  126. 4. **"Buy $25 YES on market abc123"** → Take position on target market
  127. 5. **"Buy $25 NO on market xyz789"** → Take position on covering market
  128. 6. **"Show my PolyClaw positions"** → Verify entries and track P&L
  129. ## Environment variables
  130. | Variable | Required | Description |
  131. |----------|----------|-------------|
  132. | `CHAINSTACK_NODE` | Yes (trading) | Polygon RPC URL |
  133. | `OPENROUTER_API_KEY` | Yes (hedge) | OpenRouter API key for LLM |
  134. | `POLYCLAW_PRIVATE_KEY` | Yes (trading) | EVM private key (hex) |
  135. | `HTTPS_PROXY` | No | Only needed if CLOB orders fail (see [troubleshooting](#clob-order-failed--ip-blocked-by-cloudflare)) |
  136. | `CLOB_MAX_RETRIES` | No | Max retries for CLOB orders (default: 5) |
  137. ## Directory structure
  138. ```
  139. polyclaw/
  140. ├── SKILL.md # OpenClaw skill manifest
  141. ├── README.md # This file
  142. ├── pyproject.toml # Python dependencies (uv)
  143. │
  144. ├── scripts/
  145. │ ├── polyclaw.py # CLI dispatcher
  146. │ ├── markets.py # Market browsing (Gamma API)
  147. │ ├── wallet.py # Wallet management
  148. │ ├── trade.py # Split + CLOB execution
  149. │ ├── positions.py # Position tracking + P&L
  150. │ └── hedge.py # LLM hedge discovery
  151. │
  152. └── lib/
  153. ├── __init__.py # Package marker
  154. ├── clob_client.py # py-clob-client wrapper
  155. ├── contracts.py # CTF ABI + addresses
  156. ├── coverage.py # Coverage calculation + tiers
  157. ├── gamma_client.py # Polymarket Gamma API client
  158. ├── llm_client.py # OpenRouter LLM client
  159. ├── position_storage.py # Position JSON storage
  160. └── wallet_manager.py # Wallet lifecycle
  161. ```
  162. ## Trading flow
  163. 1. **Set approvals** (one-time): `polyclaw wallet approve`
  164. 2. **Execute trade**: `polyclaw buy <market_id> YES 50`
  165. - Split $50 pUSD → 50 YES + 50 NO tokens
  166. - Sell 50 NO tokens via CLOB → recover ~$15 (at 30¢)
  167. - Result: 50 YES tokens, net cost ~$35
  168. 3. **Track position**: `polyclaw positions`
  169. ### Understanding the split mechanism
  170. Polymarket uses a **Conditional Token Framework (CTF)**. You can't directly "buy YES tokens" — instead:
  171. 1. **Split**: Deposit pUSD into the CTF contract, which mints equal amounts of YES + NO tokens
  172. 2. **Sell unwanted**: Sell the side you don't want via the CLOB order book
  173. 3. **Result**: You hold your desired position, having recovered partial cost from selling the other side
  174. **Example** (buying YES at $0.65):
  175. ```
  176. Split: $2 pUSD → 2 YES + 2 NO tokens
  177. Sell: 2 NO tokens @ $0.35 → recover ~$0.70
  178. Net: Paid ~$1.30 for 2 YES tokens (effective price: $0.65)
  179. ```
  180. ### CLOB order IDs
  181. When you execute a trade, the CLOB sell returns an **order ID** like:
  182. ```
  183. 0xc93d6214515b2436feb684854c98d314ad19111d7ab822a9c885d61588d5beaa
  184. ```
  185. This is **not a blockchain transaction hash** — it's an off-chain Polymarket order book identifier. CLOB orders are matched off-chain and settled in batches on-chain.
  186. **What you can do with the order ID:**
  187. Query order details via the CLOB API (requires wallet authentication):
  188. ```python
  189. from py_clob_client.client import ClobClient
  190. client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
  191. creds = client.create_or_derive_api_creds()
  192. client.set_api_creds(creds)
  193. order = client.get_order("0xc93d6214...")
  194. # Returns: id, market, side, price, size_matched, status, created_at, etc.
  195. ```
  196. **API endpoint:** `GET https://clob.polymarket.com/data/order/<order_hash>`
  197. **Response fields:** `id`, `market`, `asset_id`, `side`, `price`, `original_size`, `size_matched`, `status` (MATCHED/LIVE/CANCELLED), `type` (FOK/GTC), `created_at`, `maker_address`, `associate_trades`
  198. **Note:** There's no public explorer for CLOB order IDs. To view your trade history, connect your wallet at polymarket.com → Portfolio → Activity.
  199. ## Hedge discovery flow
  200. 1. **Scan markets**: `polyclaw hedge scan --query "election"`
  201. 2. **Review output**: Table shows Tier, Coverage, Cost, Target, Cover
  202. 3. **Analyze pair**: `polyclaw hedge analyze <id1> <id2>`
  203. 4. **Execute if profitable**: Buy both positions manually
  204. **Coverage tiers:**
  205. - **Tier 1 (HIGH):** ≥95% coverage — near-arbitrage
  206. - **Tier 2 (GOOD):** 90-95% — strong hedges
  207. - **Tier 3 (MODERATE):** 85-90% — decent but noticeable risk
  208. - **Tier 4 (LOW):** <85% — speculative (filtered by default)
  209. ## Polymarket contracts (Polygon mainnet, CLOB V2)
  210. Post 2026-04-28 cutover. Collateral is pUSD; USDC.e is wrapped 1:1 via the Collateral Onramp.
  211. | Contract | Address |
  212. |----------|---------|
  213. | pUSD (collateral) | `0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB` |
  214. | USDC.e (onramp input) | `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174` |
  215. | Collateral Onramp (`wrap()`) | `0x93070a847efEf7F70739046A929D47a521F5B8ee` |
  216. | CTF | `0x4D97DCd97eC945f40cF65F87097ACe5EA0476045` |
  217. | CTF Exchange (V2) | `0xE111180000d2663C0091e4f400237545B87B996B` |
  218. | Neg Risk CTF Exchange (V2) | `0xe2222d279d744050d28e00520010520000310F59` |
  219. | Neg Risk Adapter | `0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296` |
  220. ## Troubleshooting
  221. ### "No wallet available"
  222. Set the `POLYCLAW_PRIVATE_KEY` environment variable:
  223. ```bash
  224. export POLYCLAW_PRIVATE_KEY="0x..."
  225. ```
  226. ### "CHAINSTACK_NODE not set"
  227. Set the Polygon RPC URL:
  228. ```bash
  229. export CHAINSTACK_NODE="https://polygon-mainnet.core.chainstack.com/YOUR_KEY"
  230. ```
  231. ### "OPENROUTER_API_KEY not set"
  232. Required for hedge commands. Get a free key at https://openrouter.ai/settings/keys:
  233. ```bash
  234. export OPENROUTER_API_KEY="sk-or-v1-..."
  235. ```
  236. ### Hedge scan finds 0 results or spurious results
  237. Model quality matters. The default `nvidia/nemotron-nano-9b-v2:free` works well. If using a different model:
  238. - Some models find spurious correlations (false positives)
  239. - Some models return empty responses (DeepSeek R1 uses `reasoning_content`)
  240. - Try `--model nvidia/nemotron-nano-9b-v2:free` explicitly
  241. ### "Insufficient pUSD"
  242. Trades require pUSD (Polymarket USD), not USDC.e. Check balances with:
  243. ```bash
  244. uv run python scripts/polyclaw.py wallet status
  245. ```
  246. If you have USDC.e but no pUSD, wrap it 1:1 via the Collateral Onramp's `wrap()` function (`0x9307...B8ee`). The polymarket.com UI does this automatically; API-only users wrap manually.
  247. ### "CLOB order failed" / "IP blocked by Cloudflare"
  248. Polymarket's CLOB API uses Cloudflare protection that blocks POST requests from many IPs. The solution is a **rotating residential proxy** with retry logic.
  249. **Recommended setup (IPRoyal or similar):**
  250. ```bash
  251. export HTTPS_PROXY="http://user:pass@geo.iproyal.com:12321"
  252. export CLOB_MAX_RETRIES=10
  253. ```
  254. The CLOB client automatically retries with new IPs until finding an unblocked one. Typically succeeds within 5-10 attempts.
  255. **Alternative options:**
  256. 1. **Sell manually** — Your split succeeded. Go to polymarket.com to sell tokens
  257. 2. **Use `--skip-sell`** — Keep both tokens: `polyclaw buy <id> YES 50 --skip-sell`
  258. ### "Approvals not set"
  259. Run the one-time approval setup:
  260. ```bash
  261. uv run python scripts/polyclaw.py wallet approve
  262. ```
  263. ## License
  264. Apache 2.0
  265. ## Credits
  266. Based on [polymarket-alpha-bot](https://github.com/chainstacklabs/polymarket-alpha-bot) by Chainstack.
  267. - **Chainstack** — Polygon RPC infrastructure
  268. - **Polymarket** — Prediction market platform
  269. - **OpenRouter** — LLM API for hedge discovery

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.