$npx -y skills add franalgaba/grimoire --skill grimoire-polymarketQueries Polymarket market data and CLOB state, and manages CLOB orders via the Grimoire venue CLI wrapper backed by the official Polymarket CLI.
| 1 | # Grimoire Polymarket Skill |
| 2 | |
| 3 | Use this skill for Polymarket market discovery, CLOB market data, and order-management operations through the `polymarket` venue adapter. |
| 4 | |
| 5 | Preferred invocations: |
| 6 | |
| 7 | - `grimoire venue polymarket ...` |
| 8 | - `npx -y @grimoirelabs/cli venue polymarket ...` (no-install) |
| 9 | - `bun run packages/cli/src/index.ts venue polymarket ...` (repo-local) |
| 10 | - `grimoire-polymarket ...` (direct binary from `@grimoirelabs/venues`) |
| 11 | |
| 12 | Recommended preflight: |
| 13 | |
| 14 | - `grimoire venue doctor --adapter polymarket --json` |
| 15 | - `grimoire venue polymarket info --format json` |
| 16 | |
| 17 | ## Commands |
| 18 | |
| 19 | Canonical agent commands: |
| 20 | |
| 21 | - `grimoire venue polymarket info [--format <auto|json|table>]` |
| 22 | - `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>]` |
| 23 | |
| 24 | Allowed passthrough groups (official CLI surface, restricted by wrapper policy): |
| 25 | |
| 26 | - `markets` (`list|get|search|tags`) |
| 27 | - `data` (positions/value/leaderboards/etc.) |
| 28 | |
| 29 | Blocked groups in this wrapper (intentionally not exposed for agents): |
| 30 | |
| 31 | - `wallet` |
| 32 | - `bridge` |
| 33 | - `approve` |
| 34 | - `ctf` |
| 35 | - `setup` |
| 36 | - `upgrade` |
| 37 | - `shell` |
| 38 | |
| 39 | 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. |
| 40 | |
| 41 | ## Examples |
| 42 | |
| 43 | ```bash |
| 44 | # Wrapper/health |
| 45 | grimoire venue polymarket info --format json |
| 46 | grimoire venue polymarket status --format json |
| 47 | |
| 48 | # Canonical discovery |
| 49 | grimoire venue polymarket search-markets --query bitcoin --active-only true --open-only true --format json |
| 50 | grimoire venue polymarket search-markets --category sports --league "la liga" --active-only true --open-only true --format json |
| 51 | |
| 52 | # Official passthrough discovery/data |
| 53 | grimoire venue polymarket markets list --limit 25 --format json |
| 54 | grimoire venue polymarket markets search "atleti" --limit 25 --format json |
| 55 | grimoire venue polymarket data positions <address> --limit 25 --format json |
| 56 | grimoire venue polymarket data trades <address> --limit 25 --format json |
| 57 | grimoire venue polymarket data leaderboard --period week --order-by vol --limit 25 --format json |
| 58 | |
| 59 | # Legacy compatibility aliases (still supported) |
| 60 | grimoire venue polymarket book --token-id <token_id> --format json |
| 61 | grimoire venue polymarket price --token-id <token_id> --side buy --format json |
| 62 | grimoire venue polymarket order --order-id <order_id> --format json |
| 63 | grimoire venue polymarket open-orders --market <condition_id> --format json |
| 64 | ``` |
| 65 | |
| 66 | ## Runtime Configuration |
| 67 | |
| 68 | Adapter/runtime auth (for spell execution): |
| 69 | |
| 70 | - required by default: `POLYMARKET_PRIVATE_KEY` |
| 71 | - optional API creds: `POLYMARKET_API_KEY`, `POLYMARKET_API_SECRET`, `POLYMARKET_API_PASSPHRASE` |
| 72 | - optional derive toggle (default true): `POLYMARKET_DERIVE_API_KEY=true|false` |
| 73 | - optional signature routing: `POLYMARKET_SIGNATURE_TYPE` (`0` EOA, `1` POLY_PROXY, `2` GNOSIS_SAFE), `POLYMARKET_FUNDER` |
| 74 | - `grimoire cast` / `grimoire resume` key-based flows inject the same wallet-manager key into the Polymarket adapter, so a separate `POLYMARKET_PRIVATE_KEY` env is not required there. |
| 75 | |
| 76 | Venue CLI backend: |
| 77 | |
| 78 | - Official binary required: `polymarket` |
| 79 | - Install: `brew tap Polymarket/polymarket-cli && brew install polymarket` |
| 80 | - Optional path override: `POLYMARKET_OFFICIAL_CLI=/custom/path/polymarket` |
| 81 | |
| 82 | ## Spell Actions |
| 83 | |
| 84 | Polymarket uses `custom` action type with `op: "order"` for order placement: |
| 85 | |
| 86 | ```spell |
| 87 | polymarket.custom( |
| 88 | op="order", |
| 89 | token_id="TOKEN_ID", |
| 90 | price="0.55", |
| 91 | size="100", |
| 92 | side="BUY", |
| 93 | order_type="GTC", |
| 94 | ) |
| 95 | ``` |
| 96 | |
| 97 | The adapter does not support runtime constraints (`max_slippage`, etc.). Order routing: |
| 98 | - `GTC`/`GTD` → limit order (`createAndPostOrder`) |
| 99 | - `FOK`/`FAK` → market order (`createAndPostMarketOrder`) |
| 100 | |
| 101 | ## Metric Surface (Spell Comparisons) |
| 102 | |
| 103 | Polymarket exposes `mid_price` for CLOB token midpoint comparisons: |
| 104 | |
| 105 | ```spell |
| 106 | poly_mid = metric("mid_price", polymarket, USDC, "token_id=<clobTokenId>") |
| 107 | ``` |
| 108 | |
| 109 | Selector keys accepted: `token_id`, `tokenid`, `market_id`, `id`. |
| 110 | If selector is omitted, the metric falls back to the 3rd argument value. |
| 111 | |
| 112 | ## Adapter Notes |
| 113 | |
| 114 | - Adapter name: `polymarket` |
| 115 | - Execution type: `offchain` |
| 116 | - Supported chain metadata: `137` (Polygon) |
| 117 | - Action type: `custom` |
| 118 | - Supported custom ops: `order`, `cancel_order`, `cancel_orders`, `cancel_all`, `heartbeat` |
| 119 | |
| 120 | Order argument aliases accepted: |
| 121 | |
| 122 | - token: `token_id` or `tokenID` or `tokenId` or `coin` |
| 123 | - amount: `size` or `amou |