grimoire-polymarket
franalgaba/grimoire
Query Polymarket markets and manage CLOB orders via the Grimoire CLI wrapper.
What is grimoire-polymarket?
This skill provides access to Polymarket market discovery, CLOB market data queries, and order management through the Grimoire venue adapter. Use it to search markets by category, sport, or text; retrieve positions and trades; and place or cancel orders on the Polymarket CLOB.
- Search and discover Polymarket markets with filters (category, sport, league, active/open status)
- Query CLOB market data including order books, prices, and trade history
- Retrieve user positions, trades, and leaderboard data
- Place limit and market orders (GTC/GTD/FOK/FAK)
- Cancel individual orders or all orders in a market
- Access mid-price metrics for token comparisons
How to install grimoire-polymarket
npx skills add https://github.com/franalgaba/grimoire --skill grimoire-polymarket- Official Polymarket CLI binary installed (brew tap Polymarket/polymarket-cli && brew install polymarket)
- POLYMARKET_PRIVATE_KEY environment variable set for order execution
- Optional: POLYMARKET_API_KEY, POLYMARKET_API_SECRET, POLYMARKET_API_PASSPHRASE for API authentication
How to use grimoire-polymarket
- 1.Run `grimoire venue polymarket info --format json` to verify the adapter is healthy
- 2.Use `grimoire venue polymarket search-markets --query <text> --active-only true --format json` to discover markets
- 3.Query market data with `grimoire venue polymarket markets list --limit 25 --format json` or `grimoire venue polymarket data positions <address> --format json`
- 4.Place an order using the spell action with `op="order"`, specifying token_id, price, size, side (BUY/SELL), and order_type (GTC/GTD/FOK/FAK)
- 5.Cancel orders with `op="cancel_order"` or `op="cancel_all"` spell actions
Use cases
- Find active sports betting markets in a specific league and place a limit order
- Query your trading positions and recent trades on Polymarket
- Search for markets matching a keyword (e.g., 'bitcoin') and retrieve current CLOB pricing
- Cancel pending orders in a market before market resolution
- Retrieve leaderboard data to analyze top traders by volume or other metrics
- Traders and market makers on Polymarket
- Agents automating market discovery and order placement
- Developers building prediction market bots
- Analysts querying historical trades and positions
grimoire-polymarket FAQ
Required: POLYMARKET_PRIVATE_KEY. Optional: POLYMARKET_API_KEY, POLYMARKET_API_SECRET, POLYMARKET_API_PASSPHRASE, POLYMARKET_DERIVE_API_KEY (default true), POLYMARKET_SIGNATURE_TYPE, POLYMARKET_FUNDER, and POLYMARKET_OFFICIAL_CLI for custom binary path.
GTC (Good-Till-Cancel) and GTD (Good-Till-Date) are routed as limit orders. FOK (Fill-or-Kill) and FAK (Fill-and-Kill) are routed as market orders.
Use `grimoire venue polymarket search-markets --category <category> --league <league> --sport <sport> --format json` with optional filters like --active-only true and --open-only true.
Yes, use `grimoire venue polymarket data positions <address>` and `grimoire venue polymarket data trades <address>` to retrieve your positions and trade history.
The wrapper intentionally blocks wallet, bridge, approve, ctf, setup, upgrade, and shell operations for security reasons.
Full instructions (SKILL.md)
Source of truth, from franalgaba/grimoire.
name: grimoire-polymarket description: Queries Polymarket market data and CLOB state, and manages CLOB orders via the Grimoire venue CLI wrapper backed by the official Polymarket CLI.
Grimoire Polymarket Skill
Use this skill for Polymarket market discovery, CLOB market data, and order-management operations through the polymarket venue adapter.
Preferred invocations:
grimoire venue polymarket ...npx -y @grimoirelabs/cli venue polymarket ...(no-install)bun run packages/cli/src/index.ts venue polymarket ...(repo-local)grimoire-polymarket ...(direct binary from@grimoirelabs/venues)
Recommended preflight:
grimoire venue doctor --adapter polymarket --jsongrimoire venue polymarket info --format json
Commands
Canonical agent commands:
grimoire venue polymarket info [--format <auto|json|table>]grimoire venue polymarket search-markets [--query <text>] [--slug <slug|url>] [--question <text>] [--event <text>] [--tag <text>] [--category <text>] [--league <text>] [--sport <text>] [--open-only <true|false>] [--active-only <true|false>] [--ignore-end-date <true|false>] [--tradable-only <true|false>] [--all-pages <true|false>] [--max-pages <n>] [--stop-after-empty-pages <n>] [--limit <n>] [--format <auto|json|table>]
Allowed passthrough groups (official CLI surface, restricted by wrapper policy):
markets(list|get|search|tags)data(positions/value/leaderboards/etc.)
Blocked groups in this wrapper (intentionally not exposed for agents):
walletbridgeapprovectfsetupupgradeshell
Legacy compatibility aliases are still supported (market, book, midpoint, spread, price, last-trade-price, tick-size, neg-risk, fee-rate, price-history, order, trades, open-orders, balance-allowance, closed-only-mode, server-time) but should not be used for new agent flows.
Examples
# Wrapper/health
grimoire venue polymarket info --format json
grimoire venue polymarket status --format json
# Canonical discovery
grimoire venue polymarket search-markets --query bitcoin --active-only true --open-only true --format json
grimoire venue polymarket search-markets --category sports --league "la liga" --active-only true --open-only true --format json
# Official passthrough discovery/data
grimoire venue polymarket markets list --limit 25 --format json
grimoire venue polymarket markets search "atleti" --limit 25 --format json
grimoire venue polymarket data positions <address> --limit 25 --format json
grimoire venue polymarket data trades <address> --limit 25 --format json
grimoire venue polymarket data leaderboard --period week --order-by vol --limit 25 --format json
# Legacy compatibility aliases (still supported)
grimoire venue polymarket book --token-id <token_id> --format json
grimoire venue polymarket price --token-id <token_id> --side buy --format json
grimoire venue polymarket order --order-id <order_id> --format json
grimoire venue polymarket open-orders --market <condition_id> --format json
Runtime Configuration
Adapter/runtime auth (for spell execution):
- required by default:
POLYMARKET_PRIVATE_KEY - optional API creds:
POLYMARKET_API_KEY,POLYMARKET_API_SECRET,POLYMARKET_API_PASSPHRASE - optional derive toggle (default true):
POLYMARKET_DERIVE_API_KEY=true|false - optional signature routing:
POLYMARKET_SIGNATURE_TYPE(0EOA,1POLY_PROXY,2GNOSIS_SAFE),POLYMARKET_FUNDER grimoire cast/grimoire resumekey-based flows inject the same wallet-manager key into the Polymarket adapter, so a separatePOLYMARKET_PRIVATE_KEYenv is not required there.
Venue CLI backend:
- Official binary required:
polymarket - Install:
brew tap Polymarket/polymarket-cli && brew install polymarket - Optional path override:
POLYMARKET_OFFICIAL_CLI=/custom/path/polymarket
Spell Actions
Polymarket uses custom action type with op: "order" for order placement:
polymarket.custom(
op="order",
token_id="TOKEN_ID",
price="0.55",
size="100",
side="BUY",
order_type="GTC",
)
The adapter does not support runtime constraints (max_slippage, etc.). Order routing:
GTC/GTD→ limit order (createAndPostOrder)FOK/FAK→ market order (createAndPostMarketOrder)
Metric Surface (Spell Comparisons)
Polymarket exposes mid_price for CLOB token midpoint comparisons:
poly_mid = metric("mid_price", polymarket, USDC, "token_id=<clobTokenId>")
Selector keys accepted: token_id, tokenid, market_id, id.
If selector is omitted, the metric falls back to the 3rd argument value.
Adapter Notes
- Adapter name:
polymarket - Execution type:
offchain - Supported chain metadata:
137(Polygon) - Action type:
custom - Supported custom ops:
order,cancel_order,cancel_orders,cancel_all,heartbeat
Order argument aliases accepted:
- token:
token_idortokenIDortokenIdorcoin - amount:
sizeoramount - side:
BUY/SELL - order type:
GTC/GTD/FOK/FAK - extra compatibility aliases:
arg0..arg5,reduce_only
Order type routing:
GTC/GTD-> limit order path (createAndPostOrder)FOK/FAK-> market order path (createAndPostMarketOrder)
Notes
- Prefer
--format jsonfor agent and automation workflows. search-marketsis the agent-oriented normalized discovery command; passthroughmarkets searchis thinner and closer to official behavior.- Keep prompts/tooling on this CLI surface; do not call Polymarket HTTP APIs directly from advisory tools.
Related skills
More from franalgaba/grimoire and the wider catalog.
grimoire-hyperliquid
Queries Hyperliquid market data using the Grimoire venue CLI. Use when you need mids, books, metadata, open orders, or a withdrawal call.
grimoire-uniswap
Retrieves Uniswap router metadata using the Grimoire venue CLI. Use when you need router addresses, adapter information, or Uniswap V3/V4 details.
grimoire-aave
Fetches Aave V3 public market data using the Grimoire venue CLI. Use when you need Aave health checks, chain listings, market metadata, or reserve info.
grimoire
Install and operate Grimoire, author .spell files with full syntax coverage (including advisory decision logic), and run compile/validate/simulate/cast safely. Use when users ask to create, edit, debug, validate, simulate, execute, or explain Grimoire strategies.
grimoire-morpho-blue
Fetches Morpho Blue public deployment metadata using the Grimoire venue CLI. Use when you need contract addresses or adapter info.
grimoire-pendle
Fetches Pendle Hosted SDK metadata using the Grimoire venue CLI. Use when you need supported chains, aggregators, markets, assets, or market token details.