@spfunctions/cli 2.0.6 → 2.0.10

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 CHANGED
@@ -1,109 +1,247 @@
1
1
  # SimpleFunctions CLI (`sf`)
2
2
 
3
- Prediction market intelligence CLI. Build causal thesis models, scan Kalshi/Polymarket for mispricings, detect edges, and tradeall from the terminal.
3
+ A terminal-native prediction market agent. Builds causal models of the world, scans 4,000+ Kalshi and Polymarket contracts for mispricings, and trades on your thesis autonomously or with you in the loop.
4
4
 
5
- ![demo](https://raw.githubusercontent.com/spfunctions/simplefunctions-cli/main/demo.gif)
5
+ ```
6
+ $ sf world
7
+ # World State — 2026-04-05T05:38 UTC
8
+ SF Index: Uncertainty 22/100 | Geopolitical Risk 53/100
9
+
10
+ Markets: SPY $655.94 (+0.12%) | GLD $429.08 (-1.79%) | USO $138.18 (+11.99%)
11
+
12
+ ## Geopolitical
13
+ - Will the U.S. invade Iran before 2027?: 54c (-7c)
14
+ - Russia x Ukraine ceasefire by end of 2026?: 30c
15
+
16
+ ## Economy
17
+ - US recession by end of 2026?: 28c
18
+ - How many Fed rate cuts in 2026?: 0 (0 bps): 36c
19
+ ```
6
20
 
7
- ## Quick Start
21
+ ## Install
8
22
 
9
23
  ```bash
10
24
  npm install -g @spfunctions/cli
11
- sf setup # interactive config wizard
12
- sf list # see your theses
13
- sf context <id> --json # get thesis state as JSON
25
+ sf login # browser auth (recommended)
26
+ sf status # verify everything works
27
+ ```
28
+
29
+ ## What it does
30
+
31
+ **World model** — Real-time prediction index distilled from thousands of markets. One command gives any LLM situational awareness.
32
+
33
+ ```bash
34
+ sf world # ~800 token world state snapshot
35
+ sf world --delta # what changed since last check (~30 tokens)
36
+ sf world --focus energy,geo # deep coverage on specific topics
37
+ sf ideas # S&T-style trade ideas with catalyst + risk
38
+ ```
39
+
40
+ **Thesis engine** — Structured causal models with Bayesian node trees, continuous evaluation against live market data, and automatic edge detection.
41
+
42
+ ```bash
43
+ sf create "Oil will exceed $120 by Q3 due to Hormuz disruption"
44
+ sf list # all theses with confidence + status
45
+ sf context <id> # causal tree + top edges + positions
46
+ sf evaluate <id> # trigger deep re-evaluation
47
+ sf signal <id> "OPEC cuts" # inject a signal for next eval cycle
48
+ ```
49
+
50
+ **Edge detection** — Cross-venue scanner compares your model's probabilities against Kalshi and Polymarket prices.
51
+
52
+ ```bash
53
+ sf edges # top mispricings across all theses
54
+ sf scan "recession" # search 4,000+ markets by keyword
55
+ sf book KXRECSSNBER-26 # orderbook depth
56
+ sf watch oil orderbook # live terminal orderbook stream
57
+ ```
58
+
59
+ **Intent system** — Declarative execution: describe what you want, the runtime handles when and how.
60
+
61
+ ```bash
62
+ sf intent buy KXRECSSNBER-26 10 --price 30 --trigger below:28 --auto
63
+ sf intent list # active intents + fill status
64
+ sf runtime start # daemon evaluates triggers, executes orders
65
+ ```
66
+
67
+ **Interactive agent** — Natural language interface with 30+ tools. Maintains a persistent workspace, shares context across sessions, and can schedule its own future actions.
68
+
69
+ ```bash
70
+ sf agent <id> # TUI agent with tool calling
71
+ sf agent <id> --once "summarize my portfolio risk" # single-shot
72
+ sf agent <id> --plain # readline mode, no TUI
73
+ sf telegram --daemon # Telegram bot (text + voice)
74
+ ```
75
+
76
+ **X / Twitter intelligence** — Social signal layer.
77
+
78
+ ```bash
79
+ sf x "tariff impact" # discussion summary + top posts
80
+ sf x-volume "iran oil" # volume and velocity trend
81
+ sf x-news "fed rate" # Grok-aggregated news stories
82
+ sf x-account @elikinosian # recent posts from an account
14
83
  ```
15
84
 
16
85
  ## Setup
17
86
 
18
- ### Interactive (recommended)
87
+ ### Quick (browser login)
19
88
 
20
89
  ```bash
21
- sf setup
90
+ sf login
22
91
  ```
23
92
 
24
- This walks you through:
25
- 1. **SF API key** (required) — get one at [simplefunctions.dev](https://simplefunctions.dev)
26
- 2. **Kalshi credentials** (optional) — for positions, trading, and orderbook data
27
- 3. **Trading mode** (optional) — enable `sf buy`/`sf sell` commands
93
+ ### Power user
28
94
 
29
- Config is saved to `~/.sf/config.json`. Environment variables override config values.
95
+ ```bash
96
+ sf setup # interactive wizard: API key, Kalshi, Polymarket, trading
97
+ sf setup --check # show config status
98
+ sf setup --polymarket # configure Polymarket wallet
99
+ sf setup --enable-trading # unlock buy/sell/intent commands
100
+ ```
30
101
 
31
- ### Manual
102
+ Config is saved to `~/.sf/config.json`. Environment variables override config values:
32
103
 
33
104
  ```bash
34
- export SF_API_KEY=sf_live_xxx # required
35
- export KALSHI_API_KEY_ID=xxx # optional, for positions/trading
36
- export KALSHI_PRIVATE_KEY_PATH=~/.ssh/kalshi.pem # optional, for positions/trading
105
+ export SF_API_KEY=sf_live_xxx
106
+ export KALSHI_API_KEY_ID=xxx
107
+ export KALSHI_PRIVATE_KEY_PATH=~/.kalshi/private.pem
37
108
  ```
38
109
 
39
110
  ### Verify
40
111
 
41
112
  ```bash
42
- sf setup --check # show current config status
43
- sf list # should show your theses
113
+ $ sf status
114
+ API ok simplefunctions.dev 252ms
115
+ Auth ok sf_live_8838...
116
+ Kalshi ok $156.42 balance
117
+ Polymarket ok 0xd53b9354...
118
+ Theses ok 4 active, 4 total
119
+ Trading ok enabled
120
+ Runtime -- not running (sf runtime start)
121
+ Telegram ok PID 84372
44
122
  ```
45
123
 
46
- ## Commands
124
+ ## Command Reference
47
125
 
48
- ### Thesis Management
126
+ ### World Model (no auth required)
49
127
 
50
128
  | Command | Description |
51
129
  |---------|-------------|
52
- | `sf list` | List all theses with status, confidence, and update time |
53
- | `sf get <id>` | Full thesis details: causal tree, edges, positions, last evaluation |
54
- | `sf context <id>` | Compact context snapshot (primary command for agents) |
55
- | `sf create "thesis"` | Create a new thesis (waits for formation by default) |
56
- | `sf signal <id> "text"` | Inject a signal (news, observation) for next evaluation |
57
- | `sf evaluate <id>` | Trigger deep evaluation with heavy model |
58
- | `sf publish <id>` | Make thesis publicly viewable |
59
- | `sf unpublish <id>` | Remove from public view |
130
+ | `sf world` | Prediction index: markets + geopolitics + economy + crypto + elections |
131
+ | `sf world --delta` | Changes since last check (~30 tokens, ideal for agent polling) |
132
+ | `sf world --focus <topics>` | Deep coverage on specific topics |
133
+ | `sf ideas` | Trade ideas with conviction, catalyst, direction, risk |
134
+ | `sf query "question"` | LLM-enhanced market knowledge search |
135
+ | `sf markets` | Traditional markets: SPY, VIX, bonds, gold, oil |
60
136
 
61
- ### Market Exploration (no auth required)
137
+ ### Thesis
62
138
 
63
139
  | Command | Description |
64
140
  |---------|-------------|
65
- | `sf scan "keywords"` | Search Kalshi markets by keyword |
66
- | `sf scan --series KXWTIMAX` | List all markets in a series |
67
- | `sf scan --market TICKER` | Get single market detail |
68
- | `sf explore` | Browse public theses |
141
+ | `sf list` | All theses with status, confidence, last update |
142
+ | `sf get <id>` | Full details: causal tree, edges, evaluation history |
143
+ | `sf context [id]` | No id: global market snapshot. With id: thesis context |
144
+ | `sf create "thesis"` | Create a new thesis |
145
+ | `sf signal <id> "text"` | Inject signal for next evaluation |
146
+ | `sf evaluate <id>` | Trigger deep re-evaluation |
147
+ | `sf augment <id>` | Evolve causal tree with new nodes |
148
+ | `sf heartbeat <id>` | View/configure autonomous evaluation schedule + costs |
149
+ | `sf publish` / `sf unpublish <id>` | Manage public visibility |
150
+
151
+ ### Markets
69
152
 
70
- ### Portfolio & Trading (requires Kalshi credentials)
153
+ | Command | Description |
154
+ |---------|-------------|
155
+ | `sf scan "keywords"` | Search Kalshi + Polymarket by keyword |
156
+ | `sf scan --series TICKER` | Browse all markets in a Kalshi series |
157
+ | `sf edges [--json]` | Top mispricings across all theses |
158
+ | `sf watch [query] [mode]` | Live market watch (modes: orderbook, flow, cross-venue, all) |
159
+ | `sf book <ticker> [...]` | Orderbook depth for specific markets |
160
+ | `sf whatif <id>` | What-if scenario analysis on causal tree |
161
+ | `sf liquidity [topic]` | Orderbook liquidity scanner |
162
+ | `sf forecast <event>` | Market distribution (P50/P75/P90) |
163
+ | `sf explore [slug]` | Browse public theses |
164
+
165
+ ### Portfolio
71
166
 
72
167
  | Command | Description |
73
168
  |---------|-------------|
74
- | `sf edges` | Top edges across all theses what to trade now |
75
- | `sf positions` | Current positions with P&L and edge overlay |
169
+ | `sf positions` | Kalshi + Polymarket positions with P&L |
76
170
  | `sf balance` | Account balance |
77
171
  | `sf orders` | Resting (open) orders |
78
172
  | `sf fills` | Recent trade fills |
79
- | `sf performance` | P&L over time with thesis event annotations |
80
173
  | `sf settlements` | Settled contracts with final P&L |
81
- | `sf liquidity` | Market liquidity scanner by topic |
174
+ | `sf performance` | P&L over time with event annotations |
175
+ | `sf dashboard` | Interactive TUI portfolio overview |
176
+
177
+ ### Intents & Runtime
82
178
 
83
- ### Trading (requires `sf setup --enable-trading`)
179
+ Intents are declarative execution orders. You define the trade and trigger condition; the runtime daemon evaluates and executes.
84
180
 
85
181
  | Command | Description |
86
182
  |---------|-------------|
87
- | `sf buy <ticker> <qty>` | Buy contracts |
183
+ | `sf intent buy <ticker> <qty>` | Create buy intent (`--trigger below:28`, `--trigger time:<ISO>`, `--soft "condition"`, `--auto`) |
184
+ | `sf intent sell <ticker> <qty>` | Create sell intent |
185
+ | `sf intent list` | Active intents (`--all` for history) |
186
+ | `sf intent status <id>` | Detailed status + fills |
187
+ | `sf intent cancel <id>` | Cancel an intent |
188
+ | `sf runtime start` | Start execution daemon (Kalshi + Polymarket) |
189
+ | `sf runtime stop` | Stop daemon |
190
+ | `sf runtime status` | Active intents + runtime state |
191
+ | `sf backtest <ticker>` | Strategy backtest (`--entry-below 35 --stop 20 --tp 60 --days 30`) |
192
+ | `sf heartbeat <id>` | View/configure heartbeat + closed-loop (`--closed-loop-entry`, `--closed-loop-exit`) |
193
+
194
+ ### Trading (requires `--enable-trading`)
195
+
196
+ | Command | Description |
197
+ |---------|-------------|
198
+ | `sf buy <ticker> <qty>` | Buy contracts (`--price 31`, `--market`, `--side yes\|no`) |
88
199
  | `sf sell <ticker> <qty>` | Sell contracts |
89
200
  | `sf cancel [orderId]` | Cancel order(s) |
90
201
  | `sf rfq <ticker> <qty>` | Request for quote on large orders |
91
202
 
92
- ### Analysis
203
+ ### Agent
93
204
 
94
205
  | Command | Description |
95
206
  |---------|-------------|
96
- | `sf whatif <id>` | What-if scenario: "if node X drops to 10%..." |
97
- | `sf feed` | Evaluation history stream |
98
- | `sf forecast <event>` | Market distribution forecast (P50/P75/P90) |
99
- | `sf dashboard` | Interactive TUI portfolio overview |
207
+ | `sf agent [id]` | Interactive agent (TUI with panels) |
208
+ | `sf agent [id] --plain` | Readline mode, pipe-friendly |
209
+ | `sf agent [id] --once "prompt"` | Single-shot: run, answer, exit |
210
+ | `sf prompt [id]` | Print dynamic system prompt for any LLM |
211
+ | `sf telegram [--daemon]` | Telegram bot (text + voice messages) |
212
+
213
+ The agent has 30+ tools including market scanning, trading, workspace read/write, X search, self-wake scheduling, and a math calculator. Slash commands inside the agent: `/voice` `/tree` `/edges` `/pos` `/eval` `/balance` `/intents` `/wakes` `/alerts` `/switch` `/model` `/help` `/exit`.
214
+
215
+ ### X / Twitter
100
216
 
101
- ### Interactive Modes
217
+ | Command | Description |
218
+ |---------|-------------|
219
+ | `sf x "query"` | Discussion summary + top posts |
220
+ | `sf x-volume "query"` | Discussion volume and velocity trend |
221
+ | `sf x-news "query"` | Grok-aggregated news stories |
222
+ | `sf x-account @username` | Recent posts from a specific account |
223
+
224
+ ### Info
102
225
 
103
226
  | Command | Description |
104
227
  |---------|-------------|
105
- | `sf agent [id]` | Interactive agent with natural language + tool calling |
106
- | `sf telegram` | Telegram bot for monitoring and trading |
228
+ | `sf feed` | Evaluation history stream |
229
+ | `sf delta <id>` | Changes since last check |
230
+ | `sf milestones` | Upcoming Kalshi events |
231
+ | `sf schedule` | Exchange status |
232
+ | `sf announcements` | Exchange announcements |
233
+ | `sf history <ticker>` | Historical market data |
234
+ | `sf status` | Full system health check |
235
+
236
+ ### Sharing
237
+
238
+ Any command with `--share` generates a short URL:
239
+
240
+ ```bash
241
+ sf scan "gold" --share
242
+ sf query "fed rate" --share
243
+ sf context --share
244
+ ```
107
245
 
108
246
  ## JSON Output
109
247
 
@@ -113,139 +251,121 @@ Most commands support `--json` for machine-readable output:
113
251
  sf list --json
114
252
  sf context f582bf76 --json
115
253
  sf edges --json
116
- sf scan "oil" --json
117
- sf get f582bf76 --json
254
+ sf world --json
255
+ sf ideas --json
256
+ sf intent list --json
118
257
  ```
119
258
 
120
259
  ## For AI Agents
121
260
 
122
- **If you are an AI coding agent (Claude, GPT, OpenClaw, Cursor, etc.), follow these steps:**
261
+ If you are an AI agent (Claude, GPT, Cursor, etc.), these are the commands that matter:
123
262
 
124
- ### Step 1: Install and configure
263
+ ### Setup
125
264
 
126
265
  ```bash
127
266
  npm install -g @spfunctions/cli
128
- sf setup --key sf_live_YOUR_KEY_HERE
267
+ sf login # or: export SF_API_KEY=sf_live_xxx
268
+ sf list # verify: should print theses
129
269
  ```
130
270
 
131
- If `sf setup` is not available or you cannot run interactive commands:
132
- ```bash
133
- export SF_API_KEY=sf_live_YOUR_KEY_HERE
134
- ```
135
-
136
- ### Step 2: Verify it works
271
+ ### Primary commands
137
272
 
138
273
  ```bash
139
- sf list
140
- ```
274
+ # World state in ~800 tokens — give your agent situational awareness
275
+ sf world --json
141
276
 
142
- Expected output (table format):
143
- ```
144
- ID Status Conf Updated Title
145
- f582bf76 active 82% Mar 12 11:13 Oil prices will exceed $100...
146
- a1b2c3d4 active 65% Mar 11 09:30 Fed will cut rates by June...
147
- ```
277
+ # What changed since last poll — ~30 tokens, efficient for loops
278
+ sf world --delta --json
148
279
 
149
- If you see theses, the CLI is working. If you see an error, check that `SF_API_KEY` is set correctly.
280
+ # Thesis context: causal tree + edges + positions + evaluation
281
+ sf context <thesisId> --json
150
282
 
151
- ### Step 3: Get thesis context (most important command)
283
+ # Top mispricings across all theses
284
+ sf edges --json
152
285
 
153
- ```bash
154
- sf context <thesisId> --json
286
+ # Single-shot agent: ask a question, get an answer, exit
287
+ sf agent <thesisId> --once "what is the biggest risk to my portfolio?"
155
288
  ```
156
289
 
157
- This returns a JSON object with the complete thesis state:
290
+ ### Key JSON fields
291
+
292
+ `sf context <id> --json` returns:
158
293
 
159
294
  ```json
160
295
  {
161
- "thesisId": "f582bf76-3113-4208-b0c1-...",
162
- "thesis": "Oil prices will exceed $100 by end of 2026",
163
- "title": "Oil Bull Thesis",
164
- "status": "active",
165
- "confidence": 0.82,
296
+ "confidence": 0.31,
166
297
  "causalTree": {
167
- "rootClaim": "Oil prices will exceed $100",
168
- "nodes": [
169
- {
170
- "id": "n1",
171
- "label": "Supply disruption",
172
- "probability": 0.75,
173
- "importance": 0.6,
174
- "depth": 0
175
- }
176
- ]
298
+ "nodes": [{ "id": "n1", "label": "...", "probability": 0.95 }]
177
299
  },
178
- "edges": [
179
- {
180
- "marketId": "KXWTIMAX-26DEC31-T100",
181
- "market": "Will oil exceed $100 by Dec 2026?",
182
- "venue": "kalshi",
183
- "direction": "yes",
184
- "marketPrice": 35,
185
- "thesisPrice": 55,
186
- "edge": 20,
187
- "confidence": 0.8
188
- }
189
- ],
190
- "lastEvaluation": {
191
- "summary": "Supply concerns rising due to...",
192
- "newConfidence": 0.82,
193
- "confidenceDelta": 0.03
194
- }
300
+ "edges": [{
301
+ "marketId": "KXWTIMAX-26DEC31-T140",
302
+ "venue": "kalshi",
303
+ "marketPrice": 62,
304
+ "thesisPrice": 95,
305
+ "edge": 33
306
+ }]
195
307
  }
196
308
  ```
197
309
 
198
- **Key fields:**
199
310
  - `confidence` — overall thesis probability (0 to 1)
200
- - `edges[].edge` — mispricing size in cents (positive = market underpriced vs thesis)
201
- - `edges[].marketPrice` — current market price in cents (0-100)
202
- - `edges[].thesisPrice` — what the thesis model thinks the price should be
203
- - `lastEvaluation.summary` — human-readable summary of latest analysis
311
+ - `edges[].edge` — mispricing in cents (positive = market underpriced vs model)
312
+ - `edges[].marketPrice` — current market price (0-100 cents)
204
313
 
205
- ### Step 4: Other useful commands
314
+ ### Patterns
206
315
 
207
316
  ```bash
208
- # Inject a signal for the thesis to consider in its next evaluation
209
- sf signal <thesisId> "Breaking: OPEC announces production cut" --type news
210
-
211
- # View top edges (mispricings) across all theses
212
- sf edges --json
213
-
214
- # Search Kalshi markets by keyword
215
- sf scan "recession" --json
317
+ # Monitor: poll world state, react to deltas
318
+ sf world --delta --json
216
319
 
217
- # Trigger a deep re-evaluation
218
- sf evaluate <thesisId>
320
+ # React to news: inject signal, re-evaluate, read updated state
321
+ sf signal <id> "Breaking: OPEC cuts production" --type news
322
+ sf evaluate <id>
323
+ sf context <id> --json
219
324
 
220
- # What-if analysis: what happens if a node probability changes?
221
- sf whatif <thesisId>
325
+ # Trade: create intent with trigger, let runtime execute
326
+ sf intent buy KXRECSSNBER-26 5 --price 30 --trigger below:28 --auto
327
+ sf runtime start
222
328
  ```
223
329
 
224
- ### Common patterns for agents
330
+ ### Error codes
225
331
 
226
- **Monitor a thesis:**
227
- ```bash
228
- sf context <id> --json # poll periodically, check confidence changes
229
- ```
332
+ | Error | Fix |
333
+ |-------|-----|
334
+ | "API key required" | `sf login` or set `SF_API_KEY` |
335
+ | "Thesis not found" | `sf list` to get valid IDs (8-char prefix works) |
336
+ | "Kalshi not configured" | `sf setup` to add Kalshi credentials |
337
+ | "Trading disabled" | `sf setup --enable-trading` |
230
338
 
231
- **React to news:**
232
- ```bash
233
- sf signal <id> "Reuters: Iran nuclear deal collapses" --type news
234
- sf evaluate <id> # trigger re-evaluation after injecting signal
235
- sf context <id> --json # read updated state
236
- ```
339
+ ## Architecture
237
340
 
238
- **Find trading opportunities:**
239
- ```bash
240
- sf edges --json # get top mispricings sorted by edge size
341
+ ```
342
+ You ──→ sf agent ──→ LLM (Claude/GPT) ──→ 30+ tools
343
+ │ │
344
+ │ ┌────────────────────────┘
345
+ ▼ ▼
346
+ ┌─────────────────────┐
347
+ │ SF API Server │
348
+ │ thesis · edges · │
349
+ │ intents · eval · │
350
+ │ proxy (LLM/TTS) │
351
+ └────────┬────────────┘
352
+
353
+ ┌────────┴────────┐
354
+ │ │
355
+ ┌────▼────┐ ┌──────▼──────┐
356
+ │ Kalshi │ │ Polymarket │
357
+ │ API │ │ API │
358
+ └─────────┘ └─────────────┘
359
+
360
+ Local only (never leaves your machine):
361
+ ~/.sf/config.json — API keys, Kalshi private key path
362
+ ~/.sf/workspace/ — agent scratchpad (notes, context logs)
363
+ ~/.sf/wake/ — scheduled agent wake conditions
364
+ ~/.sf/bus/ — daemon ↔ agent message bus
365
+ ~/.sf/trade-journal.jsonl — local trade log
241
366
  ```
242
367
 
243
- ### Error handling
244
-
245
- - **"API key required"** — set `SF_API_KEY` env var or run `sf setup --key <key>`
246
- - **"Thesis not found"** — use `sf list` to get valid thesis IDs. IDs can be short prefixes (first 8 chars)
247
- - **"Kalshi not configured"** — positions/trading commands need Kalshi credentials via `sf setup`
248
- - **Exit code 0** — success. **Exit code 1** — error (message printed to stderr)
368
+ **Kalshi credentials never leave your machine.** Orders are signed locally with your RSA private key and sent directly to the Kalshi API. The SF server never sees your trading keys.
249
369
 
250
370
  ## Local Development
251
371
 
@@ -254,6 +374,10 @@ cd cli
254
374
  npm install
255
375
  npm run dev -- list # run without building
256
376
  npm run build # compile to dist/
257
- npm run test # run unit tests
377
+ npm run test # run tests
258
378
  npm link # install as global 'sf' command
259
379
  ```
380
+
381
+ ## License
382
+
383
+ MIT
@@ -0,0 +1 @@
1
+ "use strict";exports.id=122,exports.ids=[122],exports.modules={93122:(t,e,i)=>{e.syncPositionsIfEnabled=async function(){const t=(0,s.loadConfig)();if(!t.syncPositions)return null;if(!t.apiKey)return null;const e=[];try{const{getPositions:t,isKalshiConfigured:s}=await Promise.resolve().then(i.t.bind(i,96139,23));if(s()){const i=await t();if(i)for(const t of i)t.quantity>0&&e.push({ticker:t.ticker,venue:"kalshi",side:t.side||"yes",quantity:t.quantity,avgPrice:t.average_price_paid||0,title:t.market_title||t.ticker})}}catch{}try{const{polymarketGetPositions:s}=await Promise.resolve().then(i.bind(i,34331)),n=t.polymarketWalletAddress||process.env.POLYMARKET_WALLET_ADDRESS;if(n){const t=await s(n);for(const i of t){const t=parseFloat(String(i.size||"0"));t>0&&e.push({ticker:i.asset||i.conditionId||"",venue:"polymarket",side:"Yes"===i.outcome?"yes":"no",quantity:Math.round(t),avgPrice:100*parseFloat(String(i.avgPrice||"0")),title:i.title||i.asset||""})}}}catch{}if(0===e.length)return{synced:0,matched:0};try{const t=new n.SFClient,i=await t.syncPositions(e);return{synced:i.synced||0,matched:i.matched||0}}catch{return null}};const s=i(11627),n=i(19218)}};