@0xmonaco/types 0.8.11 → 0.8.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/applications/requests.d.ts +15 -15
  2. package/dist/applications/responses.d.ts +57 -56
  3. package/dist/auth/responses.d.ts +2 -1
  4. package/dist/contracts/balances.d.ts +1 -1
  5. package/dist/delegated-agents/index.d.ts +22 -21
  6. package/dist/faucet/index.d.ts +4 -4
  7. package/dist/fees/index.d.ts +4 -4
  8. package/dist/fees/responses.d.ts +17 -17
  9. package/dist/fees/responses.js +20 -20
  10. package/dist/margin-accounts/index.d.ts +78 -46
  11. package/dist/market/index.d.ts +132 -129
  12. package/dist/positions/index.d.ts +67 -45
  13. package/dist/profile/index.d.ts +92 -89
  14. package/dist/sdk/index.d.ts +3 -3
  15. package/dist/sub-accounts/index.d.ts +22 -21
  16. package/dist/trading/index.d.ts +6 -6
  17. package/dist/trading/orders.d.ts +20 -20
  18. package/dist/trading/responses.d.ts +79 -79
  19. package/dist/validation/margin-accounts.d.ts +47 -5
  20. package/dist/validation/margin-accounts.js +34 -8
  21. package/dist/validation/market.d.ts +1 -1
  22. package/dist/validation/market.js +1 -1
  23. package/dist/validation/positions.d.ts +11 -7
  24. package/dist/validation/positions.js +10 -6
  25. package/dist/validation/profile.d.ts +10 -10
  26. package/dist/validation/profile.js +10 -10
  27. package/dist/validation/trading.d.ts +17 -17
  28. package/dist/validation/trading.js +36 -36
  29. package/dist/validation/vault.d.ts +4 -0
  30. package/dist/validation/vault.js +1 -0
  31. package/dist/vault/index.d.ts +33 -12
  32. package/dist/vault/responses.d.ts +50 -12
  33. package/dist/websocket/events/balance-events.d.ts +2 -1
  34. package/dist/websocket/events/movement-events.d.ts +2 -1
  35. package/dist/whitelist/index.d.ts +4 -4
  36. package/dist/wire/operations.d.ts +1 -1
  37. package/dist/wire/operations.js +9 -2
  38. package/dist/wire/schema.d.ts +1323 -853
  39. package/dist/withdrawals/index.d.ts +83 -12
  40. package/package.json +2 -2
@@ -5,7 +5,7 @@ import { z } from "zod";
5
5
  import { OrderSideSchema, OrderTypeSchema, PositionSideSchema, PositiveDecimalStringSchema, UUIDSchema } from "./trading";
6
6
  const PaginationSchema = z.object({
7
7
  page: z.number().int().min(1, "Page must be at least 1").optional(),
8
- page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
8
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
9
9
  });
10
10
  export const ListMarginAccountsSchema = PaginationSchema.extend({
11
11
  state: z.string().trim().min(1, "State cannot be empty").optional(),
@@ -15,6 +15,11 @@ export const GetMarginAccountSummarySchema = z.object({
15
15
  marginAccountId: UUIDSchema,
16
16
  tradingPairId: UUIDSchema.optional(),
17
17
  });
18
+ export const GetParentMarginAccountSummarySchema = z
19
+ .object({
20
+ tradingPairId: UUIDSchema.optional(),
21
+ })
22
+ .optional();
18
23
  export const GetAvailableCollateralSchema = z
19
24
  .object({
20
25
  asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
@@ -26,7 +31,11 @@ const TransferCollateralRequestSchema = z.object({
26
31
  tradingPairId: UUIDSchema.optional(),
27
32
  strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
28
33
  });
29
- const AutoMarginBucketRequestSchema = z.object({
34
+ const ParentMarginAccountCollateralRequestSchema = z.object({
35
+ asset: z.string().trim().min(1, "Asset cannot be empty"),
36
+ amount: PositiveDecimalStringSchema,
37
+ });
38
+ const RiskBucketRequestSchema = z.object({
30
39
  tradingPairId: UUIDSchema,
31
40
  strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
32
41
  });
@@ -34,13 +43,22 @@ export const TransferCollateralSchema = z.object({
34
43
  marginAccountId: UUIDSchema,
35
44
  request: TransferCollateralRequestSchema,
36
45
  });
37
- export const TransferCollateralToAutoMarginAccountSchema = z.object({
38
- request: TransferCollateralRequestSchema.merge(AutoMarginBucketRequestSchema),
46
+ export const TransferCollateralToParentMarginAccountSchema = z.object({
47
+ request: ParentMarginAccountCollateralRequestSchema,
48
+ });
49
+ export const TransferCollateralToRiskBucketSchema = z.object({
50
+ request: ParentMarginAccountCollateralRequestSchema.merge(RiskBucketRequestSchema),
51
+ });
52
+ export const TransferCollateralFromParentMarginAccountSchema = z.object({
53
+ request: ParentMarginAccountCollateralRequestSchema,
39
54
  });
40
55
  export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
41
56
  marginAccountId: UUIDSchema,
42
- movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
57
+ movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
43
58
  });
59
+ export const GetParentMarginAccountMovementsSchema = PaginationSchema.extend({
60
+ movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
61
+ }).optional();
44
62
  const BaseSimulateOrderRiskRequestSchema = z.object({
45
63
  tradingPairId: UUIDSchema,
46
64
  side: OrderSideSchema,
@@ -52,7 +70,7 @@ const BaseSimulateOrderRiskRequestSchema = z.object({
52
70
  reduceOnly: z.boolean().optional(),
53
71
  });
54
72
  const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict();
55
- const SimulateAutoMarginOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(AutoMarginBucketRequestSchema).strict();
73
+ const SimulateRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(RiskBucketRequestSchema).strict();
56
74
  export const SimulateOrderRiskSchema = z
57
75
  .object({
58
76
  marginAccountId: UUIDSchema,
@@ -62,9 +80,17 @@ export const SimulateOrderRiskSchema = z
62
80
  message: "price is required for LIMIT risk simulations",
63
81
  path: ["request", "price"],
64
82
  });
65
- export const SimulateAutoMarginOrderRiskSchema = z
83
+ export const SimulateParentMarginOrderRiskSchema = z
84
+ .object({
85
+ request: SimulateOrderRiskRequestSchema,
86
+ })
87
+ .refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
88
+ message: "price is required for LIMIT risk simulations",
89
+ path: ["request", "price"],
90
+ });
91
+ export const SimulateRiskBucketOrderRiskSchema = z
66
92
  .object({
67
- request: SimulateAutoMarginOrderRiskRequestSchema,
93
+ request: SimulateRiskBucketOrderRiskRequestSchema,
68
94
  })
69
95
  .refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
70
96
  message: "price is required for LIMIT risk simulations",
@@ -203,7 +203,7 @@ export declare const GetTradingPairSchema: z.ZodObject<{
203
203
  */
204
204
  export declare const SearchTradingPairsSchema: z.ZodObject<{
205
205
  query: z.ZodOptional<z.ZodString>;
206
- page_size: z.ZodOptional<z.ZodNumber>;
206
+ pageSize: z.ZodOptional<z.ZodNumber>;
207
207
  page: z.ZodOptional<z.ZodNumber>;
208
208
  }, z.core.$strip>;
209
209
  /**
@@ -214,7 +214,7 @@ export const GetTradingPairSchema = z.object({
214
214
  */
215
215
  export const SearchTradingPairsSchema = z.object({
216
216
  query: z.string().min(1, "Search query cannot be empty").optional(),
217
- page_size: z.number().int().min(1).max(100).optional(),
217
+ pageSize: z.number().int().min(1).max(100).optional(),
218
218
  page: z.number().int().min(1).optional(),
219
219
  });
220
220
  /**
@@ -4,9 +4,9 @@
4
4
  import { z } from "zod";
5
5
  export declare const ListPositionsSchema: z.ZodObject<{
6
6
  page: z.ZodOptional<z.ZodNumber>;
7
- page_size: z.ZodOptional<z.ZodNumber>;
8
- margin_account_id: z.ZodOptional<z.ZodUUID>;
9
- trading_pair_id: z.ZodOptional<z.ZodUUID>;
7
+ pageSize: z.ZodOptional<z.ZodNumber>;
8
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
9
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
10
10
  status: z.ZodOptional<z.ZodEnum<{
11
11
  OPEN: "OPEN";
12
12
  CLOSED: "CLOSED";
@@ -29,6 +29,10 @@ export declare const ClosePositionSchema: z.ZodObject<{
29
29
  quantity: z.ZodOptional<z.ZodString>;
30
30
  }, z.core.$strip>;
31
31
  }, z.core.$strip>;
32
+ export declare const BatchCloseAllSchema: z.ZodObject<{
33
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
34
+ slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$strip>;
32
36
  export declare const GetPositionRiskSchema: z.ZodObject<{
33
37
  positionId: z.ZodUUID;
34
38
  }, z.core.$strip>;
@@ -82,8 +86,8 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
82
86
  }, z.core.$strip>;
83
87
  export declare const ListPositionHistorySchema: z.ZodObject<{
84
88
  page: z.ZodOptional<z.ZodNumber>;
85
- page_size: z.ZodOptional<z.ZodNumber>;
86
- position_id: z.ZodOptional<z.ZodUUID>;
87
- margin_account_id: z.ZodOptional<z.ZodUUID>;
88
- trading_pair_id: z.ZodOptional<z.ZodUUID>;
89
+ pageSize: z.ZodOptional<z.ZodNumber>;
90
+ positionId: z.ZodOptional<z.ZodUUID>;
91
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
92
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
89
93
  }, z.core.$strip>;
@@ -5,7 +5,7 @@ import { z } from "zod";
5
5
  import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, UUIDSchema, } from "./trading";
6
6
  const PaginationSchema = z.object({
7
7
  page: z.number().int().min(1, "Page must be at least 1").optional(),
8
- page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
8
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
9
9
  });
10
10
  const PositionStatusSchema = z.enum(["OPEN", "CLOSED", "LIQUIDATING"], {
11
11
  message: 'Position status must be "OPEN", "CLOSED", or "LIQUIDATING"',
@@ -17,8 +17,8 @@ const PositionIdSchema = z.object({
17
17
  positionId: UUIDSchema,
18
18
  });
19
19
  export const ListPositionsSchema = PaginationSchema.extend({
20
- margin_account_id: UUIDSchema.optional(),
21
- trading_pair_id: UUIDSchema.optional(),
20
+ marginAccountId: UUIDSchema.optional(),
21
+ tradingPairId: UUIDSchema.optional(),
22
22
  status: PositionStatusSchema.optional(),
23
23
  });
24
24
  export const GetPositionSchema = PositionIdSchema;
@@ -38,6 +38,10 @@ export const ClosePositionSchema = PositionIdSchema.extend({
38
38
  message: "limitPrice is only allowed for LIMIT close requests",
39
39
  path: ["request", "limitPrice"],
40
40
  });
41
+ export const BatchCloseAllSchema = z.object({
42
+ tradingPairId: UUIDSchema.optional(),
43
+ slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
44
+ });
41
45
  export const GetPositionRiskSchema = PositionIdSchema;
42
46
  export const AddPositionMarginSchema = PositionIdSchema.extend({
43
47
  request: z.object({
@@ -87,7 +91,7 @@ export const AttachPositionTpSlSchema = PositionIdSchema.extend({
87
91
  }),
88
92
  });
89
93
  export const ListPositionHistorySchema = PaginationSchema.extend({
90
- position_id: UUIDSchema.optional(),
91
- margin_account_id: UUIDSchema.optional(),
92
- trading_pair_id: UUIDSchema.optional(),
94
+ positionId: UUIDSchema.optional(),
95
+ marginAccountId: UUIDSchema.optional(),
96
+ tradingPairId: UUIDSchema.optional(),
93
97
  });
@@ -36,15 +36,15 @@ export declare const TransactionTypeSchema: z.ZodEnum<{
36
36
  */
37
37
  export declare const GetUserMovementsSchema: z.ZodObject<{
38
38
  page: z.ZodOptional<z.ZodNumber>;
39
- page_size: z.ZodOptional<z.ZodNumber>;
40
- entry_type: z.ZodOptional<z.ZodEnum<{
39
+ pageSize: z.ZodOptional<z.ZodNumber>;
40
+ entryType: z.ZodOptional<z.ZodEnum<{
41
41
  CREDIT: "CREDIT";
42
42
  DEBIT: "DEBIT";
43
43
  LOCK: "LOCK";
44
44
  UNLOCK: "UNLOCK";
45
45
  FEE: "FEE";
46
46
  }>>;
47
- transaction_type: z.ZodOptional<z.ZodEnum<{
47
+ transactionType: z.ZodOptional<z.ZodEnum<{
48
48
  FEE: "FEE";
49
49
  DEPOSIT: "DEPOSIT";
50
50
  WITHDRAWAL: "WITHDRAWAL";
@@ -54,7 +54,7 @@ export declare const GetUserMovementsSchema: z.ZodObject<{
54
54
  INTEREST: "INTEREST";
55
55
  REWARD: "REWARD";
56
56
  }>>;
57
- asset_id: z.ZodOptional<z.ZodUUID>;
57
+ assetId: z.ZodOptional<z.ZodUUID>;
58
58
  }, z.core.$strip>;
59
59
  /**
60
60
  * Get User Trades validation schema
@@ -64,13 +64,13 @@ export declare const GetUserMovementsSchema: z.ZodObject<{
64
64
  */
65
65
  export declare const GetUserTradesSchema: z.ZodObject<{
66
66
  page: z.ZodOptional<z.ZodNumber>;
67
- page_size: z.ZodOptional<z.ZodNumber>;
68
- trading_pair_id: z.ZodOptional<z.ZodUUID>;
67
+ pageSize: z.ZodOptional<z.ZodNumber>;
68
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
69
69
  }, z.core.$strip>;
70
70
  export declare const ListFundingPaymentsSchema: z.ZodObject<{
71
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>;
72
+ pageSize: z.ZodOptional<z.ZodNumber>;
73
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
74
+ positionId: z.ZodOptional<z.ZodUUID>;
75
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
76
76
  }, z.core.$strip>;
@@ -26,10 +26,10 @@ export const TransactionTypeSchema = z.enum(["DEPOSIT", "WITHDRAWAL", "TRADE", "
26
26
  */
27
27
  export const GetUserMovementsSchema = z.object({
28
28
  page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
29
- 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(),
30
- entry_type: LedgerEntryTypeSchema.optional(),
31
- transaction_type: TransactionTypeSchema.optional(),
32
- asset_id: UUIDSchema.optional(),
29
+ 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(),
30
+ entryType: LedgerEntryTypeSchema.optional(),
31
+ transactionType: TransactionTypeSchema.optional(),
32
+ assetId: UUIDSchema.optional(),
33
33
  });
34
34
  /**
35
35
  * Get User Trades validation schema
@@ -39,13 +39,13 @@ export const GetUserMovementsSchema = z.object({
39
39
  */
40
40
  export const GetUserTradesSchema = z.object({
41
41
  page: z.number().int("Page must be an integer").min(1, "Page must be at least 1").optional(),
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
- trading_pair_id: UUIDSchema.optional(),
42
+ 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(),
43
+ tradingPairId: UUIDSchema.optional(),
44
44
  });
45
45
  export const ListFundingPaymentsSchema = z.object({
46
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(),
47
+ 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(),
48
+ tradingPairId: UUIDSchema.optional(),
49
+ positionId: UUIDSchema.optional(),
50
+ marginAccountId: UUIDSchema.optional(),
51
51
  });
@@ -101,8 +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
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
105
+ riskBucketCollateral: z.ZodOptional<z.ZodString>;
106
106
  strategyKey: z.ZodOptional<z.ZodString>;
107
107
  positionSide: z.ZodOptional<z.ZodEnum<{
108
108
  LONG: "LONG";
@@ -158,8 +158,8 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
158
158
  }>>;
159
159
  slippageTolerance: z.ZodOptional<z.ZodNumber>;
160
160
  marginAccountId: z.ZodOptional<z.ZodUUID>;
161
- marginBucketId: z.ZodOptional<z.ZodUUID>;
162
- marginBucketCollateral: z.ZodOptional<z.ZodString>;
161
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
162
+ riskBucketCollateral: z.ZodOptional<z.ZodString>;
163
163
  strategyKey: z.ZodOptional<z.ZodString>;
164
164
  positionSide: z.ZodOptional<z.ZodEnum<{
165
165
  LONG: "LONG";
@@ -226,9 +226,9 @@ export declare const ReplaceOrderSchema: z.ZodObject<{
226
226
  * Validates parameters for fetching paginated orders.
227
227
  * Matches the getPaginatedOrders method signature which accepts:
228
228
  * - status: OrderStatus (optional filter)
229
- * - trading_pair_id: trading pair UUID (optional filter)
229
+ * - tradingPairId: trading pair UUID (optional filter)
230
230
  * - page: number (default: 1)
231
- * - page_size: number (default: 10, max: 100)
231
+ * - pageSize: number (default: 10, max: 100)
232
232
  */
233
233
  export declare const GetPaginatedOrdersSchema: z.ZodObject<{
234
234
  status: z.ZodOptional<z.ZodEnum<{
@@ -241,14 +241,14 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
241
241
  REJECTED: "REJECTED";
242
242
  EXPIRED: "EXPIRED";
243
243
  }>>;
244
- trading_pair_id: z.ZodOptional<z.ZodUUID>;
245
- trading_mode: z.ZodOptional<z.ZodEnum<{
244
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
245
+ tradingMode: z.ZodOptional<z.ZodEnum<{
246
246
  SPOT: "SPOT";
247
247
  MARGIN: "MARGIN";
248
248
  }>>;
249
- margin_account_id: z.ZodOptional<z.ZodUUID>;
249
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
250
250
  page: z.ZodOptional<z.ZodNumber>;
251
- page_size: z.ZodOptional<z.ZodNumber>;
251
+ pageSize: z.ZodOptional<z.ZodNumber>;
252
252
  }, z.core.$strip>;
253
253
  export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
254
254
  STOP_LOSS: "STOP_LOSS";
@@ -274,8 +274,8 @@ export declare const CancelConditionalOrderSchema: z.ZodObject<{
274
274
  conditionalOrderId: z.ZodUUID;
275
275
  }, z.core.$strip>;
276
276
  export declare const ListConditionalOrdersSchema: z.ZodObject<{
277
- margin_account_id: z.ZodOptional<z.ZodUUID>;
278
- trading_pair_id: z.ZodOptional<z.ZodUUID>;
277
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
278
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
279
279
  state: z.ZodOptional<z.ZodEnum<{
280
280
  CANCELLED: "CANCELLED";
281
281
  EXPIRED: "EXPIRED";
@@ -286,7 +286,7 @@ export declare const ListConditionalOrdersSchema: z.ZodObject<{
286
286
  FAILED: "FAILED";
287
287
  }>>;
288
288
  page: z.ZodOptional<z.ZodNumber>;
289
- page_size: z.ZodOptional<z.ZodNumber>;
289
+ pageSize: z.ZodOptional<z.ZodNumber>;
290
290
  }, z.core.$strip>;
291
291
  /**
292
292
  * Single batch create order item validation schema
@@ -320,8 +320,8 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
320
320
  FOK: "FOK";
321
321
  }>>;
322
322
  marginAccountId: z.ZodOptional<z.ZodUUID>;
323
- marginBucketId: z.ZodOptional<z.ZodUUID>;
324
- marginBucketCollateral: z.ZodOptional<z.ZodString>;
323
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
324
+ riskBucketCollateral: z.ZodOptional<z.ZodString>;
325
325
  strategyKey: z.ZodOptional<z.ZodString>;
326
326
  positionSide: z.ZodOptional<z.ZodEnum<{
327
327
  LONG: "LONG";
@@ -362,8 +362,8 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
362
362
  FOK: "FOK";
363
363
  }>>;
364
364
  marginAccountId: z.ZodOptional<z.ZodUUID>;
365
- marginBucketId: z.ZodOptional<z.ZodUUID>;
366
- marginBucketCollateral: z.ZodOptional<z.ZodString>;
365
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
366
+ riskBucketCollateral: z.ZodOptional<z.ZodString>;
367
367
  strategyKey: z.ZodOptional<z.ZodString>;
368
368
  positionSide: z.ZodOptional<z.ZodEnum<{
369
369
  LONG: "LONG";
@@ -117,8 +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
+ riskBucketId: UUIDSchema.optional(),
121
+ riskBucketCollateral: PositiveDecimalStringSchema.optional(),
122
122
  strategyKey: z.string().min(1).max(128).optional(),
123
123
  positionSide: PositionSideSchema.optional(),
124
124
  leverage: PositiveDecimalStringSchema.optional(),
@@ -148,16 +148,16 @@ export const PlaceLimitOrderSchema = z
148
148
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
149
149
  path: ["options", "reduceOnly"],
150
150
  })
151
- .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
152
- message: "marginBucketCollateral is only supported for MARGIN orders",
151
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
152
+ message: "riskBucketCollateral is only supported for MARGIN orders",
153
153
  path: ["options", "tradingMode"],
154
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"],
155
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
156
+ message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
157
+ path: ["options", "riskBucketId"],
158
158
  })
159
- .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
160
- message: "reduceOnly orders cannot create a new margin bucket",
159
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.reduceOnly !== true, {
160
+ message: "reduceOnly orders cannot create a new risk bucket",
161
161
  path: ["options", "reduceOnly"],
162
162
  });
163
163
  /**
@@ -173,8 +173,8 @@ export const PlaceMarketOrderSchema = z
173
173
  tradingMode: TradingModeSchema.optional(),
174
174
  slippageTolerance: SlippageToleranceSchema,
175
175
  marginAccountId: UUIDSchema.optional(),
176
- marginBucketId: UUIDSchema.optional(),
177
- marginBucketCollateral: PositiveDecimalStringSchema.optional(),
176
+ riskBucketId: UUIDSchema.optional(),
177
+ riskBucketCollateral: PositiveDecimalStringSchema.optional(),
178
178
  strategyKey: z.string().min(1).max(128).optional(),
179
179
  positionSide: PositionSideSchema.optional(),
180
180
  leverage: PositiveDecimalStringSchema.optional(),
@@ -204,16 +204,16 @@ export const PlaceMarketOrderSchema = z
204
204
  message: "Parent TP/SL cannot be attached to reduceOnly orders",
205
205
  path: ["options", "reduceOnly"],
206
206
  })
207
- .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
208
- message: "marginBucketCollateral is only supported for MARGIN orders",
207
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
208
+ message: "riskBucketCollateral is only supported for MARGIN orders",
209
209
  path: ["options", "tradingMode"],
210
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"],
211
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.riskBucketId === undefined, {
212
+ message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
213
+ path: ["options", "riskBucketId"],
214
214
  })
215
- .refine((data) => data.options?.marginBucketCollateral === undefined || data.options?.reduceOnly !== true, {
216
- message: "reduceOnly orders cannot create a new margin bucket",
215
+ .refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.reduceOnly !== true, {
216
+ message: "reduceOnly orders cannot create a new risk bucket",
217
217
  path: ["options", "reduceOnly"],
218
218
  });
219
219
  /**
@@ -244,17 +244,17 @@ export const ReplaceOrderSchema = z.object({
244
244
  * Validates parameters for fetching paginated orders.
245
245
  * Matches the getPaginatedOrders method signature which accepts:
246
246
  * - status: OrderStatus (optional filter)
247
- * - trading_pair_id: trading pair UUID (optional filter)
247
+ * - tradingPairId: trading pair UUID (optional filter)
248
248
  * - page: number (default: 1)
249
- * - page_size: number (default: 10, max: 100)
249
+ * - pageSize: number (default: 10, max: 100)
250
250
  */
251
251
  export const GetPaginatedOrdersSchema = z.object({
252
252
  status: z.enum(ORDER_STATUS_VALUES).optional(),
253
- trading_pair_id: UUIDSchema.optional(),
254
- trading_mode: TradingModeSchema.optional(),
255
- margin_account_id: UUIDSchema.optional(),
253
+ tradingPairId: UUIDSchema.optional(),
254
+ tradingMode: TradingModeSchema.optional(),
255
+ marginAccountId: UUIDSchema.optional(),
256
256
  page: z.number().int().min(1, "Page must be at least 1").optional(),
257
- page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
257
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
258
258
  });
259
259
  export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
260
260
  message: 'conditionType must be "STOP_LOSS" or "TAKE_PROFIT"',
@@ -272,11 +272,11 @@ export const CancelConditionalOrderSchema = z.object({
272
272
  conditionalOrderId: UUIDSchema,
273
273
  });
274
274
  export const ListConditionalOrdersSchema = z.object({
275
- margin_account_id: UUIDSchema.optional(),
276
- trading_pair_id: UUIDSchema.optional(),
275
+ marginAccountId: UUIDSchema.optional(),
276
+ tradingPairId: UUIDSchema.optional(),
277
277
  state: ConditionalOrderStateSchema.optional(),
278
278
  page: z.number().int().min(1, "Page must be at least 1").optional(),
279
- page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
279
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
280
280
  });
281
281
  /**
282
282
  * Single batch create order item validation schema
@@ -298,8 +298,8 @@ export const BatchCreateOrderItemSchema = z
298
298
  expirationDate: ISO8601DateSchema.optional(),
299
299
  timeInForce: TimeInForceSchema.optional(),
300
300
  marginAccountId: UUIDSchema.optional(),
301
- marginBucketId: UUIDSchema.optional(),
302
- marginBucketCollateral: PositiveDecimalStringSchema.optional(),
301
+ riskBucketId: UUIDSchema.optional(),
302
+ riskBucketCollateral: PositiveDecimalStringSchema.optional(),
303
303
  strategyKey: z.string().min(1).max(128).optional(),
304
304
  positionSide: PositionSideSchema.optional(),
305
305
  leverage: PositiveDecimalStringSchema.optional(),
@@ -313,16 +313,16 @@ export const BatchCreateOrderItemSchema = z
313
313
  message: "Price must not be provided for MARKET orders",
314
314
  path: ["price"],
315
315
  })
316
- .refine((data) => data.marginBucketCollateral === undefined || data.tradingMode === "MARGIN", {
317
- message: "marginBucketCollateral is only supported for MARGIN orders",
316
+ .refine((data) => data.riskBucketCollateral === undefined || data.tradingMode === "MARGIN", {
317
+ message: "riskBucketCollateral is only supported for MARGIN orders",
318
318
  path: ["tradingMode"],
319
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"],
320
+ .refine((data) => data.riskBucketCollateral === undefined || data.riskBucketId === undefined, {
321
+ message: "riskBucketCollateral creates a new risk bucket and cannot be combined with riskBucketId",
322
+ path: ["riskBucketId"],
323
323
  })
324
- .refine((data) => data.marginBucketCollateral === undefined || data.reduceOnly !== true, {
325
- message: "reduceOnly orders cannot create a new margin bucket",
324
+ .refine((data) => data.riskBucketCollateral === undefined || data.reduceOnly !== true, {
325
+ message: "reduceOnly orders cannot create a new risk bucket",
326
326
  path: ["reduceOnly"],
327
327
  })
328
328
  .refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
@@ -61,6 +61,10 @@ export declare const WithdrawSchema: z.ZodObject<{
61
61
  amount: z.ZodUnion<readonly [z.ZodString, z.ZodBigInt]>;
62
62
  destination: z.ZodString;
63
63
  autoWait: z.ZodOptional<z.ZodBoolean>;
64
+ source: z.ZodOptional<z.ZodEnum<{
65
+ spot: "spot";
66
+ margin: "margin";
67
+ }>>;
64
68
  }, z.core.$strip>;
65
69
  /**
66
70
  * Get Balance validation schema
@@ -72,6 +72,7 @@ export const WithdrawSchema = z.object({
72
72
  amount: PositiveBigIntStringSchema,
73
73
  destination: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "destination must be a 0x-prefixed 20-byte hex address"),
74
74
  autoWait: z.boolean().optional(),
75
+ source: z.enum(["spot", "margin"]).optional(),
75
76
  });
76
77
  /**
77
78
  * Get Balance validation schema
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * Types for vault operations including deposits, withdrawals, and balance management.
5
5
  */
6
+ import type { Address } from "viem";
6
7
  import type { BaseAPI } from "../api/index";
7
- import type { Balance, TransactionResult, WithdrawResult } from "./responses";
8
+ import type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult } from "./responses";
8
9
  /**
9
10
  * Destination ledger for a deposit.
10
11
  * - `"spot"` (default): credit the spot/main wallet — unchanged behavior.
@@ -14,6 +15,13 @@ import type { Balance, TransactionResult, WithdrawResult } from "./responses";
14
15
  * to spot — funds are never lost.
15
16
  */
16
17
  export type DepositTarget = "spot" | "margin";
18
+ /**
19
+ * Source ledger for an external withdrawal.
20
+ * - `"spot"` (default): withdraw from the spot/main wallet.
21
+ * - `"margin"`: directly withdraw from the parent margin account's
22
+ * withdrawable collateral.
23
+ */
24
+ export type WithdrawalSource = "spot" | "margin";
17
25
  /**
18
26
  * Vault API interface.
19
27
  * Provides methods for managing token deposits and withdrawals.
@@ -40,27 +48,40 @@ export interface VaultAPI extends BaseAPI {
40
48
  */
41
49
  deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
42
50
  /**
43
- * Initiates a withdrawal: allocates a `withdrawalIndex` via the API Gateway,
44
- * receives pre-signed calldata for `executeSignedWithdrawal(...)`, and
45
- * submits it on-chain through the connected wallet.
51
+ * Initiates a withdrawal and submits its `executeWithdrawal(...)` calldata
52
+ * on-chain through the connected wallet.
53
+ *
54
+ * The API Gateway allocates a `withdrawalIndex` and debits the balance, but
55
+ * the executable calldata requires the withdrawal's merkle proof, which only
56
+ * exists once its root is confirmed on-chain (a process that can take a
57
+ * while). This method polls `GET /withdrawals/{index}` until the calldata is
58
+ * available — retrying while the gateway reports it is not yet confirmed —
59
+ * then submits it.
46
60
  *
47
61
  * @param assetId - Asset identifier (UUID) to withdraw
48
62
  * @param amount - Raw token amount (smallest unit, as bigint)
49
63
  * @param autoWait - Whether to await on-chain confirmation (defaults to true)
64
+ * @param source - Source ledger: `"spot"` (default) or `"margin"` to source
65
+ * funds directly from the parent margin account's withdrawable collateral
66
+ * @param retry - Polling cadence/timeout while waiting for the proof
50
67
  * @returns Promise resolving to `{ withdrawalIndex, transaction }`
51
68
  */
52
- withdraw(assetId: string, amount: bigint, autoWait?: boolean): Promise<WithdrawResult>;
69
+ withdraw(assetId: string, amount: bigint, autoWait?: boolean, source?: WithdrawalSource, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
70
+ withdraw(assetId: string, amount: bigint, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
53
71
  /**
54
- * Retries a previously-initiated withdrawal whose on-chain submission never
55
- * landed (wallet rejected, page reloaded before receipt, stuck mempool).
56
- * Re-fetches the same signed calldata and resubmits via the connected wallet
57
- * does NOT initiate a new withdrawal.
72
+ * Submits (or resubmits) a previously-initiated withdrawal on-chain. Polls
73
+ * for the `executeWithdrawal` calldata the same way as `withdraw` — useful
74
+ * when the original submission never landed (wallet rejected, page reloaded
75
+ * before receipt, stuck mempool) or when the proof was not yet available at
76
+ * the time of the original `withdraw()` call. Does NOT initiate a new
77
+ * withdrawal.
58
78
  *
59
79
  * @param withdrawalIndex - Index returned by the original `withdraw()` call
60
80
  * @param autoWait - Whether to await on-chain confirmation (defaults to true)
81
+ * @param retry - Polling cadence/timeout while waiting for the proof
61
82
  * @returns Promise resolving to `{ withdrawalIndex, ...transaction }`
62
83
  */
63
- retryWithdrawal(withdrawalIndex: number, autoWait?: boolean): Promise<WithdrawResult>;
84
+ retryWithdrawal(withdrawalIndex: number, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
64
85
  /**
65
86
  * Gets the balance of a token in the vault.
66
87
  * @param assetId - Asset identifier (UUID) to check
@@ -85,7 +106,7 @@ export interface VaultAPI extends BaseAPI {
85
106
  * Gets the address of the vault.
86
107
  * @returns Promise resolving to the address of the vault
87
108
  */
88
- getVaultAddress(): Promise<string>;
109
+ getVaultAddress(): Promise<Address>;
89
110
  /**
90
111
  * Sets the wallet client for signing transactions.
91
112
  * Used when the wallet becomes available after SDK initialization.
@@ -93,4 +114,4 @@ export interface VaultAPI extends BaseAPI {
93
114
  */
94
115
  setWalletClient(walletClient: unknown): void;
95
116
  }
96
- export type { Balance, TransactionResult, WithdrawResult } from "./responses";
117
+ export type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult } from "./responses";