@orangecharts/wrun-chart-host 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +67 -4
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/option-venues.constants.d.ts +2 -2
  7. package/dist/host-env.d.ts +1 -9
  8. package/dist/host-ports.types.d.ts +36 -7
  9. package/dist/index.d.ts +7 -1
  10. package/dist/index.js +7 -1
  11. package/dist/indicators/controls/tpo-session.util.d.ts +36 -13
  12. package/dist/indicators/controls/tpo-session.util.js +217 -236
  13. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  14. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  15. package/dist/interfaces/cme-realtime.interface.js +6 -3
  16. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  17. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  18. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  19. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  20. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  21. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  22. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  23. package/dist/market-data/billing.interface.d.ts +86 -12
  24. package/dist/market-data/billing.interface.js +23 -4
  25. package/dist/market-data/venue.d.ts +65 -2
  26. package/dist/market-data/venues/index.d.ts +135 -5
  27. package/dist/market-data/venues/index.js +2 -1
  28. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  29. package/dist/market-data/venues/opra.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +5 -2
  31. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  32. package/dist/market-data/venues/stocks.d.ts +130 -0
  33. package/dist/market-data/venues/stocks.js +117 -0
  34. package/dist/settings-templates/footprint-rows.js +35 -2
  35. package/dist/settings-templates/form-rows.d.ts +2 -1
  36. package/dist/settings-templates/indicator-fields.js +34 -4
  37. package/dist/settings-templates/tool-rules.d.ts +12 -5
  38. package/dist/settings-templates/tool-rules.js +11 -5
  39. package/dist/settings-templates/tool-tables.generated.js +4 -0
  40. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  41. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  42. package/dist/utility/chart/cme-realtime.util.js +10 -0
  43. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  44. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  45. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  46. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  47. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  48. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  49. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  50. package/dist/utility/chart/index-host-tier.util.js +7 -2
  51. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  52. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  53. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  54. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  55. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  56. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  57. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  58. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  59. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  60. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  61. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  62. package/dist/utility/chart/live-bucket.util.js +85 -27
  63. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  64. package/dist/utility/chart/market-sessions.util.js +220 -0
  65. package/dist/utility/chart/marketKind.util.js +5 -0
  66. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  67. package/dist/utility/chart/mixed-mode.util.js +14 -0
  68. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  69. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  70. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  71. package/dist/utility/chart/rth-session.util.js +23 -20
  72. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  73. package/dist/utility/chart/session-interval.util.js +1 -3
  74. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  75. package/dist/utility/chart/trading-day.util.js +59 -0
  76. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  77. package/dist/utility/chart/window-owner.leaf.js +45 -3
  78. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  79. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  80. package/dist/utility/intl-locale.util.js +5 -0
  81. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  82. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  83. package/dist/utility/v2/gate-plane.util.js +30 -4
  84. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  85. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  86. package/dist/utility/v2/stocks-governed.util.js +34 -0
  87. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  88. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  89. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  90. package/dist/utility/wrun/derived-roots.util.js +3 -23
  91. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  92. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  93. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  94. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  95. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  96. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  97. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  98. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  99. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  100. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  101. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  102. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  103. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  104. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  105. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  106. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  107. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  108. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  109. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  110. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  111. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  112. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  113. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  114. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  115. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  116. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  118. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  119. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  120. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  121. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  122. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  123. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  124. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  126. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  127. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  128. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  129. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  130. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  131. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  132. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  133. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  134. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  135. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  136. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  137. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  138. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  139. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  140. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  141. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  142. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  143. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  144. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  145. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  146. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  147. package/dist/utility/wrun/wrun-volume-profile.util.js +37 -29
  148. package/dist/workers/constants/socket-slots.d.ts +91 -6
  149. package/dist/workers/constants/socket-slots.js +85 -6
  150. package/package.json +5 -5
  151. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  152. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -5,36 +5,12 @@
5
5
  // seeded history ask on the same bar and fold live prints by the same rules,
6
6
  // so the lanes can never drift.
7
7
  //
8
- // The fold's rules, in order: a print needs a BUY or SELL series side, a
9
- // finite positive amount, a finite price and a wire timestamp; a print below
10
- // the acquisition's floor is rejected (`tradesTapeCellSize`: its `minSize` in
11
- // raw units, or its `minValue` in dollars, C-DOLLAR, where the cell's size is
12
- // then the print's dollar value), and on the large lane a print the
13
- // large-print table never holds (`tradesBelowLargeFloor`: a dollar-quoted
14
- // market's print under the notional floor, a CME Group print under its
15
- // product root's contracts floor); the print lands in the chart bar
16
- // holding it (`tradesBarStartMs`); a delayed print for a bar older than the
17
- // newest row never appends an out-of-order row; a live bar keeps its newest
18
- // LIVE_MAX_CELLS_PER_BAR prints (the oldest are dropped and the caller is told
19
- // through `onCapped`); the fold never mutates the rows or the cells it is
20
- // handed (the touched row is a new array in a new container).
21
- //
22
- // The floor is an ORDER's where the plane judges it per order: one aggressor
23
- // order on a CME Group venue fills as many small fills on one exchange stamp
24
- // and side, which the package (Big Trades' "Combine fills") and the template
25
- // add back into one trade. A floor applied to each fill before that drops the
26
- // fills of a big order one by one (a 147-contract NQZ6 buy of 45 fills drew 34
27
- // at a floor of 10). So where the per-order switch holds (wrun-tape-per-order
28
- // .util `wrunTapePerOrder`, on the venues `tradesFloorPerOrder` names) the
29
- // history read asks the gateway's per-order floor and keeps every fill it
30
- // answers, and the tape's live prints, judged per order by the order gate
31
- // before the queues (live-trades-order-gate.util), fold with no floor of
32
- // their own (`TradesTapeFloor.perOrder`).
8
+ // The large lane folds the collector's TRADE_LARGE rows (one per order), any other tape raw TRADE fills: never mix them.
33
9
  import { Intervals } from '../../constants/interval.constants.js';
34
10
  import { barEndMs, barStartMs } from '../../utility/chart/calendar-interval.util.js';
35
11
  import { cmeSessionBarEndMs, cmeSessionBarOpenMs, cmeSessionBucketMs, isCmeSessionLatticeExchange, isCmeSessionLatticeIntervalMs, } from '../../utility/chart/cme-session-bucket.util.js';
36
12
  import { findMonday } from '../../workers/utils/time.worker.util.js';
37
- import { liveOptionPrintPremium, liveOptionPrintUsdPremium, } from '../../utility/options/option-trade-units.util.js';
13
+ import { liveOptionPrintUsdPremium } from '../../utility/options/option-trade-units.util.js';
38
14
  export const LIVE_MAX_CELLS_PER_BAR = 20_000;
39
15
  /** The most prints one history ask reads (the history worker's cap, mirroring the historical service's
40
16
  * HIST_TRADES_MAX_CELLS): past it the ask fails loudly instead of truncating the tape, and the wrun tape's refusal
@@ -43,8 +19,7 @@ export const TRADES_HISTORY_MAX_CELLS = 300_000;
43
19
  /** The raw TRADE table's retention (about two days): a seeded history ask never reaches behind
44
20
  * it (older windows answer nothing and cost the gateway a scan over cold chunks). */
45
21
  export const TRADES_RETENTION_SEC = 2 * 24 * 3600;
46
- /** The `trade_large` table's retention (tsdb-gateway: the prints of at least $10k quote on
47
- * USD-quoted markets, copied from TRADE and kept 90 days): the large lane's horizon. */
22
+ /** The `trade_large` table's retention: the large lane's horizon. */
48
23
  export const TRADES_LARGE_RETENTION_SEC = 90 * 24 * 3600;
49
24
  /** tsdb-gateway's bar limit on the large lane (validateKiyoPlusBar, kiyo_plus_validation.go): an
50
25
  * unaggregated read (TRADE_LARGE included) is estimated at one point per minute, and a tier user's
@@ -55,13 +30,7 @@ export const TRADES_LARGE_BAR_LIMIT_SEC = 15_000 * 60;
55
30
  * lands, later than this one (the worker queue, the wire, a slow client clock), and a horizon that
56
31
  * moved past the ask's first bar would cut that bar in two again. */
57
32
  const TRADES_LARGE_BAR_LIMIT_MARGIN_SEC = 600;
58
- /** tsdb-gateway's trade_large floor (`write.large_trade_min_quote_amount`, default 10,000): a print
59
- * is copied into the table when its quote amount reaches it. */
60
- export const TRADES_LARGE_MIN_QUOTE_AMOUNT = 10_000;
61
- /** The quote assets whose quote amount is dollars (the gateway writer's `peggedUSDQuotes`): only the
62
- * prints of a market quoted in one of these are copied into trade_large, every other quote never. The
63
- * dollar rule of a market's value (wrun-chart-market-facts.util `wrunMarketDollarUnit`) reads the same
64
- * list (`isTradesDollarQuoteAsset`). */
33
+ /** A copy of the collector's `peggedUSDQuotes`, which the dollar-unit rule reads too: keep the two lists identical. */
65
34
  const TRADES_LARGE_USD_QUOTES = new Set([
66
35
  'USD',
67
36
  'USDT',
@@ -76,68 +45,72 @@ const TRADES_LARGE_USD_QUOTES = new Set([
76
45
  'TUSD',
77
46
  'RLUSD',
78
47
  ]);
79
- /** tsdb-gateway's trade_large floors on the CME Group venues (`write.large_trade_cme_contract_floors`
80
- * in charts/tsdb-gateway/values.cme.yaml since !2239, 2026-10-14, which replaces the writer's code
81
- * defaults wholesale): contracts per product root, the copy's quote amount priced with the root's
82
- * point value. A root the list lacks is never copied: the writer skips it, and its large acquisition
83
- * reads the raw tape's two hours instead (tradesLaneLimits). So a root the server floors and this
84
- * map lacks draws two hours where the table holds days (Discord #557-saturn: 6E after !2239). A copy
85
- * of the server's list until the floor rides the symbol metadata the chart already loads; then this
86
- * map goes. Until then it changes in the same round as the values file. */
87
- export const TRADES_LARGE_CME_CONTRACT_FLOORS = {
48
+ /** A raw-tape acquisition's seed cap: a longer window over the raw TRADE table costs the gateway a
49
+ * scan over cold chunks (measured 18-30 s, or a server-side internal error, for ten days). */
50
+ export const TRADES_MAX_HISTORY_SEC = 2 * 3600;
51
+ /** A CME Group contract code: the product root, a delivery month letter, one or two year digits. */
52
+ const CME_CONTRACT_CODE = /^([A-Z0-9]+?)[FGHJKMNQUVXZ]\d{1,2}$/;
53
+ /**
54
+ * The CME Group product roots the collector copies into the large-print table (TRADE_LARGE): the keys of its contracts
55
+ * floor list (streamd charts/streamd/values.cme.yaml `large_trade.contract_floors`, the 33 roots tsdb-gateway's
56
+ * values.cme.yaml listed as `write.large_trade_cme_contract_floors` before the rule moved to the collector). The
57
+ * collector copies no print of a root off the list (it only counts them, `streamd_large_trade_skipped_points_total`),
58
+ * so the table answers such a market empty, history and live:
59
+ * COMEX:MGC1! 1m on 2026-10-29 read 0 prints of any size over six hours of the table while the raw tape held 79 prints
60
+ * of 10 contracts or more in two hours (#feedback-stream 2149). A copy of the collector's list until the instrument
61
+ * registry names the served floor per root; recorded with each root's newest TRADE_LARGE row in
62
+ * tests/fixtures/wrun/tape-dollar-units.json, whose spec holds the two equal: they change in the same round as the
63
+ * collector's list.
64
+ */
65
+ export const TRADES_LARGE_CME_ROOTS = new Set([
88
66
  // Equity index
89
- ES: 10,
90
- NQ: 5,
91
- YM: 10,
92
- RTY: 10,
93
- MES: 50,
94
- MNQ: 50,
67
+ 'ES',
68
+ 'NQ',
69
+ 'YM',
70
+ 'RTY',
71
+ 'MES',
72
+ 'MNQ',
95
73
  // Energy and metals
96
- CL: 20,
97
- NG: 20,
98
- GC: 10,
99
- SI: 5,
100
- HG: 5,
74
+ 'CL',
75
+ 'NG',
76
+ 'GC',
77
+ 'SI',
78
+ 'HG',
101
79
  // FX
102
- '6A': 10,
103
- '6B': 10,
104
- '6C': 10,
105
- '6E': 10,
106
- '6J': 10,
107
- '6S': 10,
108
- '6N': 10,
109
- '6M': 10,
80
+ '6A',
81
+ '6B',
82
+ '6C',
83
+ '6E',
84
+ '6J',
85
+ '6S',
86
+ '6N',
87
+ '6M',
110
88
  // Rates
111
- ZN: 50,
112
- ZF: 50,
113
- ZT: 50,
114
- TN: 25,
115
- ZB: 25,
116
- UB: 20,
89
+ 'ZN',
90
+ 'ZF',
91
+ 'ZT',
92
+ 'TN',
93
+ 'ZB',
94
+ 'UB',
117
95
  // Grains
118
- ZC: 50,
119
- ZS: 25,
120
- ZM: 25,
121
- ZL: 25,
122
- ZW: 25,
96
+ 'ZC',
97
+ 'ZS',
98
+ 'ZM',
99
+ 'ZL',
100
+ 'ZW',
123
101
  // Crypto
124
- BTC: 5,
125
- MBT: 50,
126
- ETH: 10,
127
- };
128
- /** A raw-tape acquisition's seed cap: a longer window over the raw TRADE table costs the gateway a
129
- * scan over cold chunks (measured 18-30 s, or a server-side internal error, for ten days). */
130
- export const TRADES_MAX_HISTORY_SEC = 2 * 3600;
131
- /** A CME Group contract code: the product root, a delivery month letter, one or two year digits. */
132
- const CME_CONTRACT_CODE = /^([A-Z0-9]+?)[FGHJKMNQUVXZ]\d{1,2}$/;
133
- /** A live point's trade, whichever case carries it: the raw TRADE channel's `trade` or the large-print channel's
134
- * `tradeLarge` (the history adapter reads the two the same way). Every reader of a live print's amount reads it here,
135
- * so a floor never reads one case while the fold reads the other. */
136
- export function liveTradeOfPoint(point) {
102
+ 'BTC',
103
+ 'MBT',
104
+ 'ETH',
105
+ ]);
106
+ /** Every reader of a live amount reads here, so a floor never reads one channel's case while the fold reads the other. */
107
+ export function liveTradeOfPoint(point, large) {
137
108
  if (!point || typeof point !== 'object')
138
109
  return undefined;
139
110
  const { trade, tradeLarge } = point;
140
- return trade ?? tradeLarge;
111
+ if (large === undefined)
112
+ return trade ?? tradeLarge;
113
+ return large ? tradeLarge : trade;
141
114
  }
142
115
  /**
143
116
  * The chart bar a print at `tsMs` lands in, keyed the way the chart's candles of that market are:
@@ -218,14 +191,12 @@ export function tradesServedStartMs(nowMs, historySec, intervalMs, options = {})
218
191
  ? Number.NEGATIVE_INFINITY
219
192
  : tradesBarLimitStartMs(nowMs, options.barLimitSec, intervalMs, options.exchange));
220
193
  }
221
- /** One raw TRADE point (or a TRADE_LARGE one, its `tradeLarge` case) read the way the fold reads it:
222
- * the print's stamp in ms, its price, size, signed side and envelope exchange; null for a point the
223
- * fold rejects (no side, a non-positive or non-finite size, a bad price or stamp). */
224
- export function readLiveTradePrint(newPoint) {
194
+ /** Null for a point the fold rejects, another channel's included; without `large`, either channel (stamp readers). */
195
+ export function readLiveTradePrint(newPoint, large) {
225
196
  if (!newPoint || typeof newPoint !== 'object')
226
197
  return null;
227
198
  const point = newPoint;
228
- const trade = liveTradeOfPoint(point);
199
+ const trade = liveTradeOfPoint(point, large);
229
200
  const side = point.series?.side === 'BUY' ? 1 : point.series?.side === 'SELL' ? -1 : 0;
230
201
  const size = Number(trade?.amount);
231
202
  const price = Number(trade?.price);
@@ -250,18 +221,7 @@ export function readLiveTradePrint(newPoint) {
250
221
  ...(typeof normalizedSymbol === 'string' && normalizedSymbol !== '' ? { normalizedSymbol } : {}),
251
222
  };
252
223
  }
253
- /** Whether the large-print table floors a market's prints by notional: its normalized symbol's
254
- * quote (the second field, the gateway writer's `quoteAsset`: `BTC-USDT` quotes USDT) is USD or a
255
- * dollar stablecoin. Any other quote (KRW, a coin) is never copied: the table holds none of its
256
- * prints at all. */
257
- export function tradesLargeQuotedInDollars(normalizedSymbol) {
258
- if (typeof normalizedSymbol !== 'string')
259
- return false;
260
- const quote = normalizedSymbol.split('-')[1];
261
- return quote !== undefined && TRADES_LARGE_USD_QUOTES.has(quote);
262
- }
263
- /** Whether a quote asset's amounts are US dollars: USD or a dollar stablecoin (the gateway writer's
264
- * `peggedUSDQuotes`, the list the large-print table copies by). */
224
+ /** Whether a quote asset's amounts are US dollars (`TRADES_LARGE_USD_QUOTES`). */
265
225
  export function isTradesDollarQuoteAsset(asset) {
266
226
  return typeof asset === 'string' && TRADES_LARGE_USD_QUOTES.has(asset.trim().toUpperCase());
267
227
  }
@@ -277,11 +237,8 @@ export function isTradesDollarQuoteAsset(asset) {
277
237
  * point value `valuePerUnit` carries. A print that cannot be valued (no `valuePerUnit`, units that cannot say) is
278
238
  * null: it never folds, whatever its size.
279
239
  * - Otherwise the raw size, below a finite positive `minSize` null.
280
- * - On a tape whose prints arrive judged per order (`floor.perOrder`), no floor: the dollar value (above zero), or the
281
- * raw size, whatever the floor (the fills below it belong to an order that reached it).
282
240
  */
283
241
  export function tradesTapeCellSize(print, floor) {
284
- const perOrder = floor.perOrder === true;
285
242
  if (tradesTapeFloorIsDollars(floor)) {
286
243
  const minValue = Number(floor.minValue);
287
244
  let value;
@@ -292,10 +249,8 @@ export function tradesTapeCellSize(print, floor) {
292
249
  const unit = Number(floor.valuePerUnit);
293
250
  value = Number.isFinite(unit) && unit > 0 ? print.price * print.size * unit : null;
294
251
  }
295
- return value !== null && Number.isFinite(value) && value > 0 && (perOrder || value >= minValue) ? value : null;
252
+ return value !== null && Number.isFinite(value) && value > 0 && value >= minValue ? value : null;
296
253
  }
297
- if (perOrder)
298
- return print.size;
299
254
  const minSize = Number(floor.minSize);
300
255
  return Number.isFinite(minSize) && minSize > 0 && print.size < minSize ? null : print.size;
301
256
  }
@@ -309,20 +264,6 @@ export function tradesTapeFloorValuesPrints(floor) {
309
264
  const unit = Number(floor.valuePerUnit);
310
265
  return Number.isFinite(unit) && unit > 0;
311
266
  }
312
- /** A live print's notional: its quote amount when the frame carries one, else price x size. On an option
313
- * book (`optionUnits`) the premium in the book's own currency by the resolver's live-print rule
314
- * (option-trade-units.util `liveOptionPrintPremium`): a live print's size arrives in coin, live-feed having
315
- * applied the contract multiplier, so the premium is price x size x point value / multiplier on a USD book
316
- * and price x size on a coin book, the value the writer's floor reads once quote amounts follow the same
317
- * rule; NaN when the units cannot say, which never reaches a floor. An option price is a premium, so
318
- * neither price x size nor a frame's quote amount (a contract-multiplied figure on Binance and OKX coin
319
- * books before that rule) is the notional there. Live prints only: a history row (the gateway's raw
320
- * TRADE, stored units) never floors here. */
321
- export function tradePrintNotional(print, optionUnits) {
322
- if (optionUnits)
323
- return liveOptionPrintPremium(print.price, print.size, optionUnits) ?? Number.NaN;
324
- return print.quoteAmount ?? print.price * print.size;
325
- }
326
267
  /** A CME Group market's product root: the normalized symbol's first field (the gateway normalizer
327
268
  * builds `<root>-USD`), else the raw symbol's root (`6AZ6` is 6A, the continuous `ES1!` is ES, a
328
269
  * bare root is itself); undefined without either. */
@@ -339,31 +280,25 @@ export function tradesCmeProductRoot(market) {
339
280
  return symbol.slice(0, -2) || undefined;
340
281
  return CME_CONTRACT_CODE.exec(symbol)?.[1] ?? symbol;
341
282
  }
342
- /** The large-print table's floor on a market, the writer's rule: on a CME Group venue (the session
343
- * lattice venues) the product root's contracts floor, null for a root the list lacks (the writer
344
- * skips it); elsewhere the notional floor on a market quoted in dollars, null on any other quote
345
- * (KRW, a coin): the table holds none of its prints. */
346
- export function tradesLargeFloorOfMarket(market) {
347
- if (isCmeSessionLatticeExchange(market.exchange)) {
348
- const root = tradesCmeProductRoot(market);
349
- const min = root === undefined ? undefined : TRADES_LARGE_CME_CONTRACT_FLOORS[root];
350
- return min === undefined ? null : { kind: 'contracts', min };
351
- }
352
- return tradesLargeQuotedInDollars(market.normalizedSymbol)
353
- ? { kind: 'notional', min: TRADES_LARGE_MIN_QUOTE_AMOUNT }
354
- : null;
283
+ /** Whether the collector copies a CME Group product root into the large-print table (`TRADES_LARGE_CME_ROOTS`); false
284
+ * for an unknown root. */
285
+ export function tradesLargeServesCmeRoot(root) {
286
+ return typeof root === 'string' && TRADES_LARGE_CME_ROOTS.has(root.trim().toUpperCase());
355
287
  }
356
288
  /**
357
- * Whether the gateway floors a tape read on `exchange` per aggressor ORDER (tsdb-gateway `minAmountPerOrder`, on the
358
- * TRADE and TRADE_LARGE reads): it sums the fills that share an order (the timestamp, exchange, category, coin, symbol,
359
- * normalized symbol and side), keeps each order whose total reaches the read's floor (`minAmount`, or `minQuoteAmount`
360
- * on a dollar tape) and answers EVERY fill of it, the fills below the floor included, rows and columns unchanged. The
361
- * CME Group venues (the session lattice venues, the gateway's `isCMEGroupExchange`) honor it: one aggressor order there
362
- * fills as many small fills on one exchange timestamp, and a floor of 10 judged per fill kept 2 of the 45 fills of a
363
- * 147-contract NQZ6 buy (2026-10-23 14:31:54Z). Every other venue keeps the floor per fill and its read never names the
364
- * field (a v2-only field moves a read off /v3). The per-order switch (wrun-tape-per-order.util `wrunTapePerOrder`) can
365
- * hold on these venues alone, and the history worker checks this rule beside the ask's `perOrder` (k-trades.worker).
289
+ * Whether the large-print table holds a market's big trades, the ONE rule of the tape lane a market rides
290
+ * (`tradesLaneLimits`): on a CME Group venue only a product root the collector copies (`tradesLargeServesCmeRoot`, the
291
+ * root `tradesCmeProductRoot` reads: `MGC1!`, `MGCZ6` and `MGC-USD` are MGC, which it does not); every other market
292
+ * is the collector's dollar rule's, which copies every print of at least $10k quote on a dollar-quoted market (a
293
+ * dollar tape on any other quote is refused by name before any fetch, `wrun_tape_value_unproven`). A tape on a market
294
+ * the table does not hold rides the raw tape, never the empty table.
366
295
  */
296
+ export function tradesLargeServesMarket(market) {
297
+ if (!isCmeSessionLatticeExchange(market.exchange))
298
+ return true;
299
+ return tradesLargeServesCmeRoot(tradesCmeProductRoot(market));
300
+ }
301
+ /** The venues whose TRADE_LARGE read honors `minAmountPerOrder`; no other read may name it (a v2-only field leaves /v3). */
367
302
  export function tradesFloorPerOrder(exchange) {
368
303
  return isCmeSessionLatticeExchange(exchange);
369
304
  }
@@ -372,85 +307,40 @@ export function tradesTapeFloorIsDollars(floor) {
372
307
  const minValue = Number(floor.minValue);
373
308
  return Number.isFinite(minValue) && minValue > 0;
374
309
  }
375
- /** The tape lane an acquisition rides on a market: the large lane (the table's retention, the
376
- * gateway's bar limit, the declared history) when it asks `large` and the large-print table holds
377
- * the market, else the raw tape (a two-hour seed inside the raw table's retention). On a CME Group
378
- * venue a product root the writer lists no floor for is never copied, so a large acquisition on it
379
- * reads the raw tape in place of an empty table and its live prints fold unfloored, the same rows
380
- * either way, until the server lists the root. A dollar floor (`floor.minValue`) on that raw tape
381
- * reads no history at all (`historyCapSec` 0, the live edge): the raw tape's quote amounts are priced
382
- * by no writer rule (a backfill gap is NULL), so its rows are no proven dollars. A market quoted
383
- * outside dollars keeps the table (the control cannot tell its quote: the table answers it empty, by
384
- * its own rule). The ONE rule of a tape's served history: the request builder, the reconcile's served
385
- * start and the queue loss's repair all read it with the acquisition's floor. */
386
- export function tradesLaneLimits(large, market = {}, floor = {}) {
387
- const readsLargeTable = large && (!isCmeSessionLatticeExchange(market.exchange) || tradesLargeFloorOfMarket(market) !== null);
388
- if (readsLargeTable) {
310
+ /** The tape lane an acquisition rides: the large lane (the table's retention, the gateway's bar
311
+ * limit, the declared history) when it asks `large`, else the raw tape (a two-hour seed inside the
312
+ * raw table's retention). Big trades read the large-print table wherever it holds the market
313
+ * (`tradesLargeServesMarket`, which decides `large` where the acquisition is built): raw trade is kept
314
+ * about two days, so a longer chart would show its small prints on the newest bars alone. A CME root
315
+ * the collector does not copy rides the raw tape (its two hours and the raw live channel, every fill
316
+ * judged on its own) instead of an empty table that draws nothing. A dollar floor (`floor.minValue`)
317
+ * on the raw tape reads no history at all (`historyCapSec` 0, the live edge): the raw tape's quote
318
+ * amounts are priced by no writer rule (a backfill gap is NULL), so its rows are no proven dollars.
319
+ * The ONE rule of a tape's served history: the request builder, the reconcile's served start and the
320
+ * queue loss's repair all read it with the acquisition's floor. */
321
+ export function tradesLaneLimits(large, floor = {}) {
322
+ if (large) {
389
323
  return {
390
- readsLargeTable,
391
324
  historyCapSec: TRADES_LARGE_RETENTION_SEC,
392
325
  retentionSec: TRADES_LARGE_RETENTION_SEC,
393
326
  barLimitSec: TRADES_LARGE_BAR_LIMIT_SEC,
394
327
  };
395
328
  }
396
329
  return {
397
- readsLargeTable,
398
330
  historyCapSec: tradesTapeFloorIsDollars(floor) ? 0 : TRADES_MAX_HISTORY_SEC,
399
331
  retentionSec: TRADES_RETENTION_SEC,
400
332
  };
401
333
  }
402
- /** Whether a history re-ask on a large acquisition answers a market's prints (the tape reconcile
403
- * restoring what the queue cap dropped): the table on a market it holds, the raw tape on a CME
404
- * Group root it skips under a size floor; never a lane that serves no history under the floor
405
- * (`tradesLaneLimits`: a dollar floor on the raw tape), never a market quoted outside dollars. A
406
- * market naming no normalized symbol is assumed held. */
407
- export function tradesLargeHistoryAnswers(market, floor = {}) {
408
- if (!(tradesLaneLimits(true, market, floor).historyCapSec > 0))
409
- return false;
410
- if (isCmeSessionLatticeExchange(market.exchange))
411
- return true;
412
- return market.normalizedSymbol === undefined || tradesLargeQuotedInDollars(market.normalizedSymbol);
413
- }
414
- /** True for a live print the large-print table never holds on a market it floors: a dollar-quoted
415
- * print whose notional is under TRADES_LARGE_MIN_QUOTE_AMOUNT (the gateway copies a print whose
416
- * quote amount reaches the floor), a CME Group print of fewer contracts than its root's floor (the
417
- * frame's quote amount is price x contracts, no point value, so it never counts there). On an option
418
- * book (`market.optionUnits`) the notional is the premium the resolver reads (`tradePrintNotional`),
419
- * and a print it cannot price is under the floor. The print's
420
- * envelope names the market, else `market`. A market the table never holds is never floored here:
421
- * its lane reads the raw tape (a CME root without a floor) or the table answers it empty (a KRW or
422
- * coin quote), and in both the live prints fold. */
423
- export function tradesBelowLargeFloor(print, market) {
424
- const floor = tradesLargeFloorOfMarket({
425
- exchange: print.exchange ?? market?.exchange,
426
- normalizedSymbol: print.normalizedSymbol ?? market?.normalizedSymbol,
427
- symbol: market?.symbol,
428
- });
429
- if (floor === null)
430
- return false;
431
- if (floor.kind === 'contracts')
432
- return print.size < floor.min;
433
- return !(tradePrintNotional(print, market?.optionUnits) >= floor.min);
434
- }
435
- /** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
436
- * every other row shared by reference), or null when the point is rejected (the caller keeps
437
- * its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid.
438
- * A per-order tape (`options.perOrder`) folds its prints under no floor, the large-print table's
439
- * included. */
334
+ /** Answers NEW rows (the touched row new, the rest shared), or null to keep them: the handed rows are shared snapshots. */
440
335
  export function mergeLiveTradesDataPoint(lastDataPoint, newPoint, intervalMs, options = {}) {
441
336
  if (!Number.isFinite(intervalMs) || intervalMs <= 0)
442
337
  return null;
443
- const print = readLiveTradePrint(newPoint);
338
+ const print = readLiveTradePrint(newPoint, options.large === true);
444
339
  if (print === null)
445
340
  return null;
446
341
  const size = tradesTapeCellSize(print, options);
447
342
  if (size === null)
448
343
  return null;
449
- if (options.largeFloor !== undefined &&
450
- options.perOrder !== true &&
451
- tradesBelowLargeFloor(print, options.largeFloor)) {
452
- return null;
453
- }
454
344
  const barTs = options.barTs ?? tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
455
345
  const rows = lastDataPoint;
456
346
  const last = rows.length > 0 ? rows[rows.length - 1] : undefined;
@@ -18,9 +18,15 @@
18
18
  * The agreement itself is the server's (contracts K1 and K2 of the OPRA compliance round): `GET <basePath>/agreement`
19
19
  * serves the complete populated text with its version and hash, the acceptance names that version and both hashes,
20
20
  * and an acceptance counts only for the version the server presents now, never for a version a build carries.
21
+ *
22
+ * A card that lists several agreements (`agreements`, US stocks: one per set of product groups) speaks the per-agreement
23
+ * routes instead (docs/features/market-data/plane.md, "Agreements per product group"): `GET <basePath>/agreements/<id>`
24
+ * serves each in K1's shape, `POST <basePath>/agreements/<id>/accept { version, sha256 }` records an assent, and the
25
+ * declaration on file carries every assent it holds (`assents`, by agreement id). Real time on a product group needs
26
+ * the assent to the agreement covering it, at the version the server presents now.
21
27
  */
22
28
  import type { CancelFeedback } from '../interfaces/cancel-reason.interface.js';
23
- import type { MarketDataBillingInterval, MarketDataClassification, MarketDataProduct, MarketDataVenue } from './venue.js';
29
+ import type { MarketDataBillingInterval, MarketDataClassification, MarketDataListedAgreement, MarketDataProduct, MarketDataVenue } from './venue.js';
24
30
  /**
25
31
  * POST <basePath>/attestation request body (201 for both classifications). The server derives the classification from
26
32
  * `answers` and refuses a body whose `classification` disagrees, so the client sends the one
@@ -51,6 +57,17 @@ export interface MarketDataAttestationRecordDto {
51
57
  * shown to be inside its year.
52
58
  */
53
59
  expiresAt?: string;
60
+ /**
61
+ * A venue that lists several agreements (`agreements`): the assents this declaration holds, by agreement id, each the
62
+ * version assented to and when. An assent rides the declaration it was made on: a new declaration starts with none.
63
+ * Absent on every other venue's record.
64
+ */
65
+ assents?: Record<string, MarketDataAgreementAssentDto>;
66
+ }
67
+ /** One assent a declaration holds (`assents[<agreement id>]`): the agreement version assented to, and when (ISO). */
68
+ export interface MarketDataAgreementAssentDto {
69
+ version: string;
70
+ acceptedAt: string;
54
71
  }
55
72
  /** GET <basePath>/attestation -> 200 body. */
56
73
  export interface GetMarketDataAttestationResponseDto {
@@ -142,10 +159,24 @@ export interface MarketDataSubscriptionDto {
142
159
  /** The Stripe payment method the subscription charges, or null. Additive (a multi-product venue's DTO names it). */
143
160
  paymentMethodId?: string | null;
144
161
  }
162
+ /** `grant.steps`: the declaration and the agreement the release waits on, as orange judges the records now. */
163
+ export interface MarketDataOperatorGrantStepsDto {
164
+ declaration: 'current' | 'missing' | 'lapsed';
165
+ agreement: 'accepted' | 'missing' | 'superseded';
166
+ }
167
+ /** `grant`: an operator's real-time grant on the account (orange's `OperatorGrantDto`), null without one. */
168
+ export interface MarketDataOperatorGrantDto {
169
+ plan: string;
170
+ purpose: string;
171
+ endsAt: string | null;
172
+ steps: MarketDataOperatorGrantStepsDto;
173
+ }
145
174
  export interface GetMarketDataSubscriptionResponseDto {
146
175
  subscription: MarketDataSubscriptionDto | null;
147
176
  /** Additive (a server from before the review answers none). */
148
177
  review?: MarketDataReviewDto | null;
178
+ /** Additive (a server from before operator grants on the answer answers none). */
179
+ grant?: MarketDataOperatorGrantDto | null;
149
180
  }
150
181
  /**
151
182
  * GET <basePath>/data-terms -> 200; POST <basePath>/data-terms -> 201. Acceptance is an explicit record of the
@@ -253,6 +284,24 @@ export interface AcceptMarketDataDataTermsDto {
253
284
  displayedTextSha256: string;
254
285
  representations: MarketDataAgreementRepresentations;
255
286
  }
287
+ /**
288
+ * POST <basePath>/agreements/<id>/accept request body (a venue that lists several agreements): the version of the
289
+ * agreement the subscriber was shown (its text route's answer) and `sha256`, the browser's own SHA-256 of the exact text
290
+ * it displayed (SubtleCrypto). The server records the assent on the account's current declaration only when the version
291
+ * is the one it presents for that agreement and the hash equals that version's (else 409 `<VENUE>_AGREEMENT_STALE`),
292
+ * the declaration is a current non-professional one (else 409 `<VENUE>_ATTESTATION_REQUIRED`) and the email is verified
293
+ * (else 403 `<VENUE>_EMAIL_UNVERIFIED`); an id the venue does not have answers 404.
294
+ */
295
+ export interface AcceptMarketDataListedAgreementDto {
296
+ version: string;
297
+ sha256: string;
298
+ }
299
+ /** POST <basePath>/agreements/<id>/accept -> 201 body: the assent recorded. */
300
+ export interface AcceptMarketDataListedAgreementResponseDto {
301
+ agreementId: string;
302
+ version: string;
303
+ acceptedAt: string;
304
+ }
256
305
  /** POST <basePath>/subscription/cancel and DELETE <basePath>/subscription/cancel -> 200 body. */
257
306
  export interface MarketDataCancelResponseDto {
258
307
  message?: string;
@@ -261,10 +310,13 @@ export type MarketDataAttestation = MarketDataAttestationRecordDto;
261
310
  export type MarketDataSubscription = MarketDataSubscriptionDto;
262
311
  /** The review of the account's answers, as served (`MarketDataReviewDto`). */
263
312
  export type MarketDataReview = MarketDataReviewDto;
264
- /** GET <basePath>/subscription in the domain: the subscription and the review its answer carries, each or none. */
313
+ /** The operator's grant as the store holds it: no subscription, its steps release the grant at the gate. */
314
+ export type MarketDataOperatorGrant = MarketDataOperatorGrantDto;
315
+ /** GET <basePath>/subscription in the domain: the subscription, the review and the operator's grant, each or none. */
265
316
  export interface MarketDataSubscriptionAnswer {
266
317
  subscription: MarketDataSubscription | null;
267
318
  review: MarketDataReview | null;
319
+ grant: MarketDataOperatorGrant | null;
268
320
  }
269
321
  /** The explicit agreement record: accepted, for which version, and when. */
270
322
  export interface MarketDataAgreement {
@@ -276,6 +328,8 @@ export interface MarketDataAgreement {
276
328
  export type MarketDataAgreementDocument = MarketDataAgreementDocumentDto;
277
329
  /** The exact agreement the account accepted (K1), as the subscription page and the notice reopen it. */
278
330
  export type MarketDataAcceptedAgreement = MarketDataAcceptedAgreementDto;
331
+ /** One assent a declaration holds (a venue that lists several agreements), as served. */
332
+ export type MarketDataAgreementAssent = MarketDataAgreementAssentDto;
279
333
  /** A form's answers, keyed by the venue's question ids. A missing answer never qualifies. */
280
334
  export type MarketDataQualificationAnswers = Partial<Record<string, boolean>>;
281
335
  /** Every question of the venue's questionnaire answered with its qualifying answer. */
@@ -290,6 +344,15 @@ export declare function marketDataProductsFor(venue: MarketDataVenue, classifica
290
344
  export declare function marketDataProductByKey(venue: MarketDataVenue, key: string | null | undefined): MarketDataProduct | null;
291
345
  /** The venue records its agreement as the registration its own wall makes (never a purchase step). */
292
346
  export declare function isMarketDataRegistrationAgreement(venue: Pick<MarketDataVenue, 'agreement'>): boolean;
347
+ /** The venue's listed agreements (`agreements`, in the card's order), or none for a venue of one agreement. */
348
+ export declare function marketDataListedAgreements(venue: Pick<MarketDataVenue, 'agreements'>): readonly MarketDataListedAgreement[];
349
+ /** The listed agreement whose assent real time on `productGroup` needs (an exchange code as the gate names it), or null. */
350
+ export declare function marketDataAgreementForProductGroup(venue: Pick<MarketDataVenue, 'agreements'>, productGroup: string | null | undefined): MarketDataListedAgreement | null;
351
+ /**
352
+ * An assent counts only for the version the agreement's text route presents NOW (`current`, its K1-shaped answer),
353
+ * never for an older text and never for the card's pin. With no current text read, nothing counts.
354
+ */
355
+ export declare function isMarketDataListedAgreementCurrent(current: Pick<MarketDataAgreementDocument, 'version'> | null | undefined, assent: MarketDataAgreementAssent | null | undefined): boolean;
293
356
  /**
294
357
  * A declaration on the venue's current form (a new question set means a new declaration) whose validity has not ended
295
358
  * at `now`, either classification. The client owns expiry: `now` is the caller's clock (the store's last evaluation),
@@ -335,26 +398,30 @@ export type MarketDataCheckoutResult = {
335
398
  kind: 'busy';
336
399
  };
337
400
  /**
338
- * Transport-free failure surface for the billing calls. Unlike CME, a bare 403 is NOT an attestation gate (refusals ride
339
- * the 200 checkout body), so it never routes back into the declaration: it is a route the account may not use.
340
- * 'invoice_owed' is the tagged 409 while Stripe still collects an invoice. The agreement's typed refusals (K2), read
341
- * from the body's tag: 'agreement_stale' (409 `<VENUE>_AGREEMENT_STALE`: the text changed, read it again),
342
- * 'attestation_required' (409 `<VENUE>_ATTESTATION_REQUIRED`: declare first) and 'email_unverified' (403
343
- * `<VENUE>_EMAIL_UNVERIFIED`: verify the email first); the review's 'review_not_open' (409 `<VENUE>_REVIEW_NOT_OPEN`:
344
- * no pending review to confirm, read the records again).
401
+ * Transport-free failure surface for the billing calls. The kind says what the store and the flow do next, never what a
402
+ * page says: the words for a refusal come from the purchase-refusal resolver (docs/features/billing/purchase-
403
+ * refusals.md), which reads `cause`, the failure as it arrived (the server's tagged answer, or the transport's).
404
+ * 'refused': the server answered and refused (any status but a 401, a 429 or a 5xx), so what the account holds may
405
+ * differ from what the page shows and the store reads the records again. The refusals a store acts on itself, read from
406
+ * the body's tag, are refusals too: 'agreement_stale' (409 `<VENUE>_AGREEMENT_STALE`: the text changed, read it
407
+ * again), 'attestation_required' (`<VENUE>_ATTESTATION_REQUIRED`: the declaration on file does not count),
408
+ * 'email_unverified' (403 `<VENUE>_EMAIL_UNVERIFIED`: the verify-email card opens) and 'review_not_open' (409
409
+ * `<VENUE>_REVIEW_NOT_OPEN`: read the records again). 'unauthorized': a 401 or an expired session. 'server': a 5xx or a
410
+ * rate limit, where a retry can succeed. 'network': no answer. 'aborted': the caller's own abort, no refusal at all.
345
411
  */
346
- export type MarketDataBillingErrorKind = 'conflict' | 'invoice_owed' | 'agreement_stale' | 'attestation_required' | 'email_unverified' | 'review_not_open' | 'unauthorized' | 'forbidden' | 'network' | 'aborted' | 'server';
412
+ export type MarketDataBillingErrorKind = 'refused' | 'agreement_stale' | 'attestation_required' | 'email_unverified' | 'review_not_open' | 'unauthorized' | 'network' | 'aborted' | 'server';
347
413
  export declare class MarketDataBillingError extends Error {
348
414
  readonly kind: MarketDataBillingErrorKind;
349
415
  readonly status: number | null;
350
- /** Raw backend message: diagnostic content only, never primary UI copy. */
416
+ /** Raw backend message: diagnostic content only, never UI copy. */
351
417
  readonly diagnosticMessage: string | null;
352
- /** Stripe's hosted invoice on an 'invoice_owed' refusal; null otherwise. */
418
+ /** Stripe's hosted invoice on the owed-invoice refusal (SUBSCRIPTION_INVOICE_OWED); null otherwise. */
353
419
  readonly invoiceUrl: string | null;
354
420
  constructor(kind: MarketDataBillingErrorKind, options?: {
355
421
  status?: number | null;
356
422
  diagnosticMessage?: string | null;
357
423
  invoiceUrl?: string | null;
424
+ cause?: unknown;
358
425
  });
359
426
  }
360
427
  /** A venue's live repository boundary (src/services/market-data.service.ts; specs substitute it per venue). */
@@ -402,4 +469,11 @@ export interface MarketDataBillingRepository {
402
469
  getAcceptedAgreement(signal?: AbortSignal): Promise<MarketDataAcceptedAgreement | null>;
403
470
  /** POST <basePath>/data-terms (K2): the assent; a typed refusal throws its kind. */
404
471
  acceptDataTerms(body: AcceptMarketDataDataTermsDto, signal?: AbortSignal): Promise<MarketDataAgreement>;
472
+ /**
473
+ * GET <basePath>/agreements/<id> (a venue that lists several agreements): the agreement the server presents now, in
474
+ * K1's shape; a body that is not one throws 'server'. A venue of one agreement has no such route.
475
+ */
476
+ getListedAgreement?(agreementId: string, signal?: AbortSignal): Promise<MarketDataAgreementDocument>;
477
+ /** POST <basePath>/agreements/<id>/accept: the assent recorded; a typed refusal throws its kind. */
478
+ acceptListedAgreement?(agreementId: string, body: AcceptMarketDataListedAgreementDto, signal?: AbortSignal): Promise<MarketDataAgreementAssent>;
405
479
  }