@0xmonaco/types 0.8.8 → 0.8.11

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 (51) hide show
  1. package/README.md +5 -3
  2. package/dist/api/index.d.ts +7 -0
  3. package/dist/applications/index.d.ts +47 -5
  4. package/dist/applications/index.js +2 -1
  5. package/dist/applications/requests.d.ts +78 -0
  6. package/dist/applications/requests.js +7 -0
  7. package/dist/applications/responses.d.ts +211 -1
  8. package/dist/applications/responses.js +3 -1
  9. package/dist/auth/index.d.ts +6 -12
  10. package/dist/auth/index.js +2 -2
  11. package/dist/auth/responses.d.ts +0 -11
  12. package/dist/delegated-agents/index.d.ts +17 -1
  13. package/dist/faucet/index.d.ts +54 -0
  14. package/dist/faucet/index.js +10 -0
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.js +4 -0
  17. package/dist/margin-accounts/index.d.ts +18 -14
  18. package/dist/market/index.d.ts +116 -0
  19. package/dist/positions/index.d.ts +1 -0
  20. package/dist/profile/index.d.ts +88 -1
  21. package/dist/sdk/index.d.ts +21 -0
  22. package/dist/sub-accounts/index.d.ts +145 -0
  23. package/dist/sub-accounts/index.js +9 -0
  24. package/dist/trading/index.d.ts +6 -6
  25. package/dist/trading/responses.d.ts +8 -27
  26. package/dist/validation/margin-accounts.d.ts +7 -9
  27. package/dist/validation/margin-accounts.js +7 -9
  28. package/dist/validation/profile.d.ts +7 -0
  29. package/dist/validation/profile.js +7 -0
  30. package/dist/validation/trading.d.ts +8 -33
  31. package/dist/validation/trading.js +42 -33
  32. package/dist/validation/vault.d.ts +4 -0
  33. package/dist/validation/vault.js +2 -0
  34. package/dist/vault/index.d.ts +13 -1
  35. package/dist/whitelist/index.d.ts +44 -0
  36. package/dist/whitelist/index.js +10 -0
  37. package/dist/wire/assert.d.ts +54 -0
  38. package/dist/wire/assert.js +0 -0
  39. package/dist/wire/audit.d.ts +47 -0
  40. package/dist/wire/audit.js +43 -0
  41. package/dist/wire/coverage.d.ts +1 -0
  42. package/dist/wire/coverage.js +0 -0
  43. package/dist/wire/index.d.ts +21 -0
  44. package/dist/wire/index.js +2 -0
  45. package/dist/wire/operations.d.ts +15 -0
  46. package/dist/wire/operations.js +94 -0
  47. package/dist/wire/schema.d.ts +8460 -0
  48. package/dist/wire/schema.js +4 -0
  49. package/dist/withdrawals/index.d.ts +43 -0
  50. package/dist/withdrawals/index.js +0 -0
  51. package/package.json +6 -2
@@ -74,7 +74,9 @@ export interface CreateOrderResponse {
74
74
  match_result?: MatchResult;
75
75
  /** Resolved margin account ID for margin/perp orders */
76
76
  margin_account_id?: string;
77
- /** Resolved hidden strategy bucket key for auto margin buckets */
77
+ /** Resolved isolated margin bucket ID for bucket-scoped margin orders */
78
+ margin_bucket_id?: string;
79
+ /** Client strategy key carried for compatibility */
78
80
  strategy_key?: string;
79
81
  /** Delegated agent ID when submitted through a delegated session */
80
82
  delegation_id?: string;
@@ -286,7 +288,11 @@ export interface BatchCreateOrderParams {
286
288
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
287
289
  /** Margin account UUID for margin/perp orders */
288
290
  marginAccountId?: string;
289
- /** Optional strategy bucket key used when marginAccountId is omitted */
291
+ /** Existing isolated margin bucket UUID for bucket-scoped margin orders */
292
+ marginBucketId?: string;
293
+ /** Collateral to allocate into a new isolated margin bucket */
294
+ marginBucketCollateral?: string;
295
+ /** Client strategy key carried for compatibility */
290
296
  strategyKey?: string;
291
297
  /** Position side for margin/perp orders */
292
298
  positionSide?: PositionSide;
@@ -308,31 +314,6 @@ export interface BatchReplaceOrderParams {
308
314
  /** For sub-accounts: use master's balance (optional) */
309
315
  useMasterBalance?: boolean;
310
316
  }
311
- /**
312
- * Parameters for creating a standalone conditional TP/SL order.
313
- */
314
- export interface CreateConditionalOrderParams {
315
- tradingPairId: string;
316
- marginAccountId: string;
317
- conditionType: ConditionalOrderConditionType;
318
- triggerPrice: string;
319
- triggerSource?: ConditionalOrderTriggerSource;
320
- side: OrderSide;
321
- positionSide: Exclude<PositionSide, "NONE">;
322
- orderType: OrderType;
323
- limitPrice?: string;
324
- quantity?: string;
325
- reduceOnly?: boolean;
326
- timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
327
- slippageToleranceBps?: number;
328
- expiresAt?: string;
329
- }
330
- export interface CreateConditionalOrderResponse {
331
- conditional_order_id: string;
332
- status: "SUCCESS" | "FAILED";
333
- message: string;
334
- state: ConditionalOrderState;
335
- }
336
317
  export interface CancelConditionalOrderResponse {
337
318
  conditional_order_id: string;
338
319
  status: "SUCCESS" | "FAILED";
@@ -8,12 +8,9 @@ export declare const ListMarginAccountsSchema: z.ZodObject<{
8
8
  state: z.ZodOptional<z.ZodString>;
9
9
  tradingPairId: z.ZodOptional<z.ZodUUID>;
10
10
  }, z.core.$strip>;
11
- export declare const CreateMarginAccountSchema: z.ZodOptional<z.ZodObject<{
12
- label: z.ZodOptional<z.ZodString>;
13
- collateralAsset: z.ZodOptional<z.ZodString>;
14
- }, z.core.$strip>>;
15
11
  export declare const GetMarginAccountSummarySchema: z.ZodObject<{
16
12
  marginAccountId: z.ZodUUID;
13
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
17
14
  }, z.core.$strip>;
18
15
  export declare const GetAvailableCollateralSchema: z.ZodOptional<z.ZodObject<{
19
16
  asset: z.ZodOptional<z.ZodString>;
@@ -23,6 +20,8 @@ export declare const TransferCollateralSchema: z.ZodObject<{
23
20
  request: z.ZodObject<{
24
21
  asset: z.ZodString;
25
22
  amount: z.ZodString;
23
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
24
+ strategyKey: z.ZodOptional<z.ZodString>;
26
25
  }, z.core.$strip>;
27
26
  }, z.core.$strip>;
28
27
  export declare const TransferCollateralToAutoMarginAccountSchema: z.ZodObject<{
@@ -43,7 +42,6 @@ export declare const SimulateOrderRiskSchema: z.ZodObject<{
43
42
  marginAccountId: z.ZodUUID;
44
43
  request: z.ZodObject<{
45
44
  tradingPairId: z.ZodUUID;
46
- strategyKey: z.ZodOptional<z.ZodString>;
47
45
  side: z.ZodEnum<{
48
46
  BUY: "BUY";
49
47
  SELL: "SELL";
@@ -61,12 +59,10 @@ export declare const SimulateOrderRiskSchema: z.ZodObject<{
61
59
  quantity: z.ZodString;
62
60
  leverage: z.ZodString;
63
61
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
64
- }, z.core.$strip>;
62
+ }, z.core.$strict>;
65
63
  }, z.core.$strip>;
66
64
  export declare const SimulateAutoMarginOrderRiskSchema: z.ZodObject<{
67
65
  request: z.ZodObject<{
68
- tradingPairId: z.ZodUUID;
69
- strategyKey: z.ZodOptional<z.ZodString>;
70
66
  side: z.ZodEnum<{
71
67
  BUY: "BUY";
72
68
  SELL: "SELL";
@@ -84,5 +80,7 @@ export declare const SimulateAutoMarginOrderRiskSchema: z.ZodObject<{
84
80
  quantity: z.ZodString;
85
81
  leverage: z.ZodString;
86
82
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
87
- }, z.core.$strip>;
83
+ tradingPairId: z.ZodUUID;
84
+ strategyKey: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strict>;
88
86
  }, z.core.$strip>;
@@ -11,14 +11,9 @@ export const ListMarginAccountsSchema = PaginationSchema.extend({
11
11
  state: z.string().trim().min(1, "State cannot be empty").optional(),
12
12
  tradingPairId: UUIDSchema.optional(),
13
13
  });
14
- export const CreateMarginAccountSchema = z
15
- .object({
16
- label: z.string().trim().min(1, "Label cannot be empty").optional(),
17
- collateralAsset: z.string().trim().min(1, "Collateral asset cannot be empty").optional(),
18
- })
19
- .optional();
20
14
  export const GetMarginAccountSummarySchema = z.object({
21
15
  marginAccountId: UUIDSchema,
16
+ tradingPairId: UUIDSchema.optional(),
22
17
  });
23
18
  export const GetAvailableCollateralSchema = z
24
19
  .object({
@@ -28,6 +23,8 @@ export const GetAvailableCollateralSchema = z
28
23
  const TransferCollateralRequestSchema = z.object({
29
24
  asset: z.string().trim().min(1, "Asset cannot be empty"),
30
25
  amount: PositiveDecimalStringSchema,
26
+ tradingPairId: UUIDSchema.optional(),
27
+ strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
31
28
  });
32
29
  const AutoMarginBucketRequestSchema = z.object({
33
30
  tradingPairId: UUIDSchema,
@@ -44,9 +41,8 @@ export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
44
41
  marginAccountId: UUIDSchema,
45
42
  movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
46
43
  });
47
- const SimulateOrderRiskRequestSchema = z.object({
44
+ const BaseSimulateOrderRiskRequestSchema = z.object({
48
45
  tradingPairId: UUIDSchema,
49
- strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
50
46
  side: OrderSideSchema,
51
47
  positionSide: PositionSideSchema,
52
48
  orderType: OrderTypeSchema,
@@ -55,6 +51,8 @@ const SimulateOrderRiskRequestSchema = z.object({
55
51
  leverage: PositiveDecimalStringSchema,
56
52
  reduceOnly: z.boolean().optional(),
57
53
  });
54
+ const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict();
55
+ const SimulateAutoMarginOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(AutoMarginBucketRequestSchema).strict();
58
56
  export const SimulateOrderRiskSchema = z
59
57
  .object({
60
58
  marginAccountId: UUIDSchema,
@@ -66,7 +64,7 @@ export const SimulateOrderRiskSchema = z
66
64
  });
67
65
  export const SimulateAutoMarginOrderRiskSchema = z
68
66
  .object({
69
- request: SimulateOrderRiskRequestSchema,
67
+ request: SimulateAutoMarginOrderRiskRequestSchema,
70
68
  })
71
69
  .refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
72
70
  message: "price is required for LIMIT risk simulations",
@@ -67,3 +67,10 @@ export declare const GetUserTradesSchema: z.ZodObject<{
67
67
  page_size: z.ZodOptional<z.ZodNumber>;
68
68
  trading_pair_id: z.ZodOptional<z.ZodUUID>;
69
69
  }, z.core.$strip>;
70
+ export declare const ListFundingPaymentsSchema: z.ZodObject<{
71
+ page: z.ZodOptional<z.ZodNumber>;
72
+ page_size: z.ZodOptional<z.ZodNumber>;
73
+ trading_pair_id: z.ZodOptional<z.ZodUUID>;
74
+ position_id: z.ZodOptional<z.ZodUUID>;
75
+ margin_account_id: z.ZodOptional<z.ZodUUID>;
76
+ }, z.core.$strip>;
@@ -42,3 +42,10 @@ export const GetUserTradesSchema = z.object({
42
42
  page_size: 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(),
43
43
  trading_pair_id: UUIDSchema.optional(),
44
44
  });
45
+ export const ListFundingPaymentsSchema = z.object({
46
+ page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
47
+ page_size: 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(),
48
+ trading_pair_id: UUIDSchema.optional(),
49
+ position_id: UUIDSchema.optional(),
50
+ margin_account_id: UUIDSchema.optional(),
51
+ });
@@ -101,6 +101,8 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
101
101
  FOK: "FOK";
102
102
  }>>;
103
103
  marginAccountId: z.ZodOptional<z.ZodUUID>;
104
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
105
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
104
106
  strategyKey: z.ZodOptional<z.ZodString>;
105
107
  positionSide: z.ZodOptional<z.ZodEnum<{
106
108
  LONG: "LONG";
@@ -156,6 +158,8 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
156
158
  }>>;
157
159
  slippageTolerance: z.ZodOptional<z.ZodNumber>;
158
160
  marginAccountId: z.ZodOptional<z.ZodUUID>;
161
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
162
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
159
163
  strategyKey: z.ZodOptional<z.ZodString>;
160
164
  positionSide: z.ZodOptional<z.ZodEnum<{
161
165
  LONG: "LONG";
@@ -266,39 +270,6 @@ export declare const ClosePositionSideSchema: z.ZodEnum<{
266
270
  LONG: "LONG";
267
271
  SHORT: "SHORT";
268
272
  }>;
269
- export declare const CreateConditionalOrderSchema: z.ZodObject<{
270
- tradingPairId: z.ZodUUID;
271
- marginAccountId: z.ZodUUID;
272
- conditionType: z.ZodEnum<{
273
- STOP_LOSS: "STOP_LOSS";
274
- TAKE_PROFIT: "TAKE_PROFIT";
275
- }>;
276
- triggerPrice: z.ZodString;
277
- triggerSource: z.ZodOptional<z.ZodEnum<{
278
- MARK_PRICE: "MARK_PRICE";
279
- }>>;
280
- side: z.ZodEnum<{
281
- BUY: "BUY";
282
- SELL: "SELL";
283
- }>;
284
- positionSide: z.ZodEnum<{
285
- LONG: "LONG";
286
- SHORT: "SHORT";
287
- }>;
288
- orderType: z.ZodEnum<{
289
- LIMIT: "LIMIT";
290
- MARKET: "MARKET";
291
- }>;
292
- limitPrice: z.ZodOptional<z.ZodString>;
293
- quantity: z.ZodOptional<z.ZodString>;
294
- reduceOnly: z.ZodOptional<z.ZodBoolean>;
295
- timeInForce: z.ZodOptional<z.ZodEnum<{
296
- GTC: "GTC";
297
- IOC: "IOC";
298
- }>>;
299
- slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
300
- expiresAt: z.ZodOptional<z.ZodISODateTime>;
301
- }, z.core.$strip>;
302
273
  export declare const CancelConditionalOrderSchema: z.ZodObject<{
303
274
  conditionalOrderId: z.ZodUUID;
304
275
  }, z.core.$strip>;
@@ -349,6 +320,8 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
349
320
  FOK: "FOK";
350
321
  }>>;
351
322
  marginAccountId: z.ZodOptional<z.ZodUUID>;
323
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
324
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
352
325
  strategyKey: z.ZodOptional<z.ZodString>;
353
326
  positionSide: z.ZodOptional<z.ZodEnum<{
354
327
  LONG: "LONG";
@@ -389,6 +362,8 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
389
362
  FOK: "FOK";
390
363
  }>>;
391
364
  marginAccountId: z.ZodOptional<z.ZodUUID>;
365
+ marginBucketId: z.ZodOptional<z.ZodUUID>;
366
+ marginBucketCollateral: z.ZodOptional<z.ZodString>;
392
367
  strategyKey: z.ZodOptional<z.ZodString>;
393
368
  positionSide: z.ZodOptional<z.ZodEnum<{
394
369
  LONG: "LONG";
@@ -117,6 +117,8 @@ export const PlaceLimitOrderSchema = z
117
117
  expirationDate: ISO8601DateSchema.optional(),
118
118
  timeInForce: TimeInForceSchema.optional(),
119
119
  marginAccountId: UUIDSchema.optional(),
120
+ marginBucketId: UUIDSchema.optional(),
121
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
120
122
  strategyKey: z.string().min(1).max(128).optional(),
121
123
  positionSide: PositionSideSchema.optional(),
122
124
  leverage: PositiveDecimalStringSchema.optional(),
@@ -145,6 +147,18 @@ export const PlaceLimitOrderSchema = z
145
147
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
146
148
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
147
149
  path: ["options", "reduceOnly"],
150
+ })
151
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
152
+ message: "marginBucketCollateral is only supported for MARGIN orders",
153
+ path: ["options", "tradingMode"],
154
+ })
155
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.marginBucketId === undefined, {
156
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
157
+ path: ["options", "marginBucketId"],
158
+ })
159
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
160
+ message: "reduceOnly orders cannot create a new margin bucket",
161
+ path: ["options", "reduceOnly"],
148
162
  });
149
163
  /**
150
164
  * Place Market Order validation schema
@@ -159,6 +173,8 @@ export const PlaceMarketOrderSchema = z
159
173
  tradingMode: TradingModeSchema.optional(),
160
174
  slippageTolerance: SlippageToleranceSchema,
161
175
  marginAccountId: UUIDSchema.optional(),
176
+ marginBucketId: UUIDSchema.optional(),
177
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
162
178
  strategyKey: z.string().min(1).max(128).optional(),
163
179
  positionSide: PositionSideSchema.optional(),
164
180
  leverage: PositiveDecimalStringSchema.optional(),
@@ -187,6 +203,18 @@ export const PlaceMarketOrderSchema = z
187
203
  .refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
188
204
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
189
205
  path: ["options", "reduceOnly"],
206
+ })
207
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
208
+ message: "marginBucketCollateral is only supported for MARGIN orders",
209
+ path: ["options", "tradingMode"],
210
+ })
211
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.marginBucketId === undefined, {
212
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
213
+ path: ["options", "marginBucketId"],
214
+ })
215
+ .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
216
+ message: "reduceOnly orders cannot create a new margin bucket",
217
+ path: ["options", "reduceOnly"],
190
218
  });
191
219
  /**
192
220
  * Cancel Order validation schema
@@ -240,39 +268,6 @@ export const ConditionalOrderStateSchema = z.enum(["PENDING_PARENT", "ACTIVE", "
240
268
  export const ClosePositionSideSchema = z.enum(["LONG", "SHORT"], {
241
269
  message: 'Position side must be "LONG" or "SHORT"',
242
270
  });
243
- export const CreateConditionalOrderSchema = z
244
- .object({
245
- tradingPairId: UUIDSchema,
246
- marginAccountId: UUIDSchema,
247
- conditionType: ConditionalOrderConditionTypeSchema,
248
- triggerPrice: PositiveDecimalStringSchema,
249
- triggerSource: ConditionalOrderTriggerSourceSchema.optional(),
250
- side: OrderSideSchema,
251
- positionSide: ClosePositionSideSchema,
252
- orderType: OrderTypeSchema,
253
- limitPrice: PositiveDecimalStringSchema.optional(),
254
- quantity: PositiveDecimalStringSchema.optional(),
255
- reduceOnly: z.boolean().optional(),
256
- timeInForce: ConditionalTimeInForceSchema.optional(),
257
- slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
258
- expiresAt: ISO8601DateSchema.optional(),
259
- })
260
- .refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
261
- message: "limitPrice is required for LIMIT conditional orders",
262
- path: ["limitPrice"],
263
- })
264
- .refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
265
- message: "limitPrice must not be provided for MARKET conditional orders",
266
- path: ["limitPrice"],
267
- })
268
- .refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
269
- message: "timeInForce is only allowed for LIMIT conditional orders",
270
- path: ["timeInForce"],
271
- })
272
- .refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
273
- message: "slippageToleranceBps is only allowed for MARKET conditional orders",
274
- path: ["slippageToleranceBps"],
275
- });
276
271
  export const CancelConditionalOrderSchema = z.object({
277
272
  conditionalOrderId: UUIDSchema,
278
273
  });
@@ -303,6 +298,8 @@ export const BatchCreateOrderItemSchema = z
303
298
  expirationDate: ISO8601DateSchema.optional(),
304
299
  timeInForce: TimeInForceSchema.optional(),
305
300
  marginAccountId: UUIDSchema.optional(),
301
+ marginBucketId: UUIDSchema.optional(),
302
+ marginBucketCollateral: PositiveDecimalStringSchema.optional(),
306
303
  strategyKey: z.string().min(1).max(128).optional(),
307
304
  positionSide: PositionSideSchema.optional(),
308
305
  leverage: PositiveDecimalStringSchema.optional(),
@@ -315,6 +312,18 @@ export const BatchCreateOrderItemSchema = z
315
312
  .refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
316
313
  message: "Price must not be provided for MARKET orders",
317
314
  path: ["price"],
315
+ })
316
+ .refine((data) => data.marginBucketCollateral === undefined || data.tradingMode === "MARGIN", {
317
+ message: "marginBucketCollateral is only supported for MARGIN orders",
318
+ path: ["tradingMode"],
319
+ })
320
+ .refine((data) => data.marginBucketCollateral === undefined || data.marginBucketId === undefined, {
321
+ message: "marginBucketCollateral creates a new bucket and cannot be combined with marginBucketId",
322
+ path: ["marginBucketId"],
323
+ })
324
+ .refine((data) => data.marginBucketCollateral === undefined || data.reduceOnly !== true, {
325
+ message: "reduceOnly orders cannot create a new margin bucket",
326
+ path: ["reduceOnly"],
318
327
  })
319
328
  .refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
320
329
  message: "positionSide is required for MARGIN orders",
@@ -44,6 +44,10 @@ export declare const DepositSchema: z.ZodObject<{
44
44
  assetId: z.ZodUUID;
45
45
  amount: z.ZodUnion<readonly [z.ZodString, z.ZodBigInt]>;
46
46
  autoWait: z.ZodOptional<z.ZodBoolean>;
47
+ target: z.ZodOptional<z.ZodEnum<{
48
+ spot: "spot";
49
+ margin: "margin";
50
+ }>>;
47
51
  }, z.core.$strip>;
48
52
  /**
49
53
  * Withdraw validation schema.
@@ -57,6 +57,8 @@ export const DepositSchema = z.object({
57
57
  assetId: UUIDSchema,
58
58
  amount: PositiveBigIntStringSchema,
59
59
  autoWait: z.boolean().optional(),
60
+ // Destination ledger: "spot" (default) or "margin" to route into margin collateral.
61
+ target: z.enum(["spot", "margin"]).optional(),
60
62
  });
61
63
  /**
62
64
  * Withdraw validation schema.
@@ -5,6 +5,15 @@
5
5
  */
6
6
  import type { BaseAPI } from "../api/index";
7
7
  import type { Balance, TransactionResult, WithdrawResult } from "./responses";
8
+ /**
9
+ * Destination ledger for a deposit.
10
+ * - `"spot"` (default): credit the spot/main wallet — unchanged behavior.
11
+ * - `"margin"`: route the deposit straight into the parent margin account's
12
+ * collateral (auto-creating the account if it does not exist yet). A deposit
13
+ * that cannot be routed to margin (unsupported asset, etc.) safely falls back
14
+ * to spot — funds are never lost.
15
+ */
16
+ export type DepositTarget = "spot" | "margin";
8
17
  /**
9
18
  * Vault API interface.
10
19
  * Provides methods for managing token deposits and withdrawals.
@@ -24,9 +33,12 @@ export interface VaultAPI extends BaseAPI {
24
33
  * @param assetId - Asset identifier (UUID) to deposit
25
34
  * @param amount - Amount to deposit
26
35
  * @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
36
+ * @param target - Destination ledger: `"spot"` (default) or `"margin"` to
37
+ * route the deposit into the parent margin account's collateral. Margin
38
+ * deposits that cannot be routed fall back to spot.
27
39
  * @returns Promise resolving to the transaction result
28
40
  */
29
- deposit(assetId: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
41
+ deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
30
42
  /**
31
43
  * Initiates a withdrawal: allocates a `withdrawalIndex` via the API Gateway,
32
44
  * receives pre-signed calldata for `executeSignedWithdrawal(...)`, and
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
11
+ import type { BaseAPI } from "../api";
12
+ /** Body for a whitelist application. */
13
+ export interface SubmitWhitelistRequest {
14
+ /** Applicant wallet address (0x-prefixed, 40 hex chars) */
15
+ wallet_address: string;
16
+ /** Applicant email address */
17
+ email: string;
18
+ /** Applicant Twitter/X username (1-15 chars) */
19
+ twitter_username?: string;
20
+ /** Applicant Telegram username (5-32 chars) */
21
+ telegram_username?: string;
22
+ }
23
+ /** Response to a whitelist application. */
24
+ export interface SubmitWhitelistResponse {
25
+ /** Human-readable status message */
26
+ message: string;
27
+ /** Created user UUID (pending approval) */
28
+ user_id: string | null;
29
+ }
30
+ /**
31
+ * Whitelist API interface. The submit endpoint is public (no auth required).
32
+ */
33
+ export interface WhitelistAPI extends BaseAPI {
34
+ /**
35
+ * Submits a whitelist (waitlist) application.
36
+ *
37
+ * Public/unauthenticated. The server validates and de-duplicates by wallet
38
+ * address and email, creating an inactive user pending approval.
39
+ *
40
+ * @param body - Applicant details
41
+ * @returns Promise resolving to the status message and created user id
42
+ */
43
+ submit(body: SubmitWhitelistRequest): Promise<SubmitWhitelistResponse>;
44
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Compile-time helpers that tie the hand-written ergonomic SDK types to the
3
+ * generated wire schema in `./schema.ts`.
4
+ *
5
+ * Everything here lives purely at the type level — there is no runtime output —
6
+ * so a field the OpenAPI spec gains but an ergonomic type forgot to declare
7
+ * becomes a `tsc` error. This is the type-checking half of the MON-1476 drift
8
+ * tripwire (the other half is the CI fail-on-diff check on the generated
9
+ * `schema.ts`). See `./README.md` for how to register a new type.
10
+ */
11
+ import type { components } from "./schema";
12
+ /** All schema component types generated from the OpenAPI spec. */
13
+ export type WireSchemas = components["schemas"];
14
+ /** A single generated wire schema, addressed by its OpenAPI component name. */
15
+ export type WireSchema<K extends keyof WireSchemas> = WireSchemas[K];
16
+ /** Strip every `_` from a string-literal type: `a_b_c` -> `abc`. */
17
+ type StripUnderscores<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${StripUnderscores<Tail>}` : S;
18
+ /**
19
+ * Canonical form of a field name: lower-cased and underscore-free, so that
20
+ * snake_case (`available_balance`) and camelCase (`availableBalance`) names
21
+ * collapse to the same key. This lets the coverage check ignore the casing
22
+ * convention a given ergonomic domain happens to use.
23
+ *
24
+ * Caveat: names that differ only by case (e.g. `T` vs `t`) collapse together —
25
+ * do not register types that rely on such a distinction.
26
+ */
27
+ type CanonicalKey<S extends string> = Lowercase<StripUnderscores<S>>;
28
+ /** Re-key an object type by the canonical form of each of its string keys. */
29
+ type CanonicalKeys<T> = {
30
+ [K in keyof T as K extends string ? CanonicalKey<K> : never]: true;
31
+ };
32
+ /** Canonical wire field names that the ergonomic type `Ergo` does not declare. */
33
+ export type MissingWireFields<Ergo, Wire> = Exclude<keyof CanonicalKeys<Wire>, keyof CanonicalKeys<Ergo>>;
34
+ /**
35
+ * Resolves to `true` when `Ergo` declares every field the wire schema `Wire`
36
+ * has (comparing canonical names, so casing/underscore style is irrelevant and
37
+ * ergonomic enrichments — extra fields, bigint/branded value types — are
38
+ * allowed). Otherwise resolves to an error object naming the missing fields, so
39
+ * a failing {@link Expect} points straight at the drift.
40
+ */
41
+ export type WireCovered<Ergo, Wire> = [MissingWireFields<Ergo, Wire>] extends [never] ? true : {
42
+ __MISSING_WIRE_FIELDS__: MissingWireFields<Ergo, Wire>;
43
+ };
44
+ /**
45
+ * Assertion sink. `Expect<WireCovered<Ergo, Wire>>` is a type alias that only
46
+ * type-checks when its argument is exactly `true`, emitting no runtime code:
47
+ *
48
+ * type _Balance = Expect<WireCovered<AccountBalance, WireSchema<"AccountBalance">>>;
49
+ *
50
+ * If `WireCovered` resolves to the error object, `T extends true` fails and
51
+ * `tsc` reports the missing wire fields at this line.
52
+ */
53
+ export type Expect<T extends true> = T;
54
+ export {};
File without changes
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { type OperationId } from "./operations";
22
+ import type { operations } from "./schema";
23
+ /** A surface's coverage registries (the two maps exported by its `coverage.ts`). */
24
+ export interface SurfaceClassification {
25
+ /** operationId → the SDK symbol (method/hook/tool) that covers it. */
26
+ covered: Partial<Record<keyof operations, string>>;
27
+ /** operationId → the reason it is intentionally not covered. */
28
+ excluded: Partial<Record<keyof operations, string>>;
29
+ }
30
+ /** Result of auditing one surface's classification against the spec. */
31
+ export interface CoverageAudit {
32
+ /** operationIds in the spec that appear in neither `covered` nor `excluded`. */
33
+ unclassified: OperationId[];
34
+ /** operationIds listed in BOTH `covered` and `excluded`. */
35
+ duplicated: string[];
36
+ /** Registry keys that are not (or no longer) real operationIds. */
37
+ unknown: string[];
38
+ /** True when the surface classifies every operationId exactly once. */
39
+ ok: boolean;
40
+ }
41
+ /**
42
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
43
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
44
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
45
+ * exercise synthetic op sets.
46
+ */
47
+ export declare function auditSurface(classification: SurfaceClassification, operationIds?: readonly string[]): CoverageAudit;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { OPERATION_IDS } from "./operations";
22
+ /**
23
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
24
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
25
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
26
+ * exercise synthetic op sets.
27
+ */
28
+ export function auditSurface(classification, operationIds = OPERATION_IDS) {
29
+ const covered = Object.keys(classification.covered);
30
+ const excluded = Object.keys(classification.excluded);
31
+ const all = new Set(operationIds);
32
+ const classified = new Set([...covered, ...excluded]);
33
+ const excludedSet = new Set(excluded);
34
+ const unclassified = operationIds.filter((op) => !classified.has(op));
35
+ const duplicated = covered.filter((op) => excludedSet.has(op)).sort();
36
+ const unknown = [...new Set([...covered, ...excluded].filter((op) => !all.has(op)))].sort();
37
+ return {
38
+ unclassified: unclassified,
39
+ duplicated,
40
+ unknown,
41
+ ok: unclassified.length === 0 && duplicated.length === 0 && unknown.length === 0,
42
+ };
43
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes