@0xmonaco/types 1.0.74 → 1.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/api/index.d.ts +0 -7
  2. package/dist/applications/index.d.ts +14 -15
  3. package/dist/applications/index.js +2 -2
  4. package/dist/applications/requests.d.ts +70 -15
  5. package/dist/applications/requests.js +2 -3
  6. package/dist/applications/responses.d.ts +35 -39
  7. package/dist/applications/responses.js +1 -1
  8. package/dist/buildercodes/index.d.ts +3 -4
  9. package/dist/buildercodes/responses.d.ts +10 -3
  10. package/dist/buildercodes/responses.js +24 -4
  11. package/dist/fees/responses.js +2 -2
  12. package/dist/managed-markets/index.d.ts +21 -2
  13. package/dist/margin-accounts/index.d.ts +72 -12
  14. package/dist/market/index.d.ts +76 -6
  15. package/dist/pitpass/index.d.ts +16 -11
  16. package/dist/pitpass/index.js +1 -1
  17. package/dist/pitpass/responses.d.ts +21 -0
  18. package/dist/pitpass/responses.js +43 -14
  19. package/dist/positions/index.d.ts +81 -14
  20. package/dist/profile/index.d.ts +114 -44
  21. package/dist/sdk/index.d.ts +12 -4
  22. package/dist/trading/index.d.ts +1 -1
  23. package/dist/trading/orders.d.ts +6 -32
  24. package/dist/trading/responses.d.ts +9 -14
  25. package/dist/validation/applications.d.ts +51 -0
  26. package/dist/validation/applications.js +45 -0
  27. package/dist/validation/index.d.ts +2 -0
  28. package/dist/validation/index.js +2 -0
  29. package/dist/validation/managed-markets.d.ts +17 -0
  30. package/dist/validation/managed-markets.js +17 -0
  31. package/dist/validation/margin-accounts.d.ts +10 -3
  32. package/dist/validation/margin-accounts.js +17 -6
  33. package/dist/validation/market.d.ts +45 -0
  34. package/dist/validation/market.js +43 -0
  35. package/dist/validation/positions.d.ts +5 -3
  36. package/dist/validation/positions.js +12 -5
  37. package/dist/validation/profile.d.ts +19 -2
  38. package/dist/validation/profile.js +36 -4
  39. package/dist/validation/trading.d.ts +2 -2
  40. package/dist/validation/vault.d.ts +14 -0
  41. package/dist/validation/vault.js +14 -0
  42. package/dist/websocket/base.d.ts +56 -6
  43. package/dist/websocket/client.d.ts +8 -3
  44. package/dist/websocket/events/index.d.ts +1 -0
  45. package/dist/websocket/events/index.js +1 -0
  46. package/dist/websocket/events/instrument-events.d.ts +27 -1
  47. package/dist/websocket/events/instrument-events.js +6 -1
  48. package/dist/websocket/events/market-stats-events.d.ts +41 -5
  49. package/dist/websocket/events/market-stats-events.js +3 -2
  50. package/dist/websocket/events/orders-events.d.ts +30 -3
  51. package/dist/websocket/events/position-events.d.ts +15 -0
  52. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  53. package/dist/websocket/events/position-valuation-events.js +15 -0
  54. package/dist/wire/operations.d.ts +1 -1
  55. package/dist/wire/operations.js +2 -0
  56. package/dist/wire/schema.d.ts +906 -284
  57. package/dist/withdrawals/index.d.ts +27 -6
  58. package/package.json +2 -2
@@ -3,11 +3,18 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  import { MarketSlippageToleranceBpsSchema, OrderSideSchema, OrderTypeSchema, PositionSideSchema, PositiveDecimalStringSchema, UUIDSchema } from "./trading";
6
- const PaginationSchema = z.object({
7
- page: z.number().int().min(1, "Page must be at least 1").optional(),
8
- pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
6
+ const CursorPaginationSchema = z.object({
7
+ /**
8
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
9
+ * keep passing `page`, and the request would then come back as the first
10
+ * cursor page every time — the same silent duplicate-page failure the REST
11
+ * 400 guard exists to prevent (0XM-2788).
12
+ */
13
+ page: z.never().optional(),
14
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
15
+ pageToken: z.string().optional(),
9
16
  });
10
- export const ListMarginAccountsSchema = PaginationSchema.extend({
17
+ export const ListMarginAccountsSchema = CursorPaginationSchema.extend({
11
18
  state: z.string().trim().min(1, "State cannot be empty").optional(),
12
19
  tradingPairId: UUIDSchema.optional(),
13
20
  });
@@ -121,11 +128,11 @@ export const TransferCollateralToRiskBucketSchema = z.object({
121
128
  export const TransferCollateralFromParentMarginAccountSchema = z.object({
122
129
  request: ParentMarginAccountCollateralRequestSchema,
123
130
  });
124
- export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
131
+ export const GetMarginAccountMovementsSchema = CursorPaginationSchema.extend({
125
132
  marginAccountId: UUIDSchema,
126
133
  movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
127
134
  });
128
- export const GetParentMarginAccountMovementsSchema = PaginationSchema.extend({
135
+ export const GetParentMarginAccountMovementsSchema = CursorPaginationSchema.extend({
129
136
  movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
130
137
  }).optional();
131
138
  const BaseSimulateOrderRiskRequestSchema = z.object({
@@ -246,6 +253,10 @@ export const CreateMarginSubAccountSchema = z.object({
246
253
  export const CloseMarginSubAccountSchema = z.object({
247
254
  marginAccountId: UUIDSchema,
248
255
  });
256
+ export const SubAccountCollateralTransferSchema = z.object({
257
+ marginAccountId: UUIDSchema,
258
+ amount: PositiveDecimalStringSchema,
259
+ });
249
260
  export const GetMarginAccountPnlSchema = z.object({
250
261
  marginAccountId: UUIDSchema,
251
262
  });
@@ -220,3 +220,48 @@ export declare const SearchTradingPairsSchema: z.ZodObject<{
220
220
  export declare const GetMarketMetadataSchema: z.ZodObject<{
221
221
  tradingPairId: z.ZodUUID;
222
222
  }, z.core.$strip>;
223
+ /** Per-pair funding history; the pair id is path-bound and validated separately. */
224
+ export declare const ListFundingHistorySchema: z.ZodObject<{
225
+ page: z.ZodOptional<z.ZodNever>;
226
+ startTime: z.ZodOptional<z.ZodString>;
227
+ endTime: z.ZodOptional<z.ZodString>;
228
+ pageSize: z.ZodOptional<z.ZodNumber>;
229
+ pageToken: z.ZodOptional<z.ZodString>;
230
+ orderBy: z.ZodOptional<z.ZodEnum<{
231
+ ASC: "ASC";
232
+ DESC: "DESC";
233
+ }>>;
234
+ }, z.core.$strip>;
235
+ /** All-markets funding history. */
236
+ export declare const ListAllFundingHistorySchema: z.ZodObject<{
237
+ page: z.ZodOptional<z.ZodNever>;
238
+ startTime: z.ZodOptional<z.ZodString>;
239
+ endTime: z.ZodOptional<z.ZodString>;
240
+ pageSize: z.ZodOptional<z.ZodNumber>;
241
+ pageToken: z.ZodOptional<z.ZodString>;
242
+ orderBy: z.ZodOptional<z.ZodEnum<{
243
+ ASC: "ASC";
244
+ DESC: "DESC";
245
+ }>>;
246
+ }, z.core.$strip>;
247
+ /**
248
+ * Public trades-feed listing validation schema.
249
+ *
250
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted, but NOT for
251
+ * the same reason as {@link ListFundingHistorySchema}. That one is built on a
252
+ * query builder that serializes whatever keys the params object carries, so a
253
+ * leftover `page` reaches the wire and comes back as the server's `400`.
254
+ * `getTrades` instead sets `pageSize` and `pageToken` explicitly, so a stray
255
+ * `page` never leaves the client at all — which makes rejecting it more
256
+ * important here, not less. Stripped silently, it would leave the caller
257
+ * requesting page 2, 3, 4 and receiving the FIRST cursor page every time, with
258
+ * no error from either side to reveal the loop. `z.never()` turns that silent
259
+ * non-advancing walk into an immediate `ValidationError`.
260
+ *
261
+ * The ceiling is the cursor-mode 1000; the historical default of 25 stays.
262
+ */
263
+ export declare const GetTradesSchema: z.ZodObject<{
264
+ page: z.ZodOptional<z.ZodNever>;
265
+ pageSize: z.ZodOptional<z.ZodNumber>;
266
+ pageToken: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$strip>;
@@ -224,3 +224,46 @@ export const SearchTradingPairsSchema = z.object({
224
224
  export const GetMarketMetadataSchema = z.object({
225
225
  tradingPairId: UUIDSchema,
226
226
  });
227
+ /**
228
+ * Funding-history listing validation schemas.
229
+ *
230
+ * Cursor paged (0XM-2818). `page` is REJECTED rather than omitted: `withQuery`
231
+ * builds the query string from `Object.entries(params)`, so an untyped caller's
232
+ * leftover `page` would otherwise reach the wire and come back as a server
233
+ * `400` — a round trip to learn what the SDK already knows. Rejecting here
234
+ * fails the call immediately with a `ValidationError`, and the `deny_unknown_fields`
235
+ * 400 stays as the server-side backstop.
236
+ */
237
+ const FundingHistoryCursorSchema = z.object({
238
+ page: z.never().optional(),
239
+ startTime: z.string().optional(),
240
+ endTime: z.string().optional(),
241
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
242
+ pageToken: z.string().optional(),
243
+ orderBy: z.enum(["ASC", "DESC"], { message: 'orderBy must be "ASC" or "DESC"' }).optional(),
244
+ });
245
+ /** Per-pair funding history; the pair id is path-bound and validated separately. */
246
+ export const ListFundingHistorySchema = FundingHistoryCursorSchema;
247
+ /** All-markets funding history. */
248
+ export const ListAllFundingHistorySchema = FundingHistoryCursorSchema;
249
+ /**
250
+ * Public trades-feed listing validation schema.
251
+ *
252
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted, but NOT for
253
+ * the same reason as {@link ListFundingHistorySchema}. That one is built on a
254
+ * query builder that serializes whatever keys the params object carries, so a
255
+ * leftover `page` reaches the wire and comes back as the server's `400`.
256
+ * `getTrades` instead sets `pageSize` and `pageToken` explicitly, so a stray
257
+ * `page` never leaves the client at all — which makes rejecting it more
258
+ * important here, not less. Stripped silently, it would leave the caller
259
+ * requesting page 2, 3, 4 and receiving the FIRST cursor page every time, with
260
+ * no error from either side to reveal the loop. `z.never()` turns that silent
261
+ * non-advancing walk into an immediate `ValidationError`.
262
+ *
263
+ * The ceiling is the cursor-mode 1000; the historical default of 25 stays.
264
+ */
265
+ export const GetTradesSchema = z.object({
266
+ page: z.never().optional(),
267
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
268
+ pageToken: z.string().optional(),
269
+ });
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  export declare const ListPositionsSchema: z.ZodObject<{
6
- page: z.ZodOptional<z.ZodNumber>;
6
+ page: z.ZodOptional<z.ZodNever>;
7
7
  pageSize: z.ZodOptional<z.ZodNumber>;
8
+ pageToken: z.ZodOptional<z.ZodString>;
8
9
  marginAccountId: z.ZodOptional<z.ZodUUID>;
9
10
  tradingPairId: z.ZodOptional<z.ZodUUID>;
10
11
  status: z.ZodOptional<z.ZodEnum<{
@@ -21,9 +22,9 @@ export declare const ClosePositionSchema: z.ZodObject<{
21
22
  positionId: z.ZodUUID;
22
23
  request: z.ZodObject<{
23
24
  closeType: z.ZodEnum<{
24
- IOC: "IOC";
25
25
  LIMIT: "LIMIT";
26
26
  MARKET: "MARKET";
27
+ IOC: "IOC";
27
28
  }>;
28
29
  limitPrice: z.ZodOptional<z.ZodString>;
29
30
  slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
@@ -84,8 +85,9 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
84
85
  }, z.core.$strip>;
85
86
  }, z.core.$strip>;
86
87
  export declare const ListPositionHistorySchema: z.ZodObject<{
87
- page: z.ZodOptional<z.ZodNumber>;
88
+ page: z.ZodOptional<z.ZodNever>;
88
89
  pageSize: z.ZodOptional<z.ZodNumber>;
90
+ pageToken: z.ZodOptional<z.ZodString>;
89
91
  positionId: z.ZodOptional<z.ZodUUID>;
90
92
  marginAccountId: z.ZodOptional<z.ZodUUID>;
91
93
  tradingPairId: z.ZodOptional<z.ZodUUID>;
@@ -3,9 +3,16 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, TrailingStopLegSchema, UUIDSchema, } from "./trading";
6
- const PaginationSchema = z.object({
7
- page: z.number().int().min(1, "Page must be at least 1").optional(),
8
- pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
6
+ const CursorPaginationSchema = z.object({
7
+ /**
8
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
9
+ * keep passing `page`, and the request would then come back as the first
10
+ * cursor page every time — the same silent duplicate-page failure the REST
11
+ * 400 guard exists to prevent (0XM-2788).
12
+ */
13
+ page: z.never().optional(),
14
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
15
+ pageToken: z.string().optional(),
9
16
  });
10
17
  // Filter values accepted by the list-positions endpoint. Narrower than the
11
18
  // returned PositionStatus: the backend folds EXPIRED positions under CLOSED, so
@@ -19,7 +26,7 @@ const ClosePositionTypeSchema = z.enum(["MARKET", "LIMIT", "IOC"], {
19
26
  const PositionIdSchema = z.object({
20
27
  positionId: UUIDSchema,
21
28
  });
22
- export const ListPositionsSchema = PaginationSchema.extend({
29
+ export const ListPositionsSchema = CursorPaginationSchema.extend({
23
30
  marginAccountId: UUIDSchema.optional(),
24
31
  tradingPairId: UUIDSchema.optional(),
25
32
  status: PositionStatusSchema.optional(),
@@ -100,7 +107,7 @@ export const AttachPositionTpSlSchema = PositionIdSchema.extend({
100
107
  path: ["oco"],
101
108
  }),
102
109
  });
103
- export const ListPositionHistorySchema = PaginationSchema.extend({
110
+ export const ListPositionHistorySchema = CursorPaginationSchema.extend({
104
111
  positionId: UUIDSchema.optional(),
105
112
  marginAccountId: UUIDSchema.optional(),
106
113
  tradingPairId: UUIDSchema.optional(),
@@ -48,8 +48,13 @@ export declare const SetSelfTradePreventionDefaultSchema: z.ZodObject<{
48
48
  * All fields are optional — an empty object or undefined is valid.
49
49
  */
50
50
  export declare const GetUserMovementsSchema: z.ZodObject<{
51
- page: z.ZodOptional<z.ZodNumber>;
51
+ page: z.ZodOptional<z.ZodNever>;
52
52
  pageSize: z.ZodOptional<z.ZodNumber>;
53
+ pageToken: z.ZodOptional<z.ZodString>;
54
+ orderBy: z.ZodOptional<z.ZodEnum<{
55
+ ASC: "ASC";
56
+ DESC: "DESC";
57
+ }>>;
53
58
  entryType: z.ZodOptional<z.ZodEnum<{
54
59
  CREDIT: "CREDIT";
55
60
  DEBIT: "DEBIT";
@@ -81,9 +86,21 @@ export declare const GetUserTradesSchema: z.ZodObject<{
81
86
  tradingPairId: z.ZodOptional<z.ZodUUID>;
82
87
  pageToken: z.ZodOptional<z.ZodString>;
83
88
  }, z.core.$strip>;
89
+ /**
90
+ * Get User Balances validation schema
91
+ *
92
+ * Validates parameters for the cursor-paged balances listing. All fields are
93
+ * optional — an empty object or undefined is valid.
94
+ */
95
+ export declare const GetUserBalancesSchema: z.ZodObject<{
96
+ page: z.ZodOptional<z.ZodNever>;
97
+ pageSize: z.ZodOptional<z.ZodNumber>;
98
+ pageToken: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$strip>;
84
100
  export declare const ListFundingPaymentsSchema: z.ZodObject<{
85
- page: z.ZodOptional<z.ZodNumber>;
101
+ page: z.ZodOptional<z.ZodNever>;
86
102
  pageSize: z.ZodOptional<z.ZodNumber>;
103
+ pageToken: z.ZodOptional<z.ZodString>;
87
104
  tradingPairId: z.ZodOptional<z.ZodUUID>;
88
105
  positionId: z.ZodOptional<z.ZodUUID>;
89
106
  marginAccountId: z.ZodOptional<z.ZodUUID>;
@@ -33,8 +33,16 @@ export const SetSelfTradePreventionDefaultSchema = z.object({
33
33
  * All fields are optional — an empty object or undefined is valid.
34
34
  */
35
35
  export const GetUserMovementsSchema = z.object({
36
- page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
37
- pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
36
+ /**
37
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
38
+ * keep passing `page`, and the request would come back as the first cursor
39
+ * page every time — the same silent duplicate-page failure the REST 400
40
+ * guard exists to prevent (0XM-2788).
41
+ */
42
+ page: z.never().optional(),
43
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
44
+ pageToken: z.string().optional(),
45
+ orderBy: z.enum(["ASC", "DESC"]).optional(),
38
46
  entryType: LedgerEntryTypeSchema.optional(),
39
47
  transactionType: TransactionTypeSchema.optional(),
40
48
  assetId: UUIDSchema.optional(),
@@ -57,9 +65,33 @@ export const GetUserTradesSchema = z.object({
57
65
  tradingPairId: UUIDSchema.optional(),
58
66
  pageToken: z.string().optional(),
59
67
  });
68
+ /**
69
+ * Get User Balances validation schema
70
+ *
71
+ * Validates parameters for the cursor-paged balances listing. All fields are
72
+ * optional — an empty object or undefined is valid.
73
+ */
74
+ export const GetUserBalancesSchema = z.object({
75
+ /**
76
+ * Rejected, not ignored. Without a schema at all a JS or `any` caller's
77
+ * `page` was silently dropped while building the query string, so the call
78
+ * resolved with the FIRST cursor page on every request — the quiet
79
+ * duplicate-page failure the REST 400 guard exists to prevent (0XM-2821).
80
+ */
81
+ page: z.never().optional(),
82
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
83
+ pageToken: z.string().optional(),
84
+ });
60
85
  export const ListFundingPaymentsSchema = z.object({
61
- page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
62
- pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
86
+ /**
87
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
88
+ * keep passing `page`, and the request would come back as the first cursor
89
+ * page every time — the same silent duplicate-page failure the REST 400
90
+ * guard exists to prevent (0XM-2788).
91
+ */
92
+ page: z.never().optional(),
93
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
94
+ pageToken: z.string().optional(),
63
95
  tradingPairId: UUIDSchema.optional(),
64
96
  positionId: UUIDSchema.optional(),
65
97
  marginAccountId: UUIDSchema.optional(),
@@ -375,11 +375,11 @@ export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
375
375
  export declare const ConditionalOrderStateSchema: z.ZodEnum<{
376
376
  CANCELLED: "CANCELLED";
377
377
  EXPIRED: "EXPIRED";
378
- FAILED: "FAILED";
379
378
  PENDING_PARENT: "PENDING_PARENT";
380
379
  ACTIVE: "ACTIVE";
381
380
  TRIGGERING: "TRIGGERING";
382
381
  TRIGGERED: "TRIGGERED";
382
+ FAILED: "FAILED";
383
383
  }>;
384
384
  export declare const ClosePositionSideSchema: z.ZodEnum<{
385
385
  LONG: "LONG";
@@ -395,11 +395,11 @@ export declare const ListConditionalOrdersSchema: z.ZodObject<{
395
395
  state: z.ZodOptional<z.ZodEnum<{
396
396
  CANCELLED: "CANCELLED";
397
397
  EXPIRED: "EXPIRED";
398
- FAILED: "FAILED";
399
398
  PENDING_PARENT: "PENDING_PARENT";
400
399
  ACTIVE: "ACTIVE";
401
400
  TRIGGERING: "TRIGGERING";
402
401
  TRIGGERED: "TRIGGERED";
402
+ FAILED: "FAILED";
403
403
  }>>;
404
404
  pageSize: z.ZodOptional<z.ZodNumber>;
405
405
  pageToken: z.ZodOptional<z.ZodString>;
@@ -75,3 +75,17 @@ export declare const WithdrawSchema: z.ZodObject<{
75
75
  export declare const GetBalanceSchema: z.ZodObject<{
76
76
  assetId: z.ZodUUID;
77
77
  }, z.core.$strip>;
78
+ /**
79
+ * Pending-withdrawals listing validation schema.
80
+ *
81
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted: the client
82
+ * forwards the params field by field, which would drop a stray `page` before it
83
+ * reached the wire, so a JavaScript or `any` caller looping on `{ page: n }`
84
+ * would be handed the FIRST cursor page on every call and would never advance —
85
+ * the exact failure the REST 400 exists to surface.
86
+ */
87
+ export declare const ListPendingWithdrawalsSchema: z.ZodObject<{
88
+ page: z.ZodOptional<z.ZodNever>;
89
+ pageSize: z.ZodOptional<z.ZodNumber>;
90
+ pageToken: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>;
@@ -86,3 +86,17 @@ export const WithdrawSchema = z.object({
86
86
  export const GetBalanceSchema = z.object({
87
87
  assetId: UUIDSchema,
88
88
  });
89
+ /**
90
+ * Pending-withdrawals listing validation schema.
91
+ *
92
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted: the client
93
+ * forwards the params field by field, which would drop a stray `page` before it
94
+ * reached the wire, so a JavaScript or `any` caller looping on `{ page: n }`
95
+ * would be handed the FIRST cursor page on every call and would never advance —
96
+ * the exact failure the REST 400 exists to surface.
97
+ */
98
+ export const ListPendingWithdrawalsSchema = z.object({
99
+ page: z.never().optional(),
100
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
101
+ pageToken: z.string().optional(),
102
+ });
@@ -7,8 +7,40 @@
7
7
  * WebSocket connection status
8
8
  */
9
9
  export type WebSocketStatus = "connected" | "connecting" | "disconnected" | "reconnecting";
10
- /** Handler invoked whenever the WebSocket connection status changes. */
11
- export type StatusHandler = (status: WebSocketStatus) => void;
10
+ /**
11
+ * Connection-attempt context delivered with every status change.
12
+ *
13
+ * `"reconnecting"` with `hasConnected: false` means the client has never
14
+ * reached the server and is still trying (the first connect failed);
15
+ * `hasConnected: true` means a working connection was lost.
16
+ */
17
+ export interface WebSocketStatusInfo {
18
+ /**
19
+ * The retry this status refers to. `0` for `"connecting"` and
20
+ * `"connected"`; `1`, `2`, … for `"reconnecting"` (the retry just
21
+ * scheduled); for `"disconnected"`, the number of retries scheduled in the
22
+ * outage before it, counting one still in backoff when `disconnect()` is
23
+ * called (`0` after a clean close of a working connection).
24
+ */
25
+ attempt: number;
26
+ /**
27
+ * Whether this client has reached the server at least once since it was
28
+ * created or since the last `disconnect()`.
29
+ */
30
+ hasConnected: boolean;
31
+ /**
32
+ * Set only on `"reconnecting"`: the delay, in milliseconds, before the
33
+ * scheduled retry opens its connection.
34
+ */
35
+ nextRetryDelayMs?: number;
36
+ }
37
+ /**
38
+ * Handler invoked whenever the WebSocket connection status changes.
39
+ *
40
+ * Inside the handler, `getStatus()` returns the status being reported. A
41
+ * handler that takes only `status` remains valid.
42
+ */
43
+ export type StatusHandler = (status: WebSocketStatus, info: WebSocketStatusInfo) => void;
12
44
  /**
13
45
  * Why the connection was re-established. Delivered by
14
46
  * {@link MonacoWebSocketConfig.onResync} after the socket reopens and sends its
@@ -129,9 +161,11 @@ export interface MonacoWebSocketConfig {
129
161
  /** Enable auto-reconnect on disconnect (default: true) */
130
162
  autoReconnect?: boolean;
131
163
  /**
132
- * Maximum reconnection attempts (default: unlimited). Retry delay is
133
- * full-jitter exponential backoff capped at 30s, so unlimited retries are
134
- * capped-rate, not a tight loop.
164
+ * Maximum reconnection attempts per outage (default: unlimited). Retry
165
+ * delay is full-jitter exponential backoff capped at 30s, so unlimited
166
+ * retries are capped-rate, not a tight loop. Once the attempts run out the
167
+ * client reports `"disconnected"`; a later `connect()` starts a fresh
168
+ * budget.
135
169
  */
136
170
  maxReconnectAttempts?: number;
137
171
  /** Base delay for the exponential backoff in milliseconds (default: 1000) */
@@ -141,7 +175,23 @@ export interface MonacoWebSocketConfig {
141
175
  * retried, in milliseconds (default: 10000)
142
176
  */
143
177
  connectionTimeoutMs?: number;
144
- /** Callback for connection status changes */
178
+ /**
179
+ * Called on every connection status change, with the attempt context in
180
+ * {@link WebSocketStatusInfo}:
181
+ *
182
+ * - `"connecting"` — a connection is opening outside a retry cycle: the
183
+ * first connect, a `connect()` after a terminal `"disconnected"`, or a
184
+ * fresh session's reconnect after terminal authentication loss.
185
+ * - `"connected"` — the connection opened.
186
+ * - `"reconnecting"` — a retry is scheduled, once per retry. It holds until
187
+ * a retry connects or the retries run out; retries do not report
188
+ * `"connecting"`.
189
+ * - `"disconnected"` — terminal: a clean close, retries exhausted, terminal
190
+ * authentication loss, or `disconnect()`.
191
+ *
192
+ * An error thrown by this callback, or a rejection of the promise an async
193
+ * callback returns, is logged and does not affect the connection.
194
+ */
145
195
  onStatusChange?: StatusHandler;
146
196
  /**
147
197
  * Called after every automatic reconnect sends authentication/subscription
@@ -52,7 +52,7 @@ import type { Interval } from "../market";
52
52
  import type { TradingMode } from "../trading";
53
53
  import type { WebSocketStatus } from "./base";
54
54
  import type { OrderbookQuotationMode } from "./clients/orderbook-client";
55
- import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, TradeEvent, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
55
+ import type { AccountEvent, AccountEventData, ConditionalOrderEvent, ConditionalOrderEventData, CopyEvent, CopyRelationshipEventData, InstrumentEvent, InstrumentEventData, LiquidationEvent, LiquidationEventData, MarketStatsAllEvent, MarketStatsData, MarketStatsEvent, MarketStatsSummary, OHLCVEvent, OHLCVPriceType, OrderbookEvent, OrderEvent, PositionEvent, PositionEventData, PositionValuationEvent, TradeEvent, TwapOrderEvent, TwapOrderEventData, UserBalanceEvent, UserBalanceEventData, UserMovementEvent } from "./events";
56
56
  import type { OrderSnapshotItem, SnapshotHandler } from "./snapshots";
57
57
  export type MessageHandler<T> = (data: T) => void;
58
58
  export interface MonacoWebSocket {
@@ -84,8 +84,13 @@ export interface MonacoWebSocket {
84
84
  conditionalOrders: (handler: MessageHandler<ConditionalOrderEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<ConditionalOrderEventData>) => () => void;
85
85
  /** Subscribe to TWAP parent-order lifecycle events (requires authentication) */
86
86
  twapOrders: (handler: MessageHandler<TwapOrderEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<TwapOrderEventData>) => () => void;
87
- /** Subscribe to position state updates (requires authentication); omit `tradingPairId` for all pairs. `onSnapshot` receives every open position */
88
- positions: (handler: MessageHandler<PositionEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<PositionEventData>) => () => void;
87
+ /**
88
+ * Subscribe to position state updates (requires authentication); omit `tradingPairId` for all pairs. `onSnapshot` receives every open position.
89
+ *
90
+ * `handler` receives lifecycle `position_update` frames only. `onValuation`, when given, receives the periodic `position_valuation`
91
+ * frames carried on the same channel; without it they are ignored. Apply a valuation only to a position already held as `OPEN`.
92
+ */
93
+ positions: (handler: MessageHandler<PositionEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<PositionEventData>, onValuation?: MessageHandler<PositionValuationEvent>) => () => void;
89
94
  /** Subscribe to liquidation alerts (requires authentication); omit `tradingPairId` for all pairs */
90
95
  liquidations: (handler: MessageHandler<LiquidationEvent>, tradingPairId?: string, onSnapshot?: SnapshotHandler<LiquidationEventData>) => () => void;
91
96
  /** Subscribe to account-level margin health updates for the authenticated user (requires authentication) */
@@ -10,5 +10,6 @@ export * from "./ohlcv-events";
10
10
  export * from "./orderbook-events";
11
11
  export * from "./orders-events";
12
12
  export * from "./position-events";
13
+ export * from "./position-valuation-events";
13
14
  export * from "./trade-events";
14
15
  export * from "./twap-order-events";
@@ -10,5 +10,6 @@ export * from "./ohlcv-events";
10
10
  export * from "./orderbook-events";
11
11
  export * from "./orders-events";
12
12
  export * from "./position-events";
13
+ export * from "./position-valuation-events";
13
14
  export * from "./trade-events";
14
15
  export * from "./twap-order-events";
@@ -15,13 +15,18 @@
15
15
  * A subscriber receives a subscribe-time snapshot of the current active-pair
16
16
  * configuration list (each frame a `Listing` baseline) before the live diffs.
17
17
  *
18
- * Perp-only fields (`maxLeverage`, `initialMarginRate`, `maintenanceMarginRate`)
18
+ * Perp-only fields (`minLeverage`, `maxLeverage`, `initialMarginRate`, `maintenanceMarginRate`)
19
19
  * are optional and omitted on the wire for spot markets, which have no leverage
20
20
  * or margin parameters. All numeric quantities are decimal strings.
21
21
  *
22
22
  * Every frame (snapshot and live) carries `baseIconUrl` and `quoteIconUrl` for
23
23
  * the market's two assets, each `null` when that asset has no icon configured,
24
24
  * so a client can render a position's asset icons from the instrument row alone.
25
+ *
26
+ * Every frame also carries the market's asset identity: `baseAssetId`,
27
+ * `quoteAssetId`, `baseToken`, `quoteToken`, `baseAssetName`, `quoteAssetName`,
28
+ * `baseDecimals` and `quoteDecimals`. Perp frames add `minLeverage`. These are
29
+ * declared optional because a server that predates them omits them.
25
30
  */
26
31
  /**
27
32
  * The kind of instrument change a frame reports.
@@ -69,6 +74,25 @@ export interface InstrumentEventData {
69
74
  marketType: string;
70
75
  /** Asset-class category, e.g. "crypto", "equities", "commodities" */
71
76
  category: string;
77
+ /**
78
+ * Base asset identifier (UUID). The server sends this on every market (spot
79
+ * and perp); declared optional because an older server omits it.
80
+ */
81
+ baseAssetId?: string;
82
+ /** Quote asset identifier (UUID). See {@link InstrumentEventData.baseAssetId}. */
83
+ quoteAssetId?: string;
84
+ /** Base asset ticker symbol, e.g. "BTC". Sent on every market. */
85
+ baseToken?: string;
86
+ /** Quote asset ticker symbol, e.g. "USDC". Sent on every market. */
87
+ quoteToken?: string;
88
+ /** Base asset display name, e.g. "Bitcoin". Sent on every market. */
89
+ baseAssetName?: string;
90
+ /** Quote asset display name, e.g. "USD Coin". Sent on every market. */
91
+ quoteAssetName?: string;
92
+ /** Base asset decimals (integer). Sent on every market. */
93
+ baseDecimals?: number;
94
+ /** Quote asset decimals (integer). Sent on every market. */
95
+ quoteDecimals?: number;
72
96
  /**
73
97
  * Base asset icon URL, or `null` when the asset has no icon configured.
74
98
  * The server sends this on every market (spot and perp) as an explicit `null`
@@ -83,6 +107,8 @@ export interface InstrumentEventData {
83
107
  * {@link InstrumentEventData.baseIconUrl}.
84
108
  */
85
109
  quoteIconUrl?: string | null;
110
+ /** Minimum leverage (decimal string). Perp-only; omitted for spot. */
111
+ minLeverage?: string;
86
112
  /** Maximum leverage (decimal string). Perp-only; omitted for spot. */
87
113
  maxLeverage?: string;
88
114
  /** Initial margin rate (decimal string). Perp-only; omitted for spot. */
@@ -15,11 +15,16 @@
15
15
  * A subscriber receives a subscribe-time snapshot of the current active-pair
16
16
  * configuration list (each frame a `Listing` baseline) before the live diffs.
17
17
  *
18
- * Perp-only fields (`maxLeverage`, `initialMarginRate`, `maintenanceMarginRate`)
18
+ * Perp-only fields (`minLeverage`, `maxLeverage`, `initialMarginRate`, `maintenanceMarginRate`)
19
19
  * are optional and omitted on the wire for spot markets, which have no leverage
20
20
  * or margin parameters. All numeric quantities are decimal strings.
21
21
  *
22
22
  * Every frame (snapshot and live) carries `baseIconUrl` and `quoteIconUrl` for
23
23
  * the market's two assets, each `null` when that asset has no icon configured,
24
24
  * so a client can render a position's asset icons from the instrument row alone.
25
+ *
26
+ * Every frame also carries the market's asset identity: `baseAssetId`,
27
+ * `quoteAssetId`, `baseToken`, `quoteToken`, `baseAssetName`, `quoteAssetName`,
28
+ * `baseDecimals` and `quoteDecimals`. Perp frames add `minLeverage`. These are
29
+ * declared optional because a server that predates them omits them.
25
30
  */