@0xmonaco/types 0.8.7-develop.5d0e403 → 0.8.7-develop.a107b34
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.
- package/README.md +5 -3
- package/dist/margin-accounts/index.d.ts +52 -16
- package/dist/market/index.d.ts +41 -5
- package/dist/positions/index.d.ts +23 -1
- package/dist/profile/index.d.ts +79 -0
- package/dist/sdk/index.d.ts +9 -0
- package/dist/trading/index.d.ts +6 -10
- package/dist/trading/responses.d.ts +6 -31
- package/dist/validation/margin-accounts.d.ts +50 -10
- package/dist/validation/margin-accounts.js +36 -12
- package/dist/validation/positions.d.ts +4 -0
- package/dist/validation/positions.js +4 -0
- package/dist/validation/profile.d.ts +7 -0
- package/dist/validation/profile.js +7 -0
- package/dist/validation/trading.d.ts +8 -41
- package/dist/validation/trading.js +27 -60
- package/dist/validation/vault.d.ts +8 -0
- package/dist/validation/vault.js +3 -0
- package/dist/vault/index.d.ts +44 -12
- package/dist/vault/responses.d.ts +23 -8
- package/dist/wire/audit.d.ts +47 -0
- package/dist/wire/audit.js +43 -0
- package/dist/wire/index.d.ts +7 -0
- package/dist/wire/index.js +2 -0
- package/dist/wire/operations.d.ts +15 -0
- package/dist/wire/operations.js +100 -0
- package/dist/wire/schema.d.ts +687 -296
- package/dist/withdrawals/index.d.ts +25 -8
- package/package.json +2 -2
|
@@ -11,15 +11,15 @@ 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 EnsureParentMarginAccountSchema = 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
|
});
|
|
18
|
+
export const GetParentMarginAccountSummarySchema = z
|
|
19
|
+
.object({
|
|
20
|
+
tradingPairId: UUIDSchema.optional(),
|
|
21
|
+
})
|
|
22
|
+
.optional();
|
|
23
23
|
export const GetAvailableCollateralSchema = z
|
|
24
24
|
.object({
|
|
25
25
|
asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
|
|
@@ -28,8 +28,14 @@ export const GetAvailableCollateralSchema = z
|
|
|
28
28
|
const TransferCollateralRequestSchema = z.object({
|
|
29
29
|
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
30
30
|
amount: PositiveDecimalStringSchema,
|
|
31
|
+
tradingPairId: UUIDSchema.optional(),
|
|
32
|
+
strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
|
|
31
33
|
});
|
|
32
|
-
const
|
|
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({
|
|
33
39
|
tradingPairId: UUIDSchema,
|
|
34
40
|
strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
|
|
35
41
|
});
|
|
@@ -37,16 +43,24 @@ export const TransferCollateralSchema = z.object({
|
|
|
37
43
|
marginAccountId: UUIDSchema,
|
|
38
44
|
request: TransferCollateralRequestSchema,
|
|
39
45
|
});
|
|
40
|
-
export const
|
|
41
|
-
request:
|
|
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,
|
|
42
54
|
});
|
|
43
55
|
export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
|
|
44
56
|
marginAccountId: UUIDSchema,
|
|
45
57
|
movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
46
58
|
});
|
|
47
|
-
const
|
|
59
|
+
export const GetParentMarginAccountMovementsSchema = PaginationSchema.extend({
|
|
60
|
+
movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
61
|
+
}).optional();
|
|
62
|
+
const BaseSimulateOrderRiskRequestSchema = z.object({
|
|
48
63
|
tradingPairId: UUIDSchema,
|
|
49
|
-
strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
|
|
50
64
|
side: OrderSideSchema,
|
|
51
65
|
positionSide: PositionSideSchema,
|
|
52
66
|
orderType: OrderTypeSchema,
|
|
@@ -55,6 +69,8 @@ const SimulateOrderRiskRequestSchema = z.object({
|
|
|
55
69
|
leverage: PositiveDecimalStringSchema,
|
|
56
70
|
reduceOnly: z.boolean().optional(),
|
|
57
71
|
});
|
|
72
|
+
const SimulateOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.strict();
|
|
73
|
+
const SimulateRiskBucketOrderRiskRequestSchema = BaseSimulateOrderRiskRequestSchema.merge(RiskBucketRequestSchema).strict();
|
|
58
74
|
export const SimulateOrderRiskSchema = z
|
|
59
75
|
.object({
|
|
60
76
|
marginAccountId: UUIDSchema,
|
|
@@ -64,7 +80,7 @@ export const SimulateOrderRiskSchema = z
|
|
|
64
80
|
message: "price is required for LIMIT risk simulations",
|
|
65
81
|
path: ["request", "price"],
|
|
66
82
|
});
|
|
67
|
-
export const
|
|
83
|
+
export const SimulateParentMarginOrderRiskSchema = z
|
|
68
84
|
.object({
|
|
69
85
|
request: SimulateOrderRiskRequestSchema,
|
|
70
86
|
})
|
|
@@ -72,3 +88,11 @@ export const SimulateAutoMarginOrderRiskSchema = z
|
|
|
72
88
|
message: "price is required for LIMIT risk simulations",
|
|
73
89
|
path: ["request", "price"],
|
|
74
90
|
});
|
|
91
|
+
export const SimulateRiskBucketOrderRiskSchema = z
|
|
92
|
+
.object({
|
|
93
|
+
request: SimulateRiskBucketOrderRiskRequestSchema,
|
|
94
|
+
})
|
|
95
|
+
.refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
|
|
96
|
+
message: "price is required for LIMIT risk simulations",
|
|
97
|
+
path: ["request", "price"],
|
|
98
|
+
});
|
|
@@ -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>;
|
|
@@ -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({
|
|
@@ -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,8 +101,8 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
|
|
|
101
101
|
FOK: "FOK";
|
|
102
102
|
}>>;
|
|
103
103
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
162
|
-
|
|
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";
|
|
@@ -270,39 +270,6 @@ export declare const ClosePositionSideSchema: z.ZodEnum<{
|
|
|
270
270
|
LONG: "LONG";
|
|
271
271
|
SHORT: "SHORT";
|
|
272
272
|
}>;
|
|
273
|
-
export declare const CreateConditionalOrderSchema: z.ZodObject<{
|
|
274
|
-
tradingPairId: z.ZodUUID;
|
|
275
|
-
marginAccountId: z.ZodUUID;
|
|
276
|
-
conditionType: z.ZodEnum<{
|
|
277
|
-
STOP_LOSS: "STOP_LOSS";
|
|
278
|
-
TAKE_PROFIT: "TAKE_PROFIT";
|
|
279
|
-
}>;
|
|
280
|
-
triggerPrice: z.ZodString;
|
|
281
|
-
triggerSource: z.ZodOptional<z.ZodEnum<{
|
|
282
|
-
MARK_PRICE: "MARK_PRICE";
|
|
283
|
-
}>>;
|
|
284
|
-
side: z.ZodEnum<{
|
|
285
|
-
BUY: "BUY";
|
|
286
|
-
SELL: "SELL";
|
|
287
|
-
}>;
|
|
288
|
-
positionSide: z.ZodEnum<{
|
|
289
|
-
LONG: "LONG";
|
|
290
|
-
SHORT: "SHORT";
|
|
291
|
-
}>;
|
|
292
|
-
orderType: z.ZodEnum<{
|
|
293
|
-
LIMIT: "LIMIT";
|
|
294
|
-
MARKET: "MARKET";
|
|
295
|
-
}>;
|
|
296
|
-
limitPrice: z.ZodOptional<z.ZodString>;
|
|
297
|
-
quantity: z.ZodOptional<z.ZodString>;
|
|
298
|
-
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
299
|
-
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
300
|
-
GTC: "GTC";
|
|
301
|
-
IOC: "IOC";
|
|
302
|
-
}>>;
|
|
303
|
-
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
304
|
-
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
305
|
-
}, z.core.$strip>;
|
|
306
273
|
export declare const CancelConditionalOrderSchema: z.ZodObject<{
|
|
307
274
|
conditionalOrderId: z.ZodUUID;
|
|
308
275
|
}, z.core.$strip>;
|
|
@@ -353,8 +320,8 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
|
|
|
353
320
|
FOK: "FOK";
|
|
354
321
|
}>>;
|
|
355
322
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
356
|
-
|
|
357
|
-
|
|
323
|
+
riskBucketId: z.ZodOptional<z.ZodUUID>;
|
|
324
|
+
riskBucketCollateral: z.ZodOptional<z.ZodString>;
|
|
358
325
|
strategyKey: z.ZodOptional<z.ZodString>;
|
|
359
326
|
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
360
327
|
LONG: "LONG";
|
|
@@ -395,8 +362,8 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
|
|
|
395
362
|
FOK: "FOK";
|
|
396
363
|
}>>;
|
|
397
364
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
398
|
-
|
|
399
|
-
|
|
365
|
+
riskBucketId: z.ZodOptional<z.ZodUUID>;
|
|
366
|
+
riskBucketCollateral: z.ZodOptional<z.ZodString>;
|
|
400
367
|
strategyKey: z.ZodOptional<z.ZodString>;
|
|
401
368
|
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
402
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
|
-
|
|
121
|
-
|
|
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?.
|
|
152
|
-
message: "
|
|
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?.
|
|
156
|
-
message: "
|
|
157
|
-
path: ["options", "
|
|
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?.
|
|
160
|
-
message: "reduceOnly orders cannot create a new
|
|
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
|
-
|
|
177
|
-
|
|
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?.
|
|
208
|
-
message: "
|
|
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?.
|
|
212
|
-
message: "
|
|
213
|
-
path: ["options", "
|
|
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?.
|
|
216
|
-
message: "reduceOnly orders cannot create a new
|
|
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
|
/**
|
|
@@ -268,39 +268,6 @@ export const ConditionalOrderStateSchema = z.enum(["PENDING_PARENT", "ACTIVE", "
|
|
|
268
268
|
export const ClosePositionSideSchema = z.enum(["LONG", "SHORT"], {
|
|
269
269
|
message: 'Position side must be "LONG" or "SHORT"',
|
|
270
270
|
});
|
|
271
|
-
export const CreateConditionalOrderSchema = z
|
|
272
|
-
.object({
|
|
273
|
-
tradingPairId: UUIDSchema,
|
|
274
|
-
marginAccountId: UUIDSchema,
|
|
275
|
-
conditionType: ConditionalOrderConditionTypeSchema,
|
|
276
|
-
triggerPrice: PositiveDecimalStringSchema,
|
|
277
|
-
triggerSource: ConditionalOrderTriggerSourceSchema.optional(),
|
|
278
|
-
side: OrderSideSchema,
|
|
279
|
-
positionSide: ClosePositionSideSchema,
|
|
280
|
-
orderType: OrderTypeSchema,
|
|
281
|
-
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
282
|
-
quantity: PositiveDecimalStringSchema.optional(),
|
|
283
|
-
reduceOnly: z.boolean().optional(),
|
|
284
|
-
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
285
|
-
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
286
|
-
expiresAt: ISO8601DateSchema.optional(),
|
|
287
|
-
})
|
|
288
|
-
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
289
|
-
message: "limitPrice is required for LIMIT conditional orders",
|
|
290
|
-
path: ["limitPrice"],
|
|
291
|
-
})
|
|
292
|
-
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
293
|
-
message: "limitPrice must not be provided for MARKET conditional orders",
|
|
294
|
-
path: ["limitPrice"],
|
|
295
|
-
})
|
|
296
|
-
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
297
|
-
message: "timeInForce is only allowed for LIMIT conditional orders",
|
|
298
|
-
path: ["timeInForce"],
|
|
299
|
-
})
|
|
300
|
-
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
301
|
-
message: "slippageToleranceBps is only allowed for MARKET conditional orders",
|
|
302
|
-
path: ["slippageToleranceBps"],
|
|
303
|
-
});
|
|
304
271
|
export const CancelConditionalOrderSchema = z.object({
|
|
305
272
|
conditionalOrderId: UUIDSchema,
|
|
306
273
|
});
|
|
@@ -331,8 +298,8 @@ export const BatchCreateOrderItemSchema = z
|
|
|
331
298
|
expirationDate: ISO8601DateSchema.optional(),
|
|
332
299
|
timeInForce: TimeInForceSchema.optional(),
|
|
333
300
|
marginAccountId: UUIDSchema.optional(),
|
|
334
|
-
|
|
335
|
-
|
|
301
|
+
riskBucketId: UUIDSchema.optional(),
|
|
302
|
+
riskBucketCollateral: PositiveDecimalStringSchema.optional(),
|
|
336
303
|
strategyKey: z.string().min(1).max(128).optional(),
|
|
337
304
|
positionSide: PositionSideSchema.optional(),
|
|
338
305
|
leverage: PositiveDecimalStringSchema.optional(),
|
|
@@ -346,16 +313,16 @@ export const BatchCreateOrderItemSchema = z
|
|
|
346
313
|
message: "Price must not be provided for MARKET orders",
|
|
347
314
|
path: ["price"],
|
|
348
315
|
})
|
|
349
|
-
.refine((data) => data.
|
|
350
|
-
message: "
|
|
316
|
+
.refine((data) => data.riskBucketCollateral === undefined || data.tradingMode === "MARGIN", {
|
|
317
|
+
message: "riskBucketCollateral is only supported for MARGIN orders",
|
|
351
318
|
path: ["tradingMode"],
|
|
352
319
|
})
|
|
353
|
-
.refine((data) => data.
|
|
354
|
-
message: "
|
|
355
|
-
path: ["
|
|
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"],
|
|
356
323
|
})
|
|
357
|
-
.refine((data) => data.
|
|
358
|
-
message: "reduceOnly orders cannot create a new
|
|
324
|
+
.refine((data) => data.riskBucketCollateral === undefined || data.reduceOnly !== true, {
|
|
325
|
+
message: "reduceOnly orders cannot create a new risk bucket",
|
|
359
326
|
path: ["reduceOnly"],
|
|
360
327
|
})
|
|
361
328
|
.refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
|
|
@@ -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 +61,10 @@ export declare const WithdrawSchema: z.ZodObject<{
|
|
|
57
61
|
amount: z.ZodUnion<readonly [z.ZodString, z.ZodBigInt]>;
|
|
58
62
|
destination: z.ZodString;
|
|
59
63
|
autoWait: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
spot: "spot";
|
|
66
|
+
margin: "margin";
|
|
67
|
+
}>>;
|
|
60
68
|
}, z.core.$strip>;
|
|
61
69
|
/**
|
|
62
70
|
* Get Balance validation schema
|
package/dist/validation/vault.js
CHANGED
|
@@ -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.
|
|
@@ -70,6 +72,7 @@ export const WithdrawSchema = z.object({
|
|
|
70
72
|
amount: PositiveBigIntStringSchema,
|
|
71
73
|
destination: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "destination must be a 0x-prefixed 20-byte hex address"),
|
|
72
74
|
autoWait: z.boolean().optional(),
|
|
75
|
+
source: z.enum(["spot", "margin"]).optional(),
|
|
73
76
|
});
|
|
74
77
|
/**
|
|
75
78
|
* Get Balance validation schema
|
package/dist/vault/index.d.ts
CHANGED
|
@@ -4,7 +4,23 @@
|
|
|
4
4
|
* Types for vault operations including deposits, withdrawals, and balance management.
|
|
5
5
|
*/
|
|
6
6
|
import type { BaseAPI } from "../api/index";
|
|
7
|
-
import type { Balance, TransactionResult, WithdrawResult } from "./responses";
|
|
7
|
+
import type { Balance, TransactionResult, WithdrawalRetryOptions, 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";
|
|
17
|
+
/**
|
|
18
|
+
* Source ledger for an external withdrawal.
|
|
19
|
+
* - `"spot"` (default): withdraw from the spot/main wallet.
|
|
20
|
+
* - `"margin"`: directly withdraw from the parent margin account's
|
|
21
|
+
* withdrawable collateral.
|
|
22
|
+
*/
|
|
23
|
+
export type WithdrawalSource = "spot" | "margin";
|
|
8
24
|
/**
|
|
9
25
|
* Vault API interface.
|
|
10
26
|
* Provides methods for managing token deposits and withdrawals.
|
|
@@ -24,31 +40,47 @@ export interface VaultAPI extends BaseAPI {
|
|
|
24
40
|
* @param assetId - Asset identifier (UUID) to deposit
|
|
25
41
|
* @param amount - Amount to deposit
|
|
26
42
|
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
43
|
+
* @param target - Destination ledger: `"spot"` (default) or `"margin"` to
|
|
44
|
+
* route the deposit into the parent margin account's collateral. Margin
|
|
45
|
+
* deposits that cannot be routed fall back to spot.
|
|
27
46
|
* @returns Promise resolving to the transaction result
|
|
28
47
|
*/
|
|
29
|
-
deposit(assetId: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
48
|
+
deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
|
|
30
49
|
/**
|
|
31
|
-
* Initiates a withdrawal
|
|
32
|
-
*
|
|
33
|
-
*
|
|
50
|
+
* Initiates a withdrawal and submits its `executeWithdrawal(...)` calldata
|
|
51
|
+
* on-chain through the connected wallet.
|
|
52
|
+
*
|
|
53
|
+
* The API Gateway allocates a `withdrawalIndex` and debits the balance, but
|
|
54
|
+
* the executable calldata requires the withdrawal's merkle proof, which only
|
|
55
|
+
* exists once its root is confirmed on-chain (a process that can take a
|
|
56
|
+
* while). This method polls `GET /withdrawals/{index}` until the calldata is
|
|
57
|
+
* available — retrying while the gateway reports it is not yet confirmed —
|
|
58
|
+
* then submits it.
|
|
34
59
|
*
|
|
35
60
|
* @param assetId - Asset identifier (UUID) to withdraw
|
|
36
61
|
* @param amount - Raw token amount (smallest unit, as bigint)
|
|
37
62
|
* @param autoWait - Whether to await on-chain confirmation (defaults to true)
|
|
63
|
+
* @param source - Source ledger: `"spot"` (default) or `"margin"` to source
|
|
64
|
+
* funds directly from the parent margin account's withdrawable collateral
|
|
65
|
+
* @param retry - Polling cadence/timeout while waiting for the proof
|
|
38
66
|
* @returns Promise resolving to `{ withdrawalIndex, transaction }`
|
|
39
67
|
*/
|
|
40
|
-
withdraw(assetId: string, amount: bigint, autoWait?: boolean): Promise<WithdrawResult>;
|
|
68
|
+
withdraw(assetId: string, amount: bigint, autoWait?: boolean, source?: WithdrawalSource, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
|
|
69
|
+
withdraw(assetId: string, amount: bigint, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
|
|
41
70
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
71
|
+
* Submits (or resubmits) a previously-initiated withdrawal on-chain. Polls
|
|
72
|
+
* for the `executeWithdrawal` calldata the same way as `withdraw` — useful
|
|
73
|
+
* when the original submission never landed (wallet rejected, page reloaded
|
|
74
|
+
* before receipt, stuck mempool) or when the proof was not yet available at
|
|
75
|
+
* the time of the original `withdraw()` call. Does NOT initiate a new
|
|
76
|
+
* withdrawal.
|
|
46
77
|
*
|
|
47
78
|
* @param withdrawalIndex - Index returned by the original `withdraw()` call
|
|
48
79
|
* @param autoWait - Whether to await on-chain confirmation (defaults to true)
|
|
80
|
+
* @param retry - Polling cadence/timeout while waiting for the proof
|
|
49
81
|
* @returns Promise resolving to `{ withdrawalIndex, ...transaction }`
|
|
50
82
|
*/
|
|
51
|
-
retryWithdrawal(withdrawalIndex: number, autoWait?: boolean): Promise<WithdrawResult>;
|
|
83
|
+
retryWithdrawal(withdrawalIndex: number, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
|
|
52
84
|
/**
|
|
53
85
|
* Gets the balance of a token in the vault.
|
|
54
86
|
* @param assetId - Asset identifier (UUID) to check
|
|
@@ -81,4 +113,4 @@ export interface VaultAPI extends BaseAPI {
|
|
|
81
113
|
*/
|
|
82
114
|
setWalletClient(walletClient: unknown): void;
|
|
83
115
|
}
|
|
84
|
-
export type { Balance, TransactionResult, WithdrawResult } from "./responses";
|
|
116
|
+
export type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult } from "./responses";
|
|
@@ -17,23 +17,38 @@ export interface TransactionResult {
|
|
|
17
17
|
receipt?: import("viem").TransactionReceipt;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Result of
|
|
20
|
+
* Result of a withdrawal.
|
|
21
21
|
*
|
|
22
|
-
* The API gateway allocates a `withdrawalIndex` via the matching engine
|
|
23
|
-
*
|
|
24
|
-
* `
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* authenticates against.
|
|
22
|
+
* The API gateway allocates a `withdrawalIndex` via the matching engine. Once
|
|
23
|
+
* the withdrawal's root is confirmed on-chain, the gateway serves the vault
|
|
24
|
+
* contract's `executeWithdrawal(...)` calldata (authorised by the withdrawal's
|
|
25
|
+
* merkle proof, not a signature); the SDK submits it through the connected
|
|
26
|
+
* wallet.
|
|
28
27
|
*
|
|
29
28
|
* Extends [`TransactionResult`] so callers can read `hash`, `status`, `nonce`
|
|
30
29
|
* (and `receipt` when `autoWait` is true) directly off the result, just like
|
|
31
30
|
* `approve` / `deposit`.
|
|
32
31
|
*/
|
|
33
32
|
export interface WithdrawResult extends TransactionResult {
|
|
34
|
-
/** Allocated withdrawal index — matches `
|
|
33
|
+
/** Allocated withdrawal index — matches `executeWithdrawal.index`. */
|
|
35
34
|
withdrawalIndex: number;
|
|
36
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Controls how the SDK polls for a withdrawal's `executeWithdrawal` calldata
|
|
38
|
+
* while its merkle proof is not yet available (the withdrawal root has not been
|
|
39
|
+
* confirmed on-chain). The gateway returns 404 (row not persisted yet) or 409
|
|
40
|
+
* (proof not confirmed yet) until ready; the SDK retries on both.
|
|
41
|
+
*/
|
|
42
|
+
export interface WithdrawalRetryOptions {
|
|
43
|
+
/** Delay between polls, in milliseconds. Defaults to 5000. */
|
|
44
|
+
pollIntervalMs?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum total time to wait for the proof, in milliseconds. Defaults to
|
|
47
|
+
* 1_800_000 (30 minutes). Pass `Infinity` to retry indefinitely until the
|
|
48
|
+
* proof is available.
|
|
49
|
+
*/
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
}
|
|
37
52
|
/**
|
|
38
53
|
* Token balance information.
|
|
39
54
|
*/
|
|
@@ -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
|
+
}
|