@structbuild/sdk 0.5.10 → 0.6.0

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.
@@ -157,6 +157,77 @@ export interface components {
157
157
  * @enum {string}
158
158
  */
159
159
  AssetWindowFilterTimeframe: "5m" | "15m" | "1h" | "4h" | "1d" | "24h";
160
+ /** @description Category PnL webhook payload. */
161
+ CategoryPnlPayload: {
162
+ trader?: string | null;
163
+ category?: string | null;
164
+ /** @description Aggregation timeframe: "1d", "7d", "30d", or "lifetime" */
165
+ timeframe: string;
166
+ /** Format: double */
167
+ realized_pnl_usd?: number | null;
168
+ /** Format: int64 */
169
+ markets_in_category?: number | null;
170
+ /** Format: int64 */
171
+ markets_traded?: number | null;
172
+ /** Format: int64 */
173
+ outcomes_traded?: number | null;
174
+ /** Format: int64 */
175
+ total_buys?: number | null;
176
+ /** Format: int64 */
177
+ total_sells?: number | null;
178
+ /** Format: int64 */
179
+ total_redemptions?: number | null;
180
+ /** Format: int64 */
181
+ total_merges?: number | null;
182
+ /** Format: int64 */
183
+ total_splits?: number | null;
184
+ /** Format: double */
185
+ total_volume_usd?: number | null;
186
+ /** Format: double */
187
+ buy_usd?: number | null;
188
+ /** Format: double */
189
+ sell_usd?: number | null;
190
+ /** Format: double */
191
+ redemption_usd?: number | null;
192
+ /** Format: double */
193
+ merge_usd?: number | null;
194
+ /** Format: double */
195
+ convert_collateral_usd?: number | null;
196
+ /** Format: double */
197
+ split_volume_usd?: number | null;
198
+ /** Format: double */
199
+ total_fees?: number | null;
200
+ /** Format: double */
201
+ total_shares_bought?: number | null;
202
+ /** Format: int64 */
203
+ markets_won?: number | null;
204
+ /** Format: int64 */
205
+ markets_lost?: number | null;
206
+ /** Format: double */
207
+ market_win_rate_pct?: number | null;
208
+ /** Format: double */
209
+ avg_hold_time_seconds?: number | null;
210
+ /** Format: double */
211
+ best_trade_pnl_usd?: number | null;
212
+ best_trade_condition_id?: string | null;
213
+ /** Format: double */
214
+ worst_trade_pnl_usd?: number | null;
215
+ worst_trade_condition_id?: string | null;
216
+ /** Format: double */
217
+ total_wins_usd?: number | null;
218
+ /** Format: double */
219
+ total_losses_usd?: number | null;
220
+ /** Format: double */
221
+ avg_win_usd?: number | null;
222
+ /** Format: double */
223
+ avg_loss_usd?: number | null;
224
+ /** Format: double */
225
+ profit_factor?: number | null;
226
+ /** Format: int64 */
227
+ first_trade_at?: number | null;
228
+ /** Format: int64 */
229
+ last_trade_at?: number | null;
230
+ };
160
231
  /**
161
232
  * @description Subscription filters for the `close_to_bond` event. At least one of
162
233
  * `min_probability` or `max_probability` is required (enforced at runtime).
@@ -257,6 +328,18 @@ export interface components {
257
328
  */
258
329
  threshold: number;
259
330
  };
331
+ ConditionHolderMetricsFilters: {
332
+ condition_ids?: string[];
333
+ };
334
+ ConditionHolderMetricsPayload: {
335
+ /** Format: int32 */
336
+ ts: number;
337
+ /** Format: int64 */
338
+ block: number;
339
+ condition_id: string;
340
+ /** Format: int32 */
341
+ holder_count: number;
342
+ };
260
343
  /** @description Payload delivered when a market's volume or transaction metrics cross a configured threshold */
261
344
  ConditionMetricsPayload: {
262
345
  /** @description Market condition ID */
@@ -363,6 +446,25 @@ export interface components {
363
446
  DeleteWebhookResponse: {
364
447
  deleted: boolean;
365
448
  };
449
+ /**
450
+ * @description What triggered a position update. Each value is serialised as a
451
+ * lowercase string in the `dirty_kinds` array on every payload, and
452
+ * the same values are accepted as a subscribe-time filter on rooms
453
+ * that expose one.
454
+ *
455
+ * * `trade` — a buy, sell, merge, split, redemption, or NegRisk
456
+ * convert landed for the position
457
+ * * `price` — the outcome price moved (mark-to-market refresh)
458
+ * * `window` — a 1d / 7d / 30d rolling window boundary was crossed
459
+ * * `position_resolved` — the market that owns this position resolved
460
+ * on this update
461
+ * * `market_resolved` — the market itself resolved (stamped on
462
+ * `MarketRollup` rows for lifetime holders who never redeemed).
463
+ * Carried on the resolution tick stream and on any full-row update
464
+ * that bundles a resolution with a trade.
465
+ * @enum {string}
466
+ */
467
+ DirtyKind: "trade" | "price" | "window" | "position_resolved" | "market_resolved";
366
468
  /** @description V2 UMA OOv2: a proposed price was disputed. */
367
469
  DisputePriceEvent: {
368
470
  id: string;
@@ -393,6 +495,18 @@ export interface components {
393
495
  slug?: string | null;
394
496
  event_slug?: string | null;
395
497
  };
498
+ EventHolderMetricsFilters: {
499
+ event_slugs?: string[];
500
+ };
501
+ EventHolderMetricsPayload: {
502
+ /** Format: int32 */
503
+ ts: number;
504
+ /** Format: int64 */
505
+ block: number;
506
+ event_slug: string;
507
+ /** Format: int32 */
508
+ holder_count: number;
509
+ };
396
510
  /** @description Subscription filters for the `event_metrics` event. All fields are optional. */
397
511
  EventMetricsFilters: {
398
512
  /** @description Restrict to these events. Empty = all events. */
@@ -482,47 +596,6 @@ export interface components {
482
596
  */
483
597
  unique_builder_traders?: number | null;
484
598
  };
485
- /** @description Event PnL webhook payload. */
486
- EventPnlPayload: {
487
- trader?: string | null;
488
- event_slug?: string | null;
489
- /** @description Aggregation timeframe: "1d", "7d", "30d", or "lifetime" */
490
- timeframe: string;
491
- /** Format: int64 */
492
- markets_traded?: number | null;
493
- /** Format: int64 */
494
- outcomes_traded?: number | null;
495
- /** Format: int64 */
496
- total_buys?: number | null;
497
- /** Format: int64 */
498
- total_sells?: number | null;
499
- /** Format: int64 */
500
- total_redemptions?: number | null;
501
- /** Format: int64 */
502
- total_merges?: number | null;
503
- /** Format: double */
504
- total_volume_usd?: number | null;
505
- /** Format: double */
506
- buy_usd?: number | null;
507
- /** Format: double */
508
- sell_usd?: number | null;
509
- /** Format: double */
510
- redemption_usd?: number | null;
511
- /** Format: double */
512
- merge_usd?: number | null;
513
- /** Format: double */
514
- realized_pnl_usd?: number | null;
515
- /** Format: int64 */
516
- winning_markets?: number | null;
517
- /** Format: int64 */
518
- losing_markets?: number | null;
519
- /** Format: double */
520
- total_fees?: number | null;
521
- /** Format: int64 */
522
- first_trade_at?: number | null;
523
- /** Format: int64 */
524
- last_trade_at?: number | null;
525
- };
526
599
  /** @description Subscription filters for the `event_volume_milestone` event. */
527
600
  EventVolumeMilestoneFilters: {
528
601
  /** @description **Required.** Aggregation windows to monitor. */
@@ -615,6 +688,35 @@ export interface components {
615
688
  */
616
689
  fees: number;
617
690
  };
691
+ /** @description Exit Markers webhook payload — one position open->closed transition. */
692
+ ExitMarkersPayload: {
693
+ trader: string;
694
+ position_id: string;
695
+ condition_id: string;
696
+ event_slug: string;
697
+ market_slug: string;
698
+ title: string;
699
+ question: string;
700
+ image_url: string;
701
+ outcome: string;
702
+ /** Format: int32 */
703
+ outcome_index?: number | null;
704
+ /** Format: double */
705
+ pnl_usd: number;
706
+ /** Format: double */
707
+ pnl_pct: number;
708
+ /** Format: double */
709
+ cost_basis_usd: number;
710
+ /** @description resolved_win | resolved_loss | sold_win | sold_loss */
711
+ reason: string;
712
+ /** Format: int64 */
713
+ block: number;
714
+ /**
715
+ * Format: int32
716
+ * @description Exit time, unix seconds.
717
+ */
718
+ ts: number;
719
+ };
618
720
  /** @description Payload delivered when a tracked trader executes their first-ever trade on Polymarket */
619
721
  FirstTradePayload: {
620
722
  /** @description Limit-order maker wallet address (lowercase) */
@@ -686,7 +788,10 @@ export interface components {
686
788
  trader?: string | null;
687
789
  /** @description Aggregation timeframe: "1d", "7d", "30d", or "lifetime" */
688
790
  timeframe: string;
689
- /** Format: double */
791
+ /**
792
+ * Format: double
793
+ * @description Realized PnL for the timeframe (matches REST `/pnl/global`).
794
+ */
690
795
  realized_pnl_usd?: number | null;
691
796
  /** Format: int64 */
692
797
  events_traded?: number | null;
@@ -700,6 +805,8 @@ export interface components {
700
805
  total_redemptions?: number | null;
701
806
  /** Format: int64 */
702
807
  total_merges?: number | null;
808
+ /** Format: int64 */
809
+ total_splits?: number | null;
703
810
  /** Format: double */
704
811
  total_volume_usd?: number | null;
705
812
  /** Format: double */
@@ -710,6 +817,26 @@ export interface components {
710
817
  redemption_volume_usd?: number | null;
711
818
  /** Format: double */
712
819
  merge_volume_usd?: number | null;
820
+ /** Format: double */
821
+ convert_collateral_usd?: number | null;
822
+ /** Format: double */
823
+ split_volume_usd?: number | null;
824
+ /** Format: int64 */
825
+ maker_rebate_count?: number | null;
826
+ /** Format: double */
827
+ maker_rebate_usd?: number | null;
828
+ /** Format: int64 */
829
+ reward_count?: number | null;
830
+ /** Format: double */
831
+ reward_usd?: number | null;
832
+ /** Format: int64 */
833
+ yield_count?: number | null;
834
+ /** Format: double */
835
+ yield_usd?: number | null;
836
+ /** Format: int64 */
837
+ total_credit_count?: number | null;
838
+ /** Format: double */
839
+ total_credit_usd?: number | null;
713
840
  /** Format: int64 */
714
841
  markets_won?: number | null;
715
842
  /** Format: int64 */
@@ -717,9 +844,15 @@ export interface components {
717
844
  /** Format: double */
718
845
  market_win_rate_pct?: number | null;
719
846
  /** Format: double */
720
- avg_pnl_per_market?: number | null;
847
+ total_wins_usd?: number | null;
721
848
  /** Format: double */
722
- avg_pnl_per_trade?: number | null;
849
+ total_losses_usd?: number | null;
850
+ /** Format: double */
851
+ avg_win_usd?: number | null;
852
+ /** Format: double */
853
+ avg_loss_usd?: number | null;
854
+ /** Format: double */
855
+ profit_factor?: number | null;
723
856
  /** Format: double */
724
857
  avg_hold_time_seconds?: number | null;
725
858
  /** Format: double */
@@ -727,6 +860,9 @@ export interface components {
727
860
  /** Format: double */
728
861
  best_trade_pnl_usd?: number | null;
729
862
  best_trade_condition_id?: string | null;
863
+ /** Format: double */
864
+ worst_trade_pnl_usd?: number | null;
865
+ worst_trade_condition_id?: string | null;
730
866
  /** Format: int64 */
731
867
  first_trade_at?: number | null;
732
868
  /** Format: int64 */
@@ -825,8 +961,13 @@ export interface components {
825
961
  trader?: string | null;
826
962
  condition_id?: string | null;
827
963
  event_slug?: string | null;
964
+ category?: string | null;
828
965
  /** @description Aggregation timeframe: "1d", "7d", "30d", or "lifetime" */
829
966
  timeframe: string;
967
+ /** Format: double */
968
+ realized_pnl_usd?: number | null;
969
+ /** Format: double */
970
+ current_shares_balance?: number | null;
830
971
  /** Format: int64 */
831
972
  outcomes_traded?: number | null;
832
973
  /** Format: int64 */
@@ -837,6 +978,8 @@ export interface components {
837
978
  total_redemptions?: number | null;
838
979
  /** Format: int64 */
839
980
  total_merges?: number | null;
981
+ /** Format: int64 */
982
+ total_splits?: number | null;
840
983
  /** Format: double */
841
984
  buy_usd?: number | null;
842
985
  /** Format: double */
@@ -846,11 +989,13 @@ export interface components {
846
989
  /** Format: double */
847
990
  merge_usd?: number | null;
848
991
  /** Format: double */
849
- realized_pnl_usd?: number | null;
850
- /** Format: int64 */
851
- winning_outcomes?: number | null;
992
+ convert_collateral_usd?: number | null;
993
+ /** Format: double */
994
+ split_volume_usd?: number | null;
852
995
  /** Format: double */
853
996
  total_fees?: number | null;
997
+ /** Format: double */
998
+ total_shares_bought?: number | null;
854
999
  /** Format: int64 */
855
1000
  first_trade_at?: number | null;
856
1001
  /** Format: int64 */
@@ -1187,7 +1332,7 @@ export interface components {
1187
1332
  */
1188
1333
  PnlFilterTimeframe: "1d" | "7d" | "30d" | "lifetime";
1189
1334
  /**
1190
- * @description PnL timeframe enum for webhook filtering
1335
+ * @description PnL timeframe enum for webhook filtering.
1191
1336
  * @enum {string}
1192
1337
  */
1193
1338
  PnlTimeframeFilter: "1d" | "7d" | "30d" | "lifetime";
@@ -1195,7 +1340,7 @@ export interface components {
1195
1340
  * @description Polymarket webhook event types
1196
1341
  * @enum {string}
1197
1342
  */
1198
- PolymarketWebhookEvent: "trader_first_trade" | "trader_new_market" | "trader_whale_trade" | "trader_new_trade" | "trader_trade_event" | "trader_global_pnl" | "trader_market_pnl" | "trader_event_pnl" | "trader_global_pnl_v3" | "trader_market_pnl_v3" | "trader_event_pnl_v3" | "trader_category_pnl_v3" | "trader_position_resolved_v3" | "trader_exit_markers_v3" | "position_holder_metrics_v3" | "condition_holder_metrics_v3" | "event_holder_metrics_v3" | "condition_metrics" | "event_metrics" | "tag_metrics" | "position_metrics" | "market_volume_milestone" | "event_volume_milestone" | "position_volume_milestone" | "probability_spike" | "market_volume_spike" | "event_volume_spike" | "position_volume_spike" | "close_to_bond" | "market_created" | "asset_price_tick" | "asset_price_window_update" | "price_spike" | "oracle_events";
1343
+ PolymarketWebhookEvent: "trader_first_trade" | "trader_new_market" | "trader_whale_trade" | "trader_new_trade" | "trader_trade_event" | "trader_global_pnl" | "trader_market_pnl" | "trader_category_pnl" | "trader_position_resolved" | "trader_exit_markers" | "position_holder_metrics" | "condition_holder_metrics" | "event_holder_metrics" | "condition_metrics" | "event_metrics" | "tag_metrics" | "position_metrics" | "market_volume_milestone" | "event_volume_milestone" | "position_volume_milestone" | "probability_spike" | "market_volume_spike" | "event_volume_spike" | "position_volume_spike" | "close_to_bond" | "market_created" | "asset_price_tick" | "asset_price_window_update" | "price_spike" | "oracle_events";
1199
1344
  /**
1200
1345
  * @description Polymarket-specific webhook filters
1201
1346
  *
@@ -1384,6 +1529,26 @@ export interface components {
1384
1529
  */
1385
1530
  oracle_event_types?: string[];
1386
1531
  };
1532
+ PositionHolderMetricsFilters: {
1533
+ position_ids?: string[];
1534
+ };
1535
+ PositionHolderMetricsPayload: {
1536
+ /** Format: int32 */
1537
+ ts: number;
1538
+ /** Format: int64 */
1539
+ block: number;
1540
+ position_id: string;
1541
+ /** Format: int32 */
1542
+ holder_count: number;
1543
+ /** Format: double */
1544
+ total_balance: number;
1545
+ /** Format: double */
1546
+ total_cost_basis: number;
1547
+ /** Format: int32 */
1548
+ condition_holder_count?: number | null;
1549
+ /** Format: int32 */
1550
+ event_holder_count?: number | null;
1551
+ };
1387
1552
  /** @description Subscription filters for the `position_metrics` event. All fields are optional. */
1388
1553
  PositionMetricsFilters: {
1389
1554
  /** @description Restrict to these outcome token IDs. */
@@ -1548,6 +1713,141 @@ export interface components {
1548
1713
  /** Format: double */
1549
1714
  avg_sell_shares?: number | null;
1550
1715
  };
1716
+ PositionResolvedPayload: {
1717
+ trader?: string;
1718
+ position_id?: string;
1719
+ condition_id?: string | null;
1720
+ event_slug?: string | null;
1721
+ /**
1722
+ * @description Market category slug (e.g. "politics", "sports") — mirror of
1723
+ * `PositionRollup.category_id` resolved against the rollup
1724
+ * interner. Surfaces on the `/trader/{addr}/positions` API and
1725
+ * enables direct category-filtered + sorted position lookups
1726
+ * without a cross-grain join.
1727
+ */
1728
+ category?: string | null;
1729
+ outcome?: string | null;
1730
+ /** Format: int32 */
1731
+ outcome_index?: number | null;
1732
+ /** Format: int64 */
1733
+ total_buys?: number;
1734
+ /** Format: int64 */
1735
+ total_sells?: number;
1736
+ /** Format: int64 */
1737
+ total_merges?: number;
1738
+ /** Format: int64 */
1739
+ total_splits?: number;
1740
+ /** Format: int32 */
1741
+ winning_outcome_index?: number | null;
1742
+ /** Format: double */
1743
+ total_shares_bought?: number;
1744
+ /** Format: double */
1745
+ total_shares_sold?: number;
1746
+ /** Format: double */
1747
+ buy_usd?: number;
1748
+ /** Format: double */
1749
+ sell_usd?: number;
1750
+ /** Format: double */
1751
+ avg_entry_price?: number;
1752
+ /** Format: double */
1753
+ total_fees?: number;
1754
+ /** Format: double */
1755
+ realized_pnl_usd?: number;
1756
+ /** Format: double */
1757
+ total_pnl_usd?: number;
1758
+ /** Format: double */
1759
+ redemption_usd?: number;
1760
+ open?: boolean;
1761
+ won?: boolean | null;
1762
+ /** Format: int64 */
1763
+ first_trade_at?: number | null;
1764
+ /** Format: int64 */
1765
+ last_trade_at?: number | null;
1766
+ /**
1767
+ * @description What kind of activity triggered this update. One or more of
1768
+ * `"trade"`, `"price"`, `"window"`, `"position_resolved"`.
1769
+ * Subscribers that only care about one kind filter on
1770
+ * `data.dirty_kinds` containing the value.
1771
+ */
1772
+ dirty_kinds?: components["schemas"]["DirtyKind"][];
1773
+ /**
1774
+ * Format: double
1775
+ * @description `realized_pnl_usd / (buy_usd + total_fees) * 100` for the
1776
+ * window. `0.0` when the trader has no cost basis on this row yet.
1777
+ */
1778
+ realized_pnl_pct?: number;
1779
+ /** @description Market slug for the parent market of this outcome. */
1780
+ market_slug?: string | null;
1781
+ /** @description Market title. */
1782
+ title?: string | null;
1783
+ /** @description Market question. */
1784
+ question?: string | null;
1785
+ /** @description Market image URL. */
1786
+ image_url?: string | null;
1787
+ /**
1788
+ * Format: int32
1789
+ * @description NegRisk conversion count + share deltas for this position.
1790
+ */
1791
+ converted_count?: number;
1792
+ /** Format: double */
1793
+ converted_shares_gained?: number;
1794
+ /** Format: double */
1795
+ converted_shares_lost?: number;
1796
+ /**
1797
+ * Format: double
1798
+ * @description Aggregate buy/sell USD totals for this position across its
1799
+ * lifetime.
1800
+ */
1801
+ total_buy_usd?: number;
1802
+ /** Format: double */
1803
+ total_sell_usd?: number;
1804
+ /**
1805
+ * Format: double
1806
+ * @description Merge proceeds (Y+N → collateral).
1807
+ */
1808
+ merge_usd?: number;
1809
+ /**
1810
+ * Format: double
1811
+ * @description Sell-side average price.
1812
+ */
1813
+ avg_exit_price?: number | null;
1814
+ /**
1815
+ * Format: double
1816
+ * @description Volume-weighted average trade price across buys + sells.
1817
+ */
1818
+ avg_price?: number | null;
1819
+ /**
1820
+ * Format: double
1821
+ * @description Mark-to-market values from the latest price tick.
1822
+ */
1823
+ current_price?: number | null;
1824
+ /** Format: double */
1825
+ current_shares_balance?: number | null;
1826
+ /** Format: double */
1827
+ current_value?: number | null;
1828
+ /**
1829
+ * Format: double
1830
+ * @description Last on-chain trade price for the outcome token.
1831
+ */
1832
+ last_traded_price?: number | null;
1833
+ /**
1834
+ * Format: int64
1835
+ * @description Market resolution deadline as Unix seconds.
1836
+ */
1837
+ end_date?: number | null;
1838
+ /** @description NegRisk multi-outcome flag. */
1839
+ is_neg_risk?: boolean | null;
1840
+ /**
1841
+ * @description `true` when the market is resolved AND the trader still holds
1842
+ * shares (redeem available).
1843
+ */
1844
+ redeemable?: boolean | null;
1845
+ /**
1846
+ * @description `true` when the market is NegRisk, unresolved, and the trader
1847
+ * holds shares (NegRisk-adapter merge available).
1848
+ */
1849
+ mergeable?: boolean | null;
1850
+ };
1551
1851
  /** @description Subscription filters for the `position_volume_milestone` event. */
1552
1852
  PositionVolumeMilestoneFilters: {
1553
1853
  /** @description **Required.** Aggregation windows to monitor. */
@@ -2202,51 +2502,63 @@ export interface components {
2202
2502
  * @enum {string}
2203
2503
  */
2204
2504
  TradeEventFilterType: "OrderFilled" | "OrdersMatched" | "MakerRebate" | "Reward" | "Yield" | "Redemption" | "Merge" | "Split" | "Cancelled" | "PositionsConverted" | "Initialization" | "Proposal" | "Dispute" | "Settled" | "Resolution" | "ConditionResolution" | "Reset" | "Flag" | "Unflag" | "Pause" | "Unpause" | "ManualResolution" | "NegRiskOutcomeReported" | "RegisterToken";
2205
- /** @description Subscription filters for the `trader_event_pnl` event. All fields are optional. */
2206
- TraderEventPnlFilters: {
2207
- /** @description Track only these trader wallet addresses. */
2505
+ /** @description Subscription filters for the `trader_category_pnl` event. All fields are optional. */
2506
+ TraderCategoryPnlFilters: {
2507
+ /** @description Track only these trader wallet addresses. Empty = all traders. */
2208
2508
  traders?: string[] | null;
2209
- /** @description Restrict to these events. */
2210
- event_slugs?: string[] | null;
2509
+ /** @description Restrict to these market categories (e.g. `politics`, `sports`). */
2510
+ categories?: string[] | null;
2211
2511
  /**
2212
2512
  * Format: double
2213
- * @description Only fire when per-event realized PnL ≥ this value (USD).
2513
+ * @description Only fire when per-category realized PnL ≥ this value (USD). Use negative values for loss thresholds.
2214
2514
  */
2215
2515
  min_realized_pnl_usd?: number | null;
2216
2516
  /**
2217
2517
  * Format: double
2218
- * @description Only fire when per-event realized PnL ≤ this value (USD).
2518
+ * @description Only fire when per-category realized PnL ≤ this value (USD).
2219
2519
  */
2220
2520
  max_realized_pnl_usd?: number | null;
2221
2521
  /**
2222
2522
  * Format: double
2223
- * @description Only fire when total event volume ≥ this value (USD).
2523
+ * @description Only fire when total category volume ≥ this value (USD).
2224
2524
  */
2225
2525
  min_volume_usd?: number | null;
2226
2526
  /**
2227
2527
  * Format: double
2228
- * @description Only fire when total event volume ≤ this value (USD).
2528
+ * @description Only fire when total category volume ≤ this value (USD).
2229
2529
  */
2230
2530
  max_volume_usd?: number | null;
2231
2531
  /**
2232
2532
  * Format: double
2233
- * @description Only fire when buy volume within the event ≥ this value (USD).
2533
+ * @description Only fire when buy volume within the category ≥ this value (USD).
2234
2534
  */
2235
2535
  min_buy_usd?: number | null;
2236
2536
  /**
2237
2537
  * Format: double
2238
- * @description Only fire when sell volume within the event ≥ this value (USD).
2538
+ * @description Only fire when sell volume within the category ≥ this value (USD).
2239
2539
  */
2240
2540
  min_sell_volume_usd?: number | null;
2241
2541
  /**
2242
- * Format: int64
2243
- * @description Only fire when the trader has traded in ≥ this many markets within the event.
2244
- */
2542
+ * Format: double
2543
+ * @description Only fire when market win rate ≥ this percentage (0.0–100.0).
2544
+ */
2545
+ min_win_rate?: number | null;
2546
+ /**
2547
+ * Format: int64
2548
+ * @description Only fire when the trader has traded in ≥ this many markets within the category.
2549
+ */
2245
2550
  min_markets_traded?: number | null;
2246
- /** @description Restrict to these PnL windows. */
2551
+ /** @description Restrict to these PnL windows. Empty = all windows. */
2247
2552
  timeframes?: components["schemas"]["PnlFilterTimeframe"][] | null;
2248
- /** @description When `true`, suppress webhooks for short-term "updown" markets. Default: `false`. */
2249
- exclude_shortterm_markets?: boolean | null;
2553
+ };
2554
+ /** @description Subscription filters for the `trader_pnl_exits` event. All fields are optional. */
2555
+ TraderExitMarkersFilters: {
2556
+ /** @description Track only these trader wallet addresses. Empty = all traders. */
2557
+ traders?: string[] | null;
2558
+ /** @description Restrict to these markets. */
2559
+ condition_ids?: string[] | null;
2560
+ /** @description Restrict to positions in these events. */
2561
+ event_slugs?: string[] | null;
2250
2562
  };
2251
2563
  /** @description Subscription filters for the `trader_first_trade` event. All fields are optional. */
2252
2564
  TraderFirstTradeFilters: {
@@ -2418,6 +2730,19 @@ export interface components {
2418
2730
  /** @description When `true`, suppress webhooks for short-term "updown" markets. Default: `false`. */
2419
2731
  exclude_shortterm_markets?: boolean | null;
2420
2732
  };
2733
+ /** @description Subscription filters for the `trader_position_resolved` event. All fields are optional. */
2734
+ TraderPositionResolvedFilters: {
2735
+ /** @description Track only these trader wallet addresses. Empty = all traders. */
2736
+ traders?: string[] | null;
2737
+ /** @description Restrict to these markets. */
2738
+ condition_ids?: string[] | null;
2739
+ /** @description Restrict to positions in these events. */
2740
+ event_slugs?: string[] | null;
2741
+ /** @description Restrict to these outcome indexes within the resolved market. */
2742
+ outcome_indexes?: number[] | null;
2743
+ /** @description Only fire for won (`true`) or lost (`false`) positions. Omit to receive both. */
2744
+ won_only?: boolean | null;
2745
+ };
2421
2746
  /**
2422
2747
  * @description Subscription filters for the `trader_trade_event` event. All fields are optional.
2423
2748
  * `event_slugs` and `exclude_shortterm_markets` require explicit `trade_types` that
@@ -2927,7 +3252,7 @@ export interface components {
2927
3252
  /** @description Non-null when the subscribe was rejected. */
2928
3253
  error?: string | null;
2929
3254
  };
2930
- /** @description List-API-shaped filter evaluated in-memory against changed rows. `status` is NOT accepted — the cache only holds open markets. */
3255
+ /** @description List-API-shaped filter applied to changed rows. `status` is NOT accepted — only open markets are streamed. */
2931
3256
  MarketsStreamFilter: {
2932
3257
  /** @description Case-insensitive substring match on `title`. 3–100 chars. */
2933
3258
  search?: string;
@@ -3619,16 +3944,18 @@ export interface components {
3619
3944
  action: "subscribe" | "unsubscribe_all";
3620
3945
  /** @description EVM wallet addresses */
3621
3946
  traders: string[];
3622
- /** @description Restrict pushed updates to this subset of PnL granularities. Empty/omitted = all three. Unknown values reject the subscription. */
3623
- update_types?: ("global" | "market" | "event")[];
3624
- /** @description Restrict pushed updates to these aggregation timeframes. Empty/omitted = all four. Unknown values reject the subscription. */
3947
+ /** @description Restrict pushed updates to this subset of PnL granularities. Empty/omitted = all four. Unknown values reject the subscription. */
3948
+ update_types?: ("global" | "market" | "category")[];
3949
+ /** @description Restrict pushed updates to these aggregation timeframes. Empty/omitted = all four. Unknown values reject the subscription. Ignored by window-agnostic tick / resolution events. */
3625
3950
  timeframes?: ("1d" | "7d" | "30d" | "lifetime")[];
3951
+ /** @description Restrict pushed updates to events whose `dirty_kinds` intersects this set. Empty/omitted or `["all"]` = every kind. Unknown values reject the subscription. */
3952
+ dirty_kinds?: ("trade" | "price" | "window" | "market_resolved" | "all")[];
3626
3953
  };
3627
3954
  /** @description Server acknowledgement for a trader PnL subscription. Echoes the accepted (normalized) filter sets so clients can confirm the active subscription. */
3628
3955
  TraderPnlSubscribeResponse: {
3629
3956
  traders?: string[];
3630
3957
  /** @description Accepted update types. Empty = all. */
3631
- update_types?: ("global" | "market" | "event")[];
3958
+ update_types?: ("global" | "market" | "category")[];
3632
3959
  /** @description Accepted timeframes. Empty = all. */
3633
3960
  timeframes?: ("1d" | "7d" | "30d" | "lifetime")[];
3634
3961
  /** @description Trader addresses that were rejected (invalid EVM format). */
@@ -3636,43 +3963,62 @@ export interface components {
3636
3963
  /** @description Set if the entire subscription was rejected (e.g. empty traders, or an invalid update_type / timeframe value). */
3637
3964
  error?: string | null;
3638
3965
  };
3639
- /** @description Server-pushed event: global (portfolio-level) PnL update for a trader. Envelope type: "trader_global_pnl_update". */
3640
- TraderGlobalPnlEvent: {
3966
+ /** @description One global (portfolio-level) PnL row inside a `trader_global_pnl_batch` envelope's `data` array. */
3967
+ TraderGlobalPnlRow: {
3641
3968
  /** @description Trader EVM wallet address */
3642
3969
  trader: string;
3643
- /** @description Total realized PnL in USD (decimal string) */
3644
- realized_pnl_usd: string;
3970
+ dirty_kinds?: ("trade" | "price" | "window" | "market_resolved")[];
3971
+ /** @description "1d", "7d", "30d", or "lifetime" */
3972
+ timeframe?: string | null;
3973
+ /** @description Realized PnL for the timeframe */
3974
+ realized_pnl_usd: number;
3645
3975
  /** Format: int64 */
3646
- events_traded?: number | null;
3976
+ events_traded?: number;
3647
3977
  /** Format: int64 */
3648
- markets_traded?: number | null;
3978
+ markets_traded?: number;
3649
3979
  /** Format: int64 */
3650
- total_buys?: number | null;
3980
+ total_buys?: number;
3651
3981
  /** Format: int64 */
3652
- total_sells?: number | null;
3982
+ total_sells?: number;
3653
3983
  /** Format: int64 */
3654
- total_redemptions?: number | null;
3984
+ total_redemptions?: number;
3655
3985
  /** Format: int64 */
3656
- total_merges?: number | null;
3657
- /** @description Total USD volume (decimal string) */
3658
- total_volume_usd: string;
3659
- buy_volume_usd: string;
3660
- sell_volume_usd: string;
3661
- redemption_volume_usd: string;
3662
- merge_volume_usd: string;
3986
+ total_merges?: number;
3663
3987
  /** Format: int64 */
3664
- markets_won?: number | null;
3988
+ total_splits?: number;
3989
+ total_volume_usd?: number;
3990
+ buy_volume_usd?: number;
3991
+ sell_volume_usd?: number;
3992
+ redemption_volume_usd?: number;
3993
+ merge_volume_usd?: number;
3994
+ split_volume_usd?: number;
3665
3995
  /** Format: int64 */
3666
- markets_lost?: number | null;
3667
- /** @description Win rate percentage (decimal string) */
3668
- market_win_rate_pct: string;
3669
- avg_pnl_per_market: string;
3670
- avg_pnl_per_trade: string;
3671
- avg_hold_time_seconds: string;
3672
- total_fees: string;
3673
- best_trade_pnl_usd: string;
3996
+ maker_rebate_count?: number;
3997
+ maker_rebate_usd?: number;
3998
+ /** Format: int64 */
3999
+ reward_count?: number;
4000
+ reward_usd?: number;
4001
+ /** Format: int64 */
4002
+ yield_count?: number;
4003
+ yield_usd?: number;
4004
+ /** Format: int64 */
4005
+ total_credit_count?: number;
4006
+ total_credit_usd?: number;
4007
+ /** Format: int64 */
4008
+ markets_won?: number;
4009
+ /** Format: int64 */
4010
+ markets_lost?: number;
4011
+ market_win_rate_pct?: number;
4012
+ total_wins_usd?: number;
4013
+ total_losses_usd?: number;
4014
+ avg_win_usd?: number | null;
4015
+ avg_loss_usd?: number | null;
4016
+ profit_factor?: number | null;
4017
+ avg_hold_time_seconds?: number;
4018
+ total_fees?: number;
4019
+ best_trade_pnl_usd?: number | null;
3674
4020
  best_trade_condition_id?: string | null;
3675
- worst_trade_pnl_usd: string;
4021
+ worst_trade_pnl_usd?: number | null;
3676
4022
  worst_trade_condition_id?: string | null;
3677
4023
  /**
3678
4024
  * Format: int64
@@ -3684,37 +4030,38 @@ export interface components {
3684
4030
  * @description Unix seconds
3685
4031
  */
3686
4032
  last_trade_at?: number | null;
3687
- /** Format: int64 */
3688
- timestamp?: number | null;
3689
- /** @description "1d", "7d", "30d", or "lifetime" */
3690
- timeframe?: string | null;
3691
4033
  };
3692
- /** @description Server-pushed event: per-market PnL update for a trader. Envelope type: "trader_market_pnl_update". */
3693
- TraderMarketPnlEvent: {
4034
+ /** @description One per-market PnL row inside a `trader_market_pnl_batch` envelope's `data` array. */
4035
+ TraderMarketPnlRow: {
3694
4036
  trader: string;
4037
+ dirty_kinds?: ("trade" | "price" | "window" | "market_resolved")[];
4038
+ /** @description "1d", "7d", "30d", or "lifetime" */
4039
+ timeframe?: string | null;
3695
4040
  /** @description 64-char hex condition ID */
3696
4041
  condition_id: string;
4042
+ realized_pnl_usd?: number;
4043
+ current_shares_balance?: number;
4044
+ category?: string | null;
3697
4045
  event_slug?: string | null;
3698
4046
  /** Format: int64 */
3699
- outcomes_traded?: number | null;
4047
+ outcomes_traded?: number;
3700
4048
  /** Format: int64 */
3701
- total_buys?: number | null;
4049
+ total_buys?: number;
3702
4050
  /** Format: int64 */
3703
- total_sells?: number | null;
4051
+ total_sells?: number;
3704
4052
  /** Format: int64 */
3705
- total_redemptions?: number | null;
4053
+ total_redemptions?: number;
3706
4054
  /** Format: int64 */
3707
- total_merges?: number | null;
3708
- /** @description Total buy volume in USD (decimal string) */
3709
- buy_usd: string;
3710
- sell_usd: string;
3711
- redemption_usd: string;
3712
- merge_usd: string;
3713
- /** @description Realized PnL in USD (decimal string) */
3714
- realized_pnl_usd: string;
4055
+ total_merges?: number;
3715
4056
  /** Format: int64 */
3716
- winning_outcomes?: number | null;
3717
- total_fees: string;
4057
+ total_splits?: number;
4058
+ buy_usd?: number;
4059
+ sell_usd?: number;
4060
+ redemption_usd?: number;
4061
+ merge_usd?: number;
4062
+ split_volume_usd?: number;
4063
+ total_fees?: number;
4064
+ total_shares_bought?: number;
3718
4065
  /**
3719
4066
  * Format: int64
3720
4067
  * @description Unix seconds
@@ -3725,114 +4072,540 @@ export interface components {
3725
4072
  * @description Unix seconds
3726
4073
  */
3727
4074
  last_trade_at?: number | null;
3728
- /** Format: int64 */
3729
- timestamp?: number | null;
4075
+ };
4076
+ /** @description One per-category PnL row inside a `trader_category_pnl_batch` envelope's `data` array. */
4077
+ TraderCategoryPnlRow: {
4078
+ trader: string;
4079
+ dirty_kinds?: ("trade" | "price" | "window" | "market_resolved")[];
3730
4080
  /** @description "1d", "7d", "30d", or "lifetime" */
3731
4081
  timeframe?: string | null;
4082
+ category: string;
4083
+ realized_pnl_usd?: number;
4084
+ /** Format: int64 */
4085
+ markets_in_category?: number;
4086
+ /** Format: int64 */
4087
+ markets_traded?: number;
4088
+ /** Format: int64 */
4089
+ outcomes_traded?: number;
4090
+ /** Format: int64 */
4091
+ total_buys?: number;
4092
+ /** Format: int64 */
4093
+ total_sells?: number;
4094
+ /** Format: int64 */
4095
+ total_redemptions?: number;
4096
+ /** Format: int64 */
4097
+ total_merges?: number;
4098
+ /** Format: int64 */
4099
+ total_splits?: number;
4100
+ total_volume_usd?: number;
4101
+ buy_usd?: number;
4102
+ sell_usd?: number;
4103
+ redemption_usd?: number;
4104
+ merge_usd?: number;
4105
+ split_volume_usd?: number;
4106
+ total_fees?: number;
4107
+ total_shares_bought?: number;
4108
+ /** Format: int64 */
4109
+ markets_won?: number;
4110
+ /** Format: int64 */
4111
+ markets_lost?: number;
4112
+ market_win_rate_pct?: number;
4113
+ avg_hold_time_seconds?: number;
4114
+ best_trade_pnl_usd?: number | null;
4115
+ best_trade_condition_id?: string | null;
4116
+ worst_trade_pnl_usd?: number | null;
4117
+ worst_trade_condition_id?: string | null;
4118
+ total_wins_usd?: number;
4119
+ total_losses_usd?: number;
4120
+ avg_win_usd?: number | null;
4121
+ avg_loss_usd?: number | null;
4122
+ profit_factor?: number | null;
4123
+ /**
4124
+ * Format: int64
4125
+ * @description Unix seconds
4126
+ */
4127
+ first_trade_at?: number | null;
4128
+ /**
4129
+ * Format: int64
4130
+ * @description Unix seconds
4131
+ */
4132
+ last_trade_at?: number | null;
3732
4133
  };
3733
- /** @description Server-pushed event: per-event PnL update for a trader. Envelope type: "trader_event_pnl_update". */
3734
- TraderEventPnlEvent: {
4134
+ /** @description Row carried by `trader_global_tick_batch` (price-only trader aggregate). */
4135
+ TraderGlobalTickRow: {
3735
4136
  trader: string;
3736
- event_slug: string;
4137
+ realized_pnl_usd?: number;
4138
+ open_positions_value?: number;
3737
4139
  /** Format: int64 */
3738
- markets_traded?: number | null;
4140
+ last_block?: number;
4141
+ /**
4142
+ * Format: int64
4143
+ * @description Unix seconds
4144
+ */
4145
+ last_trade_at?: number | null;
4146
+ dirty_kinds?: "price"[];
4147
+ };
4148
+ /** @description Row carried by `trader_market_tick_batch` (price-only per-market). */
4149
+ TraderMarketTickRow: {
4150
+ trader: string;
4151
+ condition_id: string;
4152
+ realized_pnl_usd?: number;
3739
4153
  /** Format: int64 */
3740
- outcomes_traded?: number | null;
4154
+ last_block?: number;
4155
+ /**
4156
+ * Format: int64
4157
+ * @description Unix seconds
4158
+ */
4159
+ last_trade_at?: number | null;
4160
+ dirty_kinds?: "price"[];
4161
+ };
4162
+ /** @description Row carried by `trader_category_tick_batch` (price-only per-category). */
4163
+ TraderCategoryTickRow: {
4164
+ trader: string;
4165
+ category: string;
4166
+ realized_pnl_usd?: number;
3741
4167
  /** Format: int64 */
3742
- total_buys?: number | null;
4168
+ last_block?: number;
4169
+ /**
4170
+ * Format: int64
4171
+ * @description Unix seconds
4172
+ */
4173
+ last_trade_at?: number | null;
4174
+ dirty_kinds?: "price"[];
4175
+ };
4176
+ /** @description Row carried by `trader_global_resolution_batch` (trader-aggregate resolution). */
4177
+ TraderGlobalResolutionRow: {
4178
+ trader: string;
4179
+ realized_pnl_usd?: number;
3743
4180
  /** Format: int64 */
3744
- total_sells?: number | null;
4181
+ markets_won?: number;
3745
4182
  /** Format: int64 */
3746
- total_redemptions?: number | null;
4183
+ markets_lost?: number;
3747
4184
  /** Format: int64 */
3748
- total_merges?: number | null;
3749
- /** @description Total USD volume (decimal string) */
3750
- total_volume_usd: string;
3751
- buy_usd: string;
3752
- sell_usd: string;
3753
- redemption_usd: string;
3754
- merge_usd: string;
3755
- /** @description Realized PnL in USD (decimal string) */
3756
- realized_pnl_usd: string;
4185
+ markets_resolved?: number;
4186
+ total_wins_usd_lifetime?: number;
4187
+ total_losses_usd_lifetime?: number;
3757
4188
  /** Format: int64 */
3758
- winning_markets?: number | null;
4189
+ last_block?: number;
4190
+ /**
4191
+ * Format: int64
4192
+ * @description Unix seconds
4193
+ */
4194
+ last_trade_at?: number | null;
4195
+ dirty_kinds?: "market_resolved"[];
4196
+ };
4197
+ /** @description Row carried by `trader_market_resolution_batch` (per-market resolution). */
4198
+ TraderMarketResolutionRow: {
4199
+ trader: string;
4200
+ condition_id: string;
4201
+ resolved?: boolean;
4202
+ won?: boolean | null;
4203
+ realized_pnl_usd?: number;
3759
4204
  /** Format: int64 */
3760
- losing_markets?: number | null;
3761
- total_fees: string;
4205
+ last_block?: number;
3762
4206
  /**
3763
4207
  * Format: int64
3764
4208
  * @description Unix seconds
3765
4209
  */
3766
- first_trade_at?: number | null;
4210
+ last_trade_at?: number | null;
4211
+ dirty_kinds?: "market_resolved"[];
4212
+ };
4213
+ /** @description Row carried by `trader_category_resolution_batch` (per-category resolution). */
4214
+ TraderCategoryResolutionRow: {
4215
+ trader: string;
4216
+ category: string;
4217
+ realized_pnl_usd?: number;
4218
+ /** Format: int64 */
4219
+ markets_won?: number;
4220
+ /** Format: int64 */
4221
+ markets_lost?: number;
4222
+ total_wins_usd_lifetime?: number;
4223
+ total_losses_usd_lifetime?: number;
4224
+ /** Format: int64 */
4225
+ last_block?: number;
3767
4226
  /**
3768
4227
  * Format: int64
3769
4228
  * @description Unix seconds
3770
4229
  */
3771
4230
  last_trade_at?: number | null;
4231
+ dirty_kinds?: "market_resolved"[];
4232
+ };
4233
+ /** @description Server-pushed per-block batch. Envelope type: `trader_global_pnl_batch`. `data` carries every matching row from the block. */
4234
+ TraderGlobalPnlBatchEvent: {
4235
+ /** @enum {string} */
4236
+ type: "trader_global_pnl_batch";
4237
+ /** @enum {string} */
4238
+ room_id: "polymarket_trader_pnl";
3772
4239
  /** Format: int64 */
3773
- timestamp?: number | null;
4240
+ block: number;
4241
+ /** @description "1d", "7d", "30d", or "lifetime" */
4242
+ timeframe?: string | null;
4243
+ data: components["schemas"]["TraderGlobalPnlRow"][];
4244
+ };
4245
+ /** @description Server-pushed per-block batch. Envelope type: `trader_market_pnl_batch`. `data` carries every matching row from the block. */
4246
+ TraderMarketPnlBatchEvent: {
4247
+ /** @enum {string} */
4248
+ type: "trader_market_pnl_batch";
4249
+ /** @enum {string} */
4250
+ room_id: "polymarket_trader_pnl";
4251
+ /** Format: int64 */
4252
+ block: number;
4253
+ /** @description "1d", "7d", "30d", or "lifetime" */
4254
+ timeframe?: string | null;
4255
+ data: components["schemas"]["TraderMarketPnlRow"][];
4256
+ };
4257
+ /** @description Server-pushed per-block batch. Envelope type: `trader_category_pnl_batch`. `data` carries every matching row from the block. */
4258
+ TraderCategoryPnlBatchEvent: {
4259
+ /** @enum {string} */
4260
+ type: "trader_category_pnl_batch";
4261
+ /** @enum {string} */
4262
+ room_id: "polymarket_trader_pnl";
4263
+ /** Format: int64 */
4264
+ block: number;
3774
4265
  /** @description "1d", "7d", "30d", or "lifetime" */
3775
4266
  timeframe?: string | null;
4267
+ data: components["schemas"]["TraderCategoryPnlRow"][];
4268
+ };
4269
+ /** @description Server-pushed per-block batch. Envelope type: `trader_global_tick_batch`. `data` carries every matching row from the block. */
4270
+ TraderGlobalTickBatchEvent: {
4271
+ /** @enum {string} */
4272
+ type: "trader_global_tick_batch";
4273
+ /** @enum {string} */
4274
+ room_id: "polymarket_trader_pnl";
4275
+ /** Format: int64 */
4276
+ block: number;
4277
+ data: components["schemas"]["TraderGlobalTickRow"][];
4278
+ };
4279
+ /** @description Server-pushed per-block batch. Envelope type: `trader_market_tick_batch`. `data` carries every matching row from the block. */
4280
+ TraderMarketTickBatchEvent: {
4281
+ /** @enum {string} */
4282
+ type: "trader_market_tick_batch";
4283
+ /** @enum {string} */
4284
+ room_id: "polymarket_trader_pnl";
4285
+ /** Format: int64 */
4286
+ block: number;
4287
+ data: components["schemas"]["TraderMarketTickRow"][];
4288
+ };
4289
+ /** @description Server-pushed per-block batch. Envelope type: `trader_category_tick_batch`. `data` carries every matching row from the block. */
4290
+ TraderCategoryTickBatchEvent: {
4291
+ /** @enum {string} */
4292
+ type: "trader_category_tick_batch";
4293
+ /** @enum {string} */
4294
+ room_id: "polymarket_trader_pnl";
4295
+ /** Format: int64 */
4296
+ block: number;
4297
+ data: components["schemas"]["TraderCategoryTickRow"][];
4298
+ };
4299
+ /** @description Server-pushed per-block batch. Envelope type: `trader_global_resolution_batch`. `data` carries every matching row from the block. */
4300
+ TraderGlobalResolutionBatchEvent: {
4301
+ /** @enum {string} */
4302
+ type: "trader_global_resolution_batch";
4303
+ /** @enum {string} */
4304
+ room_id: "polymarket_trader_pnl";
4305
+ /** Format: int64 */
4306
+ block: number;
4307
+ data: components["schemas"]["TraderGlobalResolutionRow"][];
4308
+ };
4309
+ /** @description Server-pushed per-block batch. Envelope type: `trader_market_resolution_batch`. `data` carries every matching row from the block. */
4310
+ TraderMarketResolutionBatchEvent: {
4311
+ /** @enum {string} */
4312
+ type: "trader_market_resolution_batch";
4313
+ /** @enum {string} */
4314
+ room_id: "polymarket_trader_pnl";
4315
+ /** Format: int64 */
4316
+ block: number;
4317
+ data: components["schemas"]["TraderMarketResolutionRow"][];
3776
4318
  };
3777
- /** @description Subscribe to the trader positions stream. traders is required and must be non-empty. */
4319
+ /** @description Server-pushed per-block batch. Envelope type: `trader_category_resolution_batch`. `data` carries every matching row from the block. */
4320
+ TraderCategoryResolutionBatchEvent: {
4321
+ /** @enum {string} */
4322
+ type: "trader_category_resolution_batch";
4323
+ /** @enum {string} */
4324
+ room_id: "polymarket_trader_pnl";
4325
+ /** Format: int64 */
4326
+ block: number;
4327
+ data: components["schemas"]["TraderCategoryResolutionRow"][];
4328
+ };
4329
+ /** @description Subscribe to the trader positions stream. `traders` is required and must be non-empty. `dirty_kinds` is an optional narrowing filter — empty/omitted or `["all"]` = receive every kind of update. */
3778
4330
  TraderPositionsSubscribeMessage: {
3779
4331
  /** @enum {string} */
3780
4332
  action: "subscribe" | "unsubscribe_all";
3781
4333
  /** @description EVM wallet addresses */
3782
4334
  traders: string[];
4335
+ /** @description Restrict pushed updates to this subset of update kinds. Omit, leave empty, or pass `["all"]` to accept every kind (the default). Unknown values reject the subscription. */
4336
+ dirty_kinds?: ("trade" | "price" | "position_resolved" | "all")[];
3783
4337
  };
3784
- /** @description Server acknowledgement for a trader positions subscription */
4338
+ /** @description Server acknowledgement for a trader positions subscription. */
3785
4339
  TraderPositionsSubscribeResponse: {
3786
4340
  traders?: string[];
4341
+ /** @description Echoed accepted dirty_kinds filter. Empty = all. */
4342
+ dirty_kinds?: ("trade" | "price" | "position_resolved")[];
3787
4343
  rejected?: string[];
3788
4344
  error?: string | null;
3789
4345
  };
3790
- /** @description Server-pushed event: full position snapshot for a tracked trader. Envelope type: "trader_position_update". Pushed whenever a position's PnL changes. */
3791
- TraderPositionUpdateEvent: {
3792
- /** @description Trader EVM wallet address */
3793
- trader: string;
4346
+ /** @description One position-update row inside a `trader_position_batch` envelope's `data` array. */
4347
+ TraderPositionRow: {
3794
4348
  /** @description ERC-1155 token ID (decimal string) */
3795
4349
  position_id?: string | null;
3796
4350
  condition_id?: string | null;
3797
4351
  market_slug?: string | null;
3798
4352
  event_slug?: string | null;
3799
- /** @description Market title / question */
3800
4353
  title?: string | null;
4354
+ question?: string | null;
3801
4355
  image_url?: string | null;
3802
4356
  /** @description Outcome name (e.g. "Yes") */
3803
4357
  outcome?: string | null;
3804
4358
  outcome_index?: number | null;
3805
- /** @description True if this outcome resolved as winner */
4359
+ open?: boolean | null;
4360
+ /** @description Resolution outcome — present once the market resolved */
3806
4361
  won?: boolean | null;
3807
4362
  /** Format: int64 */
3808
4363
  total_buys?: number | null;
3809
4364
  /** Format: int64 */
3810
4365
  total_sells?: number | null;
4366
+ /** Format: int64 */
4367
+ converted_count?: number | null;
4368
+ converted_shares_gained?: number | null;
4369
+ converted_shares_lost?: number | null;
3811
4370
  total_shares_bought?: number | null;
3812
4371
  total_shares_sold?: number | null;
3813
4372
  total_buy_usd?: number | null;
3814
4373
  total_sell_usd?: number | null;
3815
4374
  redemption_usd?: number | null;
3816
- /** @description Average entry price (0–1) */
4375
+ merge_usd?: number | null;
4376
+ /** @description 0–1 */
3817
4377
  avg_entry_price?: number | null;
3818
- /** @description Average exit price (0–1) */
3819
4378
  avg_exit_price?: number | null;
4379
+ /** @description Volume-weighted across buys + sells */
4380
+ avg_price?: number | null;
3820
4381
  realized_pnl_usd?: number | null;
4382
+ realized_pnl_pct?: number | null;
3821
4383
  total_fees?: number | null;
3822
4384
  /**
3823
4385
  * Format: int64
3824
- * @description Unix seconds
4386
+ * @description Unix milliseconds
3825
4387
  */
3826
4388
  first_trade_at?: number | null;
3827
4389
  /**
3828
4390
  * Format: int64
3829
- * @description Unix seconds
4391
+ * @description Unix milliseconds
3830
4392
  */
3831
4393
  last_trade_at?: number | null;
3832
- /** @description Current ERC-1155 token balance */
4394
+ /** @description Latest on-chain mark for the outcome token */
4395
+ current_price?: number | null;
3833
4396
  current_shares_balance?: number | null;
3834
- /** @description Realized PnL as a percentage of cost basis */
4397
+ /** @description current_price × current_shares_balance */
4398
+ current_value?: number | null;
4399
+ last_traded_price?: number | null;
4400
+ /**
4401
+ * Format: int64
4402
+ * @description Market resolution deadline (Unix seconds)
4403
+ */
4404
+ end_date?: number | null;
4405
+ /** @description True for multi-outcome NegRisk markets */
4406
+ is_neg_risk?: boolean | null;
4407
+ /** @description Market resolved AND trader still holds shares */
4408
+ redeemable?: boolean | null;
4409
+ /** @description NegRisk market, unresolved, trader holds shares */
4410
+ mergeable?: boolean | null;
4411
+ /** @description What kind of activity triggered this update. One or more of: `trade` (a buy, sell, merge, split, redemption, or NegRisk convert landed), `price` (outcome price moved), `position_resolved` (the position's market resolved on this update). */
4412
+ dirty_kinds?: ("trade" | "price" | "position_resolved")[];
4413
+ };
4414
+ /** @description Server-pushed per-block batch of position updates. Envelope type: `trader_position_batch`. Carries every row from the named block that matched the subscriber's filter. Empty batches are not sent. Each row's `dirty_kinds` field describes what triggered that row's update — including resolutions (`position_resolved`). */
4415
+ TraderPositionBatchEvent: {
4416
+ /** @enum {string} */
4417
+ type: "trader_position_batch";
4418
+ /** @enum {string} */
4419
+ room_id: "polymarket_trader_positions";
4420
+ /**
4421
+ * Format: int64
4422
+ * @description Block number these rows were computed at.
4423
+ */
4424
+ block: number;
4425
+ data: components["schemas"]["TraderPositionRow"][];
4426
+ };
4427
+ /** @description One price-tick row inside a `trader_position_price_batch` envelope's `data` array. */
4428
+ TraderPositionPriceRow: {
4429
+ trader?: string | null;
4430
+ /** @description ERC-1155 token ID (decimal string) */
4431
+ position_id?: string | null;
4432
+ condition_id?: string | null;
4433
+ /** @description Latest on-chain mark for the outcome token */
4434
+ current_price?: number | null;
4435
+ current_value?: number | null;
4436
+ realized_pnl_usd?: number | null;
3835
4437
  realized_pnl_pct?: number | null;
4438
+ /** Format: int64 */
4439
+ last_block?: number | null;
4440
+ /**
4441
+ * Format: int64
4442
+ * @description Unix milliseconds
4443
+ */
4444
+ last_trade_at?: number | null;
4445
+ dirty_kinds?: "price"[];
4446
+ };
4447
+ /** @description Server-pushed per-block batch of position price ticks (mark-to-market refreshes). Envelope type: `trader_position_price_batch`. */
4448
+ TraderPositionPriceBatchEvent: {
4449
+ /** @enum {string} */
4450
+ type: "trader_position_price_batch";
4451
+ /** @enum {string} */
4452
+ room_id: "polymarket_trader_positions";
4453
+ /** Format: int64 */
4454
+ block: number;
4455
+ data: components["schemas"]["TraderPositionPriceRow"][];
4456
+ };
4457
+ /** @description One resolution row inside a `trader_position_resolution_batch` envelope's `data` array. */
4458
+ TraderPositionResolutionRow: {
4459
+ trader?: string | null;
4460
+ /** @description ERC-1155 token ID (decimal string) */
4461
+ position_id?: string | null;
4462
+ condition_id?: string | null;
4463
+ resolved?: boolean | null;
4464
+ won?: boolean | null;
4465
+ realized_pnl_usd?: number | null;
4466
+ realized_pnl_pct?: number | null;
4467
+ /** Format: int64 */
4468
+ last_block?: number | null;
4469
+ /**
4470
+ * Format: int64
4471
+ * @description Unix milliseconds
4472
+ */
4473
+ last_trade_at?: number | null;
4474
+ dirty_kinds?: "position_resolved"[];
4475
+ };
4476
+ /** @description Server-pushed per-block batch of position resolutions. Envelope type: `trader_position_resolution_batch`. */
4477
+ TraderPositionResolutionBatchEvent: {
4478
+ /** @enum {string} */
4479
+ type: "trader_position_resolution_batch";
4480
+ /** @enum {string} */
4481
+ room_id: "polymarket_trader_positions";
4482
+ /** Format: int64 */
4483
+ block: number;
4484
+ data: components["schemas"]["TraderPositionResolutionRow"][];
4485
+ };
4486
+ /** @description Subscribe to the trader exit markers stream. `traders` is required and must be non-empty. `reasons` is an optional narrowing filter — empty/omitted or `["all"]` = receive every exit reason. */
4487
+ TraderExitMarkersSubscribeMessage: {
4488
+ /** @enum {string} */
4489
+ action: "subscribe" | "unsubscribe_all";
4490
+ /** @description EVM wallet addresses */
4491
+ traders: string[];
4492
+ /** @description Restrict pushed exits to this subset of reasons. Omit, leave empty, or pass `["all"]` to accept every reason (the default). Unknown values reject the subscription. */
4493
+ reasons?: ("resolved_win" | "resolved_loss" | "sold_win" | "sold_loss" | "all")[];
4494
+ };
4495
+ /** @description Server acknowledgement for a trader exit markers subscription. */
4496
+ TraderExitMarkersSubscribeResponse: {
4497
+ traders?: string[];
4498
+ /** @description Echoed accepted reasons filter. Empty = all. */
4499
+ reasons?: ("resolved_win" | "resolved_loss" | "sold_win" | "sold_loss")[];
4500
+ rejected?: string[];
4501
+ error?: string | null;
4502
+ };
4503
+ /** @description One exit row inside a `trader_exit_marker_batch` envelope's `data` array. */
4504
+ TraderExitMarkerRow: {
4505
+ /** @description EVM wallet address */
4506
+ trader?: string;
4507
+ /** @description ERC-1155 token ID (decimal string) */
4508
+ position_id?: string;
4509
+ condition_id?: string;
4510
+ event_slug?: string;
4511
+ market_slug?: string;
4512
+ title?: string;
4513
+ /** @description Full market question text */
4514
+ question?: string;
4515
+ image_url?: string;
4516
+ /** @description Outcome name (e.g. "Yes") */
4517
+ outcome?: string;
4518
+ outcome_index?: number | null;
4519
+ /** @description Realized PnL at exit, USD */
4520
+ pnl_usd?: number;
4521
+ /** @description Realized PnL at exit, percent */
4522
+ pnl_pct?: number;
4523
+ cost_basis_usd?: number;
4524
+ /**
4525
+ * @description Why the position closed: `resolved_*` held to market resolution (win/loss by verdict); `sold_*` closed before resolution (win/loss by realized PnL sign).
4526
+ * @enum {string}
4527
+ */
4528
+ reason?: "resolved_win" | "resolved_loss" | "sold_win" | "sold_loss";
4529
+ /**
4530
+ * Format: int64
4531
+ * @description Block the exit was recorded at
4532
+ */
4533
+ block?: number;
4534
+ /**
4535
+ * Format: int64
4536
+ * @description Exit time, Unix seconds
4537
+ */
4538
+ ts?: number;
4539
+ };
4540
+ /** @description Server-pushed per-block batch of position exits. Envelope type: `trader_exit_marker_batch`. Carries every exit from the named block that matched the subscriber's filter. Empty batches are not sent. */
4541
+ TraderExitMarkerBatchEvent: {
4542
+ /** @enum {string} */
4543
+ type: "trader_exit_marker_batch";
4544
+ /** @enum {string} */
4545
+ room_id: "polymarket_trader_pnl_exits";
4546
+ /**
4547
+ * Format: int64
4548
+ * @description Block number these exits were recorded at.
4549
+ */
4550
+ block: number;
4551
+ data: components["schemas"]["TraderExitMarkerRow"][];
4552
+ };
4553
+ /** @description Subscribe to holder metrics for explicit positions, conditions, or events. At least one identifier array must be non-empty. Omitted arrays receive no updates for that metric family. Up to 500 total identifiers are accepted. */
4554
+ HolderMetricsSubscribeMessage: {
4555
+ /** @enum {string} */
4556
+ action: "subscribe" | "unsubscribe_all";
4557
+ /** @description Position token IDs to receive position holder metrics for. */
4558
+ position_ids?: string[];
4559
+ /** @description Condition IDs to receive condition holder metrics for. */
4560
+ condition_ids?: string[];
4561
+ /** @description Event slugs to receive event holder metrics for. */
4562
+ event_slugs?: string[];
4563
+ };
4564
+ PositionHolderMetricsRow: {
4565
+ ts?: number;
4566
+ block?: number;
4567
+ position_id?: string;
4568
+ holder_count?: number;
4569
+ total_balance?: number;
4570
+ total_cost_basis?: number;
4571
+ condition_holder_count?: number | null;
4572
+ event_holder_count?: number | null;
4573
+ };
4574
+ ConditionHolderMetricsRow: {
4575
+ ts?: number;
4576
+ block?: number;
4577
+ condition_id?: string;
4578
+ holder_count?: number;
4579
+ };
4580
+ EventHolderMetricsRow: {
4581
+ ts?: number;
4582
+ block?: number;
4583
+ event_slug?: string;
4584
+ holder_count?: number;
4585
+ };
4586
+ HolderMetricsPositionBatchEvent: {
4587
+ /** @enum {string} */
4588
+ type: "holder_metrics_position_batch";
4589
+ /** @enum {string} */
4590
+ room_id: "polymarket_holder_metrics";
4591
+ block: number;
4592
+ data: components["schemas"]["PositionHolderMetricsRow"][];
4593
+ };
4594
+ HolderMetricsConditionBatchEvent: {
4595
+ /** @enum {string} */
4596
+ type: "holder_metrics_condition_batch";
4597
+ /** @enum {string} */
4598
+ room_id: "polymarket_holder_metrics";
4599
+ block: number;
4600
+ data: components["schemas"]["ConditionHolderMetricsRow"][];
4601
+ };
4602
+ HolderMetricsEventBatchEvent: {
4603
+ /** @enum {string} */
4604
+ type: "holder_metrics_event_batch";
4605
+ /** @enum {string} */
4606
+ room_id: "polymarket_holder_metrics";
4607
+ block: number;
4608
+ data: components["schemas"]["EventHolderMetricsRow"][];
3836
4609
  };
3837
4610
  /** @description Subscribe to the accounts stream. `wallets` is required. Share balance updates (`accounts_update`) are always delivered. Set `include_usdce`, `include_pusd`, or `include_matic` to also receive those balance streams. */
3838
4611
  AccountsSubscribeMessage: {
@@ -4062,7 +4835,7 @@ export interface components {
4062
4835
  /** @description Ids mode: event ids to watch. Combined with `event_slugs` up to 500 total. */
4063
4836
  event_ids?: string[];
4064
4837
  };
4065
- /** @description List-API-shaped filter evaluated in-memory against changed rows. `status` is NOT an accepted field — the cache only holds open events. */
4838
+ /** @description List-API-shaped filter applied to changed rows. `status` is NOT an accepted field — only open events are streamed. */
4066
4839
  EventsStreamFilter: {
4067
4840
  /** @description Case-insensitive substring match on `title`. 3–100 chars. */
4068
4841
  search?: string;