pandora-cli-skills 1.1.59 → 1.1.62
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.
- package/README.md +12 -11
- package/README_FOR_SHARING.md +15 -1
- package/SKILL.md +32 -7
- package/cli/lib/agent_command_service.cjs +222 -0
- package/cli/lib/agent_contract_registry.cjs +2678 -0
- package/cli/lib/agent_market_prompt_service.cjs +488 -0
- package/cli/lib/arb_command_service.cjs +15 -1
- package/cli/lib/command_router.cjs +6 -0
- package/cli/lib/contract_error_decoder.cjs +26 -3
- package/cli/lib/error_recovery_service.cjs +29 -0
- package/cli/lib/indexer_client.cjs +51 -7
- package/cli/lib/market_admin_service.cjs +197 -60
- package/cli/lib/mcp_server_service.cjs +3 -1
- package/cli/lib/mcp_tool_registry.cjs +168 -342
- package/cli/lib/mirror_handlers/sync.cjs +3 -0
- package/cli/lib/mirror_service.cjs +8 -6
- package/cli/lib/mirror_sync/execution.cjs +141 -11
- package/cli/lib/pandora_deploy_service.cjs +214 -29
- package/cli/lib/parsers/core_command_flags.cjs +55 -7
- package/cli/lib/parsers/mirror_deploy_flags.cjs +106 -4
- package/cli/lib/parsers/mirror_go_flags.cjs +123 -2
- package/cli/lib/parsers/sports_flags.cjs +102 -5
- package/cli/lib/parsers/trade_flags.cjs +49 -3
- package/cli/lib/scan_command_service.cjs +2 -1
- package/cli/lib/schema_command_service.cjs +269 -413
- package/cli/lib/sports_creation_service.cjs +4 -1
- package/cli/lib/trade_command_service.cjs +100 -23
- package/cli/lib/trade_market_type_service.cjs +90 -0
- package/cli/pandora.cjs +785 -237
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,11 @@ pandora --output json trade --dry-run \
|
|
|
46
46
|
--market-address 0x... --side yes --amount-usdc 10 \
|
|
47
47
|
--fork --fork-rpc-url http://127.0.0.1:8545
|
|
48
48
|
|
|
49
|
+
# Dry-run a sell quote / exit path
|
|
50
|
+
pandora --output json sell --dry-run \
|
|
51
|
+
--market-address 0x... --side no --shares 25 \
|
|
52
|
+
--fork --fork-rpc-url http://127.0.0.1:8545
|
|
53
|
+
|
|
49
54
|
# NDJSON stream
|
|
50
55
|
pandora stream prices --indexer-url https://pandoraindexer.up.railway.app/ --interval-ms 1000
|
|
51
56
|
```
|
|
@@ -73,16 +78,6 @@ pandora --output json lifecycle status --id <lifecycle-id>
|
|
|
73
78
|
pandora --output json lifecycle resolve --id <lifecycle-id> --confirm
|
|
74
79
|
```
|
|
75
80
|
|
|
76
|
-
### Mega Analytics Page (Dune Panels)
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# starts local page at http://127.0.0.1:8787
|
|
80
|
-
npm run analytics:mega
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
- Panel registry source: `analytics/dune/panel_registry.json`
|
|
84
|
-
- Dashboard creation script reuses this registry: `scripts/create_pandora_dashboard.js`
|
|
85
|
-
|
|
86
81
|
## Risk Controls
|
|
87
82
|
|
|
88
83
|
- Inspect/engage panic lock:
|
|
@@ -115,6 +110,9 @@ npm run analytics:mega
|
|
|
115
110
|
## Command Surface
|
|
116
111
|
|
|
117
112
|
- `pandora markets list|get`
|
|
113
|
+
- `pandora scan`
|
|
114
|
+
- `scan` is the canonical enriched discovery workflow.
|
|
115
|
+
- `markets scan` remains a backward-compatible alias.
|
|
118
116
|
- `pandora sports books list`
|
|
119
117
|
- `pandora sports events list|live`
|
|
120
118
|
- `pandora sports odds snapshot|bulk`
|
|
@@ -125,11 +123,14 @@ npm run analytics:mega
|
|
|
125
123
|
- `pandora lifecycle start|status|resolve`
|
|
126
124
|
- `pandora quote`
|
|
127
125
|
- `pandora trade`
|
|
126
|
+
- `pandora sell`
|
|
128
127
|
- `pandora claim --market-address <address>|--all --dry-run|--execute`
|
|
129
128
|
- `pandora history`
|
|
130
129
|
- `pandora export`
|
|
130
|
+
- `pandora arb scan --output ndjson|json`
|
|
131
131
|
- `pandora arbitrage`
|
|
132
|
-
- `
|
|
132
|
+
- `arb scan` is the canonical arbitrage workflow.
|
|
133
|
+
- `arbitrage` remains a bounded one-shot compatibility wrapper.
|
|
133
134
|
- `pandora odds record|history`
|
|
134
135
|
- `pandora autopilot run|once`
|
|
135
136
|
- `pandora mirror browse|plan|deploy|verify|lp-explain|hedge-calc|simulate|go|sync|status|close`
|
package/README_FOR_SHARING.md
CHANGED
|
@@ -101,6 +101,7 @@ Prerequisite: Node.js `>=18`.
|
|
|
101
101
|
- Read-only indexer commands (GraphQL-backed):
|
|
102
102
|
- `pandora markets list|get`
|
|
103
103
|
- `pandora scan`
|
|
104
|
+
- `scan` is the canonical enriched discovery flow; `markets scan` remains an alias.
|
|
104
105
|
- `pandora quote`
|
|
105
106
|
- `pandora portfolio`
|
|
106
107
|
- `pandora watch`
|
|
@@ -117,8 +118,10 @@ Prerequisite: Node.js `>=18`.
|
|
|
117
118
|
- `pandora stream events` (reactive event feed in NDJSON)
|
|
118
119
|
- Phase 2 trading helpers:
|
|
119
120
|
- `pandora quote --market-address <0x...> --side yes|no --amount-usdc <amount>`
|
|
121
|
+
- `pandora quote --market-address <0x...> --side yes|no --mode sell --shares <amount>`
|
|
120
122
|
- `pandora trade --dry-run --market-address <0x...> --side yes|no --amount-usdc <amount> [--max-amount-usdc <amount>] [--min-probability-pct <0-100>] [--max-probability-pct <0-100>]`
|
|
121
123
|
- `pandora trade --execute ...` performs allowance check, conditional USDC approve, then `buy`.
|
|
124
|
+
- `pandora sell --dry-run|--execute --market-address <0x...> --side yes|no --shares <amount> [--min-amount-out-raw <uint>]`
|
|
122
125
|
- Phase 3 wallet analytics:
|
|
123
126
|
- `pandora portfolio --wallet <0x...> [--chain-id <id>] [--limit <n>] [--include-events|--no-events]`
|
|
124
127
|
- `pandora watch --wallet <0x...> --iterations 10 --interval-ms 5000`
|
|
@@ -126,6 +129,7 @@ Prerequisite: Node.js `>=18`.
|
|
|
126
129
|
- Phase 4 intelligence and automation:
|
|
127
130
|
- `pandora history --wallet <0x...> --limit 50`
|
|
128
131
|
- `pandora export --wallet <0x...> --format csv --year 2026 --out ./trades-2026.csv`
|
|
132
|
+
- `pandora arb scan --source polymarket --output json --iterations 1 --min-spread-pct 3`
|
|
129
133
|
- `pandora arbitrage --venues pandora,polymarket --min-spread-pct 3`
|
|
130
134
|
- `pandora autopilot run|once ...`
|
|
131
135
|
- `pandora mirror browse|plan|deploy|verify|lp-explain|hedge-calc|simulate|go|sync|status|close ...`
|
|
@@ -179,6 +183,7 @@ Prerequisite: Node.js `>=18`.
|
|
|
179
183
|
### Fork runtime support
|
|
180
184
|
- Supported families:
|
|
181
185
|
- `trade`
|
|
186
|
+
- `sell`
|
|
182
187
|
- `resolve`
|
|
183
188
|
- `claim`
|
|
184
189
|
- `lp`
|
|
@@ -201,6 +206,9 @@ Prerequisite: Node.js `>=18`.
|
|
|
201
206
|
Mirror advanced flags (for operator tuning):
|
|
202
207
|
- `--sync-interval-ms <ms>` on `mirror go` to control auto-sync tick cadence.
|
|
203
208
|
- `--oracle <address>` / `--factory <address>` on `mirror deploy` and `mirror go` for explicit contract overrides.
|
|
209
|
+
- `--rules "<text>"` on `mirror deploy` for direct rules override without a plan file.
|
|
210
|
+
- `--distribution-yes-pct <0-100>` / `--distribution-no-pct <0-100>` on `mirror deploy|go` as percentage alternatives to raw 1e9 part hints.
|
|
211
|
+
- `--max-imbalance <n>` now accepts the full uint24 range, including `0` for "no guard".
|
|
204
212
|
- `--polymarket-gamma-mock-url <url>` on `mirror browse|plan|verify|go|sync|status` for deterministic mock-source testing.
|
|
205
213
|
- `--polymarket-tag-id <id>` / `--polymarket-tag-ids <csv>` on `mirror browse` (aliases: `--sport-tag-id`, `--sport-tag-ids`) to query sports-tagged Gamma events.
|
|
206
214
|
- `--no-stream` on `mirror sync` to disable per-tick stdout line streaming in run mode.
|
|
@@ -220,6 +228,7 @@ Mirror advanced flags (for operator tuning):
|
|
|
220
228
|
- `pandora watch --wallet <0x...> --iterations 3 --interval-ms 1000 --alert-net-liquidity-below -100`
|
|
221
229
|
- `pandora history --wallet <0x...> --limit 50`
|
|
222
230
|
- `pandora export --wallet <0x...> --format csv --out ./trades.csv`
|
|
231
|
+
- `pandora arb scan --source polymarket --output json --iterations 1 --min-spread-pct 2 --min-tvl 50`
|
|
223
232
|
- `pandora arbitrage --venues pandora,polymarket --min-spread-pct 2 --cross-venue-only --with-rules --include-similarity`
|
|
224
233
|
- `pandora autopilot once --market-address <0x...> --side no --amount-usdc 10 --trigger-yes-below 15 --paper`
|
|
225
234
|
- `pandora mirror browse --polymarket-tag-id 82 --min-yes-pct 20 --max-yes-pct 80 --min-volume-24h 100000 --limit 10`
|
|
@@ -258,19 +267,23 @@ Mirror advanced flags (for operator tuning):
|
|
|
258
267
|
|
|
259
268
|
## Phase 2 JSON contracts
|
|
260
269
|
- `quote`:
|
|
261
|
-
- envelope is `ok=true`, `command="quote"`, with `data.marketAddress`, `data.side`, `data.
|
|
270
|
+
- envelope is `ok=true`, `command="quote"`, with `data.marketAddress`, `data.side`, `data.mode`, either `data.amountUsdc` (buy) or `data.amount` (sell), plus `data.odds`, `data.quoteAvailable`, and `data.estimate` (or `null` when unavailable).
|
|
262
271
|
- `trade --dry-run`:
|
|
263
272
|
- envelope is `ok=true`, `command="trade"`, with `data.mode="dry-run"`, `data.quote`, `data.selectedProbabilityPct`, `data.riskGuards`, and `data.executionPlan.steps`.
|
|
264
273
|
- `trade --execute`:
|
|
265
274
|
- envelope is `ok=true`, `command="trade"`, with tx metadata (`approveTxHash` optional, `buyTxHash` required on success) plus `selectedProbabilityPct` and `riskGuards`.
|
|
275
|
+
- `sell --dry-run|--execute`:
|
|
276
|
+
- envelope is `ok=true`, `command="sell"`, with `data.action="sell"`, sell-aware quote/tx metadata, and `minAmountOutRaw` instead of buy-side minimum-share semantics.
|
|
266
277
|
|
|
267
278
|
## Phase 2 limitations
|
|
268
279
|
- `trade` auto-detects market type and uses the correct buy signature:
|
|
269
280
|
- PariMutuel: `buy(bool,uint256,uint256)`
|
|
270
281
|
- AMM: `buy(bool,uint256,uint256,uint256)` (deadline-aware)
|
|
282
|
+
- `sell` is AMM-only and uses `sell(bool,uint112,uint256,uint256)`.
|
|
271
283
|
- `minSharesOut` protection defaults to raw `0` unless explicitly set with `--min-shares-out-raw`.
|
|
272
284
|
- If indexer odds are unavailable, `quote` still returns a structured payload with `quoteAvailable=false`.
|
|
273
285
|
- `trade --execute` blocks unquoted execution by default unless `--min-shares-out-raw` or `--allow-unquoted-execute` is provided.
|
|
286
|
+
- `sell --execute` blocks unquoted execution by default unless `--min-amount-out-raw` or `--allow-unquoted-execute` is provided.
|
|
274
287
|
|
|
275
288
|
## Phase 3 JSON contracts
|
|
276
289
|
- `portfolio`:
|
|
@@ -295,6 +308,7 @@ Mirror advanced flags (for operator tuning):
|
|
|
295
308
|
- envelope is `ok=true`, `command="export"`, with `data.format`, `data.columns`, `data.count`, optional `data.outPath`, and materialized `data.content`.
|
|
296
309
|
- `arbitrage`:
|
|
297
310
|
- envelope is `ok=true`, `command="arbitrage"`, with `data.parameters`, `data.sources`, and `data.opportunities[]`.
|
|
311
|
+
- use `arb scan` as the canonical arbitrage interface; `arbitrage` is the compatibility one-shot wrapper.
|
|
298
312
|
- agent-focused flags:
|
|
299
313
|
- `--cross-venue-only` (default) prevents same-venue duplicate-market noise.
|
|
300
314
|
- `--allow-same-venue` re-enables same-venue matching.
|
package/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pandora-cli-skills
|
|
3
3
|
summary: Canonical skill and operator guide for Pandora CLI including mirror, polymarket, resolve, and LP flows.
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.62
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Pandora CLI & Skills
|
|
@@ -40,10 +40,13 @@ npm link
|
|
|
40
40
|
- `--output json` is supported for all commands except `launch`/`clone-bet`; those stream script output directly.
|
|
41
41
|
- Agent schema command: `pandora --output json schema`
|
|
42
42
|
- MCP server mode: `pandora mcp`
|
|
43
|
+
- Agent market prompt tools:
|
|
44
|
+
- `pandora --output json agent market autocomplete --question "<text>" [--market-type amm|parimutuel]`
|
|
45
|
+
- `pandora --output json agent market validate --question "<text>" --rules "<text>" --target-timestamp <unix-seconds> [--sources <url...>]`
|
|
43
46
|
- Guided setup command: `pandora setup`
|
|
44
47
|
- Phase 1 discovery command: `pandora scan`
|
|
45
48
|
- Phase 1 lifecycle filters: `pandora markets list --active|--resolved|--expiring-soon`
|
|
46
|
-
- Phase 2 trading commands: `pandora quote`, `pandora trade`
|
|
49
|
+
- Phase 2 trading commands: `pandora quote`, `pandora trade`, `pandora sell`
|
|
47
50
|
- Phase 2 risk guardrails: `--max-amount-usdc`, `--min-probability-pct`, `--max-probability-pct`
|
|
48
51
|
- Phase 3 analytics command: `pandora portfolio`
|
|
49
52
|
- Phase 3 monitoring command: `pandora watch`
|
|
@@ -52,6 +55,7 @@ npm link
|
|
|
52
55
|
- Phase 4 commands:
|
|
53
56
|
- `pandora history`
|
|
54
57
|
- `pandora export`
|
|
58
|
+
- `pandora arb scan`
|
|
55
59
|
- `pandora arbitrage`
|
|
56
60
|
- `pandora autopilot run|once`
|
|
57
61
|
- `pandora mirror browse|plan|deploy|verify|lp-explain|hedge-calc|simulate|go|sync|status|close`
|
|
@@ -72,6 +76,10 @@ npm link
|
|
|
72
76
|
- `--fork-chain-id <id>`
|
|
73
77
|
- JSON errors can include additive recovery hints:
|
|
74
78
|
- `error.recovery = { action, command, retryable }`
|
|
79
|
+
- Agent/MCP market creation policy:
|
|
80
|
+
- Agent-drafted manual markets should start with `agent market autocomplete` when rules, sources, or timing still need to be generated/refined.
|
|
81
|
+
- Execute/live MCP calls for `sports create run`, `mirror deploy`, and `mirror go` require a PASS attestation from `agent market validate`.
|
|
82
|
+
- Dry-run outputs for those flows include the exact validation ticket that must be echoed back via `agentPreflight` on the execute call.
|
|
75
83
|
- Doctor checks:
|
|
76
84
|
- env presence + format validation
|
|
77
85
|
- RPC reachability and chain id match
|
|
@@ -83,6 +91,15 @@ npm link
|
|
|
83
91
|
- Current risk-counter semantics:
|
|
84
92
|
- `max_position_usd` guards per-operation notional.
|
|
85
93
|
- `max_daily_loss_usd` is enforced as daily live notional (`counters.liveNotionalUsdc`).
|
|
94
|
+
|
|
95
|
+
## Canonical command paths
|
|
96
|
+
- Market discovery:
|
|
97
|
+
- `pandora scan` is the canonical enriched discovery flow.
|
|
98
|
+
- `pandora markets scan` remains a backward-compatible alias.
|
|
99
|
+
- `pandora markets list` is the raw indexer browse surface.
|
|
100
|
+
- Arbitrage:
|
|
101
|
+
- `pandora arb scan` is the canonical arbitrage flow for bounded JSON or streaming NDJSON scans.
|
|
102
|
+
- `pandora arbitrage` remains a backward-compatible one-shot wrapper over the same cross-venue engine.
|
|
86
103
|
- `max_open_markets` is enforced as daily live operation count (`counters.liveOps`).
|
|
87
104
|
|
|
88
105
|
## Quant ABM baseline (module contract)
|
|
@@ -132,11 +149,14 @@ pandora [--output table|json] positions list [--wallet <address>] [--market-addr
|
|
|
132
149
|
pandora [--output table|json] portfolio --wallet <address> [--chain-id <id>] [--limit <n>] [--include-events|--no-events] [--with-lp] [--rpc-url <url>]
|
|
133
150
|
pandora [--output table|json] watch [--wallet <address>] [--market-address <address>] [--side yes|no] [--amount-usdc <amount>] [--iterations <n>] [--interval-ms <ms>] [--chain-id <id>] [--include-events|--no-events] [--yes-pct <0-100>] [--alert-yes-below <0-100>] [--alert-yes-above <0-100>] [--alert-net-liquidity-below <amount>] [--alert-net-liquidity-above <amount>] [--fail-on-alert] [--track-brier] [--brier-source <name>] [--brier-file <path>] [--group-by source|market|competition]
|
|
134
151
|
pandora [--output table|json] scan [--limit <n>] [--after <cursor>] [--before <cursor>] [--order-by <field>] [--order-direction asc|desc] [--chain-id <id>] [--creator <address>] [--poll-address <address>] [--market-type <type>] [--where-json <json>] [--active|--resolved|--expiring-soon] [--expiring-hours <n>] [--expand]
|
|
135
|
-
pandora [--output table|json]
|
|
152
|
+
pandora [--output table|json] markets scan [scan flags] # backward-compatible alias of scan
|
|
153
|
+
pandora [--output table|json] quote [--indexer-url <url>] [--timeout-ms <ms>] --market-address <address> --side yes|no [--mode buy|sell] --amount-usdc <amount>|--shares <amount>|--amounts <csv> [--yes-pct <0-100>] [--slippage-bps <0-10000>]
|
|
136
154
|
pandora [--output table|json] trade [--indexer-url <url>] [--timeout-ms <ms>] [--dotenv-path <path>] [--skip-dotenv] --market-address <address> --side yes|no --amount-usdc <amount> --dry-run|--execute [--yes-pct <0-100>] [--slippage-bps <0-10000>] [--min-shares-out-raw <uint>] [--max-amount-usdc <amount>] [--min-probability-pct <0-100>] [--max-probability-pct <0-100>] [--allow-unquoted-execute] [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--usdc <address>]
|
|
155
|
+
pandora [--output table|json] sell [--indexer-url <url>] [--timeout-ms <ms>] [--dotenv-path <path>] [--skip-dotenv] --market-address <address> --side yes|no --shares <amount>|--amount <amount> --dry-run|--execute [--yes-pct <0-100>] [--slippage-bps <0-10000>] [--min-amount-out-raw <uint>] [--allow-unquoted-execute] [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--usdc <address>]
|
|
137
156
|
pandora [--output table|json] claim [--dotenv-path <path>] [--skip-dotenv] --market-address <address>|--all [--wallet <address>] --dry-run|--execute [--fork] [--fork-rpc-url <url>] [--fork-chain-id <id>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--indexer-url <url>] [--timeout-ms <ms>]
|
|
138
157
|
pandora [--output table|json] history --wallet <address> [--chain-id <id>] [--market-address <address>] [--side yes|no|both] [--status all|open|won|lost|closed] [--limit <n>] [--after <cursor>] [--before <cursor>] [--order-by timestamp|pnl|entry-price|mark-price] [--order-direction asc|desc] [--include-seed]
|
|
139
158
|
pandora [--output table|json] export --wallet <address> --format csv|json [--chain-id <id>] [--year <yyyy>] [--from <unix>] [--to <unix>] [--out <path>]
|
|
159
|
+
pandora arb scan [--source pandora|polymarket] [--markets <csv>] --output ndjson|json [--min-net-spread-pct <n>] [--fee-pct-per-leg <n>] [--slippage-pct-per-leg <n>] [--amount-usdc <n>] [--combinatorial] [--max-bundle-size <n>] [--iterations <n>] [--interval-ms <ms>]
|
|
140
160
|
pandora [--output table|json] arbitrage [--chain-id <id>] [--venues pandora,polymarket] [--limit <n>] [--min-spread-pct <n>] [--min-liquidity-usdc <n>] [--max-close-diff-hours <n>] [--similarity-threshold <0-1>] [--cross-venue-only|--allow-same-venue] [--with-rules] [--include-similarity] [--question-contains <text>] [--polymarket-host <url>] [--polymarket-mock-url <url>]
|
|
141
161
|
pandora [--output table|json] autopilot run|once --market-address <address> --side yes|no --amount-usdc <amount> [--trigger-yes-below <0-100>] [--trigger-yes-above <0-100>] [--paper|--execute-live] [--interval-ms <ms>] [--cooldown-ms <ms>] [--max-amount-usdc <amount>] [--max-open-exposure-usdc <amount>] [--max-trades-per-day <n>] [--state-file <path>] [--kill-switch-file <path>] [--webhook-url <url>] [--telegram-bot-token <token>] [--telegram-chat-id <id>] [--discord-webhook-url <url>]
|
|
142
162
|
pandora [--output table|json] mirror browse|plan|deploy|verify|lp-explain|hedge-calc|simulate|go|sync|status|close ...
|
|
@@ -162,12 +182,12 @@ Mirror subcommand detail:
|
|
|
162
182
|
```text
|
|
163
183
|
browse --min-yes-pct <n> --max-yes-pct <n> --min-volume-24h <n> [--closes-after <date>] [--closes-before <date>] [--question-contains <text>] [--limit <n>] [--chain-id <id>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
|
|
164
184
|
plan --source polymarket --polymarket-market-id <id>|--polymarket-slug <slug> [--chain-id <id>] [--target-slippage-bps <n>] [--turnover-target <n>] [--depth-slippage-bps <n>] [--safety-multiplier <n>] [--min-liquidity-usdc <n>] [--max-liquidity-usdc <n>] [--with-rules] [--include-similarity] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
|
|
165
|
-
deploy --plan-file <path>|--polymarket-market-id <id>|--polymarket-slug <slug> --dry-run|--execute [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--oracle <address>] [--factory <address>] [--usdc <address>] [--distribution-yes <parts>] [--distribution-no <parts>] [--sources <url...>] [--min-close-lead-seconds <n>] [--manifest-file <path>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
|
|
185
|
+
deploy --plan-file <path>|--polymarket-market-id <id>|--polymarket-slug <slug> --dry-run|--execute [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--oracle <address>] [--factory <address>] [--usdc <address>] [--distribution-yes <parts>] [--distribution-no <parts>] [--distribution-yes-pct <0-100>] [--distribution-no-pct <0-100>] [--rules <text>] [--sources <url...>] [--min-close-lead-seconds <n>] [--manifest-file <path>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
|
|
166
186
|
verify --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug> [--trust-deploy] [--manifest-file <path>] [--include-similarity] [--with-rules] [--allow-rule-mismatch] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>]
|
|
167
187
|
lp-explain --liquidity-usdc <n> [--source-yes-pct <0-100>] [--distribution-yes <parts>] [--distribution-no <parts>]
|
|
168
188
|
hedge-calc [--reserve-yes-usdc <n> --reserve-no-usdc <n>] [--excess-yes-usdc <n>] [--excess-no-usdc <n>] [--polymarket-yes-pct <0-100>] [--hedge-ratio <n>] [--hedge-cost-bps <n>] [--volume-scenarios <csv>] [--pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug>] [--trust-deploy] [--manifest-file <path>]
|
|
169
189
|
simulate --liquidity-usdc <n> [--source-yes-pct <0-100>] [--target-yes-pct <0-100>] [--distribution-yes <parts>] [--distribution-no <parts>] [--fee-tier <500-50000>] [--volume-scenarios <csv>] [--hedge-ratio <n>] [--hedge-cost-bps <n>] [--polymarket-yes-pct <0-100>]
|
|
170
|
-
go --polymarket-market-id <id>|--polymarket-slug <slug> [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--paper|--dry-run|--execute-live|--execute] [--auto-sync] [--sync-once] [--sync-interval-ms <ms>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--oracle <address>] [--factory <address>] [--sources <url...>] [--manifest-file <path>] [--trust-deploy] [--skip-gate] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--with-rules] [--include-similarity] [--min-close-lead-seconds <n>]
|
|
190
|
+
go --polymarket-market-id <id>|--polymarket-slug <slug> [--liquidity-usdc <n>] [--fee-tier <500-50000>] [--max-imbalance <n>] [--arbiter <address>] [--category <n>] [--paper|--dry-run|--execute-live|--execute] [--auto-sync] [--sync-once] [--sync-interval-ms <ms>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--oracle <address>] [--factory <address>] [--distribution-yes-pct <0-100>] [--distribution-no-pct <0-100>] [--sources <url...>] [--manifest-file <path>] [--trust-deploy] [--skip-gate] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--with-rules] [--include-similarity] [--min-close-lead-seconds <n>]
|
|
171
191
|
sync run|once|start --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug> [--paper|--dry-run|--execute-live|--execute] [--private-key <hex>] [--funder <address>] [--usdc <address>] [--trust-deploy] [--manifest-file <path>] [--skip-gate] [--daemon] [--stream|--no-stream] [--interval-ms <ms>] [--drift-trigger-bps <n>] [--hedge-trigger-usdc <n>] [--hedge-ratio <n>] [--no-hedge] [--max-rebalance-usdc <n>] [--max-hedge-usdc <n>] [--max-open-exposure-usdc <n>] [--max-trades-per-day <n>] [--cooldown-ms <ms>] [--depth-slippage-bps <n>] [--min-time-to-close-sec <n>] [--iterations <n>] [--state-file <path>] [--kill-switch-file <path>] [--chain-id <id>] [--rpc-url <url>] [--polymarket-host <url>] [--polymarket-gamma-url <url>] [--polymarket-gamma-mock-url <url>] [--polymarket-mock-url <url>] [--webhook-url <url>] [--telegram-bot-token <token>] [--telegram-chat-id <id>] [--discord-webhook-url <url>]
|
|
172
192
|
status --state-file <path>|--strategy-hash <hash> [--with-live] [--pandora-market-address <address>|--market-address <address>] [--polymarket-market-id <id>|--polymarket-slug <slug>]
|
|
173
193
|
close --pandora-market-address <address>|--market-address <address> --polymarket-market-id <id>|--polymarket-slug <slug>|--all --dry-run|--execute [--wallet <address>] [--chain-id <id>] [--rpc-url <url>] [--private-key <hex>] [--indexer-url <url>] [--timeout-ms <ms>]
|
|
@@ -354,19 +374,23 @@ pandora --output json schema
|
|
|
354
374
|
|
|
355
375
|
## Phase 2 JSON contracts
|
|
356
376
|
- `quote`:
|
|
357
|
-
- envelope is `ok=true`, `command="quote"`, with `data.marketAddress`, `data.side`, `data.
|
|
377
|
+
- envelope is `ok=true`, `command="quote"`, with `data.marketAddress`, `data.side`, `data.mode`, either `data.amountUsdc` (buy) or `data.amount` (sell), plus `data.odds`, `data.quoteAvailable`, and `data.estimate` (or `null`).
|
|
358
378
|
- `trade --dry-run`:
|
|
359
379
|
- envelope is `ok=true`, `command="trade"`, with `data.mode="dry-run"`, `data.quote`, `data.selectedProbabilityPct`, `data.riskGuards`, and `data.executionPlan.steps`.
|
|
360
380
|
- `trade --execute`:
|
|
361
381
|
- envelope is `ok=true`, `command="trade"`, with tx metadata (`approveTxHash` optional, `buyTxHash` required on success) plus `selectedProbabilityPct` and `riskGuards`.
|
|
382
|
+
- `sell --dry-run|--execute`:
|
|
383
|
+
- envelope is `ok=true`, `command="sell"`, with `data.action="sell"`, sell-aware quote/tx metadata, and `minAmountOutRaw` instead of buy-side minimum-share semantics.
|
|
362
384
|
|
|
363
385
|
## Phase 2 limitations
|
|
364
386
|
- `trade` auto-detects market type and uses the correct buy signature:
|
|
365
387
|
- PariMutuel: `buy(bool,uint256,uint256)`
|
|
366
388
|
- AMM: `buy(bool,uint256,uint256,uint256)` (deadline-aware)
|
|
389
|
+
- `sell` is AMM-only and uses `sell(bool,uint112,uint256,uint256)`.
|
|
367
390
|
- `--min-shares-out-raw` is the explicit slippage guard input for on-chain execution.
|
|
368
391
|
- If indexer odds are unavailable, `quote` still returns structured output with `quoteAvailable=false`.
|
|
369
392
|
- `trade --execute` blocks unquoted execution by default unless `--min-shares-out-raw` or `--allow-unquoted-execute` is provided.
|
|
393
|
+
- `sell --execute` blocks unquoted execution by default unless `--min-amount-out-raw` or `--allow-unquoted-execute` is provided.
|
|
370
394
|
|
|
371
395
|
## Phase 3 JSON contracts
|
|
372
396
|
- `portfolio`:
|
|
@@ -467,7 +491,7 @@ Mode aliases:
|
|
|
467
491
|
Common compatibility aliases:
|
|
468
492
|
- `--env-file` = `--dotenv-path`
|
|
469
493
|
- `--no-env-file` = `--skip-dotenv`
|
|
470
|
-
- `--amount` = `--amount-usdc`
|
|
494
|
+
- `--amount` = `--amount-usdc` on buy-side trade/watch/autopilot paths, and share input on `sell`.
|
|
471
495
|
- `--market-id` = `--condition-id` (polymarket trade)
|
|
472
496
|
- `--force-gate` = `--skip-gate` (deprecated; use `--skip-gate`)
|
|
473
497
|
|
|
@@ -475,6 +499,7 @@ Common compatibility aliases:
|
|
|
475
499
|
- Distribution inputs use parts-per-billion (ppb):
|
|
476
500
|
- `--distribution-yes 580000000` means YES seed weight = `58%`.
|
|
477
501
|
- `--distribution-no 420000000` means NO seed weight = `42%`.
|
|
502
|
+
- `--distribution-yes-pct 58 --distribution-no-pct 42` is the percentage alias form on supported deploy/create paths.
|
|
478
503
|
- Constraint: `distributionYes + distributionNo = 1_000_000_000`.
|
|
479
504
|
|
|
480
505
|
## Error code guide
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
const {
|
|
2
|
+
buildAgentMarketAutocompletePayload,
|
|
3
|
+
buildAgentMarketValidationPayload,
|
|
4
|
+
} = require('./agent_market_prompt_service.cjs');
|
|
5
|
+
|
|
6
|
+
function requireDep(deps, name) {
|
|
7
|
+
if (!deps || typeof deps[name] !== 'function') {
|
|
8
|
+
throw new Error(`createRunAgentCommand requires deps.${name}()`);
|
|
9
|
+
}
|
|
10
|
+
return deps[name];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function readFlagValue(args, index, flagName) {
|
|
14
|
+
const value = args[index + 1];
|
|
15
|
+
if (typeof value !== 'string' || value.startsWith('--')) {
|
|
16
|
+
const error = new Error(`${flagName} requires a value.`);
|
|
17
|
+
error.code = 'MISSING_FLAG_VALUE';
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function parseAgentMarketAutocompleteFlags(args) {
|
|
24
|
+
const options = {
|
|
25
|
+
question: '',
|
|
26
|
+
marketType: 'amm',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
30
|
+
const token = args[i];
|
|
31
|
+
if (token === '--question') {
|
|
32
|
+
options.question = readFlagValue(args, i, '--question');
|
|
33
|
+
i += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (token === '--market-type') {
|
|
37
|
+
options.marketType = readFlagValue(args, i, '--market-type');
|
|
38
|
+
i += 1;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const error = new Error(`Unknown flag for agent market autocomplete: ${token}`);
|
|
42
|
+
error.code = 'UNKNOWN_FLAG';
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!String(options.question || '').trim()) {
|
|
47
|
+
const error = new Error('agent market autocomplete requires --question <text>.');
|
|
48
|
+
error.code = 'MISSING_REQUIRED_FLAG';
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return options;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function parseAgentMarketValidateFlags(args) {
|
|
56
|
+
const options = {
|
|
57
|
+
question: '',
|
|
58
|
+
rules: '',
|
|
59
|
+
sources: [],
|
|
60
|
+
targetTimestamp: 0,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
64
|
+
const token = args[i];
|
|
65
|
+
if (token === '--question') {
|
|
66
|
+
options.question = readFlagValue(args, i, '--question');
|
|
67
|
+
i += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (token === '--rules') {
|
|
71
|
+
options.rules = readFlagValue(args, i, '--rules');
|
|
72
|
+
i += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (token === '--target-timestamp') {
|
|
76
|
+
const raw = readFlagValue(args, i, '--target-timestamp');
|
|
77
|
+
const numeric = Number(raw);
|
|
78
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
79
|
+
const error = new Error('--target-timestamp must be a unix timestamp in seconds.');
|
|
80
|
+
error.code = 'INVALID_FLAG_VALUE';
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
options.targetTimestamp = Math.trunc(numeric);
|
|
84
|
+
i += 1;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (token === '--sources') {
|
|
88
|
+
let consumed = 0;
|
|
89
|
+
for (let j = i + 1; j < args.length; j += 1) {
|
|
90
|
+
const value = args[j];
|
|
91
|
+
if (typeof value !== 'string' || value.startsWith('--')) break;
|
|
92
|
+
options.sources.push(value);
|
|
93
|
+
consumed += 1;
|
|
94
|
+
}
|
|
95
|
+
if (!consumed) {
|
|
96
|
+
const error = new Error('--sources requires at least one URL value.');
|
|
97
|
+
error.code = 'MISSING_FLAG_VALUE';
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
i += consumed;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (token === '--source') {
|
|
104
|
+
options.sources.push(readFlagValue(args, i, '--source'));
|
|
105
|
+
i += 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const error = new Error(`Unknown flag for agent market validate: ${token}`);
|
|
109
|
+
error.code = 'UNKNOWN_FLAG';
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!String(options.question || '').trim()) {
|
|
114
|
+
const error = new Error('agent market validate requires --question <text>.');
|
|
115
|
+
error.code = 'MISSING_REQUIRED_FLAG';
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
if (!String(options.rules || '').trim()) {
|
|
119
|
+
const error = new Error('agent market validate requires --rules <text>.');
|
|
120
|
+
error.code = 'MISSING_REQUIRED_FLAG';
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
if (!options.targetTimestamp) {
|
|
124
|
+
const error = new Error('agent market validate requires --target-timestamp <unix-seconds>.');
|
|
125
|
+
error.code = 'MISSING_REQUIRED_FLAG';
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return options;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function renderAgentPromptTable(payload) {
|
|
133
|
+
const lines = [
|
|
134
|
+
`${payload.promptKind} (${payload.promptVersion})`,
|
|
135
|
+
];
|
|
136
|
+
if (payload.ticket) {
|
|
137
|
+
lines.push(`ticket: ${payload.ticket}`);
|
|
138
|
+
}
|
|
139
|
+
lines.push('');
|
|
140
|
+
lines.push('Prompt:');
|
|
141
|
+
lines.push(payload.prompt);
|
|
142
|
+
lines.push('');
|
|
143
|
+
lines.push('Workflow:');
|
|
144
|
+
for (const note of payload.workflow && Array.isArray(payload.workflow.notes) ? payload.workflow.notes : []) {
|
|
145
|
+
lines.push(`- ${note}`);
|
|
146
|
+
}
|
|
147
|
+
if (payload.requiredAttestation) {
|
|
148
|
+
lines.push('');
|
|
149
|
+
lines.push('Required attestation:');
|
|
150
|
+
lines.push(JSON.stringify(payload.requiredAttestation, null, 2));
|
|
151
|
+
}
|
|
152
|
+
// eslint-disable-next-line no-console
|
|
153
|
+
console.log(lines.join('\n'));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function createRunAgentCommand(deps) {
|
|
157
|
+
const CliError = deps.CliError;
|
|
158
|
+
const includesHelpFlag = requireDep(deps, 'includesHelpFlag');
|
|
159
|
+
const emitSuccess = requireDep(deps, 'emitSuccess');
|
|
160
|
+
const commandHelpPayload = requireDep(deps, 'commandHelpPayload');
|
|
161
|
+
|
|
162
|
+
if (typeof CliError !== 'function') {
|
|
163
|
+
throw new Error('createRunAgentCommand requires deps.CliError.');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function runAgentCommand(args, context) {
|
|
167
|
+
const rest = Array.isArray(args) ? args : [];
|
|
168
|
+
if (!rest.length || includesHelpFlag(rest)) {
|
|
169
|
+
const usage = [
|
|
170
|
+
'pandora [--output table|json] agent market autocomplete --question <text> [--market-type amm|parimutuel]',
|
|
171
|
+
'pandora [--output table|json] agent market validate --question <text> --rules <text> --target-timestamp <unix-seconds> [--sources <url...>]',
|
|
172
|
+
];
|
|
173
|
+
if (context.outputMode === 'json') {
|
|
174
|
+
emitSuccess(context.outputMode, 'agent.help', commandHelpPayload(usage));
|
|
175
|
+
} else {
|
|
176
|
+
renderAgentPromptTable({
|
|
177
|
+
promptKind: 'agent.help',
|
|
178
|
+
promptVersion: 'n/a',
|
|
179
|
+
ticket: null,
|
|
180
|
+
prompt: usage.join('\n'),
|
|
181
|
+
workflow: {
|
|
182
|
+
notes: [
|
|
183
|
+
'Use agent market autocomplete when the agent must draft market rules or timing.',
|
|
184
|
+
'Use agent market validate before any agent-exposed market execute path.',
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const namespace = rest[0];
|
|
193
|
+
const action = rest[1];
|
|
194
|
+
const actionArgs = rest.slice(2);
|
|
195
|
+
|
|
196
|
+
if (namespace !== 'market') {
|
|
197
|
+
throw new CliError('INVALID_ARGS', 'agent requires subcommand: market autocomplete|validate');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (action === 'autocomplete') {
|
|
201
|
+
const payload = buildAgentMarketAutocompletePayload(parseAgentMarketAutocompleteFlags(actionArgs));
|
|
202
|
+
emitSuccess(context.outputMode, 'agent.market.autocomplete', payload, renderAgentPromptTable);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (action === 'validate') {
|
|
207
|
+
const payload = buildAgentMarketValidationPayload(parseAgentMarketValidateFlags(actionArgs));
|
|
208
|
+
emitSuccess(context.outputMode, 'agent.market.validate', payload, renderAgentPromptTable);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
throw new CliError('INVALID_ARGS', 'agent market requires subcommand: autocomplete|validate');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
runAgentCommand,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = {
|
|
221
|
+
createRunAgentCommand,
|
|
222
|
+
};
|