@0xmonaco/types 1.0.39 → 1.0.41

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.
@@ -80,6 +80,12 @@ export interface TransferCollateralRequest {
80
80
  amount: string;
81
81
  tradingPairId?: string;
82
82
  strategyKey?: string;
83
+ /**
84
+ * Risk bucket mode. Defaults to ISOLATED, which is selected by
85
+ * `tradingPairId`. Pass `"CROSS"` to release from the account's cross risk
86
+ * bucket, which has no trading pair and so cannot be named any other way.
87
+ */
88
+ marginMode?: MarginMode;
83
89
  }
84
90
  export interface TransferCollateralToParentMarginAccountRequest {
85
91
  asset: string;
@@ -232,6 +232,18 @@ export interface ScreenerItem {
232
232
  * null for spot pairs and margin pairs with no settled funding window yet
233
233
  */
234
234
  lastFundingTime: string | null;
235
+ /**
236
+ * Open interest in base-asset units (e.g. BTC); null for spot pairs, "0" for
237
+ * a margin pair with no open positions
238
+ */
239
+ openInterestBase: string | null;
240
+ /**
241
+ * Open interest notional in quote units (openInterestBase × latest trade
242
+ * price); null for spot pairs. Valued at the pair's latest trade price (a
243
+ * snapshot); the mark-accurate notional lives on getPerpMarketSummary /
244
+ * getOpenInterest
245
+ */
246
+ openInterestNotional: string | null;
235
247
  }
236
248
  /**
237
249
  * Paginated screener response, sorted by quoteVolume24h desc (nulls last)
@@ -269,6 +281,8 @@ export interface MarketMetadata {
269
281
  low24h: string | null;
270
282
  /** 24h volume in base asset (null if <24h data) */
271
283
  volume24h: string | null;
284
+ /** Quote-token (notional) volume over the rolling 24h window; absent/null when unavailable */
285
+ quoteVolume24h?: string | null;
272
286
  /** Absolute price change in 24h (null if <24h data) */
273
287
  priceChange24h: string | null;
274
288
  /** Percentage price change in 24h (2 decimals, null if <24h data) */
@@ -319,10 +333,18 @@ export interface PerpMarketSummary {
319
333
  indexPrice: string;
320
334
  high24h?: string;
321
335
  low24h?: string;
336
+ /** 24h volume in base asset */
322
337
  volume24h?: string;
338
+ /** 24h quote-token (notional) volume */
339
+ quoteVolume24h?: string;
323
340
  priceChange24h?: string;
324
341
  priceChangePercent24h?: string;
342
+ /** Open interest in base-asset units (legacy alias of openInterestBase) */
325
343
  openInterest: string;
344
+ /** Open interest in base-asset units (e.g. BTC) */
345
+ openInterestBase?: string;
346
+ /** Open interest notional in quote units (openInterestBase × mark price, falling back to the last trade price when no mark is available) */
347
+ openInterestNotional?: string;
326
348
  currentFundingRate?: string;
327
349
  estimatedNextFundingRate?: string;
328
350
  nextFundingTime?: string;
@@ -164,20 +164,6 @@ export interface PositionRisk {
164
164
  initialMarginRequired?: string;
165
165
  updatedAt: string;
166
166
  }
167
- export interface AddPositionMarginRequest {
168
- amount: string;
169
- asset: string;
170
- }
171
- export interface ReducePositionMarginRequest {
172
- amount: string;
173
- }
174
- export interface PositionMarginResponse {
175
- positionId: string;
176
- marginAccountId: string;
177
- newIsolatedMargin: string;
178
- status: string;
179
- message: string;
180
- }
181
167
  export interface TpSlLeg {
182
168
  triggerPrice: string;
183
169
  orderType: OrderType;
@@ -311,8 +297,6 @@ export interface PositionsAPI extends BaseAPI {
311
297
  closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
312
298
  batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
313
299
  getPositionRisk(positionId: string): Promise<PositionRisk>;
314
- addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
315
- reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
316
300
  attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
317
301
  listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
318
302
  getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
@@ -41,10 +41,17 @@ export interface TradingAPI extends BaseAPI {
41
41
  /**
42
42
  * Maker-only: rejected with a 400 carrying the structured error code
43
43
  * `POST_ONLY_WOULD_CROSS` if this limit order would cross the book.
44
- * LIMIT orders with GTC/GTD only; rejected together with IOC/FOK.
44
+ * LIMIT orders with GTC only; rejected together with IOC/FOK.
45
45
  * Echoed back as `postOnly` on order detail and list reads.
46
46
  */
47
47
  postOnly?: boolean;
48
+ /**
49
+ * Client-assigned correlation handle, echoed back on order reads and
50
+ * order WebSocket events. At most 64 characters from [A-Za-z0-9._:-].
51
+ * Not de-duplicated and not unique — a replacement re-states it and
52
+ * inherits nothing from the original order.
53
+ */
54
+ clientOrderId?: string;
48
55
  takeProfit?: ParentTpSlLegParams;
49
56
  stopLoss?: ParentTpSlLegParams;
50
57
  }): Promise<CreateOrderResponse>;
@@ -70,6 +77,13 @@ export interface TradingAPI extends BaseAPI {
70
77
  positionSide?: PositionSide;
71
78
  leverage?: string;
72
79
  reduceOnly?: boolean;
80
+ /**
81
+ * Client-assigned correlation handle, echoed back on order reads and
82
+ * order WebSocket events. At most 64 characters from [A-Za-z0-9._:-].
83
+ * Not de-duplicated and not unique — a replacement re-states it and
84
+ * inherits nothing from the original order.
85
+ */
86
+ clientOrderId?: string;
73
87
  takeProfit?: ParentTpSlLegParams;
74
88
  stopLoss?: ParentTpSlLegParams;
75
89
  }): Promise<CreateOrderResponse>;
@@ -119,6 +133,13 @@ export interface TradingAPI extends BaseAPI {
119
133
  quantity?: string;
120
134
  useMasterBalance?: boolean;
121
135
  postOnly?: boolean;
136
+ /**
137
+ * Client-assigned correlation handle, echoed back on order reads and
138
+ * order WebSocket events. At most 64 characters from [A-Za-z0-9._:-].
139
+ * Not de-duplicated and not unique — a replacement re-states it and
140
+ * inherits nothing from the original order.
141
+ */
142
+ clientOrderId?: string;
122
143
  }): Promise<ReplaceOrderResponse>;
123
144
  /**
124
145
  * Batch creates multiple orders in a single request.
@@ -40,13 +40,13 @@ export interface Order {
40
40
  averageFillPrice?: string;
41
41
  /** Trading mode (SPOT or MARGIN) */
42
42
  tradingMode: TradingMode;
43
- /** Time in force - GTC, IOC, FOK, or GTD */
43
+ /** Time in force - GTC, IOC, or FOK (GTD is deprecated and rejected) */
44
44
  timeInForce?: TimeInForce;
45
45
  /** Order creation timestamp (ISO 8601) */
46
46
  createdAt: string;
47
47
  /** Order last update timestamp (ISO 8601) */
48
48
  updatedAt?: string;
49
- /** Optional expiration date for GTD orders (ISO 8601, max 1 year) */
49
+ /** Optional expiry for a GTC order (ISO 8601, max 1 year) */
50
50
  expirationDate?: string;
51
51
  /** Application taker fee in basis points (e.g., "100" = 1%) - populated after fills */
52
52
  applicationTakerFee?: string;
@@ -70,6 +70,14 @@ export interface Order {
70
70
  reduceOnly?: boolean;
71
71
  /** Whether the order was placed post-only (maker-only). Absent for orders placed before the flag was persisted. */
72
72
  postOnly?: boolean;
73
+ /**
74
+ * Client-assigned correlation handle as stored: the value supplied on create
75
+ * or replace, with surrounding whitespace trimmed. Absent when the order
76
+ * carried none, including every order placed before the field was accepted on
77
+ * write. Not unique — several orders may share one value, so a lookup by it
78
+ * can be ambiguous.
79
+ */
80
+ clientOrderId?: string;
73
81
  /** Position ID linked to the order, when available */
74
82
  positionId?: string;
75
83
  /** Stable cause when status is CANCELLED */
@@ -134,7 +142,10 @@ export type TradingMode = "SPOT" | "MARGIN";
134
142
  * - GTC: Good Till Cancel - remains active until filled or canceled
135
143
  * - IOC: Immediate or Cancel - execute immediately and cancel unfilled portion
136
144
  * - FOK: Fill or Kill - execute completely or cancel entirely
137
- * - GTD: Good Till Date - remains active until specified expiration date
145
+ * - GTD: **deprecated, never implemented** - the server rejects it with HTTP
146
+ * 400 (`Time in force must be GTC, IOC, or FOK`). The variant is retained so
147
+ * existing code keeps compiling. For an order that expires at a set time, use
148
+ * `GTC` together with `expirationDate`.
138
149
  */
139
150
  export type TimeInForce = "GTC" | "IOC" | "FOK" | "GTD";
140
151
  /**
@@ -38,8 +38,12 @@ export interface MatchResult {
38
38
  } | null;
39
39
  }
40
40
  /**
41
- * Parent TP/SL follows the parent order quantity and becomes active once the
42
- * parent order creates or extends a position.
41
+ * A take-profit / stop-loss leg attached to an order at placement. It becomes
42
+ * active once the parent order creates or extends a position.
43
+ *
44
+ * Sizing is the leg's own, set by `quantity` / `closePosition` below — it does
45
+ * NOT follow the parent order's quantity. Sizing from the parent is what let a
46
+ * leg freeze at the order's size and under-cover a position that later grew.
43
47
  */
44
48
  export interface ParentTpSlLegParams {
45
49
  /** Mark price that arms the close order */
@@ -54,6 +58,18 @@ export interface ParentTpSlLegParams {
54
58
  slippageToleranceBps?: number;
55
59
  /** Optional conditional order expiry timestamp (ISO 8601) */
56
60
  expiresAt?: string;
61
+ /**
62
+ * Deliberate partial size: this leg closes exactly this much and never
63
+ * resizes, however the position grows. Mutually exclusive with
64
+ * `closePosition: true`; required when `closePosition: false`.
65
+ */
66
+ quantity?: string;
67
+ /**
68
+ * Resolve the full live position size when triggered, so the leg keeps
69
+ * covering the position as it grows. Mutually exclusive with `quantity`.
70
+ * Omitting both also means full-position close.
71
+ */
72
+ closePosition?: boolean;
57
73
  }
58
74
  /**
59
75
  * Response from creating an order.
@@ -354,11 +370,18 @@ export interface BatchCreateOrderParams {
354
370
  /**
355
371
  * Maker-only: rejected with a structured `error.code` of
356
372
  * `POST_ONLY_WOULD_CROSS` on this item's result if the limit order would
357
- * cross the book. LIMIT orders with GTC/GTD only; rejected on MARKET
373
+ * cross the book. LIMIT orders with GTC only; rejected on MARKET
358
374
  * orders and combined with IOC/FOK. Echoed back as `postOnly` on order
359
375
  * detail and list reads.
360
376
  */
361
377
  postOnly?: boolean;
378
+ /**
379
+ * Client-assigned correlation handle, echoed back on order reads and on
380
+ * order WebSocket events. At most 64 characters from [A-Za-z0-9._:-].
381
+ * Monaco does not de-duplicate on it and does not enforce uniqueness —
382
+ * it correlates a response to a request, it does not make a retry safe.
383
+ */
384
+ clientOrderId?: string;
362
385
  }
363
386
  /**
364
387
  * Parameters for a single order in a batch replace request
@@ -377,6 +400,13 @@ export interface BatchReplaceOrderParams {
377
400
  * inherited from the original order — see `TradingAPI.replaceOrder`.
378
401
  */
379
402
  postOnly?: boolean;
403
+ /**
404
+ * Client-assigned correlation handle, echoed back on order reads and on
405
+ * order WebSocket events. At most 64 characters from [A-Za-z0-9._:-].
406
+ * Monaco does not de-duplicate on it and does not enforce uniqueness —
407
+ * it correlates a response to a request, it does not make a retry safe.
408
+ */
409
+ clientOrderId?: string;
380
410
  }
381
411
  export interface CancelConditionalOrderResponse {
382
412
  conditionalOrderId: string;
@@ -25,6 +25,10 @@ export declare const TransferCollateralSchema: z.ZodObject<{
25
25
  amount: z.ZodString;
26
26
  tradingPairId: z.ZodOptional<z.ZodUUID>;
27
27
  strategyKey: z.ZodOptional<z.ZodString>;
28
+ marginMode: z.ZodOptional<z.ZodEnum<{
29
+ ISOLATED: "ISOLATED";
30
+ CROSS: "CROSS";
31
+ }>>;
28
32
  }, z.core.$strip>;
29
33
  }, z.core.$strip>;
30
34
  export declare const TransferCollateralToParentMarginAccountSchema: z.ZodObject<{
@@ -25,11 +25,19 @@ export const GetAvailableCollateralSchema = z
25
25
  asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
26
26
  })
27
27
  .optional();
28
- const TransferCollateralRequestSchema = z.object({
28
+ const TransferCollateralRequestSchema = z
29
+ .object({
29
30
  asset: z.string().trim().min(1, "Asset cannot be empty"),
30
31
  amount: PositiveDecimalStringSchema,
31
32
  tradingPairId: UUIDSchema.optional(),
32
33
  strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
34
+ // A cross risk bucket has no trading pair, so CROSS is the only way to name
35
+ // one on the way out (0XM-2420). The two never combine.
36
+ marginMode: z.enum(["ISOLATED", "CROSS"]).optional(),
37
+ })
38
+ .refine((request) => !(request.marginMode === "CROSS" && request.tradingPairId !== undefined), {
39
+ message: "tradingPairId is not supported for CROSS risk buckets",
40
+ path: ["tradingPairId"],
33
41
  });
34
42
  const ParentMarginAccountCollateralRequestSchema = z.object({
35
43
  asset: z.string().trim().min(1, "Asset cannot be empty"),
@@ -37,19 +37,6 @@ export declare const BatchCloseAllSchema: z.ZodObject<{
37
37
  export declare const GetPositionRiskSchema: z.ZodObject<{
38
38
  positionId: z.ZodUUID;
39
39
  }, z.core.$strip>;
40
- export declare const AddPositionMarginSchema: z.ZodObject<{
41
- positionId: z.ZodUUID;
42
- request: z.ZodObject<{
43
- amount: z.ZodString;
44
- asset: z.ZodString;
45
- }, z.core.$strip>;
46
- }, z.core.$strip>;
47
- export declare const ReducePositionMarginSchema: z.ZodObject<{
48
- positionId: z.ZodUUID;
49
- request: z.ZodObject<{
50
- amount: z.ZodString;
51
- }, z.core.$strip>;
52
- }, z.core.$strip>;
53
40
  export declare const AttachPositionTpSlSchema: z.ZodObject<{
54
41
  positionId: z.ZodUUID;
55
42
  request: z.ZodObject<{
@@ -33,12 +33,14 @@ export const ClosePositionSchema = PositionIdSchema.extend({
33
33
  quantity: PositiveDecimalStringSchema.optional(),
34
34
  }),
35
35
  })
36
- .refine((data) => data.request.closeType !== "LIMIT" || data.request.limitPrice !== undefined, {
37
- message: "limitPrice is required for LIMIT close requests",
36
+ // An IOC close is a LIMIT+IOC order server-side (`close_order_shape`), so it
37
+ // needs a price exactly like a LIMIT close does; only MARKET forbids one.
38
+ .refine((data) => data.request.closeType === "MARKET" || data.request.limitPrice !== undefined, {
39
+ message: "limitPrice is required for LIMIT and IOC close requests",
38
40
  path: ["request", "limitPrice"],
39
41
  })
40
- .refine((data) => data.request.closeType === "LIMIT" || data.request.limitPrice === undefined, {
41
- message: "limitPrice is only allowed for LIMIT close requests",
42
+ .refine((data) => data.request.closeType !== "MARKET" || data.request.limitPrice === undefined, {
43
+ message: "limitPrice is not allowed for MARKET close requests",
42
44
  path: ["request", "limitPrice"],
43
45
  });
44
46
  export const BatchCloseAllSchema = z.object({
@@ -46,17 +48,6 @@ export const BatchCloseAllSchema = z.object({
46
48
  slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
47
49
  });
48
50
  export const GetPositionRiskSchema = PositionIdSchema;
49
- export const AddPositionMarginSchema = PositionIdSchema.extend({
50
- request: z.object({
51
- amount: PositiveDecimalStringSchema,
52
- asset: z.string().trim().min(1, "Asset cannot be empty"),
53
- }),
54
- });
55
- export const ReducePositionMarginSchema = PositionIdSchema.extend({
56
- request: z.object({
57
- amount: PositiveDecimalStringSchema,
58
- }),
59
- });
60
51
  const TpSlLegSchema = z
61
52
  .object({
62
53
  triggerPrice: PositiveDecimalStringSchema,
@@ -74,6 +74,8 @@ export declare const ParentTpSlLegSchema: z.ZodObject<{
74
74
  MARKET: "MARKET";
75
75
  }>;
76
76
  limitPrice: z.ZodOptional<z.ZodString>;
77
+ quantity: z.ZodOptional<z.ZodString>;
78
+ closePosition: z.ZodOptional<z.ZodBoolean>;
77
79
  timeInForce: z.ZodOptional<z.ZodEnum<{
78
80
  GTC: "GTC";
79
81
  IOC: "IOC";
@@ -127,6 +129,8 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
127
129
  MARKET: "MARKET";
128
130
  }>;
129
131
  limitPrice: z.ZodOptional<z.ZodString>;
132
+ quantity: z.ZodOptional<z.ZodString>;
133
+ closePosition: z.ZodOptional<z.ZodBoolean>;
130
134
  timeInForce: z.ZodOptional<z.ZodEnum<{
131
135
  GTC: "GTC";
132
136
  IOC: "IOC";
@@ -141,6 +145,8 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
141
145
  MARKET: "MARKET";
142
146
  }>;
143
147
  limitPrice: z.ZodOptional<z.ZodString>;
148
+ quantity: z.ZodOptional<z.ZodString>;
149
+ closePosition: z.ZodOptional<z.ZodBoolean>;
144
150
  timeInForce: z.ZodOptional<z.ZodEnum<{
145
151
  GTC: "GTC";
146
152
  IOC: "IOC";
@@ -188,6 +194,8 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
188
194
  MARKET: "MARKET";
189
195
  }>;
190
196
  limitPrice: z.ZodOptional<z.ZodString>;
197
+ quantity: z.ZodOptional<z.ZodString>;
198
+ closePosition: z.ZodOptional<z.ZodBoolean>;
191
199
  timeInForce: z.ZodOptional<z.ZodEnum<{
192
200
  GTC: "GTC";
193
201
  IOC: "IOC";
@@ -202,6 +210,8 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
202
210
  MARKET: "MARKET";
203
211
  }>;
204
212
  limitPrice: z.ZodOptional<z.ZodString>;
213
+ quantity: z.ZodOptional<z.ZodString>;
214
+ closePosition: z.ZodOptional<z.ZodBoolean>;
205
215
  timeInForce: z.ZodOptional<z.ZodEnum<{
206
216
  GTC: "GTC";
207
217
  IOC: "IOC";
@@ -360,6 +370,12 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
360
370
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
361
371
  postOnly: z.ZodOptional<z.ZodBoolean>;
362
372
  }, z.core.$strip>;
373
+ /**
374
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
375
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
376
+ * item count is bounded independent of the transport message-size limit.
377
+ */
378
+ export declare const MAX_BATCH_ORDER_ITEMS = 100;
363
379
  /**
364
380
  * Batch Create Orders validation schema
365
381
  *
@@ -83,6 +83,8 @@ export const ParentTpSlLegSchema = z
83
83
  triggerPrice: PositiveDecimalStringSchema,
84
84
  orderType: OrderTypeSchema,
85
85
  limitPrice: PositiveDecimalStringSchema.optional(),
86
+ quantity: PositiveDecimalStringSchema.optional(),
87
+ closePosition: z.boolean().optional(),
86
88
  timeInForce: ConditionalTimeInForceSchema.optional(),
87
89
  slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
88
90
  expiresAt: ISO8601DateSchema.optional(),
@@ -102,6 +104,16 @@ export const ParentTpSlLegSchema = z
102
104
  .refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
103
105
  message: "slippageToleranceBps is only allowed for MARKET parent TP/SL",
104
106
  path: ["slippageToleranceBps"],
107
+ })
108
+ // Same sizing contract the position-attached rail enforces: omit both to
109
+ // track the live position, or name a deliberate partial that never resizes.
110
+ .refine((data) => data.closePosition !== true || data.quantity === undefined, {
111
+ message: "quantity must be omitted when closePosition is true",
112
+ path: ["quantity"],
113
+ })
114
+ .refine((data) => data.quantity !== undefined || data.closePosition !== false, {
115
+ message: "quantity is required when closePosition is false",
116
+ path: ["closePosition"],
105
117
  });
106
118
  const hasParentTpSl = (options) => options?.takeProfit !== undefined || options?.stopLoss !== undefined;
107
119
  const legacyPositionSideMatchesOrderSide = (side, positionSide) => positionSide === undefined || (positionSide !== "NONE" && ((side === "BUY" && positionSide === "LONG") || (side === "SELL" && positionSide === "SHORT")));
@@ -429,13 +441,22 @@ export const BatchCreateOrderItemSchema = z
429
441
  message: "leverage is required for normal MARGIN orders",
430
442
  path: ["leverage"],
431
443
  });
444
+ /**
445
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
446
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
447
+ * item count is bounded independent of the transport message-size limit.
448
+ */
449
+ export const MAX_BATCH_ORDER_ITEMS = 100;
432
450
  /**
433
451
  * Batch Create Orders validation schema
434
452
  *
435
453
  * Validates the full array of orders for a batch create request.
436
454
  */
437
455
  export const BatchCreateOrdersSchema = z.object({
438
- orders: z.array(BatchCreateOrderItemSchema).min(1, "At least one order is required"),
456
+ orders: z
457
+ .array(BatchCreateOrderItemSchema)
458
+ .min(1, "At least one order is required")
459
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
439
460
  });
440
461
  /**
441
462
  * Single batch replace order item validation schema
@@ -463,5 +484,8 @@ export const BatchReplaceOrderItemSchema = z
463
484
  * Validates the full array of orders for a batch replace request.
464
485
  */
465
486
  export const BatchReplaceOrdersSchema = z.object({
466
- orders: z.array(BatchReplaceOrderItemSchema).min(1, "At least one order is required"),
487
+ orders: z
488
+ .array(BatchReplaceOrderItemSchema)
489
+ .min(1, "At least one order is required")
490
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
467
491
  });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Account WebSocket Event Types
3
+ *
4
+ * Types for real-time account-level margin updates: equity, collateral, free
5
+ * collateral, margin ratio, and maintenance requirement for a margin account.
6
+ *
7
+ * This is an authenticated channel - requires the signed session-key handshake.
8
+ * Lag policy is Conflate: a lagging subscriber is fast-forwarded to the latest
9
+ * state rather than disconnected, so there is no gap signal to reconcile. Each
10
+ * frame carries the account's full current health, so consume it as a
11
+ * terminal-state snapshot per margin account, never as an additive delta.
12
+ */
13
+ /**
14
+ * Account event data carrying the current margin health of a single account.
15
+ */
16
+ export interface AccountEventData {
17
+ /** Margin account this update describes (UUID) */
18
+ marginAccountId: string;
19
+ /** Mark-inclusive account equity: collateral + unrealized PnL + funding (decimal string) */
20
+ equity: string;
21
+ /** Raw deposited collateral in USD (decimal string) */
22
+ collateral: string;
23
+ /** Collateral available for new margin allocation (decimal string) */
24
+ freeCollateral: string;
25
+ /**
26
+ * Maintenance margin required divided by equity; `0` when equity is zero
27
+ * (decimal string).
28
+ */
29
+ marginRatio: string;
30
+ /** Maintenance margin required to keep the account solvent (decimal string) */
31
+ maintenanceRequirement: string;
32
+ /** Timestamp when the account state was updated (ISO 8601) */
33
+ updatedAt: string;
34
+ }
35
+ /**
36
+ * Account event emitted when a user's account-level margin health changes.
37
+ */
38
+ export interface AccountEvent {
39
+ /** Event type identifier */
40
+ eventType: "account_update";
41
+ /** User ID (UUID) */
42
+ userId: string;
43
+ /** Account data */
44
+ data: AccountEventData;
45
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Account WebSocket Event Types
3
+ *
4
+ * Types for real-time account-level margin updates: equity, collateral, free
5
+ * collateral, margin ratio, and maintenance requirement for a margin account.
6
+ *
7
+ * This is an authenticated channel - requires the signed session-key handshake.
8
+ * Lag policy is Conflate: a lagging subscriber is fast-forwarded to the latest
9
+ * state rather than disconnected, so there is no gap signal to reconcile. Each
10
+ * frame carries the account's full current health, so consume it as a
11
+ * terminal-state snapshot per margin account, never as an additive delta.
12
+ */
@@ -6,9 +6,24 @@
6
6
  */
7
7
  import type { Address } from "viem";
8
8
  /**
9
- * Reason for the balance update
9
+ * Reason for the balance update.
10
+ *
11
+ * `fee` and `rebate` accompany a fill: `fee` when a taker/application fee is
12
+ * charged, `rebate` when a maker rebate is credited (including perp/margin
13
+ * makers). `funding` accompanies a funding settlement against margin collateral
14
+ * (also surfaced on the movements channel with `transactionType: "funding"`).
15
+ * `liquidation` and `adl` accompany a forced-close on the liquidation-worker
16
+ * path: `liquidation` on the liquidated victim's collateral, `adl` on an
17
+ * account impacted by auto-deleveraging.
18
+ *
19
+ * A single fill can emit more than one `balance_update` for the same account
20
+ * (e.g. a `trade` frame plus a `rebate` frame). Each frame carries the
21
+ * account's RESULTING balance for its token — it is a terminal-state snapshot,
22
+ * not an additive delta — so consume it by applying the latest balance per
23
+ * (account, token). That makes reconnect/replay naturally idempotent: never sum
24
+ * the `reason` frames as if they were separate credits.
10
25
  */
11
- export type BalanceUpdateReason = "lock" | "unlock" | "deposit" | "withdrawal" | "trade" | "margin_transfer_in" | "margin_transfer_out";
26
+ export type BalanceUpdateReason = "lock" | "unlock" | "deposit" | "margin_deposit" | "withdrawal" | "trade" | "fee" | "rebate" | "funding" | "liquidation" | "adl" | "margin_transfer_in" | "margin_transfer_out";
12
27
  /**
13
28
  * User balance event data containing current balance state
14
29
  */
@@ -1,3 +1,4 @@
1
+ export * from "./account-events";
1
2
  export * from "./balance-events";
2
3
  export * from "./conditional-order-events";
3
4
  export * from "./liquidation-events";
@@ -1,3 +1,4 @@
1
+ export * from "./account-events";
1
2
  export * from "./balance-events";
2
3
  export * from "./conditional-order-events";
3
4
  export * from "./liquidation-events";
@@ -13,10 +13,25 @@ export interface UserMovementEventData {
13
13
  id: string;
14
14
  /** Entry type (e.g., "credit", "debit") */
15
15
  entryType: string;
16
- /** Transaction type (e.g., "deposit", "withdrawal", "trade") */
16
+ /**
17
+ * Transaction type (e.g., "deposit", "withdrawal", "trade", "funding").
18
+ * A `funding` movement records a funding payment already settled against
19
+ * margin collateral; it reconciles with the matching `balance_update` event
20
+ * whose `reason` is `funding`.
21
+ */
17
22
  transactionType: string;
18
- /** Token contract address */
23
+ /** Movement status (e.g., "completed", "pending", "failed"). Wire: `status`. */
24
+ status?: string;
25
+ /** Token contract address. Wire: `token` (older payloads use the `token_address` alias). */
26
+ token?: Address;
27
+ /**
28
+ * Legacy alias for `token`, always populated from `token` (falling back to the
29
+ * `token_address` wire alias). Stays required for back-compat — every movement
30
+ * carries a token address — so existing consumers reading it don't break.
31
+ */
19
32
  tokenAddress: Address;
33
+ /** Asset registry id (UUID). Wire: `asset_id`. */
34
+ assetId?: string;
20
35
  /** Token symbol */
21
36
  symbol?: string;
22
37
  /** Token decimals */
@@ -49,6 +64,8 @@ export interface UserMovementEventData {
49
64
  description?: string;
50
65
  /** Transaction hash (if applicable) */
51
66
  txHash?: string;
67
+ /** Block number (if applicable). Wire: `block_number`. */
68
+ blockNumber?: number;
52
69
  /** Timestamp when the movement was created (ISO 8601) */
53
70
  createdAt?: string;
54
71
  }
@@ -59,6 +59,15 @@ export interface CommonOrderEventData {
59
59
  quantityRaw?: string;
60
60
  /** Time in force - present in most events */
61
61
  timeInForce?: TimeInForce;
62
+ /**
63
+ * Client-assigned correlation handle, echoed so an event can be matched to
64
+ * the request that placed the order without a round trip to `getOrder`.
65
+ * Carried on every order event that inherits these fields — placed, taker and
66
+ * maker fills, cancelled, rejected and expired — so a submit whose HTTP
67
+ * response was lost can be resolved from the stream alone. Omitted when the
68
+ * order carried none. Wire: `client_order_id`.
69
+ */
70
+ clientOrderId?: string;
62
71
  }
63
72
  /**
64
73
  * OrderPlaced event - emitted when a new order is placed
@@ -140,14 +149,23 @@ export interface OrderPartiallyFilledEvent extends OrderEvent {
140
149
  /** Execution price (maker orders only) */
141
150
  executionPrice?: string;
142
151
  /**
143
- * Quantity filled in this event (maker orders only). The wire field is
144
- * `filled_quantity` (→ `filledQuantity`); for a maker this is the current
145
- * trade's quantity. The previous `executionQuantity` never matched the
146
- * wire. For a taker the same-named field carries the cumulative order fill.
152
+ * Cumulative order fill so far, on EVERY role. The wire field is
153
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
154
+ * the order's cumulative fill (a maker previously reported only the current
155
+ * trade's quantity here; the older `executionQuantity` never matched the
156
+ * wire at all). The per-event increment is `lastFillQuantity`.
147
157
  */
148
158
  filledQuantity?: string;
149
159
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
150
160
  filledQuantityRaw?: string;
161
+ /**
162
+ * Incremental quantity filled by THIS event: for a taker the summed
163
+ * quantity of the trades this event covers, for a maker this single trade's
164
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
165
+ */
166
+ lastFillQuantity?: string;
167
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
168
+ lastFillQuantityRaw?: string;
151
169
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
152
170
  remainingQuantityRaw?: string;
153
171
  /**
@@ -200,14 +218,23 @@ export interface OrderFilledEvent extends OrderEvent {
200
218
  /** Execution price (maker orders only) */
201
219
  executionPrice?: string;
202
220
  /**
203
- * Quantity filled in this event (maker orders only). The wire field is
204
- * `filled_quantity` (→ `filledQuantity`); for a maker this is the current
205
- * trade's quantity. The previous `executionQuantity` never matched the
206
- * wire. For a taker the same-named field carries the cumulative order fill.
221
+ * Cumulative order fill so far, on EVERY role. The wire field is
222
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
223
+ * the order's cumulative fill (a maker previously reported only the current
224
+ * trade's quantity here; the older `executionQuantity` never matched the
225
+ * wire at all). The per-event increment is `lastFillQuantity`.
207
226
  */
208
227
  filledQuantity?: string;
209
228
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
210
229
  filledQuantityRaw?: string;
230
+ /**
231
+ * Incremental quantity filled by THIS event: for a taker the summed
232
+ * quantity of the trades this event covers, for a maker this single trade's
233
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
234
+ */
235
+ lastFillQuantity?: string;
236
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
237
+ lastFillQuantityRaw?: string;
211
238
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
212
239
  remainingQuantityRaw?: string;
213
240
  /**
@@ -231,6 +258,14 @@ export interface OrderCancelledEvent extends OrderEvent {
231
258
  reason?: string;
232
259
  /** Stable machine-readable cancellation cause */
233
260
  terminalReason?: OrderTerminalReason;
261
+ /**
262
+ * Cumulative order fill at cancellation, mirroring `filledQuantity` on the
263
+ * taker/maker fill events so consumers read one field across every order
264
+ * event (0XM-2389). `totalFilled` is retained as a legacy alias.
265
+ */
266
+ filledQuantity?: string;
267
+ /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
268
+ filledQuantityRaw?: string;
234
269
  /** Total filled quantity before cancellation */
235
270
  totalFilled?: string;
236
271
  /** `totalFilled` in RAW (integer, base-unit) precision. Wire: `total_filled_raw`. */
@@ -241,6 +276,16 @@ export interface OrderCancelledEvent extends OrderEvent {
241
276
  remainingQuantityRaw?: string;
242
277
  /** Number of trades executed before cancellation */
243
278
  tradesCount?: number;
279
+ /**
280
+ * Volume-weighted average fill price of the cancelled order, on the full
281
+ * (resting-order) cancel payload. Wire: `average_fill_price`.
282
+ */
283
+ averageFillPrice?: string;
284
+ /**
285
+ * Cancellation timestamp on the full (resting-order) cancel payload,
286
+ * RFC3339 with a `Z` suffix. Wire: `cancelled_at`.
287
+ */
288
+ cancelledAt?: string;
244
289
  };
245
290
  }
246
291
  /**
@@ -15,11 +15,12 @@ export type PositionEventSide = "LONG" | "SHORT";
15
15
  /**
16
16
  * Position lifecycle status.
17
17
  *
18
- * NOTE: this is PascalCase on the wire (`Open`, not `OPEN`) - the underlying
19
- * enum has no serde rename, unlike side/trading-mode fields. That asymmetry is
20
- * the live wire format and is preserved verbatim here.
18
+ * Matches the REST position status strings exactly (the server previously
19
+ * emitted PascalCase `Open`, which diverged from REST). Values are
20
+ * SCREAMING_SNAKE_CASE except a closing position, which REST and the wire
21
+ * report as `LIQUIDATING` (not `CLOSING`).
21
22
  */
22
- export type PositionEventStatus = "Open" | "Closing" | "Closed" | "Liquidated" | "Expired";
23
+ export type PositionEventStatus = "OPEN" | "LIQUIDATING" | "CLOSED" | "LIQUIDATED" | "EXPIRED";
23
24
  /**
24
25
  * Position event data containing the current state of a single position.
25
26
  */
@@ -32,7 +33,7 @@ export interface PositionEventData {
32
33
  tradingPairId: string;
33
34
  /** Position side */
34
35
  side: PositionEventSide;
35
- /** Position lifecycle status (PascalCase on the wire) */
36
+ /** Position lifecycle status (SCREAMING_SNAKE_CASE on the wire, e.g. "OPEN") */
36
37
  status: PositionEventStatus;
37
38
  /** Absolute position size (decimal string) */
38
39
  size: string;
@@ -48,7 +49,15 @@ export interface PositionEventData {
48
49
  isolatedMargin: string;
49
50
  /** Effective leverage (decimal string) */
50
51
  leverage: string;
51
- /** What triggered the update (e.g. "trade", free-form) */
52
+ /** Trade that caused the update, when driven by a fill (UUID). Omitted otherwise. */
53
+ tradeId?: string;
54
+ /** Order that caused the update, when driven by an order (UUID). Omitted otherwise. */
55
+ orderId?: string;
56
+ /**
57
+ * What triggered the update. Free-form, but the server uses a canonical set:
58
+ * `trade`, `close`, `liquidation`, `adl`, `funding`, `margin_added`,
59
+ * `margin_reduced`, `margin_collateral_transfer`.
60
+ */
52
61
  reason: string;
53
62
  /** Timestamp when the position state was updated (ISO 8601) */
54
63
  updatedAt: string;
@@ -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 ["add_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_conditional_order", "cancel_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "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_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "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_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "reduce_position_margin", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
13
+ export declare const OPERATION_IDS: readonly ["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_conditional_order", "cancel_order", "check_trader_code_availability", "clear_trader_code", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_conditional_order", "get_faucet_info", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_my_fee_tier", "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_rewards_balance", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trader_code_info", "get_trades", "get_trading_pair_by_id", "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_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "refresh_session", "register_deposit_address", "replace_order", "revoke_delegated_agent", "revoke_session", "set_trader_code", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "transfer_rewards", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
14
14
  /** Union of every OpenAPI operationId in the spec. */
15
15
  export type OperationId = (typeof OPERATION_IDS)[number];
@@ -11,7 +11,6 @@
11
11
  * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
12
  */
13
13
  export const OPERATION_IDS = [
14
- "add_position_margin",
15
14
  "attach_position_tp_sl",
16
15
  "batch_cancel_all",
17
16
  "batch_cancel_all_by_pair",
@@ -95,7 +94,6 @@ export const OPERATION_IDS = [
95
94
  "list_sub_accounts_with_balances",
96
95
  "list_trading_pairs",
97
96
  "mint_tokens",
98
- "reduce_position_margin",
99
97
  "refresh_session",
100
98
  "register_deposit_address",
101
99
  "replace_order",
@@ -1856,38 +1856,6 @@ export interface paths {
1856
1856
  patch?: never;
1857
1857
  trace?: never;
1858
1858
  };
1859
- "/api/v1/positions/{positionId}/margin/add": {
1860
- parameters: {
1861
- query?: never;
1862
- header?: never;
1863
- path?: never;
1864
- cookie?: never;
1865
- };
1866
- get?: never;
1867
- put?: never;
1868
- post: operations["add_position_margin"];
1869
- delete?: never;
1870
- options?: never;
1871
- head?: never;
1872
- patch?: never;
1873
- trace?: never;
1874
- };
1875
- "/api/v1/positions/{positionId}/margin/reduce": {
1876
- parameters: {
1877
- query?: never;
1878
- header?: never;
1879
- path?: never;
1880
- cookie?: never;
1881
- };
1882
- get?: never;
1883
- put?: never;
1884
- post: operations["reduce_position_margin"];
1885
- delete?: never;
1886
- options?: never;
1887
- head?: never;
1888
- patch?: never;
1889
- trace?: never;
1890
- };
1891
1859
  "/api/v1/positions/{positionId}/pnl/history": {
1892
1860
  parameters: {
1893
1861
  query?: never;
@@ -2224,19 +2192,6 @@ export interface components {
2224
2192
  */
2225
2193
  totalBalanceRaw?: string | null;
2226
2194
  };
2227
- AddPositionMarginRequest: {
2228
- /** @description Collateral asset to move into the isolated bucket. USDC is the current v1 path. */
2229
- asset?: string | null;
2230
- amount?: string | null;
2231
- };
2232
- AddPositionMarginResponse: {
2233
- positionId?: string | null;
2234
- /** @description Margin account UUID for the isolated bucket that was adjusted. */
2235
- marginAccountId?: string | null;
2236
- newIsolatedMargin?: string | null;
2237
- status?: string | null;
2238
- message?: string | null;
2239
- };
2240
2195
  AppUser: {
2241
2196
  /**
2242
2197
  * Format: uuid
@@ -2715,10 +2670,15 @@ export interface components {
2715
2670
  */
2716
2671
  marginMode?: "ISOLATED" | "CROSS" | null;
2717
2672
  /**
2718
- * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC/GTD only; rejected on MARKET orders and IOC/FOK.
2673
+ * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC only; rejected on MARKET orders and IOC/FOK.
2719
2674
  * @example false
2720
2675
  */
2721
2676
  postOnly?: boolean | null;
2677
+ /**
2678
+ * @description Client-assigned correlation handle, echoed back on order reads (detail and list) and on order WebSocket events. At most 64 characters from [A-Za-z0-9._:-]; surrounding whitespace is trimmed before storage, and a blank or whitespace-only value is treated as absent. Monaco stores and returns this value but does NOT de-duplicate on it and does not enforce uniqueness — it correlates a response to a request, it does not make a retry safe. A create whose response was lost must still be reconciled against ListOrders before resubmitting.
2679
+ * @example quote-btc-1130-a
2680
+ */
2681
+ clientOrderId?: string | null;
2722
2682
  };
2723
2683
  BatchCreateOrdersRequest: {
2724
2684
  orders: components["schemas"]["BatchCreateOrderItem"][];
@@ -2789,10 +2749,15 @@ export interface components {
2789
2749
  */
2790
2750
  useMasterBalance?: boolean | null;
2791
2751
  /**
2792
- * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC/GTD only; rejected on MARKET orders and IOC/FOK.
2752
+ * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC only; rejected on MARKET orders and IOC/FOK.
2793
2753
  * @example false
2794
2754
  */
2795
2755
  postOnly?: boolean | null;
2756
+ /**
2757
+ * @description Client-assigned correlation handle, echoed back on order reads (detail and list) and on order WebSocket events. At most 64 characters from [A-Za-z0-9._:-]; surrounding whitespace is trimmed before storage, and a blank or whitespace-only value is treated as absent. Monaco stores and returns this value but does NOT de-duplicate on it and does not enforce uniqueness — it correlates a response to a request, it does not make a retry safe. A create whose response was lost must still be reconciled against ListOrders before resubmitting. A replacement is a new order with a new id, so it carries its own value and inherits nothing from the original — restate it to keep the handle.
2758
+ * @example quote-btc-1130-a
2759
+ */
2760
+ clientOrderId?: string | null;
2796
2761
  };
2797
2762
  BatchReplaceOrdersRequest: {
2798
2763
  orders: components["schemas"]["BatchReplaceOrderItem"][];
@@ -3188,10 +3153,15 @@ export interface components {
3188
3153
  */
3189
3154
  marginMode?: "ISOLATED" | "CROSS" | null;
3190
3155
  /**
3191
- * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC/GTD only; rejected on MARKET orders and IOC/FOK.
3156
+ * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC only; rejected on MARKET orders and IOC/FOK.
3192
3157
  * @example false
3193
3158
  */
3194
3159
  postOnly?: boolean | null;
3160
+ /**
3161
+ * @description Client-assigned correlation handle, echoed back on order reads (detail and list) and on order WebSocket events. At most 64 characters from [A-Za-z0-9._:-]; surrounding whitespace is trimmed before storage, and a blank or whitespace-only value is treated as absent. Monaco stores and returns this value but does NOT de-duplicate on it and does not enforce uniqueness — it correlates a response to a request, it does not make a retry safe. A create whose response was lost must still be reconciled against ListOrders before resubmitting.
3162
+ * @example quote-btc-1130-a
3163
+ */
3164
+ clientOrderId?: string | null;
3195
3165
  };
3196
3166
  CreateOrderResponse: {
3197
3167
  /**
@@ -3873,6 +3843,11 @@ export interface components {
3873
3843
  * @example 482931
3874
3844
  */
3875
3845
  totalTradeCountLtd?: string | null;
3846
+ /**
3847
+ * @description Quote-token (notional) volume summed over the available candles in the rolling 24h window; null when quote volume is unavailable for the window
3848
+ * @example 117845632.18
3849
+ */
3850
+ quoteVolume24h?: string | null;
3876
3851
  };
3877
3852
  /** @description Exchange-wide life-to-date cumulative market statistics across all trading pairs. */
3878
3853
  GetMarketStatsResponse: {
@@ -4130,7 +4105,10 @@ export interface components {
4130
4105
  * @example 300000000
4131
4106
  */
4132
4107
  remainingQuantityRaw?: string | null;
4133
- /** @description Client-assigned order identifier */
4108
+ /**
4109
+ * @description Client-assigned correlation handle as stored: the value supplied on create or replace, with surrounding whitespace trimmed. Absent when the order carried none, including every order placed before the field was accepted on write. Not unique: Monaco neither de-duplicates nor enforces uniqueness, so several orders may share one value and a lookup by it can be ambiguous.
4110
+ * @example quote-btc-1130-a
4111
+ */
4134
4112
  clientOrderId?: string | null;
4135
4113
  /**
4136
4114
  * @description Timestamp when the order was cancelled (ISO 8601)
@@ -4274,9 +4252,17 @@ export interface components {
4274
4252
  indexPrice?: string | null;
4275
4253
  high24h?: string | null;
4276
4254
  low24h?: string | null;
4255
+ /**
4256
+ * @description Base-asset volume in the last 24 hours
4257
+ * @example 1234.5678
4258
+ */
4277
4259
  volume24h?: string | null;
4278
4260
  priceChange24h?: string | null;
4279
4261
  priceChangePercent24h?: string | null;
4262
+ /**
4263
+ * @description Open interest in base-asset units (legacy alias of openInterestBase)
4264
+ * @example 12345.67
4265
+ */
4280
4266
  openInterest?: string | null;
4281
4267
  currentFundingRate?: string | null;
4282
4268
  estimatedNextFundingRate?: string | null;
@@ -4284,6 +4270,21 @@ export interface components {
4284
4270
  marketStatus?: string | null;
4285
4271
  marketRegime?: string | null;
4286
4272
  updatedAt?: string | null;
4273
+ /**
4274
+ * @description Open interest in base-asset units (e.g. BTC)
4275
+ * @example 12345.67
4276
+ */
4277
+ openInterestBase?: string | null;
4278
+ /**
4279
+ * @description Open interest notional in quote units (openInterestBase x mark price, falling back to the last trade price when no mark is available)
4280
+ * @example 1172836500.00
4281
+ */
4282
+ openInterestNotional?: string | null;
4283
+ /**
4284
+ * @description Quote-token (notional) volume summed over the available candles in the rolling 24h window; null when quote volume is unavailable
4285
+ * @example 117845632.18
4286
+ */
4287
+ quoteVolume24h?: string | null;
4287
4288
  };
4288
4289
  GetPortfolioAssetsResponse: {
4289
4290
  window?: components["schemas"]["PortfolioSeriesWindow"];
@@ -5398,6 +5399,16 @@ export interface components {
5398
5399
  * @example 2026-06-01T00:00:00Z
5399
5400
  */
5400
5401
  expiresAt?: string | null;
5402
+ /**
5403
+ * @description Deliberate partial size: this leg closes exactly this much and never resizes, however the position grows. Omit it (or set closePosition=true) to close the whole live position at trigger time. Mutually exclusive with closePosition=true; required when closePosition=false. Same contract as TpSlLeg on the position-attached rail.
5404
+ * @example 0.5
5405
+ */
5406
+ quantity?: string | null;
5407
+ /**
5408
+ * @description Resolve the full live position size when triggered, so the leg keeps covering the position as it grows. Mutually exclusive with quantity. Omitting both also means full-position close.
5409
+ * @example true
5410
+ */
5411
+ closePosition?: boolean | null;
5401
5412
  };
5402
5413
  /**
5403
5414
  * @description A single pending withdrawal in a list response. A lightweight summary — the
@@ -5925,17 +5936,6 @@ export interface components {
5925
5936
  */
5926
5937
  relevance?: number | null;
5927
5938
  };
5928
- ReducePositionMarginRequest: {
5929
- amount?: string | null;
5930
- };
5931
- ReducePositionMarginResponse: {
5932
- positionId?: string | null;
5933
- /** @description Margin account UUID for the isolated bucket that was adjusted. */
5934
- marginAccountId?: string | null;
5935
- newIsolatedMargin?: string | null;
5936
- status?: string | null;
5937
- message?: string | null;
5938
- };
5939
5939
  RefreshRequest: Record<string, never>;
5940
5940
  RefreshResponse: {
5941
5941
  /**
@@ -5977,10 +5977,10 @@ export interface components {
5977
5977
  };
5978
5978
  ReplaceOrderRequest: {
5979
5979
  /**
5980
- * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC/GTD only; rejected on MARKET orders and IOC/FOK.
5981
- * @example false
5980
+ * @description Client-assigned correlation handle, echoed back on order reads (detail and list) and on order WebSocket events. At most 64 characters from [A-Za-z0-9._:-]; surrounding whitespace is trimmed before storage, and a blank or whitespace-only value is treated as absent. Monaco stores and returns this value but does NOT de-duplicate on it and does not enforce uniqueness — it correlates a response to a request, it does not make a retry safe. A create whose response was lost must still be reconciled against ListOrders before resubmitting. A replacement is a new order with a new id, so it carries its own value and inherits nothing from the original — restate it to keep the handle.
5981
+ * @example quote-btc-1130-a
5982
5982
  */
5983
- postOnly?: boolean | null;
5983
+ clientOrderId?: string | null;
5984
5984
  /**
5985
5985
  * @description New limit price (if changing)
5986
5986
  * @example 35500.00
@@ -5996,6 +5996,11 @@ export interface components {
5996
5996
  * @example false
5997
5997
  */
5998
5998
  useMasterBalance?: boolean | null;
5999
+ /**
6000
+ * @description Post-only: reject instead of matching if this limit order would cross the book — rejected with HTTP 400 / gRPC INVALID_ARGUMENT carrying the structured error code POST_ONLY_WOULD_CROSS (REST error-envelope 'code' field; gRPC google.rpc.ErrorInfo reason; batch per-item error.code). Matching the 'post-only order would cross' message substring is a legacy fallback. LIMIT orders with GTC only; rejected on MARKET orders and IOC/FOK.
6001
+ * @example false
6002
+ */
6003
+ postOnly?: boolean | null;
5999
6004
  };
6000
6005
  ReplaceOrderResponse: {
6001
6006
  /**
@@ -6151,6 +6156,16 @@ export interface components {
6151
6156
  * @example 1745308800000
6152
6157
  */
6153
6158
  lastFundingTime?: string | null;
6159
+ /**
6160
+ * @description Open interest in base-asset units (e.g. BTC); null for spot pairs, "0" for a margin pair with no open positions
6161
+ * @example 12345.67
6162
+ */
6163
+ openInterestBase?: string | null;
6164
+ /**
6165
+ * @description Open interest notional in quote units (openInterestBase x latest trade price); null for spot pairs. Valued at the pair's latest trade price (a snapshot); the mark-accurate notional lives on getPerpMarketSummary / getOpenInterest
6166
+ * @example 1172836500.00
6167
+ */
6168
+ openInterestNotional?: string | null;
6154
6169
  };
6155
6170
  /** @description One UTC-day bucket in a pair's 7-day snapshot. */
6156
6171
  ScreenerSnapshotPoint: {
@@ -6703,6 +6718,12 @@ export interface components {
6703
6718
  tradingPairId?: string | null;
6704
6719
  /** @description Optional strategy key echoed in responses when callers scope a risk bucket. */
6705
6720
  strategyKey?: string | null;
6721
+ /**
6722
+ * @description Risk bucket mode. Defaults to ISOLATED, which is selected by tradingPairId.
6723
+ * Pass CROSS to release from the account's cross risk bucket, which has no
6724
+ * trading pair and so cannot be named any other way. Values: ISOLATED, CROSS.
6725
+ */
6726
+ marginMode?: string | null;
6706
6727
  };
6707
6728
  TransferCollateralFromMarginAccountResponse: {
6708
6729
  movementId?: string | null;
@@ -10834,66 +10855,6 @@ export interface operations {
10834
10855
  };
10835
10856
  };
10836
10857
  };
10837
- add_position_margin: {
10838
- parameters: {
10839
- query?: never;
10840
- header?: never;
10841
- path: {
10842
- /**
10843
- * @description Position UUID for the isolated bucket being adjusted.
10844
- * @example 2b1a5f9c-0000-4000-8000-000000000002
10845
- */
10846
- positionId: string;
10847
- };
10848
- cookie?: never;
10849
- };
10850
- requestBody: {
10851
- content: {
10852
- "application/json": components["schemas"]["AddPositionMarginRequest"];
10853
- };
10854
- };
10855
- responses: {
10856
- /** @description OK */
10857
- 200: {
10858
- headers: {
10859
- [name: string]: unknown;
10860
- };
10861
- content: {
10862
- "application/json": components["schemas"]["AddPositionMarginResponse"];
10863
- };
10864
- };
10865
- };
10866
- };
10867
- reduce_position_margin: {
10868
- parameters: {
10869
- query?: never;
10870
- header?: never;
10871
- path: {
10872
- /**
10873
- * @description Position UUID for the isolated bucket being adjusted.
10874
- * @example 2b1a5f9c-0000-4000-8000-000000000002
10875
- */
10876
- positionId: string;
10877
- };
10878
- cookie?: never;
10879
- };
10880
- requestBody: {
10881
- content: {
10882
- "application/json": components["schemas"]["ReducePositionMarginRequest"];
10883
- };
10884
- };
10885
- responses: {
10886
- /** @description OK */
10887
- 200: {
10888
- headers: {
10889
- [name: string]: unknown;
10890
- };
10891
- content: {
10892
- "application/json": components["schemas"]["ReducePositionMarginResponse"];
10893
- };
10894
- };
10895
- };
10896
- };
10897
10858
  get_position_pnl_history: {
10898
10859
  parameters: {
10899
10860
  query: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "lint": "biome lint ."
21
21
  },
22
22
  "dependencies": {
23
- "@0xmonaco/contracts": "1.0.39",
23
+ "@0xmonaco/contracts": "1.0.41",
24
24
  "zod": "^4.1.12"
25
25
  },
26
26
  "peerDependencies": {