当前位置: 首页 > Skill >

PolyClaw Pro

PolyClaw Pro

1.0.0 2026.11.20 浏览:580
获取Skill文件查看使用说明
作者:陆川许可证:
本文目录展开

PolyClaw

Trading-enabled Polymarket skill for OpenClaw. Browse markets, manage wallets, execute trades, and track positions.

Features

  • Market Browsing - Search and browse Polymarket prediction markets
  • Wallet Management - Env-var based wallet configuration
  • Trading - Buy YES/NO positions via split + CLOB execution
  • Position Tracking - Track entry prices, current prices, and P&L
  • Hedge Discovery - LLM-powered covering portfolio discovery via logical implications

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 trending

# Search 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 <market_id>

Output options:

  • Default output is a formatted table (good for display)
  • Use --full flag for full question text without truncation
  • Use --json flag via scripts/markets.py --json trending for structured JSON output

Wallet Management

# Check wallet status (address, balances)
uv run python scripts/polyclaw.py wallet status

# Set 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 <market_id> YES 50

# Buy NO position for $25
uv run python scripts/polyclaw.py buy <market_id> 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 scan

# Scan 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 <market_id_1> <market_id_2>

Output options:

  • Default output is a formatted table showing Tier, Coverage, Cost, Target, and Cover
  • Use --json flag for structured JSON output
  • Use --min-coverage 0.90 to filter by minimum coverage (default 0.85)
  • Use --tier 1 to filter by tier (1=best, default 2)

Coverage tiers:

  • Tier 1 (HIGH): >=95% coverage - near-arbitrage opportunities
  • Tier 2 (GOOD): 90-95% - strong hedges
  • Tier 3 (MODERATE): 85-90% - decent but noticeable risk
  • Tier 4 (LOW): <85% - speculative (filtered by default)

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.

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
  • Fetches live on-chain positions from data-api.polymarket.com
  • Shows outcome side (YES/NO), current price, and unrealized P&L
  • No web3 dependency — uses REST API only

Auto 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.py

# Cron (every 15 minutes)
*/15 * * * * cd /path/to/polyclaw && source .env && .venv/bin/python3 auto_redeem_check.py >> /var/log/polyclaw-redeem.log 2>&1
  • Requires web3 (use .venv/bin/python3, not system python)
  • Tracks redeemed positions in redeem_state.json to avoid duplicates
  • Needs CHAINSTACK_NODE and POLYCLAW_PRIVATE_KEY env vars

Discipline 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.py

# Cron (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
  • Skips positions worth less than $1
  • Take-profit threshold defaults to 20% (configurable)

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 <usd> <slug> <channel>  # 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/python3
  • summary reads local DB and can be stale — prefer portfolio for accuracy

Security

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

  • Split $100 USDC.e → 100 YES + 100 NO tokens
  • Sell 100 NO tokens at ~$0.30 → recover ~$27 USDC.e
  • Net cost: ~$73 for 100 YES tokens (entry: $0.73)

Polymarket Contracts (Polygon Mainnet)

  • USDC.e: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
  • CTF (Conditional Tokens): 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045
  • CTF Exchange: 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E

Dependencies

Install with uv (from skill directory):

cd {baseDir}
uv sync

Limitations

  • Trading requires wallet approval setup (one-time)
  • CLOB sells may fail if liquidity is insufficient

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 the POLYCLAW_PRIVATE_KEY environment variable:

export POLYCLAW_PRIVATE_KEY="0x..."

"Insufficient USDC.e"

Check balance with uv 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:

  • Insufficient liquidity at the sell price
  • IP blocked by Cloudflare (try proxy)

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

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,031
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,029
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,017
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,011
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,011
Skill 文件
  • SKILL.md
    • PolyClaw
    • Features
    • Quick Start
      • First-Time Setup (Required for Trading)
      • Browse Markets
      • Wallet Management
      • Trading
      • Positions
      • Hedge Discovery
    • Automation Tools
      • Portfolio Live Tracking
      • Auto Redeem
      • Discipline Scanner
      • Enhanced API (polyclaw_api.py)
    • Security
    • Environment Variables
    • Trading Flow
    • Polymarket Contracts (Polygon Mainnet)
    • Dependencies
    • Limitations
      • CLOB Cloudflare Blocking
    • Troubleshooting
      • "No wallet available"
      • "Insufficient USDC.e"
      • "CLOB order failed"
      • "Approvals not set"
    • License
  • 项目或源文件

相关 Skill

更多
Simmer Simmer 面向AI代理的预测市场界面。统一API交易Polymarket和Kalshi,具备自托管钱包、安全护栏和智能上下文。
Prediction Market Pro Trader Prediction Market Pro Trader 使用基准率和贝叶斯更新分析Polymarket和Kalshi事件,识别错误定价的合约并推荐带风险控制的价值交易。
Signalradar Signalradar SignalRadar — 监控 Polymarket 预测市场的概率变化,阈值突破时发送警报。用户要求“添加 Polymarket …”时使用。
DRADIS PolyMarket Trading Automation DRADIS PolyMarket Trading Automation 实时监控与控制界面,用于DRADIS Polymarket高频交易引擎,全面支持DRADIS_API_KEY认证。
Alpha Finder (x402) Alpha Finder (x402) 市场预言机 - 预测市场情报工具,支持Polymarket和Kalshi研究、概率评估、市场情绪分析与套利机会识别。适用于研究预测市场、分析赔率或发现市场低效。费用:0.03 USDC/次(Base网络x402协议)。