OpenClaw tools & skills for Polymarket: market intel, alerts, paper trading, and guarded limit orders.
Status: WIP — starting read-only and progressively enabling live trading behind strict guardrails.
This repository adds a Polymarket integration to OpenClaw via:
- Plugins / Tools: strongly-typed functions the agent can call (read markets, fetch orderbooks, compute spread, etc.).
- Skills: the “operating manual” that teaches the assistant how to use those tools safely (read-only → paper → guarded trading).
This approach keeps credentials out of prompts and makes it possible to enforce allowlists, approvals, limits, and audit logs.
- Search/discover markets (Gamma)
- Fetch market details and orderbook snapshots (CLOB read endpoints)
- Metrics: midpoint, spread, depth, liquidity heuristics
- Watchlists + alerts (price / spread / volume / depth)
- Positions, trades, activity (Data API)
- Daily/weekly summaries
- Audit logs of decisions and tool calls
- Order simulation with slippage estimates
- Strategy prototyping (entry/exit rules)
- “Proposal-only” mode (never executes)
- Limit orders only (initially)
- Mandatory approval gates
- Daily/max exposure limits, per-market limits
- Kill-switch + cancel-all + pause watchers
- Observability + error budgets + rate limiting
openclaw-polymarket/
plugin/
polymarket-core/ # API clients + pure read-only tools
polymarket-watchers/ # background services: alerts, monitors
polymarket-trade/ # guarded trading tools (Phase 4+)
skills/
polymarket-readonly/ # safe read-only behavior
polymarket-paper/ # paper trading behavior
polymarket-trading-basic/ # live trading w/ guardrails
docs/
threat-model.md
runbooks.md
api-notes.md
infra/
docker/
compose/
terraform/ # optional (Hetzner)
- A running OpenClaw instance (local, VM, or container).
- Polymarket access:
- Read-only can be done without secrets (depending on endpoint).
- Trading requires auth (private key / L2 creds per Polymarket docs).
References:
OpenClaw repo:
https://github.com/openclaw/openclaw
Polymarket docs:
https://docs.polymarket.com/
This is a template. Adjust to how you run OpenClaw (systemd, docker, k8s, etc.).
- Clone:
git clone https://github.com/<you>/openclaw-polymarket.git
cd openclaw-polymarket- Install dependencies (example for Node-based plugin; adapt if you use Python):
cd plugin/polymarket-core
npm install
npm run build- Register the plugin in your OpenClaw config (example pseudocode):
# openclaw.yaml
plugins:
- name: polymarket-core
path: ./plugin/polymarket-core
skills:
- path: ./skills/polymarket-readonly- Start OpenClaw and test a read-only tool call:
- Ask the agent to search a market topic and summarize spread + liquidity.
Read-only (optional, depends on endpoint usage):
POLYMARKET_GAMMA_BASE_URL=
POLYMARKET_CLOB_BASE_URL=
POLYMARKET_DATA_BASE_URL=Trading (Phase 4+) — DO NOT enable until you’ve completed Phases 1–3
# L1 signing (private key / wallet)
POLYMARKET_PRIVATE_KEY=
# L2 API credentials (if you use that auth flow)
POLYMARKET_API_KEY=
POLYMARKET_API_SECRET=
POLYMARKET_API_PASSPHRASE=PM_MODE=readonly # readonly | paper | live
PM_REQUIRE_APPROVAL=true # always true for live
PM_MAX_DAILY_USD=5 # start tiny
PM_MAX_MARKET_USD=2
PM_MAX_OPEN_ORDERS=3
PM_ALLOWED_MARKET_IDS= # comma-separated allowlist
PM_LIMIT_ORDERS_ONLY=true
PM_AUDIT_LOG_PATH=./logs/pm-audit.jsonlThese are examples of what your skills should support:
- “Track these 5 markets and alert me if YES crosses 0.60.”
- “Show me top movers in my watchlist today.”
- “Explain the spread and depth for market X.”
- “Simulate buying YES at 0.58 for $2 and show expected slippage.”
- “Backtest this simple rule on the last N snapshots (if stored).”
- “Propose a limit order for $1 with max slippage 1 tick — do NOT send without my approval.”
- “Cancel all open orders and pause trading.”
- No secrets in prompts. Secrets live in env vars / secret manager only.
- Allowlist tools: start minimal; don’t enable shell/exec tools.
- Approval gate required for every live order.
- Limits: per-day, per-market, max open orders, and market allowlist.
- Audit logs: JSONL event log for every proposal/execution/cancellation.
- Kill switch: instant pause + cancel-all.
Read more in:
docs/threat-model.md
docs/runbooks.md
# build plugin(s)
cd plugin/polymarket-core && npm run build
# run tests
npm test- Tools are versioned and backwards compatible once stable.
- Skills must include explicit “DO / DON’T” rules and reference the tools only (no direct HTTP in prompts).
PRs welcome. Please:
- Keep trading features behind
PM_MODE=liveandPM_REQUIRE_APPROVAL=true. - Add tests for anything that can move funds.
- Update
docs/threat-model.mdwhen adding new capabilities.
This project is for educational and tooling purposes. It is not financial advice. Markets can be illiquid, event resolution can be non-trivial, and trading involves risk. You are responsible for understanding Polymarket rules, fees, and compliance requirements in your jurisdiction.