@0xmonaco/types 1.1.5-develop.129b2c6 → 1.1.5

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 (40) hide show
  1. package/README.md +3 -1
  2. package/dist/applications/requests.d.ts +5 -5
  3. package/dist/buildercodes/index.d.ts +11 -13
  4. package/dist/buildercodes/responses.d.ts +0 -1
  5. package/dist/buildercodes/responses.js +0 -10
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +0 -1
  8. package/dist/margin-accounts/index.d.ts +2 -7
  9. package/dist/market/index.d.ts +20 -0
  10. package/dist/profile/index.d.ts +17 -10
  11. package/dist/rfq/responses.d.ts +0 -36
  12. package/dist/rfq/responses.js +0 -29
  13. package/dist/sdk/index.d.ts +1 -4
  14. package/dist/trading/index.d.ts +2 -4
  15. package/dist/trading/orders.d.ts +0 -11
  16. package/dist/trading/responses.d.ts +2 -2
  17. package/dist/validation/margin-accounts.d.ts +2 -2
  18. package/dist/validation/margin-accounts.js +5 -5
  19. package/dist/validation/trading.d.ts +0 -15
  20. package/dist/validation/trading.js +42 -34
  21. package/dist/websocket/base.d.ts +10 -40
  22. package/dist/websocket/client.d.ts +4 -32
  23. package/dist/websocket/events/orderbook-events.d.ts +1 -41
  24. package/dist/websocket/events/rfq-events.d.ts +1 -30
  25. package/dist/websocket/events/trade-events.d.ts +0 -31
  26. package/dist/websocket/index.d.ts +0 -1
  27. package/dist/websocket/index.js +0 -1
  28. package/dist/websocket/snapshots.d.ts +1 -23
  29. package/dist/wire/operations.d.ts +1 -1
  30. package/dist/wire/operations.js +0 -16
  31. package/dist/wire/schema.d.ts +295 -2308
  32. package/package.json +2 -2
  33. package/dist/analytics/builders.d.ts +0 -131
  34. package/dist/analytics/builders.js +0 -11
  35. package/dist/analytics/index.d.ts +0 -151
  36. package/dist/analytics/index.js +0 -27
  37. package/dist/analytics/wallets.d.ts +0 -193
  38. package/dist/analytics/wallets.js +0 -16
  39. package/dist/websocket/depth.d.ts +0 -142
  40. package/dist/websocket/depth.js +0 -13
@@ -171,26 +171,6 @@ export const TrailingStopLegSchema = z
171
171
  export const ParentTrailingStopLegSchema = TrailingStopLegSchema;
172
172
  const hasParentTpSl = (options) => options?.takeProfit !== undefined || options?.stopLoss !== undefined || options?.trailingStop !== undefined;
173
173
  const legacyPositionSideMatchesOrderSide = (side, positionSide) => positionSide === undefined || (positionSide !== "NONE" && ((side === "BUY" && positionSide === "LONG") || (side === "SELL" && positionSide === "SHORT")));
174
- /**
175
- * An order's `strategyKey` names one of the caller's margin accounts by its
176
- * sub-account key (`default` is the default margin account), as
177
- * `marginAccountId` names it by id; a copy trading account's `copy:` key names
178
- * it too, for the reduce-only close a copy account admits. The server refuses
179
- * a key outside the sub-account key alphabet and a key naming none of the
180
- * caller's open sub-accounts.
181
- */
182
- export const OrderStrategyKeySchema = z
183
- .string()
184
- .trim()
185
- .min(1, "strategyKey cannot be empty")
186
- .max(64, "strategyKey must be a sub-account key: letters, digits, _ - . :, up to 64 characters")
187
- .regex(/^[A-Za-z0-9_.:-]+$/, "strategyKey must be a sub-account key: letters, digits, _ - . :, up to 64 characters");
188
- /**
189
- * A risk-bucket transfer's or preview's `strategyKey`: the order rule, and a
190
- * reserved `copy:` key is refused (a copy account's risk buckets are funded
191
- * by its follow only).
192
- */
193
- export const StrategyKeySchema = OrderStrategyKeySchema.refine((key) => !key.toLowerCase().startsWith("copy:"), "strategy keys starting with copy: are reserved");
194
174
  /**
195
175
  * Place Limit Order validation schema
196
176
  */
@@ -216,7 +196,7 @@ export const PlaceLimitOrderSchema = z
216
196
  marginMode: MarginModeSchema.optional(),
217
197
  riskBucketId: UUIDSchema.optional(),
218
198
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
219
- strategyKey: OrderStrategyKeySchema.optional(),
199
+ strategyKey: z.string().min(1).max(128).optional(),
220
200
  positionSide: PositionSideSchema.optional(),
221
201
  leverage: PositiveDecimalStringSchema.optional(),
222
202
  reduceOnly: z.boolean().optional(),
@@ -236,7 +216,7 @@ export const PlaceLimitOrderSchema = z
236
216
  message: "leverage is required for normal MARGIN orders",
237
217
  path: ["options", "leverage"],
238
218
  })
239
- .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode !== "SPOT", {
219
+ .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
240
220
  message: "takeProfit/stopLoss/trailingStop are only supported for MARGIN orders",
241
221
  path: ["options"],
242
222
  })
@@ -244,13 +224,17 @@ export const PlaceLimitOrderSchema = z
244
224
  message: "takeProfit/stopLoss/trailingStop cannot be attached to reduce-only orders",
245
225
  path: ["options"],
246
226
  })
247
- .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode !== "SPOT", {
227
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
248
228
  message: "riskBucketCollateral is only supported for MARGIN orders",
249
229
  path: ["options", "tradingMode"],
250
230
  })
251
- .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode !== "SPOT", {
231
+ .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode === "MARGIN", {
252
232
  message: "marginMode is only supported for MARGIN orders",
253
233
  path: ["options", "tradingMode"],
234
+ })
235
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.marginAccountId !== undefined, {
236
+ message: "marginAccountId is required for CROSS margin orders",
237
+ path: ["options", "marginAccountId"],
254
238
  })
255
239
  .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketId === undefined, {
256
240
  message: "marginMode CROSS cannot be combined with riskBucketId",
@@ -259,6 +243,10 @@ export const PlaceLimitOrderSchema = z
259
243
  .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketCollateral === undefined, {
260
244
  message: "marginMode CROSS cannot be combined with riskBucketCollateral",
261
245
  path: ["options", "riskBucketCollateral"],
246
+ })
247
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.strategyKey === undefined, {
248
+ message: "marginMode CROSS cannot be combined with strategyKey",
249
+ path: ["options", "strategyKey"],
262
250
  })
263
251
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
264
252
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -289,7 +277,7 @@ export const PlaceMarketOrderSchema = z
289
277
  marginMode: MarginModeSchema.optional(),
290
278
  riskBucketId: UUIDSchema.optional(),
291
279
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
292
- strategyKey: OrderStrategyKeySchema.optional(),
280
+ strategyKey: z.string().min(1).max(128).optional(),
293
281
  positionSide: PositionSideSchema.optional(),
294
282
  leverage: PositiveDecimalStringSchema.optional(),
295
283
  reduceOnly: z.boolean().optional(),
@@ -308,7 +296,7 @@ export const PlaceMarketOrderSchema = z
308
296
  message: "leverage is required for normal MARGIN orders",
309
297
  path: ["options", "leverage"],
310
298
  })
311
- .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode !== "SPOT", {
299
+ .refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
312
300
  message: "takeProfit/stopLoss/trailingStop are only supported for MARGIN orders",
313
301
  path: ["options"],
314
302
  })
@@ -316,13 +304,17 @@ export const PlaceMarketOrderSchema = z
316
304
  message: "takeProfit/stopLoss/trailingStop cannot be attached to reduce-only orders",
317
305
  path: ["options"],
318
306
  })
319
- .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode !== "SPOT", {
307
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
320
308
  message: "riskBucketCollateral is only supported for MARGIN orders",
321
309
  path: ["options", "tradingMode"],
322
310
  })
323
- .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode !== "SPOT", {
311
+ .refine((data) => data.options?.marginMode === undefined || data.options?.tradingMode === "MARGIN", {
324
312
  message: "marginMode is only supported for MARGIN orders",
325
313
  path: ["options", "tradingMode"],
314
+ })
315
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.marginAccountId !== undefined, {
316
+ message: "marginAccountId is required for CROSS margin orders",
317
+ path: ["options", "marginAccountId"],
326
318
  })
327
319
  .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketId === undefined, {
328
320
  message: "marginMode CROSS cannot be combined with riskBucketId",
@@ -331,6 +323,10 @@ export const PlaceMarketOrderSchema = z
331
323
  .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.riskBucketCollateral === undefined, {
332
324
  message: "marginMode CROSS cannot be combined with riskBucketCollateral",
333
325
  path: ["options", "riskBucketCollateral"],
326
+ })
327
+ .refine((data) => data.options?.marginMode !== "CROSS" || data.options?.strategyKey === undefined, {
328
+ message: "marginMode CROSS cannot be combined with strategyKey",
329
+ path: ["options", "strategyKey"],
334
330
  })
335
331
  .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
336
332
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -470,7 +466,7 @@ export const CreateTwapOrderSchema = z
470
466
  riskBucketId: UUIDSchema.optional(),
471
467
  marginMode: MarginModeSchema.optional(),
472
468
  leverage: PositiveDecimalStringSchema.optional(),
473
- strategyKey: OrderStrategyKeySchema.optional(),
469
+ strategyKey: z.string().min(1).max(128).optional(),
474
470
  useMasterBalance: z.boolean().optional(),
475
471
  clientTwapId: z.string().min(1).max(36, "clientTwapId cannot exceed 36 characters").optional(),
476
472
  triggerPrice: PositiveDecimalStringSchema.optional(),
@@ -486,17 +482,21 @@ export const CreateTwapOrderSchema = z
486
482
  message: "startTime is only valid together with endTime",
487
483
  path: ["options", "startTime"],
488
484
  })
489
- .refine((data) => data.options.marginMode === undefined || data.options.tradingMode !== "SPOT", {
485
+ .refine((data) => data.options.marginMode === undefined || data.options.tradingMode === "MARGIN", {
490
486
  message: "marginMode is only supported for MARGIN orders",
491
487
  path: ["options", "tradingMode"],
492
488
  })
493
- .refine((data) => data.options.riskBucketId === undefined || data.options.tradingMode !== "SPOT", {
489
+ .refine((data) => data.options.riskBucketId === undefined || data.options.tradingMode === "MARGIN", {
494
490
  message: "riskBucketId is only supported for MARGIN orders",
495
491
  path: ["options", "tradingMode"],
496
492
  })
497
493
  .refine((data) => data.options.marginMode !== "CROSS" || data.options.riskBucketId === undefined, {
498
494
  message: "marginMode CROSS cannot be combined with riskBucketId",
499
495
  path: ["options", "riskBucketId"],
496
+ })
497
+ .refine((data) => data.options.marginMode !== "CROSS" || data.options.strategyKey === undefined, {
498
+ message: "marginMode CROSS cannot be combined with strategyKey",
499
+ path: ["options", "strategyKey"],
500
500
  })
501
501
  .refine((data) => data.options.tradingMode !== "MARGIN" || data.options.reduceOnly === true || data.options.leverage !== undefined, {
502
502
  message: "leverage is required for normal MARGIN TWAP orders",
@@ -614,7 +614,7 @@ export const BatchCreateOrderItemSchema = z
614
614
  marginMode: MarginModeSchema.optional(),
615
615
  riskBucketId: UUIDSchema.optional(),
616
616
  riskBucketCollateral: PositiveDecimalStringSchema.optional(),
617
- strategyKey: OrderStrategyKeySchema.optional(),
617
+ strategyKey: z.string().min(1).max(128).optional(),
618
618
  positionSide: PositionSideSchema.optional(),
619
619
  leverage: PositiveDecimalStringSchema.optional(),
620
620
  reduceOnly: z.boolean().optional(),
@@ -641,13 +641,17 @@ export const BatchCreateOrderItemSchema = z
641
641
  message: "postOnly cannot be combined with IOC/FOK time in force",
642
642
  path: ["postOnly"],
643
643
  })
644
- .refine((data) => data.riskBucketCollateral === undefined || data.tradingMode !== "SPOT", {
644
+ .refine((data) => data.riskBucketCollateral === undefined || data.tradingMode === "MARGIN", {
645
645
  message: "riskBucketCollateral is only supported for MARGIN orders",
646
646
  path: ["tradingMode"],
647
647
  })
648
- .refine((data) => data.marginMode === undefined || data.tradingMode !== "SPOT", {
648
+ .refine((data) => data.marginMode === undefined || data.tradingMode === "MARGIN", {
649
649
  message: "marginMode is only supported for MARGIN orders",
650
650
  path: ["tradingMode"],
651
+ })
652
+ .refine((data) => data.marginMode !== "CROSS" || data.marginAccountId !== undefined, {
653
+ message: "marginAccountId is required for CROSS margin orders",
654
+ path: ["marginAccountId"],
651
655
  })
652
656
  .refine((data) => data.marginMode !== "CROSS" || data.riskBucketId === undefined, {
653
657
  message: "marginMode CROSS cannot be combined with riskBucketId",
@@ -656,6 +660,10 @@ export const BatchCreateOrderItemSchema = z
656
660
  .refine((data) => data.marginMode !== "CROSS" || data.riskBucketCollateral === undefined, {
657
661
  message: "marginMode CROSS cannot be combined with riskBucketCollateral",
658
662
  path: ["riskBucketCollateral"],
663
+ })
664
+ .refine((data) => data.marginMode !== "CROSS" || data.strategyKey === undefined, {
665
+ message: "marginMode CROSS cannot be combined with strategyKey",
666
+ path: ["strategyKey"],
659
667
  })
660
668
  .refine((data) => data.riskBucketCollateral === undefined || data.riskBucketId === undefined, {
661
669
  message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
@@ -71,43 +71,23 @@ export interface WebSocketStatusInfo {
71
71
  */
72
72
  export type StatusHandler = (status: WebSocketStatus, info: WebSocketStatusInfo) => void;
73
73
  /**
74
- * Why the application should refetch REST state, delivered by
75
- * {@link MonacoWebSocketConfig.onResync}. Two cases:
76
- *
77
- * - A reconnect (`reason` absent): sent after the socket reopens and sends its
78
- * authentication/subscription requests, without waiting for server acks or
79
- * snapshots. Refetch every channel.
80
- * - A scoped resync (`reason: "resynced"`, 0XM-3553): the connection stayed
81
- * open, but the server reported that an upstream loss may have cost the
82
- * listed `channels` frames, or re-sent a snapshot for a channel that has no
83
- * snapshot handler. Delivered once per burst, no earlier than the server's
84
- * requested delay, with `code: 1013` and `slowClient: true` so a handler
85
- * written for reconnects still refetches (everything). Refetch only
86
- * `channels` to recover precisely. The subscriptions stay active.
87
- *
88
- * The application owns channel-specific recovery; the SDK does not refetch
89
- * REST state itself.
74
+ * Why the connection was re-established. Delivered by
75
+ * {@link MonacoWebSocketConfig.onResync} after the socket reopens and sends its
76
+ * authentication/subscription requests. It does not wait for server acks or
77
+ * snapshots. The application owns channel-specific recovery; the SDK does not
78
+ * automatically refetch REST state.
90
79
  */
91
80
  export interface WebSocketResyncInfo {
92
81
  /** WebSocket close code of the connection that was lost. */
93
82
  code: number;
94
83
  /**
95
- * True when the server closed with 1013 (try again later): the connection
96
- * fell behind, or the server lost events upstream, and any of its streams
97
- * may have a gap. Order, account and engine-sourced public streams carry no
98
- * wire sequence number, so the 1013 close is their gap signal and a snapshot
99
- * refetch is the only safe repair. `depth`, `bbo` and a single market's
100
- * market-data-sourced `trades` rebuild from the snapshot the reconnect
101
- * brings; `trades:*` has no snapshot, so backfill its history over REST.
84
+ * True when the server closed with 1013 (try again later): the client fell
85
+ * behind a sequential stream (orders, conditional orders, liquidations,
86
+ * trades, movements) and the stream has a gap. There is no wire sequence
87
+ * number — the 1013 close is the gap signal, and a snapshot refetch is the
88
+ * only safe repair.
102
89
  */
103
90
  slowClient: boolean;
104
- /** `"resynced"` for a scoped resync; absent on a reconnect. */
105
- reason?: "resynced";
106
- /**
107
- * The channels to refetch, exactly as subscribed, on a scoped resync;
108
- * absent on a reconnect, which covers every channel.
109
- */
110
- channels?: string[];
111
91
  }
112
92
  /** Handler invoked after a reconnect resumes the live stream. */
113
93
  export type ResyncHandler = (info: WebSocketResyncInfo) => void;
@@ -220,16 +200,6 @@ export type ReauthenticationRequiredHandler = (info: WebSocketReauthenticationIn
220
200
  export interface MonacoWebSocketConfig {
221
201
  /** Enable auto-reconnect on disconnect (default: true) */
222
202
  autoReconnect?: boolean;
223
- /**
224
- * Offer the server the `resync` capability (default: true when
225
- * {@link onResync} is set, 0XM-3553; never without it, since the channels
226
- * would have nowhere to go): on an
227
- * upstream loss it can attribute, the server keeps the connection open and
228
- * names the channels to refetch (delivered through {@link onResync} with
229
- * `reason: "resynced"`), or re-sends their snapshots, instead of closing it
230
- * with 1013. `false` keeps the close-and-reconnect behaviour.
231
- */
232
- scopedResync?: boolean;
233
203
  /**
234
204
  * Maximum reconnection attempts per outage (default: unlimited). Retry
235
205
  * delay is full-jitter exponential backoff capped at 30s, so unlimited
@@ -59,14 +59,8 @@ import type { Interval } from "../market";
59
59
  import type { TradingMode } from "../trading";
60
60
  import type { SubscriptionChangeHandler, WebSocketStatus, WebSocketSubscriptionState } from "./base";
61
61
  import type { OrderbookQuotationMode } from "./clients/orderbook-client";
62
- import type { Bbo, DepthBook, LocalBookOptions } from "./depth";
63
- import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketLiquidationEvent, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, RfqEvent, RfqTradeEvent, TradeEvent, TradeEventData, TradeGap, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
62
+ import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketLiquidationEvent, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, RfqEvent, RfqTradeEvent, TradeEvent, TradeEventData, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
64
63
  import type { OHLCVSnapshotCandle, OrderSnapshotItem, SnapshotHandler } from "./snapshots";
65
- /** Options for `ws.trades`. */
66
- export interface TradesOptions {
67
- /** Called when a sequenced trade does not link to the last trade delivered (it is still delivered). */
68
- onGap?: (gap: TradeGap) => void;
69
- }
70
64
  export type MessageHandler<T> = (data: T) => void;
71
65
  export interface MonacoWebSocket {
72
66
  /** Connect to the WebSocket server */
@@ -98,26 +92,10 @@ export interface MonacoWebSocket {
98
92
  /** Subscribe to order events (requires authentication); `onSnapshot` receives every resting order on the pair */
99
93
  orders: (tradingPairId: string, tradingMode: TradingMode, handler: MessageHandler<OrderEvent>, onSnapshot?: SnapshotHandler<OrderSnapshotItem>) => () => void;
100
94
  /**
101
- * Subscribe to orderbook events (public); `onSnapshot` receives one event, the current book, in the same shape as a
102
- * live event. From the matching engine it is the top 20 levels with `sequence` 0; from the market-data service it is
103
- * grouped over the whole book (at most 20 levels or buckets per side), carries `bookSeq`, and its `sequence` equals
104
- * `bookSeq`. From the engine, a pair or mode with no book gets `[]`; from the market-data service, an unknown pair
105
- * gets a `SNAPSHOT_UNAVAILABLE` error (through `onError`) instead, and no snapshot until the pair is listed.
95
+ * Subscribe to orderbook events (public); `onSnapshot` receives one event, the current book read from the matching
96
+ * engine, in the same shape as a live event. Its `sequence` is 0. A pair or mode with no book gets `[]`.
106
97
  */
107
98
  orderbook: (tradingPairId: string, tradingMode: TradingMode, magnitude: number, quotationMode: OrderbookQuotationMode, handler: MessageHandler<OrderbookEvent>, onSnapshot?: SnapshotHandler<OrderbookEvent>) => () => void;
108
- /**
109
- * Keep a local depth book from the market-data `depth:<tradingPairId>:<SPOT|MARGIN>` channel (public): up to 1000
110
- * levels per side. The subscribe-time snapshot is the base; live frames that do not link to it are dropped or
111
- * trigger a rebuild from a fresh snapshot. `onBook` receives the whole book after the snapshot and after every
112
- * applied frame. Subscribers on the same channel share one book. Returns a function that stops listening.
113
- */
114
- depth: (tradingPairId: string, tradingMode: TradingMode, onBook: MessageHandler<DepthBook>, options?: LocalBookOptions) => () => void;
115
- /**
116
- * Keep the top of book from the market-data `bbo:<tradingPairId>:<SPOT|MARGIN>` channel (public), with the same
117
- * snapshot handoff and link checks as `depth`. `onBbo` receives the current best bid and ask (an empty side is
118
- * `null`) after the snapshot and after every applied frame.
119
- */
120
- bbo: (tradingPairId: string, tradingMode: TradingMode, onBbo: MessageHandler<Bbo>, options?: LocalBookOptions) => () => void;
121
99
  /**
122
100
  * Subscribe to OHLCV candlestick events (public); `onSnapshot` receives the series' newest 350 candles, oldest first.
123
101
  * The newest snapshot candle can be partial or missing, so upsert live candles by `T`. A `*` price type gets no snapshot.
@@ -126,14 +104,8 @@ export interface MonacoWebSocket {
126
104
  /**
127
105
  * Subscribe to trade events (public); `onSnapshot` receives the pair's newest 50 trades, newest first.
128
106
  * The snapshot can overlap the first live trades or miss one executed just before subscribing, so dedupe on `tradeId`.
129
- *
130
- * When the server sources trades from market-data, each trade carries `seq` / `matchIndex` / `prevSeq` /
131
- * `prevMatchIndex`, and the snapshot's `meta.cursor` names the trade it is current as of. The helper then drops
132
- * trades at or below the cursor or the last delivered trade, and reports one that does not link to the last
133
- * delivered trade to `options.onGap` (still delivering it: the server forwards only linking trades, so a mismatch
134
- * means a frame was lost on this client). Without those fields every trade is delivered as before.
135
107
  */
136
- trades: (tradingPairId: string, handler: MessageHandler<TradeEvent>, onSnapshot?: SnapshotHandler<TradeEventData>, options?: TradesOptions) => () => void;
108
+ trades: (tradingPairId: string, handler: MessageHandler<TradeEvent>, onSnapshot?: SnapshotHandler<TradeEventData>) => () => void;
137
109
  /** Subscribe to user movement events (requires authentication) */
138
110
  movements: (handler: MessageHandler<UserMovementEvent>) => () => void;
139
111
  /** Subscribe to user order events for all trading pairs (requires authentication); `onSnapshot` receives every resting order */
@@ -67,46 +67,6 @@ export interface OrderbookEvent {
67
67
  quoteDecimals: number;
68
68
  /** Event timestamp */
69
69
  timestamp: string;
70
- /**
71
- * Sequence number for ordering. Under the default engine source it is the
72
- * matching engine's own frame counter; when the server renders the channel
73
- * from market-data's book (`WS_ORDERBOOK_SOURCE=market_data`) it equals
74
- * `bookSeq`. The two are different number spaces: do not compare a value
75
- * from one source with a value from the other (a reconnect or deploy can
76
- * switch sources). For exact comparison under the market-data source use
77
- * `bookSeq`, a u64 decimal string.
78
- */
70
+ /** Sequence number for ordering */
79
71
  sequence: number;
80
- /**
81
- * Durable-log sequence this book is exact as of, as a decimal string
82
- * (a u64 can exceed `Number.MAX_SAFE_INTEGER`; compare with `BigInt`).
83
- *
84
- * Present on a REST snapshot of more than 100 levels: a point-in-time
85
- * read and staleness check, not a base for applying depth deltas (the REST
86
- * snapshot may come from a different market-data replica than the stream;
87
- * for a live local book use `sdk.ws.depth`, which hands off from the
88
- * `depth` channel's own snapshot). A side that came back with as many
89
- * levels as requested may hold more.
90
- *
91
- * Also present on every `orderbook` WebSocket frame and snapshot row when
92
- * the server renders the channel from market-data's book
93
- * (`WS_ORDERBOOK_SOURCE=market_data`): the same watermark the `depth`
94
- * channel carries, identical on every server. Each such frame restates the
95
- * book, so per subscription (one channel string: pair, mode, magnitude and
96
- * quotation) a frame whose `bookSeq` is not past the last one applied to it
97
- * can be ignored. The watermark is the book's, shared by every magnitude
98
- * and quotation of it: a newly subscribed variant starts from its own
99
- * snapshot even when its `bookSeq` equals another variant's.
100
- */
101
- bookSeq?: string;
102
- /**
103
- * On an `orderbook` WebSocket frame rendered from market-data's book
104
- * (`WS_ORDERBOOK_SOURCE=market_data`): the `bookSeq` of the previous frame
105
- * this server rendered for the book, `"0"` before the first, as a decimal
106
- * string. A `prevBookSeq` at or below the `bookSeq` you hold means no
107
- * rendered state was skipped. Informational only: every frame restates the
108
- * whole book, so nothing needs to be re-requested when it is higher.
109
- * Absent under the engine source and on REST snapshots.
110
- */
111
- prevBookSeq?: string;
112
72
  }
@@ -42,17 +42,9 @@ export interface RfqRequestedEvent {
42
42
  }
43
43
  /** One side of the taker's view: the allocation that would fill the quantity. */
44
44
  export interface RfqSideViewEventData {
45
- /** All-in volume-weighted price, the taker's Monaco and builder fees included. */
45
+ /** All-in volume-weighted price, the taker's fee included. */
46
46
  vwap: string;
47
47
  availableQuantity: string;
48
- /** The volume-weighted price before fees. */
49
- grossVwap?: string;
50
- /** Estimated Monaco taker fee on `availableQuantity`, in the quote asset. */
51
- estimatedMonacoFee?: string;
52
- /** Estimated builder fee on `availableQuantity`, in the quote asset. */
53
- estimatedBuilderFee?: string;
54
- /** Estimated total taker fee on `availableQuantity`, in the quote asset. */
55
- estimatedTotalFee?: string;
56
48
  }
57
49
  /** The taker's view of the quotes. No maker identity or individual quote. */
58
50
  export interface RfqViewEventData {
@@ -65,10 +57,6 @@ export interface RfqViewEventData {
65
57
  asOfMs: number;
66
58
  /** Pushes can arrive out of order: keep the view with the highest `sequence`. */
67
59
  sequence: number;
68
- /** Your Monaco taker fee rate in this view, in centi-bps. */
69
- monacoFeeCbps?: number;
70
- /** Your frontend's builder fee rate in this view, in centi-bps; frozen when you accept. */
71
- builderFeeCbps?: number;
72
60
  }
73
61
  /** To the taker: its view moved. */
74
62
  export interface RfqViewEvent {
@@ -94,18 +82,6 @@ export interface RfqSelectionEventData {
94
82
  makerFeeCbps: number;
95
83
  /** Reject or improve before this time; silence executes. */
96
84
  lastLookDeadlineAtMs: number;
97
- /**
98
- * The MOST your frontend's builder add-on charges on this fill, in centi-bps:
99
- * the rate stored on your quote order. A fill charges it or nothing, never
100
- * more; the receipt shows what was charged. Absent when it could not be read.
101
- */
102
- maxBuilderFeeCbps?: number;
103
- /**
104
- * Estimated net at `quantity` and `price`, in the quote asset, at
105
- * `makerFeeCbps` plus `maxBuilderFeeCbps`: the least you receive when
106
- * selling, the most you pay when buying. Absent with `maxBuilderFeeCbps`.
107
- */
108
- estimatedNet?: string;
109
85
  }
110
86
  /** To one selected maker: its last-look prompt. */
111
87
  export interface RfqSelectedEvent {
@@ -118,12 +94,7 @@ export interface RfqFillEventData {
118
94
  executionId: string;
119
95
  price: string;
120
96
  quantity: string;
121
- /** Your whole taker fee on this fill: `monacoFee` plus `builderFee`. */
122
97
  fee: string;
123
- /** The Monaco part of `fee`. */
124
- monacoFee?: string;
125
- /** The builder part of `fee`. */
126
- builderFee?: string;
127
98
  }
128
99
  /** How an RFQ ended, for its taker. */
129
100
  export interface RfqOutcomeEventData {
@@ -53,35 +53,4 @@ export interface TradeEvent {
53
53
  tradingMode: TradingMode | (string & {});
54
54
  /** Trade execution data */
55
55
  data: TradeEventData;
56
- /**
57
- * The trade's position in its pair's chain: the durable-log sequence of the
58
- * step that executed it. Present only when the server sources trades from
59
- * market-data (`WS_TRADES_SOURCE=market_data`); absent otherwise.
60
- */
61
- seq?: number;
62
- /** The trade's index among its step's fills; with `seq`, the trade's key. Same presence as `seq`. */
63
- matchIndex?: number;
64
- /** `seq` of the previous trade on the pair; 0 when the publisher knows none. Same presence as `seq`. */
65
- prevSeq?: number;
66
- /** `matchIndex` of the previous trade on the pair; `null` when the publisher knows none. Same presence as `seq`. */
67
- prevMatchIndex?: number | null;
68
- }
69
- /**
70
- * A sequenced trade `ws.trades` received that did not link to the last trade
71
- * it delivered (or the snapshot cursor). The server forwards only linking
72
- * trades, so this means a frame was lost or unreadable on the client; the
73
- * trade is still delivered and the chain continues from it.
74
- */
75
- export interface TradeGap {
76
- tradingPairId: string;
77
- /** The key of the last trade delivered, or the snapshot cursor. */
78
- expected: {
79
- seq: number;
80
- matchIndex: number;
81
- };
82
- /** The received trade's link as sent; `null` where the frame carried none. */
83
- received: {
84
- prevSeq: number | null;
85
- prevMatchIndex: number | null;
86
- };
87
56
  }
@@ -6,6 +6,5 @@
6
6
  export * from "./base";
7
7
  export * from "./client";
8
8
  export * from "./clients/orderbook-client";
9
- export * from "./depth";
10
9
  export * from "./events";
11
10
  export * from "./snapshots";
@@ -6,6 +6,5 @@
6
6
  export * from "./base";
7
7
  export * from "./client";
8
8
  export * from "./clients/orderbook-client";
9
- export * from "./depth";
10
9
  export * from "./events";
11
10
  export * from "./snapshots";
@@ -51,29 +51,7 @@ import type { OrderOrigin } from "./events/orders-events";
51
51
  * already holds a second subscriber's callback waits for the next reconnect;
52
52
  * see `MonacoWebSocket` for the full rule.
53
53
  */
54
- export type SnapshotHandler<T> = (items: T[], meta?: SnapshotMeta) => void;
55
- /**
56
- * The trade a `trades:<pair>` snapshot is current as of: trades at or below
57
- * this key, compared as `(seq, matchIndex)`, are already reflected, and the
58
- * next live trade links to it exactly.
59
- */
60
- export interface TradeSnapshotCursor {
61
- seq: number;
62
- matchIndex: number;
63
- }
64
- /**
65
- * What a `Snapshot` frame carries beside its rows. Today only the
66
- * `trades:<pair>` snapshot uses it, and only when the server sources trades
67
- * from market-data.
68
- */
69
- export interface SnapshotMeta {
70
- /**
71
- * `trades:<pair>` only: the trade the live frames continue from, or `null`
72
- * when nothing was applied since the server seeded the pair (the first live
73
- * trade is then the base). Absent under the default engine source.
74
- */
75
- cursor?: TradeSnapshotCursor | null;
76
- }
54
+ export type SnapshotHandler<T> = (items: T[]) => void;
77
55
  /**
78
56
  * One candle in an `ohlcv` channel snapshot: the live frame's candlestick
79
57
  * without `s`.
@@ -10,6 +10,6 @@
10
10
  * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
11
  * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
12
  */
13
- export declare const OPERATION_IDS: readonly ["accept_rfq", "add_follow_position_margin", "attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_all_after", "cancel_conditional_order", "cancel_order", "cancel_rfq", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "close_sub_account", "create_challenge", "create_delegated_session", "create_order", "create_rfq", "create_sub_account", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_builder", "get_builder_series", "get_builder_totals", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_fee_schedule", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_liquidation_metrics", "get_margin_account_movements", "get_margin_account_pnl", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "get_my_referral_tree", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_protocol_series", "get_protocol_totals", "get_pulse", "get_region_status", "get_rewards_balance", "get_rfq", "get_rfq_capabilities", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_sweeper_deposit_status", "get_token_custody", "get_trade_by_id", "get_trade_flow", "get_trader_code_info", "get_trader_metrics", "get_trades", "get_trading_pair_by_id", "get_treasury_net_fees", "get_twap_order", "get_twap_order_tca", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_wallet_summary", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_all_liquidation_events", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_builder_fee_changes", "list_builder_leaderboard", "list_buildercode_payouts", "list_builders", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_insurance_funds", "list_invite_codes", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_liquidation_events", "list_managed_market_assignments", "list_margin_accounts", "list_market_volumes", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_sweeper_deposits", "list_token_custody", "list_trades", "list_trading_pairs", "list_twap_order_slices", "list_twap_orders", "list_vault_deposits", "list_vault_withdrawals", "list_wallet_leaderboard", "list_wallet_liquidations", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "request_invite_codes", "respond_rfq_last_look", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "transfer_collateral", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_from_sub_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_collateral_to_sub_account", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "upsert_follow", "upsert_lead_trader", "upsert_rfq_quote", "verify_signature", "withdraw_rfq_quote"];
13
+ export declare const OPERATION_IDS: readonly ["accept_rfq", "add_follow_position_margin", "attach_position_tp_sl", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_all_after", "cancel_conditional_order", "cancel_order", "cancel_rfq", "cancel_twap_order", "check_trader_code_availability", "claim_buildercode_rewards", "claim_managed_market_lease", "clear_trader_code", "close_all_copy_positions", "close_follow_positions", "close_position", "close_sub_account", "create_challenge", "create_delegated_session", "create_order", "create_rfq", "create_sub_account", "create_sub_account_limit", "create_twap_order", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_buildercode_payout_summary", "get_buildercode_rewards_balance", "get_buildercodes_config", "get_candles", "get_conditional_order", "get_faucet_info", "get_fee_schedule", "get_follow", "get_funding_state", "get_index_price", "get_lead_trader", "get_liquidation_metrics", "get_margin_account_movements", "get_margin_account_pnl", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "get_my_lead_trader", "get_my_referral_downline", "get_my_referral_position", "get_my_referral_tree", "get_my_trader_code", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_assets", "get_portfolio_chart", "get_portfolio_margin", "get_portfolio_performance", "get_portfolio_realized_pnl", "get_portfolio_stats", "get_portfolio_summary", "get_position", "get_position_pnl_history", "get_position_risk", "get_pulse", "get_region_status", "get_rewards_balance", "get_rfq", "get_rfq_capabilities", "get_screener", "get_self_trade_prevention_default", "get_sub_account_limits", "get_sweeper_chains", "get_sweeper_deposit_status", "get_trade_by_id", "get_trade_flow", "get_trader_code_info", "get_trader_metrics", "get_trades", "get_trading_pair_by_id", "get_twap_order", "get_twap_order_tca", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_all_funding_history", "list_all_liquidation_events", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_builder_fee_changes", "list_buildercode_payouts", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_follow_leader_positions", "list_funding_history", "list_funding_payments", "list_insurance_funds", "list_invite_codes", "list_lead_trader_closed_trades", "list_lead_trader_open_positions", "list_lead_traders", "list_liquidation_events", "list_managed_market_assignments", "list_margin_accounts", "list_my_followers", "list_my_follows", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_sweeper_deposits", "list_trades", "list_trading_pairs", "list_twap_order_slices", "list_twap_orders", "mint_tokens", "preview_follow", "refresh_managed_market_quotes", "refresh_session", "register_deposit_address", "replace_order", "request_invite_codes", "respond_rfq_last_look", "revoke_delegated_agent", "revoke_session", "set_builder_fee", "set_self_trade_prevention_default", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "stop_follow", "transfer_collateral", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_from_sub_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_collateral_to_sub_account", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "upsert_follow", "upsert_lead_trader", "upsert_rfq_quote", "verify_signature", "withdraw_rfq_quote"];
14
14
  /** Union of every OpenAPI operationId in the spec. */
15
15
  export type OperationId = (typeof OPERATION_IDS)[number];
@@ -44,9 +44,6 @@ export const OPERATION_IDS = [
44
44
  "get_application_config",
45
45
  "get_application_stats",
46
46
  "get_available_collateral",
47
- "get_builder",
48
- "get_builder_series",
49
- "get_builder_totals",
50
47
  "get_buildercode_payout_summary",
51
48
  "get_buildercode_rewards_balance",
52
49
  "get_buildercodes_config",
@@ -89,8 +86,6 @@ export const OPERATION_IDS = [
89
86
  "get_position",
90
87
  "get_position_pnl_history",
91
88
  "get_position_risk",
92
- "get_protocol_series",
93
- "get_protocol_totals",
94
89
  "get_pulse",
95
90
  "get_region_status",
96
91
  "get_rewards_balance",
@@ -101,14 +96,12 @@ export const OPERATION_IDS = [
101
96
  "get_sub_account_limits",
102
97
  "get_sweeper_chains",
103
98
  "get_sweeper_deposit_status",
104
- "get_token_custody",
105
99
  "get_trade_by_id",
106
100
  "get_trade_flow",
107
101
  "get_trader_code_info",
108
102
  "get_trader_metrics",
109
103
  "get_trades",
110
104
  "get_trading_pair_by_id",
111
- "get_treasury_net_fees",
112
105
  "get_twap_order",
113
106
  "get_twap_order_tca",
114
107
  "get_user_balance_by_asset",
@@ -116,7 +109,6 @@ export const OPERATION_IDS = [
116
109
  "get_user_movements",
117
110
  "get_user_profile",
118
111
  "get_user_trades",
119
- "get_wallet_summary",
120
112
  "get_withdrawal",
121
113
  "health_check",
122
114
  "initiate_withdrawal",
@@ -127,9 +119,7 @@ export const OPERATION_IDS = [
127
119
  "list_application_orders",
128
120
  "list_application_users",
129
121
  "list_builder_fee_changes",
130
- "list_builder_leaderboard",
131
122
  "list_buildercode_payouts",
132
- "list_builders",
133
123
  "list_conditional_orders",
134
124
  "list_delegated_agent_owners",
135
125
  "list_delegated_agents",
@@ -144,7 +134,6 @@ export const OPERATION_IDS = [
144
134
  "list_liquidation_events",
145
135
  "list_managed_market_assignments",
146
136
  "list_margin_accounts",
147
- "list_market_volumes",
148
137
  "list_my_followers",
149
138
  "list_my_follows",
150
139
  "list_pending_withdrawals",
@@ -152,15 +141,10 @@ export const OPERATION_IDS = [
152
141
  "list_positions",
153
142
  "list_sub_accounts_with_balances",
154
143
  "list_sweeper_deposits",
155
- "list_token_custody",
156
144
  "list_trades",
157
145
  "list_trading_pairs",
158
146
  "list_twap_order_slices",
159
147
  "list_twap_orders",
160
- "list_vault_deposits",
161
- "list_vault_withdrawals",
162
- "list_wallet_leaderboard",
163
- "list_wallet_liquidations",
164
148
  "mint_tokens",
165
149
  "preview_follow",
166
150
  "refresh_managed_market_quotes",