@0xmonaco/types 1.0.39 → 1.0.40

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,7 +41,7 @@ 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;
@@ -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;
@@ -134,7 +134,10 @@ export type TradingMode = "SPOT" | "MARGIN";
134
134
  * - GTC: Good Till Cancel - remains active until filled or canceled
135
135
  * - IOC: Immediate or Cancel - execute immediately and cancel unfilled portion
136
136
  * - FOK: Fill or Kill - execute completely or cancel entirely
137
- * - GTD: Good Till Date - remains active until specified expiration date
137
+ * - GTD: **deprecated, never implemented** - the server rejects it with HTTP
138
+ * 400 (`Time in force must be GTC, IOC, or FOK`). The variant is retained so
139
+ * existing code keeps compiling. For an order that expires at a set time, use
140
+ * `GTC` together with `expirationDate`.
138
141
  */
139
142
  export type TimeInForce = "GTC" | "IOC" | "FOK" | "GTD";
140
143
  /**
@@ -354,7 +354,7 @@ export interface BatchCreateOrderParams {
354
354
  /**
355
355
  * Maker-only: rejected with a structured `error.code` of
356
356
  * `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
357
+ * cross the book. LIMIT orders with GTC only; rejected on MARKET
358
358
  * orders and combined with IOC/FOK. Echoed back as `postOnly` on order
359
359
  * detail and list reads.
360
360
  */
@@ -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,
@@ -360,6 +360,12 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
360
360
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
361
361
  postOnly: z.ZodOptional<z.ZodBoolean>;
362
362
  }, z.core.$strip>;
363
+ /**
364
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
365
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
366
+ * item count is bounded independent of the transport message-size limit.
367
+ */
368
+ export declare const MAX_BATCH_ORDER_ITEMS = 100;
363
369
  /**
364
370
  * Batch Create Orders validation schema
365
371
  *
@@ -429,13 +429,22 @@ export const BatchCreateOrderItemSchema = z
429
429
  message: "leverage is required for normal MARGIN orders",
430
430
  path: ["leverage"],
431
431
  });
432
+ /**
433
+ * Maximum items per batch create/replace/cancel request. Mirrors the server's
434
+ * cap (Zenith #11): a batch is one matching-engine sequencer command, so its
435
+ * item count is bounded independent of the transport message-size limit.
436
+ */
437
+ export const MAX_BATCH_ORDER_ITEMS = 100;
432
438
  /**
433
439
  * Batch Create Orders validation schema
434
440
  *
435
441
  * Validates the full array of orders for a batch create request.
436
442
  */
437
443
  export const BatchCreateOrdersSchema = z.object({
438
- orders: z.array(BatchCreateOrderItemSchema).min(1, "At least one order is required"),
444
+ orders: z
445
+ .array(BatchCreateOrderItemSchema)
446
+ .min(1, "At least one order is required")
447
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
439
448
  });
440
449
  /**
441
450
  * Single batch replace order item validation schema
@@ -463,5 +472,8 @@ export const BatchReplaceOrderItemSchema = z
463
472
  * Validates the full array of orders for a batch replace request.
464
473
  */
465
474
  export const BatchReplaceOrdersSchema = z.object({
466
- orders: z.array(BatchReplaceOrderItemSchema).min(1, "At least one order is required"),
475
+ orders: z
476
+ .array(BatchReplaceOrderItemSchema)
477
+ .min(1, "At least one order is required")
478
+ .max(MAX_BATCH_ORDER_ITEMS, `At most ${MAX_BATCH_ORDER_ITEMS} orders per batch request`),
467
479
  });
@@ -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
  */
@@ -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
  }
@@ -140,14 +140,23 @@ export interface OrderPartiallyFilledEvent extends OrderEvent {
140
140
  /** Execution price (maker orders only) */
141
141
  executionPrice?: string;
142
142
  /**
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.
143
+ * Cumulative order fill so far, on EVERY role. The wire field is
144
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
145
+ * the order's cumulative fill (a maker previously reported only the current
146
+ * trade's quantity here; the older `executionQuantity` never matched the
147
+ * wire at all). The per-event increment is `lastFillQuantity`.
147
148
  */
148
149
  filledQuantity?: string;
149
150
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
150
151
  filledQuantityRaw?: string;
152
+ /**
153
+ * Incremental quantity filled by THIS event: for a taker the summed
154
+ * quantity of the trades this event covers, for a maker this single trade's
155
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
156
+ */
157
+ lastFillQuantity?: string;
158
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
159
+ lastFillQuantityRaw?: string;
151
160
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
152
161
  remainingQuantityRaw?: string;
153
162
  /**
@@ -200,14 +209,23 @@ export interface OrderFilledEvent extends OrderEvent {
200
209
  /** Execution price (maker orders only) */
201
210
  executionPrice?: string;
202
211
  /**
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.
212
+ * Cumulative order fill so far, on EVERY role. The wire field is
213
+ * `filled_quantity` (→ `filledQuantity`); for both taker and maker it is
214
+ * the order's cumulative fill (a maker previously reported only the current
215
+ * trade's quantity here; the older `executionQuantity` never matched the
216
+ * wire at all). The per-event increment is `lastFillQuantity`.
207
217
  */
208
218
  filledQuantity?: string;
209
219
  /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
210
220
  filledQuantityRaw?: string;
221
+ /**
222
+ * Incremental quantity filled by THIS event: for a taker the summed
223
+ * quantity of the trades this event covers, for a maker this single trade's
224
+ * quantity. Omitted when the event carries no fill. Wire: `last_fill_quantity`.
225
+ */
226
+ lastFillQuantity?: string;
227
+ /** `lastFillQuantity` in RAW (integer, base-unit) precision. Wire: `last_fill_quantity_raw`. */
228
+ lastFillQuantityRaw?: string;
211
229
  /** `remainingQuantity` in RAW (integer, base-unit) precision. Wire: `remaining_quantity_raw`. */
212
230
  remainingQuantityRaw?: string;
213
231
  /**
@@ -231,6 +249,14 @@ export interface OrderCancelledEvent extends OrderEvent {
231
249
  reason?: string;
232
250
  /** Stable machine-readable cancellation cause */
233
251
  terminalReason?: OrderTerminalReason;
252
+ /**
253
+ * Cumulative order fill at cancellation, mirroring `filledQuantity` on the
254
+ * taker/maker fill events so consumers read one field across every order
255
+ * event (0XM-2389). `totalFilled` is retained as a legacy alias.
256
+ */
257
+ filledQuantity?: string;
258
+ /** `filledQuantity` in RAW (integer, base-unit) precision. Wire: `filled_quantity_raw`. */
259
+ filledQuantityRaw?: string;
234
260
  /** Total filled quantity before cancellation */
235
261
  totalFilled?: string;
236
262
  /** `totalFilled` in RAW (integer, base-unit) precision. Wire: `total_filled_raw`. */
@@ -241,6 +267,16 @@ export interface OrderCancelledEvent extends OrderEvent {
241
267
  remainingQuantityRaw?: string;
242
268
  /** Number of trades executed before cancellation */
243
269
  tradesCount?: number;
270
+ /**
271
+ * Volume-weighted average fill price of the cancelled order, on the full
272
+ * (resting-order) cancel payload. Wire: `average_fill_price`.
273
+ */
274
+ averageFillPrice?: string;
275
+ /**
276
+ * Cancellation timestamp on the full (resting-order) cancel payload,
277
+ * RFC3339 with a `Z` suffix. Wire: `cancelled_at`.
278
+ */
279
+ cancelledAt?: string;
244
280
  };
245
281
  }
246
282
  /**
@@ -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,7 +2670,7 @@ 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;
@@ -2789,7 +2744,7 @@ export interface components {
2789
2744
  */
2790
2745
  useMasterBalance?: boolean | null;
2791
2746
  /**
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.
2747
+ * @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
2748
  * @example false
2794
2749
  */
2795
2750
  postOnly?: boolean | null;
@@ -3188,7 +3143,7 @@ export interface components {
3188
3143
  */
3189
3144
  marginMode?: "ISOLATED" | "CROSS" | null;
3190
3145
  /**
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.
3146
+ * @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
3147
  * @example false
3193
3148
  */
3194
3149
  postOnly?: boolean | null;
@@ -3873,6 +3828,11 @@ export interface components {
3873
3828
  * @example 482931
3874
3829
  */
3875
3830
  totalTradeCountLtd?: string | null;
3831
+ /**
3832
+ * @description Quote-token (notional) volume summed over the available candles in the rolling 24h window; null when quote volume is unavailable for the window
3833
+ * @example 117845632.18
3834
+ */
3835
+ quoteVolume24h?: string | null;
3876
3836
  };
3877
3837
  /** @description Exchange-wide life-to-date cumulative market statistics across all trading pairs. */
3878
3838
  GetMarketStatsResponse: {
@@ -4274,9 +4234,17 @@ export interface components {
4274
4234
  indexPrice?: string | null;
4275
4235
  high24h?: string | null;
4276
4236
  low24h?: string | null;
4237
+ /**
4238
+ * @description Base-asset volume in the last 24 hours
4239
+ * @example 1234.5678
4240
+ */
4277
4241
  volume24h?: string | null;
4278
4242
  priceChange24h?: string | null;
4279
4243
  priceChangePercent24h?: string | null;
4244
+ /**
4245
+ * @description Open interest in base-asset units (legacy alias of openInterestBase)
4246
+ * @example 12345.67
4247
+ */
4280
4248
  openInterest?: string | null;
4281
4249
  currentFundingRate?: string | null;
4282
4250
  estimatedNextFundingRate?: string | null;
@@ -4284,6 +4252,21 @@ export interface components {
4284
4252
  marketStatus?: string | null;
4285
4253
  marketRegime?: string | null;
4286
4254
  updatedAt?: string | null;
4255
+ /**
4256
+ * @description Open interest in base-asset units (e.g. BTC)
4257
+ * @example 12345.67
4258
+ */
4259
+ openInterestBase?: string | null;
4260
+ /**
4261
+ * @description Open interest notional in quote units (openInterestBase x mark price, falling back to the last trade price when no mark is available)
4262
+ * @example 1172836500.00
4263
+ */
4264
+ openInterestNotional?: string | null;
4265
+ /**
4266
+ * @description Quote-token (notional) volume summed over the available candles in the rolling 24h window; null when quote volume is unavailable
4267
+ * @example 117845632.18
4268
+ */
4269
+ quoteVolume24h?: string | null;
4287
4270
  };
4288
4271
  GetPortfolioAssetsResponse: {
4289
4272
  window?: components["schemas"]["PortfolioSeriesWindow"];
@@ -5925,17 +5908,6 @@ export interface components {
5925
5908
  */
5926
5909
  relevance?: number | null;
5927
5910
  };
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
5911
  RefreshRequest: Record<string, never>;
5940
5912
  RefreshResponse: {
5941
5913
  /**
@@ -5977,7 +5949,7 @@ export interface components {
5977
5949
  };
5978
5950
  ReplaceOrderRequest: {
5979
5951
  /**
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.
5952
+ * @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.
5981
5953
  * @example false
5982
5954
  */
5983
5955
  postOnly?: boolean | null;
@@ -6151,6 +6123,16 @@ export interface components {
6151
6123
  * @example 1745308800000
6152
6124
  */
6153
6125
  lastFundingTime?: string | null;
6126
+ /**
6127
+ * @description Open interest in base-asset units (e.g. BTC); null for spot pairs, "0" for a margin pair with no open positions
6128
+ * @example 12345.67
6129
+ */
6130
+ openInterestBase?: string | null;
6131
+ /**
6132
+ * @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
6133
+ * @example 1172836500.00
6134
+ */
6135
+ openInterestNotional?: string | null;
6154
6136
  };
6155
6137
  /** @description One UTC-day bucket in a pair's 7-day snapshot. */
6156
6138
  ScreenerSnapshotPoint: {
@@ -6703,6 +6685,12 @@ export interface components {
6703
6685
  tradingPairId?: string | null;
6704
6686
  /** @description Optional strategy key echoed in responses when callers scope a risk bucket. */
6705
6687
  strategyKey?: string | null;
6688
+ /**
6689
+ * @description Risk bucket mode. Defaults to ISOLATED, which is selected by tradingPairId.
6690
+ * Pass CROSS to release from the account's cross risk bucket, which has no
6691
+ * trading pair and so cannot be named any other way. Values: ISOLATED, CROSS.
6692
+ */
6693
+ marginMode?: string | null;
6706
6694
  };
6707
6695
  TransferCollateralFromMarginAccountResponse: {
6708
6696
  movementId?: string | null;
@@ -10834,66 +10822,6 @@ export interface operations {
10834
10822
  };
10835
10823
  };
10836
10824
  };
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
10825
  get_position_pnl_history: {
10898
10826
  parameters: {
10899
10827
  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.40",
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.40",
24
24
  "zod": "^4.1.12"
25
25
  },
26
26
  "peerDependencies": {