PolyClaw Pro
by @lmanchu
Trade on Polymarket via split + CLOB execution. Browse markets, track positions with P&L, discover hedges via LLM. Includes automation tools: live portfolio...
clawhub install polyclaw-proπ About This Skill
name: polyclaw description: "Trade on Polymarket via split + CLOB execution. Browse markets, track positions with P&L, discover hedges via LLM. Includes automation tools: live portfolio tracking, auto-redeem, discipline scanner, and API bridge. Polygon/Web3." 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)"}]}}
PolyClaw
Trading-enabled Polymarket skill for OpenClaw. Browse markets, manage wallets, execute trades, and track positions.
Features
Quick Start
First, install dependencies (from skill directory):
cd {baseDir}
uv sync
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.
Browse Markets
# Trending markets by volume
uv run python scripts/polyclaw.py markets trendingSearch markets
uv run python scripts/polyclaw.py markets search "election"Market details (returns full JSON with all fields)
uv run python scripts/polyclaw.py market
Output options:
--full flag for full question text without truncation--json flag via scripts/markets.py --json trending for structured JSON outputWallet Management
# Check wallet status (address, balances)
uv run python scripts/polyclaw.py wallet statusSet contract approvals (one-time)
uv run python scripts/polyclaw.py wallet approve
The wallet is configured via the POLYCLAW_PRIVATE_KEY environment variable.
Trading
# Buy YES position for $50
uv run python scripts/polyclaw.py buy YES 50Buy NO position for $25
uv run python scripts/polyclaw.py buy NO 25
Positions
# List all positions with P&L
uv run python scripts/polyclaw.py positions
Hedge Discovery
Find covering portfolios - pairs of market positions that hedge each other via contrapositive logic.
# Scan trending markets for hedges
uv run python scripts/polyclaw.py hedge scanScan markets matching a query
uv run python scripts/polyclaw.py hedge scan --query "election"Analyze specific markets for hedging relationship
uv run python scripts/polyclaw.py hedge analyze
Output options:
--json flag for structured JSON output--min-coverage 0.90 to filter by minimum coverage (default 0.85)--tier 1 to filter by tier (1=best, default 2)Coverage tiers:
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 if needed.
Automation Tools
Portfolio Live Tracking
Real-time position tracking via Polymarket Data API. Groups positions by (slug, outcome) and displays YES/NO side, current value, and P&L with cost basis from portfolio.json.
uv run python portfolio_live.py
data-api.polymarket.comAuto Redeem
Automatically detects and redeems settled (resolved) markets. Checks payoutDenominator on-chain via the CTF contract. When a market resolves, submits a redeemPositions transaction through the NegRiskAdapter.
# Manual run
cd {baseDir} && source .env && .venv/bin/python3 auto_redeem_check.pyCron (every 15 minutes)
*/15 * * * * cd /path/to/polyclaw && source .env && .venv/bin/python3 auto_redeem_check.py >> /var/log/polyclaw-redeem.log 2>&1
web3 (use .venv/bin/python3, not system python)redeem_state.json to avoid duplicatesCHAINSTACK_NODE and POLYCLAW_PRIVATE_KEY env varsDiscipline Scanner
Automated take-profit scanner. Sells positions that are up 20%+ with slippage protection. Configurable via cfo_params.json (DISCIPLINE_TP_PCT key).
# Manual run
cd {baseDir} && export $(grep -v "^#" .env | xargs) && .venv/bin/python3 discipline_scanner.pyCron (every 30 minutes)
*/30 * * * * cd /path/to/polyclaw && export $(grep -v "^#" .env | xargs) && .venv/bin/python3 discipline_scanner.py >> /var/log/polyclaw-discipline.log 2>&1
Enhanced API (polyclaw_api.py)
CLI bridge for external integrations (e.g., Wells TG Bot via SSH). Provides structured JSON output for programmatic use.
python3 polyclaw_api.py portfolio # All open positions with live prices (JSON)
python3 polyclaw_api.py summary # Text summary of portfolio
python3 polyclaw_api.py balance # CLOB + on-chain wallet balance
python3 polyclaw_api.py risk # Current risk rules
python3 polyclaw_api.py risk_check # Pre-trade risk check
python3 polyclaw_api.py swap auto # Swap all non-USDC.e to USDC.e
python3 polyclaw_api.py swap status # Show token balances
portfolio is the recommended command for live position data (reads Data API, not local DB)balance requires web3 β use .venv/bin/python3summary reads local DB and can be stale β prefer portfolio for accuracySecurity
For the MVP, the private key is stored in an environment variable for simplicity and Claude Code compatibility.
Security Warning: Keep only small amounts in this wallet. Withdraw regularly to a secure wallet.
Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| CHAINSTACK_NODE | Yes (trading) | Polygon RPC URL |
| OPENROUTER_API_KEY | Yes (hedge) | OpenRouter API key for LLM hedge discovery |
| POLYCLAW_PRIVATE_KEY | Yes (trading) | EVM private key (hex, with or without 0x prefix) |
| HTTPS_PROXY | Recommended | Rotating residential proxy for CLOB (e.g., IPRoyal) |
| CLOB_MAX_RETRIES | No | Max CLOB retries with IP rotation (default: 5) |
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.
Trading Flow
1. Split Position - USDC.e is split into YES + NO tokens via CTF contract 2. Sell Unwanted - The unwanted side is sold via CLOB order book 3. Result - You hold the wanted position, recovered partial cost from selling unwanted
Example: Buy YES at $0.70
Polymarket Contracts (Polygon Mainnet)
0x2791Bca1f2de4661ED88A30C99A7a9449Aa841740x4D97DCd97eC945f40cF65F87097ACe5EA04760450x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982EDependencies
Install with uv (from skill directory):
cd {baseDir}
uv sync
Limitations
CLOB Cloudflare Blocking
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.
Solution: Residential proxy with retry logic
The recommended setup uses a rotating residential proxy (e.g., IPRoyal, BrightData). The CLOB client automatically retries with new IPs until one works:
export HTTPS_PROXY="http://user:pass@geo.iproyal.com:12321"
export CLOB_MAX_RETRIES=10 # Default is 5
With this setup, CLOB orders typically succeed within 5-10 retries as the proxy rotates through IPs until finding an unblocked one.
Alternative workarounds:
1. Use --skip-sell β Keep both YES and NO tokens, sell manually on polymarket.com
2. No proxy β Split still works; only CLOB sell is affected
If CLOB fails after all retries, your split still succeeded. The output tells you how many tokens to sell manually.
Troubleshooting
"No wallet available"
Set thePOLYCLAW_PRIVATE_KEY environment variable:
export POLYCLAW_PRIVATE_KEY="0x..."
"Insufficient USDC.e"
Check balance withuv run python scripts/polyclaw.py wallet status. You need USDC.e (bridged USDC) on Polygon."CLOB order failed"
The CLOB sell may fail due to:Your split still succeeded - you have the tokens, just couldn't sell unwanted side.
"Approvals not set"
First trade requires contract approvals. Run:uv run python scripts/polyclaw.py wallet approve
License
MIT
π‘ Examples
First, install dependencies (from skill directory):
cd {baseDir}
uv sync
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.
Browse Markets
# Trending markets by volume
uv run python scripts/polyclaw.py markets trendingSearch markets
uv run python scripts/polyclaw.py markets search "election"Market details (returns full JSON with all fields)
uv run python scripts/polyclaw.py market
Output options:
--full flag for full question text without truncation--json flag via scripts/markets.py --json trending for structured JSON outputWallet Management
# Check wallet status (address, balances)
uv run python scripts/polyclaw.py wallet statusSet contract approvals (one-time)
uv run python scripts/polyclaw.py wallet approve
The wallet is configured via the POLYCLAW_PRIVATE_KEY environment variable.
Trading
# Buy YES position for $50
uv run python scripts/polyclaw.py buy YES 50Buy NO position for $25
uv run python scripts/polyclaw.py buy NO 25
Positions
# List all positions with P&L
uv run python scripts/polyclaw.py positions
Hedge Discovery
Find covering portfolios - pairs of market positions that hedge each other via contrapositive logic.
# Scan trending markets for hedges
uv run python scripts/polyclaw.py hedge scanScan markets matching a query
uv run python scripts/polyclaw.py hedge scan --query "election"Analyze specific markets for hedging relationship
uv run python scripts/polyclaw.py hedge analyze
Output options:
--json flag for structured JSON output--min-coverage 0.90 to filter by minimum coverage (default 0.85)--tier 1 to filter by tier (1=best, default 2)Coverage tiers:
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 if needed.
π Tips & Best Practices
"No wallet available"
Set thePOLYCLAW_PRIVATE_KEY environment variable:
export POLYCLAW_PRIVATE_KEY="0x..."
"Insufficient USDC.e"
Check balance withuv run python scripts/polyclaw.py wallet status. You need USDC.e (bridged USDC) on Polygon."CLOB order failed"
The CLOB sell may fail due to:Your split still succeeded - you have the tokens, just couldn't sell unwanted side.
"Approvals not set"
First trade requires contract approvals. Run:uv run python scripts/polyclaw.py wallet approve