@oracle-agent/oracle 0.24.1 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/assets/skills/chain/SKILL.md +34 -0
  2. package/dist/assets/skills/chain-defi-ecosystem-analysis/SKILL.md +181 -0
  3. package/dist/assets/skills/chain-ecosystem-gap-analysis/SKILL.md +162 -0
  4. package/dist/assets/skills/cross-chain-twap-execution/SKILL.md +125 -0
  5. package/dist/assets/skills/defi-protocol-pmf-assessment/SKILL.md +332 -0
  6. package/dist/assets/skills/evm-contract-research.md +8 -3
  7. package/dist/assets/skills/multi-venue-prepare-only-ranking/SKILL.md +93 -0
  8. package/dist/assets/skills/oracle-access-control/SKILL.md +71 -0
  9. package/dist/assets/skills/oracle-action-arming/SKILL.md +99 -0
  10. package/dist/assets/skills/oracle-airdrop-calculator/SKILL.md +111 -0
  11. package/dist/assets/skills/oracle-desk-product/SKILL.md +341 -0
  12. package/dist/assets/skills/oracle-evm/SKILL.md +55 -0
  13. package/dist/assets/skills/oracle-harness/SKILL.md +41 -0
  14. package/dist/assets/skills/oracle-mcp-install/SKILL.md +140 -0
  15. package/dist/assets/skills/oracle-multichain-convert/SKILL.md +87 -0
  16. package/dist/assets/skills/oracle-native-harness/SKILL.md +32 -0
  17. package/dist/assets/skills/oracle-ownership-gate/SKILL.md +42 -0
  18. package/dist/assets/skills/oracle-public-product-ux/SKILL.md +114 -0
  19. package/dist/assets/skills/oracle-tailscale/SKILL.md +32 -0
  20. package/dist/assets/skills/oracle-thin-client/SKILL.md +47 -0
  21. package/dist/assets/skills/perp-venue-funding-research/SKILL.md +161 -0
  22. package/dist/assets/skills/polymarket/SKILL.md +160 -0
  23. package/dist/assets/skills/protocol-api-key-integration/SKILL.md +141 -0
  24. package/dist/assets/skills/self-custodial-onchain-execution/SKILL.md +1284 -0
  25. package/dist/assets/skills/setup/SKILL.md +40 -0
  26. package/dist/assets/skills/stable-launch-ops/SKILL.md +89 -0
  27. package/dist/assets/skills/trade-loop-circuit-breaker/SKILL.md +441 -0
  28. package/dist/assets/skills/venue-capability-boundaries/SKILL.md +32 -0
  29. package/dist/bin/desk-server.mjs +16 -16
  30. package/dist/bin/oracle-data-mcp.mjs +1 -1
  31. package/dist/bin/oracle-equities.mjs +1 -1
  32. package/dist/bin/oracle-init.mjs +9 -9
  33. package/dist/cli/commands/bootstrap.mjs +1 -1
  34. package/dist/cli/commands/chat.mjs +78 -77
  35. package/dist/cli/commands/doctor.mjs +8 -6
  36. package/dist/cli/commands/eval.mjs +1 -1
  37. package/dist/cli/commands/harness.mjs +6 -6
  38. package/dist/cli/commands/model.mjs +82 -81
  39. package/dist/cli/commands/receipt.mjs +5 -0
  40. package/dist/cli/commands/setup.mjs +1 -1
  41. package/dist/cli/commands/venues.mjs +3 -0
  42. package/dist/cli/commands/watch.mjs +16 -0
  43. package/dist/equities/index.mjs +1 -1
  44. package/dist/index.mjs +1 -1
  45. package/package.json +1 -1
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: polymarket
3
+ description: "Query Polymarket: markets, prices, orderbooks, history."
4
+ version: 1.1.0
5
+ author: Hermes Agent + Teknium
6
+ tags: [polymarket, prediction-markets, market-data, trading]
7
+ platforms: [linux, macos, windows]
8
+ ---
9
+
10
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
11
+
12
+
13
+ # Polymarket — Prediction Market Data
14
+
15
+ Query prediction market data from Polymarket using their public REST APIs.
16
+ All endpoints are read-only and require zero authentication.
17
+
18
+ See `references/api-endpoints.md` for the full endpoint reference with curl examples.
19
+ See `scripts/polymarket.py` for the CLI helper.
20
+ See `scripts/polymarket_digest.py` for the automated digest script.
21
+ See `references/2026-competitive-landscape.md` for who's making money in 2026 and which strategies work.
22
+ See `references/odds-api-io-provider.md` for the bot's sports-odds source (odds-api.io v3) — auth, the host-mismatch 401 trap, the 5-book plan cap, and the working call sequence to pull a match's live moneyline.
23
+ See `references/odds-api-io-football.md` for World Cup / football-specific usage: correct sport slug (`football` not `soccer_fifa_world_cup`), required `bookmakers` param, pre-configured 5-book list, event ID discovery, and response shape.
24
+
25
+ ## When to Use
26
+
27
+ - User asks about prediction markets, betting odds, or event probabilities
28
+ - User wants to know "what are the odds of X happening?"
29
+ - User asks about Polymarket specifically
30
+ - User wants market prices, orderbook data, or price history
31
+ - User asks to monitor or track prediction market movements
32
+ - Scheduled cron job to produce a market digest
33
+
34
+ ## Key Concepts
35
+
36
+ - **Events** contain one or more **Markets** (1:many relationship)
37
+ - **Markets** are binary outcomes with Yes/No prices between 0.00 and 1.00
38
+ - Prices ARE probabilities: price 0.65 means the market thinks 65% likely
39
+ - `outcomePrices` field: JSON-encoded array like `["0.80", "0.20"]`
40
+ - `clobTokenIds` field: JSON-encoded array of two token IDs [Yes, No] for price/book queries
41
+ - `conditionId` field: hex string used for price history queries
42
+ - Volume is in USDC (US dollars)
43
+
44
+ ## Three Public APIs
45
+
46
+ 1. **Gamma API** at `gamma-api.polymarket.com` — Discovery, search, browsing
47
+ 2. **CLOB API** at `clob.polymarket.com` — Real-time prices, orderbooks, history
48
+ 3. **Data API** at `data-api.polymarket.com` — Trades, open interest
49
+
50
+ ## Typical Workflow
51
+
52
+ When a user asks about prediction market odds:
53
+
54
+ 1. **Search** using the Gamma API public-search endpoint with their query
55
+ 2. **Parse** the response — extract events and their nested markets
56
+ 3. **Present** market question, current prices as percentages, and volume
57
+ 4. **Deep dive** if asked — use clobTokenIds for orderbook, conditionId for history
58
+
59
+ ## Presenting Results
60
+
61
+ Format prices as percentages for readability:
62
+ - outcomePrices `["0.652", "0.348"]` becomes "Yes: 65.2%, No: 34.8%"
63
+ - Always show the market question and probability
64
+ - Include volume when available
65
+
66
+ Example: `"Will X happen?" — 65.2% Yes ($1.2M volume)`
67
+
68
+ ## Parsing Double-Encoded Fields
69
+
70
+ The Gamma API returns `outcomePrices`, `outcomes`, and `clobTokenIds` as JSON strings
71
+ inside JSON responses (double-encoded). When processing with Python, parse them with
72
+ `json.loads(market['outcomePrices'])` to get the actual array.
73
+
74
+ ## Pitfalls
75
+
76
+ ### Data API attributes trades to proxy wallet, not signing EOA
77
+
78
+ When querying `data-api.polymarket.com` endpoints (`/trades`, `/positions`, `/activity`) for a specific wallet, **query the PROXY wallet, not the signing EOA.** Polymarket assigns a proxy contract address for each user — trades, positions, and activity are attributed to the proxy, not the EOA that signed the transactions.
79
+
80
+ - The EOA `0x4d47b675` (DEMI's wallet) returns **zero results** from the Data API — query the proxy address instead.
81
+ - The proxy wallet for this setup: `0x635be4D2eE8EE926C1EF44D982a2D031ba0d1013`.
82
+ - Trade record keys from `/trades`: `proxyWallet, side, asset, conditionId, size, price, timestamp, title, slug, eventSlug, outcome, outcomeIndex, transactionHash`. `timestamp` is unix seconds. `price` 0-1. `size` = shares.
83
+ - The stale bot analysis file at `data/all_trades_analysis.json` is **generatedAt 2026-04-28, wrong-proxy, contaminated** — always pull live from the Data API.
84
+ - Pre-2026-05-14 trade data has ~30% zero-edge contamination — filter by timestamp when computing PnL/win-rate.
85
+ - Wins auto-redeem: resolved-wins show as redemption inflows in `/activity`, not sell-side fills in `/trades`. Full PnL needs merging both endpoints.
86
+
87
+ ### Security scanner blocks curl-to-python pipelines
88
+ The Hermes security scanner flags `curl ... | python3` as HIGH risk (piped input to interpreter). Save to a temp file first, then parse:
89
+ ```
90
+ curl -s 'https://gamma-api.polymarket.com/...' > /tmp/pm_data.json
91
+ python3 -c "import json; data = json.load(open('/tmp/pm_data.json'))"
92
+ ```
93
+ Or use `execute_code()` with `hermes_tools.terminal()` and separate calls.
94
+
95
+ ### Public search returns stale historical markets
96
+ `public-search?q=NBA` surfaces game-level markets from previous seasons (2024 dates) alongside active championship markets. These are `active=true` but often `closed=true` or have prices at 100%/0%. To find active championship contenders:
97
+ - Query event-specific slug: `events?slug=2026-nba-champion`
98
+ - Filter: `market['active'] == True and not market['closed']`
99
+ - Teams eliminated but not yet resolved have `active=true` + `closed=true` + `outcomePrices=["0.0000","1.0000"]`
100
+
101
+ ### Volume field type inconsistency
102
+ The `volume` field can be a string or number depending on context. When available, prefer `volumeNum` (always float) over `volume` (may be string). Always cast with `float(val)` when computing.
103
+
104
+ ### CLOB `/book` endpoint returns UNSORTED arrays
105
+
106
+ `clob.polymarket.com/book?token_id=<id>` returns `asks` and `bids` as **unsorted arrays**. `asks[0]` is often `0.999` (not the best ask), `bids[0]` can be near-zero. This looks like "always sort ascending" but it's actually random order.
107
+
108
+ **Always use reduce to find BBO:**
109
+ ```js
110
+ const bestAsk = book.asks.reduce((lo, o) => {
111
+ const p = parseFloat(o.price);
112
+ return (Number.isFinite(p) && p > 0 && p < 1 && (lo === 0 || p < lo)) ? p : lo;
113
+ }, 0);
114
+ const bestBid = book.bids.reduce((hi, o) => {
115
+ const p = parseFloat(o.price);
116
+ return (Number.isFinite(p) && p > 0 && p < 1 && p > hi) ? p : hi;
117
+ }, 0);
118
+ ```
119
+ Using `asks[0].price` as "best ask" is a **silent logic bug** that will:
120
+ - Inflate `sumBestAsk` in neg-risk scanners (neg-risk scanner was broken for its entire deployment because of this)
121
+ - Report false-stale edges in CLOB validation passes
122
+ - Cause BBO-based edge calculations to be completely wrong
123
+
124
+ This is confirmed in the bot codebase comments: *"CLOB /book returns unsorted arrays"* (bot.js ~line 1804) and was a known bug. Always grep for `asks[0]` when auditing any CLOB-consuming code.
125
+
126
+ ### Volume field paths vary
127
+ - At event level: `event['volume']` (float)
128
+ - At market level: `market['volumeNum']` (float) or `market['volume']` (string)
129
+ - Normalize with: `float(m.get('volumeNum', 0) or m.get('volume', 0))`
130
+
131
+ ### Event-by-slug can return empty
132
+ Not all slugs resolve. `events?slug=some-slug` returns an empty list `[]` for invalid slugs. Check for this before indexing.
133
+
134
+ ## Digest / Cron Workflow
135
+
136
+ For automated market scanning (scheduled cron job), use `scripts/polymarket_digest.py`.
137
+
138
+ Typical flow:
139
+ 1. Fetch trending events: `events?limit=10&active=true&closed=false&order=volume&ascending=false`
140
+ 2. Keyword search: `public-search?q=NBA&limit=5`, `public-search?q=NHL&limit=5`, etc.
141
+ 3. For each keyword result, supplement with event-slug queries for championship/tournament events (more reliable than free-text search)
142
+ 4. Parse prices via double-encoded JSON loading
143
+ 5. Filter to active + non-closed markets with non-zero Yes prices for contenders
144
+ 6. Format as readable digest with event title, market question, Yes/No %, volume, conditionId
145
+
146
+ Important: Some keyword results are game-level markets (single games) vs championship-level. Both are valid but should be labeled clearly. Championship-level data comes from event-slug queries, game-level from public-search.
147
+
148
+ ## Rate Limits
149
+
150
+ Generous — unlikely to hit for normal usage:
151
+ - Gamma: 4,000 requests per 10 seconds (general)
152
+ - CLOB: 9,000 requests per 10 seconds (general)
153
+ - Data: 1,000 requests per 10 seconds (general)
154
+
155
+ ## Limitations
156
+
157
+ - This skill is read-only — it does not support placing trades
158
+ - Trading requires wallet-based crypto authentication (EIP-712 signatures)
159
+ - Some new markets may have empty price history
160
+ - Geographic restrictions apply to trading but read-only data is globally accessible
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: protocol-api-key-integration
3
+ description: Safely connect API keys for trading protocols and venue SDKs without exposing secrets; use read/health/preview first, live execution double-gated.
4
+ triggers:
5
+ - connect protocol API keys
6
+ - Pear Protocol keys
7
+ - Hyperliquid protocol keys
8
+ - add venue API key
9
+ - trading SDK credentials
10
+ - ChangeNOW API key
11
+ - BTC to ETH convert in Oracle
12
+ ---
13
+
14
+ > Oracle native tools: `oracle_cli` (read/prepare), `vault_status`, `signer_status`, `signer_execute` (needs human confirmationNonce), `skill_load`. No generic shell. No fleet SSH.
15
+
16
+
17
+ # Protocol API key integration
18
+
19
+ Use when DEMI wants Pear Protocol, Hyperliquid-adjacent tools, ChangeNOW convert, or any trading protocol API keys connected to the agent stack.
20
+
21
+ ## Hard rules
22
+ - Never accept key values in chat, prompts, or tool args.
23
+ - Never print secrets. Health output reports present/source/value redacted only.
24
+ - Main/capital wallet is not an automated signer.
25
+ - Prefer agent/API wallets that cannot withdraw.
26
+ - Install credentials through owner-only files or a local prompt that never echoes values.
27
+ - Start with read/health/preview; live orders stay disabled until explicit GO plus caps.
28
+
29
+ ## API-key-gated aggregators (0x / 1inch)
30
+
31
+ For aggregator adapters, “wired” and “configured” are different. Code/tests can prove the prepare path with fake keys, but live routes still require real keys installed in owner-only env.
32
+
33
+ - 0x uses `ZEROX_API_KEY` / `0X_API_KEY`; health with no key should report `configured:false` / key-missing, not pretend the provider is down.
34
+ - 1inch uses `ONEINCH_API_KEY`; executable `/swap` and `/approve/spender` are key-gated. Slippage for 1inch Classic Swap API is percentage points (`0.3` = 30 bps).
35
+ - Do not paste keys into chat or test fixtures. Unit tests may pass `{ apiKey: "test-key" }` only against mocked `fetchImpl`; never claim that means live configuration.
36
+ - After adding keys, verify with redacted health and one tiny fresh quote/prepare smoke; never print returned auth headers, raw key values, or env file contents.
37
+
38
+ ## ChangeNOW multi-asset convert (BTC↔ETH / any ticker)
39
+ Hosted deposit-address rail when DEX+bridges cannot cover **native BTC** or awkward pairs. No good fully on-chain BTC→ETH path in Oracle today.
40
+
41
+ - Provider: `multiagent-desk` catalog `changenow` (`src/data/providers/changenow.mjs`).
42
+ - Ops: health · currencies · minAmount · estimate/convertQuote · createExchange · status.
43
+ - **Prepare-only:** create returns deposit address; user funds it; Oracle never custodies unless separate GO to fund deposit from agent.
44
+ - Currencies public; **estimate/create need** `CHANGENOW_API_KEY` (`x-changenow-api-key`). Health reports `keyConfigured` honestly.
45
+ - Env: `CHANGENOW_API_KEY`, optional `CHANGENOW_API_URL`. Never paste keys in chat.
46
+ - Prefer desk DEX/bridges for EVM↔EVM. Full detail: `references/changenow-convert.md` + repo `docs/CHANGENOW_CONVERT.md`.
47
+
48
+ ## Standard implementation shape
49
+ 1. Pick the right repo/surface.
50
+ - Internal cross-venue/cross-chain tooling: `multiagent-desk`.
51
+ - Public RH product/site/API/MCP: only if DEMI explicitly asks; RH product normally stays RH-only.
52
+ 2. Create a root/user-only env or secret file.
53
+ - Directory mode `0700`.
54
+ - File mode `0600` or `0400`.
55
+ - Refuse group/other-readable files.
56
+ 3. Parse dotenv manually; do not shell-source untrusted secret files inside agent code.
57
+ 4. Merge precedence: owner-only file first, environment overrides second.
58
+ 5. Add redacted health output:
59
+ - file exists/mode
60
+ - credential present true/false
61
+ - SDK installed true/false
62
+ - endpoint reachable/auth-required status
63
+ - live gates true/false
64
+ 6. Add preview builders that validate symbol, size, notional cap, and return `dryRun:true`, `executable:false` by default.
65
+ 7. Add tests before production code:
66
+ - bad permissions rejected
67
+ - redacted status contains no raw secret substring
68
+ - live execution refuses when gates are off
69
+ - preview validates amount/cap without sending an order
70
+ 8. Live execution gate ladder:
71
+ - protocol key installed
72
+ - agent wallet approved/funded if required
73
+ - global execute gate on
74
+ - protocol-specific trade gate on
75
+ - per-symbol/venue allowlist
76
+ - max notional cap
77
+ - fresh quote/sim/preview
78
+ - explicit DEMI GO
79
+
80
+ ## Pear + Hyperliquid case
81
+ See `references/pear-hyperliquid-keys.md` for the current `multiagent-desk` implementation pattern, commands, and Pear SDK quirks.
82
+
83
+ ## Documenting key setup for OTHER people (open-source SETUP.md)
84
+
85
+ When the project ships to strangers, the same rules become **docs**, and DEMI asks
86
+ for them by name ("fix the read mes on how to set up, ie api for hyperliquid api
87
+ for polymarket keys and how they are stored etc"). Put it in a dedicated
88
+ `SETUP.md` and link it prominently from the README — buried key docs mean people
89
+ export secrets however they guess.
90
+
91
+ Cover, in this order:
92
+
93
+ 1. **The two planes, stated first.** Read/prepare needs no key; execute always
94
+ does. A prepared artifact is inert until something signs it. Without this
95
+ framing every later instruction reads as "give the tool your key".
96
+ 2. **What each key unlocks AND what still works without it** — as a table. People
97
+ need to know they can evaluate the thing before handing over credentials.
98
+ Hyperliquid reads are keyless; Polymarket market data is keyless.
99
+ 3. **Per-venue credential shape**, because they differ structurally:
100
+ - **Hyperliquid issues no API key.** You authorize with an Ethereum private
101
+ key — use an **API wallet** (`app.hyperliquid.xyz/API`) that can trade but
102
+ **cannot withdraw**. Say that explicitly; it is the single most important
103
+ safety fact for an agent.
104
+ - **Polymarket needs two different things**: L2 API credentials
105
+ (`API_KEY`/`API_SECRET`/`API_PASSPHRASE`) for CLOB order posting, *and* the
106
+ Polygon private key that owns the funds. Conflating them wastes an hour.
107
+ 4. **Storage, worst → best**, with the honest tradeoff at each tier: env vars
108
+ (visible in `ps`, inherited by children), a `0600` key file, an encrypted
109
+ vault. Include the `chmod`/`printf` commands so nobody invents their own.
110
+ 5. **What the encryption does NOT protect.** A vault defends backups, cloud sync,
111
+ and stolen disks at rest; it does **not** defend malware running as the user
112
+ while the process is unlocked. Overselling a file-level scheme is worse than
113
+ shipping none, because it changes behaviour.
114
+ 6. **Both trade paths side by side** — non-custodial (Oracle prepares, user's
115
+ wallet signs) and agentic (Oracle holds a key and submits) — so the reader
116
+ picks deliberately rather than defaulting into custody.
117
+
118
+ Also state where credentials travel: pinned provider endpoints, key dropped
119
+ rather than forwarded when a `baseUrl` is redirected or downgraded to `http://`.
120
+
121
+ ### Arguing for a model router without overclaiming
122
+
123
+ When the project is a library, say plainly that **any** provider works (it is
124
+ just functions plus an MCP server), then make the specific case for Hermes:
125
+ per-profile routing matches a stack whose workloads have opposite needs —
126
+ cheap/wide for research, fast for execution (latency is money), strongest for
127
+ risk review, small for unattended crons — and the research profile can hold **no
128
+ signing key at all**.
129
+
130
+ Ground it in evidence rather than adjectives. The strongest available argument is
131
+ a multi-lineage audit result: four model families reviewed this codebase and each
132
+ found a CRITICAL the others missed, so one model reviewing its own work would
133
+ have shipped three of them. That is a fact about blind spots, not a vendor pitch.
134
+
135
+ ## Reporting format
136
+ Use terse plain labels:
137
+ - Status: connected / missing keys / preview-only / live disabled
138
+ - Gates: global, protocol, cap
139
+ - Agent wallet: address only
140
+ - Secrets: present or missing, value redacted
141
+ - Next: exact local/SSH step for DEMI to install keys without pasting them