@0xmonaco/types 0.0.0-develop-20260415185155 → 0.0.0-develop-20260420223958
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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/margin-accounts/index.d.ts +106 -0
- package/dist/margin-accounts/index.js +0 -0
- package/dist/market/index.d.ts +98 -0
- package/dist/positions/index.d.ts +128 -0
- package/dist/positions/index.js +0 -0
- package/dist/sdk/index.d.ts +8 -1
- package/dist/trading/index.d.ts +24 -4
- package/dist/trading/orders.d.ts +26 -0
- package/dist/trading/responses.d.ts +83 -2
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/margin-accounts.d.ts +55 -0
- package/dist/validation/margin-accounts.js +59 -0
- package/dist/validation/positions.d.ts +89 -0
- package/dist/validation/positions.js +93 -0
- package/dist/validation/trading.d.ts +121 -0
- package/dist/validation/trading.js +124 -3
- package/dist/websocket/events/conditional-order-events.d.ts +33 -0
- package/dist/websocket/events/conditional-order-events.js +0 -0
- package/dist/websocket/events/index.d.ts +1 -0
- package/dist/websocket/events/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Margin Account API Validation Schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export declare const ListMarginAccountsSchema: z.ZodObject<{
|
|
6
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
state: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const CreateMarginAccountSchema: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
label: z.ZodOptional<z.ZodString>;
|
|
12
|
+
collateralAsset: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
export declare const GetMarginAccountSummarySchema: z.ZodObject<{
|
|
15
|
+
marginAccountId: z.ZodUUID;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const GetAvailableCollateralSchema: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
export declare const TransferCollateralSchema: z.ZodObject<{
|
|
21
|
+
marginAccountId: z.ZodUUID;
|
|
22
|
+
request: z.ZodObject<{
|
|
23
|
+
asset: z.ZodString;
|
|
24
|
+
amount: z.ZodString;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export declare const GetMarginAccountMovementsSchema: z.ZodObject<{
|
|
28
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
marginAccountId: z.ZodUUID;
|
|
31
|
+
movement_type: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const SimulateOrderRiskSchema: z.ZodObject<{
|
|
34
|
+
marginAccountId: z.ZodUUID;
|
|
35
|
+
request: z.ZodObject<{
|
|
36
|
+
tradingPairId: z.ZodUUID;
|
|
37
|
+
side: z.ZodEnum<{
|
|
38
|
+
BUY: "BUY";
|
|
39
|
+
SELL: "SELL";
|
|
40
|
+
}>;
|
|
41
|
+
positionSide: z.ZodEnum<{
|
|
42
|
+
LONG: "LONG";
|
|
43
|
+
SHORT: "SHORT";
|
|
44
|
+
NONE: "NONE";
|
|
45
|
+
}>;
|
|
46
|
+
orderType: z.ZodEnum<{
|
|
47
|
+
LIMIT: "LIMIT";
|
|
48
|
+
MARKET: "MARKET";
|
|
49
|
+
}>;
|
|
50
|
+
price: z.ZodOptional<z.ZodString>;
|
|
51
|
+
quantity: z.ZodString;
|
|
52
|
+
leverage: z.ZodString;
|
|
53
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Margin Account API Validation Schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { OrderSideSchema, OrderTypeSchema, PositionSideSchema, PositiveDecimalStringSchema, UUIDSchema } from "./trading";
|
|
6
|
+
const PaginationSchema = z.object({
|
|
7
|
+
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
8
|
+
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
9
|
+
});
|
|
10
|
+
export const ListMarginAccountsSchema = PaginationSchema.extend({
|
|
11
|
+
state: z.string().trim().min(1, "State cannot be empty").optional(),
|
|
12
|
+
});
|
|
13
|
+
export const CreateMarginAccountSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
label: z.string().trim().min(1, "Label cannot be empty").optional(),
|
|
16
|
+
collateralAsset: z.string().trim().min(1, "Collateral asset cannot be empty").optional(),
|
|
17
|
+
})
|
|
18
|
+
.optional();
|
|
19
|
+
export const GetMarginAccountSummarySchema = z.object({
|
|
20
|
+
marginAccountId: UUIDSchema,
|
|
21
|
+
});
|
|
22
|
+
export const GetAvailableCollateralSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
|
|
25
|
+
})
|
|
26
|
+
.optional();
|
|
27
|
+
export const TransferCollateralSchema = z.object({
|
|
28
|
+
marginAccountId: UUIDSchema,
|
|
29
|
+
request: z.object({
|
|
30
|
+
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
31
|
+
amount: PositiveDecimalStringSchema,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
|
|
35
|
+
marginAccountId: UUIDSchema,
|
|
36
|
+
movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
37
|
+
});
|
|
38
|
+
export const SimulateOrderRiskSchema = z
|
|
39
|
+
.object({
|
|
40
|
+
marginAccountId: UUIDSchema,
|
|
41
|
+
request: z.object({
|
|
42
|
+
tradingPairId: UUIDSchema,
|
|
43
|
+
side: OrderSideSchema,
|
|
44
|
+
positionSide: PositionSideSchema,
|
|
45
|
+
orderType: OrderTypeSchema,
|
|
46
|
+
price: PositiveDecimalStringSchema.optional(),
|
|
47
|
+
quantity: PositiveDecimalStringSchema,
|
|
48
|
+
leverage: PositiveDecimalStringSchema,
|
|
49
|
+
reduceOnly: z.boolean().optional(),
|
|
50
|
+
}),
|
|
51
|
+
})
|
|
52
|
+
.refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
|
|
53
|
+
message: "price is required for LIMIT risk simulations",
|
|
54
|
+
path: ["request", "price"],
|
|
55
|
+
})
|
|
56
|
+
.refine((data) => data.request.orderType !== "MARKET" || data.request.price === undefined, {
|
|
57
|
+
message: "price must not be provided for MARKET risk simulations",
|
|
58
|
+
path: ["request", "price"],
|
|
59
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positions API Validation Schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export declare const ListPositionsSchema: z.ZodObject<{
|
|
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>;
|
|
10
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
OPEN: "OPEN";
|
|
12
|
+
CLOSED: "CLOSED";
|
|
13
|
+
LIQUIDATING: "LIQUIDATING";
|
|
14
|
+
}>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const GetPositionSchema: z.ZodObject<{
|
|
17
|
+
positionId: z.ZodUUID;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const ClosePositionSchema: z.ZodObject<{
|
|
20
|
+
positionId: z.ZodUUID;
|
|
21
|
+
request: z.ZodObject<{
|
|
22
|
+
closeType: z.ZodEnum<{
|
|
23
|
+
LIMIT: "LIMIT";
|
|
24
|
+
MARKET: "MARKET";
|
|
25
|
+
IOC: "IOC";
|
|
26
|
+
}>;
|
|
27
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
28
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export declare const GetPositionRiskSchema: z.ZodObject<{
|
|
33
|
+
positionId: z.ZodUUID;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const AddPositionMarginSchema: z.ZodObject<{
|
|
36
|
+
positionId: z.ZodUUID;
|
|
37
|
+
request: z.ZodObject<{
|
|
38
|
+
amount: z.ZodString;
|
|
39
|
+
asset: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export declare const ReducePositionMarginSchema: z.ZodObject<{
|
|
43
|
+
positionId: z.ZodUUID;
|
|
44
|
+
request: z.ZodObject<{
|
|
45
|
+
amount: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const AttachPositionTpSlSchema: z.ZodObject<{
|
|
49
|
+
positionId: z.ZodUUID;
|
|
50
|
+
request: z.ZodObject<{
|
|
51
|
+
takeProfit: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
triggerPrice: z.ZodString;
|
|
53
|
+
orderType: z.ZodEnum<{
|
|
54
|
+
LIMIT: "LIMIT";
|
|
55
|
+
MARKET: "MARKET";
|
|
56
|
+
}>;
|
|
57
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
58
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
59
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
GTC: "GTC";
|
|
61
|
+
IOC: "IOC";
|
|
62
|
+
}>>;
|
|
63
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
stopLoss: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
triggerPrice: z.ZodString;
|
|
68
|
+
orderType: z.ZodEnum<{
|
|
69
|
+
LIMIT: "LIMIT";
|
|
70
|
+
MARKET: "MARKET";
|
|
71
|
+
}>;
|
|
72
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
73
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
74
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
GTC: "GTC";
|
|
76
|
+
IOC: "IOC";
|
|
77
|
+
}>>;
|
|
78
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export declare const ListPositionHistorySchema: z.ZodObject<{
|
|
84
|
+
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
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positions API Validation Schemas
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, UUIDSchema, } from "./trading";
|
|
6
|
+
const PaginationSchema = z.object({
|
|
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(),
|
|
9
|
+
});
|
|
10
|
+
const PositionStatusSchema = z.enum(["OPEN", "CLOSED", "LIQUIDATING"], {
|
|
11
|
+
message: 'Position status must be "OPEN", "CLOSED", or "LIQUIDATING"',
|
|
12
|
+
});
|
|
13
|
+
const ClosePositionTypeSchema = z.enum(["MARKET", "LIMIT", "IOC"], {
|
|
14
|
+
message: 'Close type must be "MARKET", "LIMIT", or "IOC"',
|
|
15
|
+
});
|
|
16
|
+
const PositionIdSchema = z.object({
|
|
17
|
+
positionId: UUIDSchema,
|
|
18
|
+
});
|
|
19
|
+
export const ListPositionsSchema = PaginationSchema.extend({
|
|
20
|
+
margin_account_id: UUIDSchema.optional(),
|
|
21
|
+
trading_pair_id: UUIDSchema.optional(),
|
|
22
|
+
status: PositionStatusSchema.optional(),
|
|
23
|
+
});
|
|
24
|
+
export const GetPositionSchema = PositionIdSchema;
|
|
25
|
+
export const ClosePositionSchema = PositionIdSchema.extend({
|
|
26
|
+
request: z.object({
|
|
27
|
+
closeType: ClosePositionTypeSchema,
|
|
28
|
+
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
29
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
30
|
+
quantity: PositiveDecimalStringSchema.optional(),
|
|
31
|
+
}),
|
|
32
|
+
})
|
|
33
|
+
.refine((data) => data.request.closeType !== "LIMIT" || data.request.limitPrice !== undefined, {
|
|
34
|
+
message: "limitPrice is required for LIMIT close requests",
|
|
35
|
+
path: ["request", "limitPrice"],
|
|
36
|
+
})
|
|
37
|
+
.refine((data) => data.request.closeType === "LIMIT" || data.request.limitPrice === undefined, {
|
|
38
|
+
message: "limitPrice is only allowed for LIMIT close requests",
|
|
39
|
+
path: ["request", "limitPrice"],
|
|
40
|
+
});
|
|
41
|
+
export const GetPositionRiskSchema = PositionIdSchema;
|
|
42
|
+
export const AddPositionMarginSchema = PositionIdSchema.extend({
|
|
43
|
+
request: z.object({
|
|
44
|
+
amount: PositiveDecimalStringSchema,
|
|
45
|
+
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
export const ReducePositionMarginSchema = PositionIdSchema.extend({
|
|
49
|
+
request: z.object({
|
|
50
|
+
amount: PositiveDecimalStringSchema,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
const TpSlLegSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
triggerPrice: PositiveDecimalStringSchema,
|
|
56
|
+
orderType: OrderTypeSchema,
|
|
57
|
+
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
58
|
+
quantity: PositiveDecimalStringSchema.optional(),
|
|
59
|
+
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
60
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
61
|
+
expiresAt: ISO8601DateSchema.optional(),
|
|
62
|
+
})
|
|
63
|
+
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
64
|
+
message: "limitPrice is required for LIMIT TP/SL legs",
|
|
65
|
+
path: ["limitPrice"],
|
|
66
|
+
})
|
|
67
|
+
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
68
|
+
message: "limitPrice must not be provided for MARKET TP/SL legs",
|
|
69
|
+
path: ["limitPrice"],
|
|
70
|
+
})
|
|
71
|
+
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
72
|
+
message: "timeInForce is only allowed for LIMIT TP/SL legs",
|
|
73
|
+
path: ["timeInForce"],
|
|
74
|
+
})
|
|
75
|
+
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
76
|
+
message: "slippageToleranceBps is only allowed for MARKET TP/SL legs",
|
|
77
|
+
path: ["slippageToleranceBps"],
|
|
78
|
+
});
|
|
79
|
+
export const AttachPositionTpSlSchema = PositionIdSchema.extend({
|
|
80
|
+
request: z
|
|
81
|
+
.object({
|
|
82
|
+
takeProfit: TpSlLegSchema.optional(),
|
|
83
|
+
stopLoss: TpSlLegSchema.optional(),
|
|
84
|
+
})
|
|
85
|
+
.refine((data) => data.takeProfit !== undefined || data.stopLoss !== undefined, {
|
|
86
|
+
message: "At least one of takeProfit or stopLoss is required",
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
export const ListPositionHistorySchema = PaginationSchema.extend({
|
|
90
|
+
position_id: UUIDSchema.optional(),
|
|
91
|
+
margin_account_id: UUIDSchema.optional(),
|
|
92
|
+
trading_pair_id: UUIDSchema.optional(),
|
|
93
|
+
});
|
|
@@ -19,6 +19,14 @@ export declare const TradingModeSchema: z.ZodEnum<{
|
|
|
19
19
|
SPOT: "SPOT";
|
|
20
20
|
MARGIN: "MARGIN";
|
|
21
21
|
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Position side validation
|
|
24
|
+
*/
|
|
25
|
+
export declare const PositionSideSchema: z.ZodEnum<{
|
|
26
|
+
LONG: "LONG";
|
|
27
|
+
SHORT: "SHORT";
|
|
28
|
+
NONE: "NONE";
|
|
29
|
+
}>;
|
|
22
30
|
/**
|
|
23
31
|
* Time in force validation
|
|
24
32
|
*/
|
|
@@ -27,6 +35,10 @@ export declare const TimeInForceSchema: z.ZodEnum<{
|
|
|
27
35
|
IOC: "IOC";
|
|
28
36
|
FOK: "FOK";
|
|
29
37
|
}>;
|
|
38
|
+
export declare const ConditionalTimeInForceSchema: z.ZodEnum<{
|
|
39
|
+
GTC: "GTC";
|
|
40
|
+
IOC: "IOC";
|
|
41
|
+
}>;
|
|
30
42
|
/**
|
|
31
43
|
* Positive decimal string validation (for quantities and prices)
|
|
32
44
|
*/
|
|
@@ -66,6 +78,14 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
|
|
|
66
78
|
IOC: "IOC";
|
|
67
79
|
FOK: "FOK";
|
|
68
80
|
}>>;
|
|
81
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
82
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
LONG: "LONG";
|
|
84
|
+
SHORT: "SHORT";
|
|
85
|
+
NONE: "NONE";
|
|
86
|
+
}>>;
|
|
87
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
88
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
69
89
|
}, z.core.$strip>>;
|
|
70
90
|
}, z.core.$strip>;
|
|
71
91
|
/**
|
|
@@ -84,6 +104,14 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
|
|
|
84
104
|
MARGIN: "MARGIN";
|
|
85
105
|
}>>;
|
|
86
106
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
107
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
108
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
LONG: "LONG";
|
|
110
|
+
SHORT: "SHORT";
|
|
111
|
+
NONE: "NONE";
|
|
112
|
+
}>>;
|
|
113
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
114
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
87
115
|
}, z.core.$strip>>;
|
|
88
116
|
}, z.core.$strip>;
|
|
89
117
|
/**
|
|
@@ -130,6 +158,11 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
|
|
|
130
158
|
EXPIRED: "EXPIRED";
|
|
131
159
|
}>>;
|
|
132
160
|
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
161
|
+
trading_mode: z.ZodOptional<z.ZodEnum<{
|
|
162
|
+
SPOT: "SPOT";
|
|
163
|
+
MARGIN: "MARGIN";
|
|
164
|
+
}>>;
|
|
165
|
+
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
133
166
|
page: z.ZodOptional<z.ZodNumber>;
|
|
134
167
|
page_size: z.ZodOptional<z.ZodNumber>;
|
|
135
168
|
}, z.core.$strip>;
|
|
@@ -140,6 +173,76 @@ export declare const OrderTypeSchema: z.ZodEnum<{
|
|
|
140
173
|
LIMIT: "LIMIT";
|
|
141
174
|
MARKET: "MARKET";
|
|
142
175
|
}>;
|
|
176
|
+
export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
|
|
177
|
+
STOP_LOSS: "STOP_LOSS";
|
|
178
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
179
|
+
}>;
|
|
180
|
+
export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
|
|
181
|
+
MARK_PRICE: "MARK_PRICE";
|
|
182
|
+
}>;
|
|
183
|
+
export declare const ConditionalOrderStateSchema: z.ZodEnum<{
|
|
184
|
+
CANCELLED: "CANCELLED";
|
|
185
|
+
EXPIRED: "EXPIRED";
|
|
186
|
+
ACTIVE: "ACTIVE";
|
|
187
|
+
TRIGGERING: "TRIGGERING";
|
|
188
|
+
TRIGGERED: "TRIGGERED";
|
|
189
|
+
FAILED: "FAILED";
|
|
190
|
+
}>;
|
|
191
|
+
export declare const ClosePositionSideSchema: z.ZodEnum<{
|
|
192
|
+
LONG: "LONG";
|
|
193
|
+
SHORT: "SHORT";
|
|
194
|
+
}>;
|
|
195
|
+
export declare const SlippageToleranceBpsSchema: z.ZodNumber;
|
|
196
|
+
export declare const CreateConditionalOrderSchema: z.ZodObject<{
|
|
197
|
+
tradingPairId: z.ZodUUID;
|
|
198
|
+
marginAccountId: z.ZodUUID;
|
|
199
|
+
conditionType: z.ZodEnum<{
|
|
200
|
+
STOP_LOSS: "STOP_LOSS";
|
|
201
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
202
|
+
}>;
|
|
203
|
+
triggerPrice: z.ZodString;
|
|
204
|
+
triggerSource: z.ZodOptional<z.ZodEnum<{
|
|
205
|
+
MARK_PRICE: "MARK_PRICE";
|
|
206
|
+
}>>;
|
|
207
|
+
side: z.ZodEnum<{
|
|
208
|
+
BUY: "BUY";
|
|
209
|
+
SELL: "SELL";
|
|
210
|
+
}>;
|
|
211
|
+
positionSide: z.ZodEnum<{
|
|
212
|
+
LONG: "LONG";
|
|
213
|
+
SHORT: "SHORT";
|
|
214
|
+
}>;
|
|
215
|
+
orderType: z.ZodEnum<{
|
|
216
|
+
LIMIT: "LIMIT";
|
|
217
|
+
MARKET: "MARKET";
|
|
218
|
+
}>;
|
|
219
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
220
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
221
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
223
|
+
GTC: "GTC";
|
|
224
|
+
IOC: "IOC";
|
|
225
|
+
}>>;
|
|
226
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
export declare const CancelConditionalOrderSchema: z.ZodObject<{
|
|
230
|
+
conditionalOrderId: z.ZodUUID;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
export declare const ListConditionalOrdersSchema: z.ZodObject<{
|
|
233
|
+
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
234
|
+
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
235
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
236
|
+
CANCELLED: "CANCELLED";
|
|
237
|
+
EXPIRED: "EXPIRED";
|
|
238
|
+
ACTIVE: "ACTIVE";
|
|
239
|
+
TRIGGERING: "TRIGGERING";
|
|
240
|
+
TRIGGERED: "TRIGGERED";
|
|
241
|
+
FAILED: "FAILED";
|
|
242
|
+
}>>;
|
|
243
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
244
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
}, z.core.$strip>;
|
|
143
246
|
/**
|
|
144
247
|
* Single batch create order item validation schema
|
|
145
248
|
*
|
|
@@ -161,6 +264,7 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
|
|
|
161
264
|
quantity: z.ZodString;
|
|
162
265
|
tradingMode: z.ZodOptional<z.ZodEnum<{
|
|
163
266
|
SPOT: "SPOT";
|
|
267
|
+
MARGIN: "MARGIN";
|
|
164
268
|
}>>;
|
|
165
269
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
166
270
|
useMasterBalance: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -170,6 +274,14 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
|
|
|
170
274
|
IOC: "IOC";
|
|
171
275
|
FOK: "FOK";
|
|
172
276
|
}>>;
|
|
277
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
278
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
279
|
+
LONG: "LONG";
|
|
280
|
+
SHORT: "SHORT";
|
|
281
|
+
NONE: "NONE";
|
|
282
|
+
}>>;
|
|
283
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
284
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
173
285
|
}, z.core.$strip>;
|
|
174
286
|
/**
|
|
175
287
|
* Batch Create Orders validation schema
|
|
@@ -191,6 +303,7 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
|
|
|
191
303
|
quantity: z.ZodString;
|
|
192
304
|
tradingMode: z.ZodOptional<z.ZodEnum<{
|
|
193
305
|
SPOT: "SPOT";
|
|
306
|
+
MARGIN: "MARGIN";
|
|
194
307
|
}>>;
|
|
195
308
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
196
309
|
useMasterBalance: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -200,6 +313,14 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
|
|
|
200
313
|
IOC: "IOC";
|
|
201
314
|
FOK: "FOK";
|
|
202
315
|
}>>;
|
|
316
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
317
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
318
|
+
LONG: "LONG";
|
|
319
|
+
SHORT: "SHORT";
|
|
320
|
+
NONE: "NONE";
|
|
321
|
+
}>>;
|
|
322
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
323
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
203
324
|
}, z.core.$strip>>;
|
|
204
325
|
}, z.core.$strip>;
|
|
205
326
|
/**
|
|
@@ -18,12 +18,21 @@ export const OrderSideSchema = z.enum(["BUY", "SELL"], {
|
|
|
18
18
|
export const TradingModeSchema = z.enum(["SPOT", "MARGIN"], {
|
|
19
19
|
message: 'Trading mode must be "SPOT" or "MARGIN"',
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Position side validation
|
|
23
|
+
*/
|
|
24
|
+
export const PositionSideSchema = z.enum(["LONG", "SHORT", "NONE"], {
|
|
25
|
+
message: 'Position side must be "LONG", "SHORT", or "NONE"',
|
|
26
|
+
});
|
|
21
27
|
/**
|
|
22
28
|
* Time in force validation
|
|
23
29
|
*/
|
|
24
30
|
export const TimeInForceSchema = z.enum(["GTC", "IOC", "FOK"], {
|
|
25
31
|
message: 'Time in force must be "GTC", "IOC", or "FOK"',
|
|
26
32
|
});
|
|
33
|
+
export const ConditionalTimeInForceSchema = z.enum(["GTC", "IOC"], {
|
|
34
|
+
message: 'Conditional order time in force must be "GTC" or "IOC"',
|
|
35
|
+
});
|
|
27
36
|
/**
|
|
28
37
|
* Positive decimal string validation (for quantities and prices)
|
|
29
38
|
*/
|
|
@@ -58,7 +67,8 @@ export const SlippageToleranceSchema = z
|
|
|
58
67
|
/**
|
|
59
68
|
* Place Limit Order validation schema
|
|
60
69
|
*/
|
|
61
|
-
export const PlaceLimitOrderSchema = z
|
|
70
|
+
export const PlaceLimitOrderSchema = z
|
|
71
|
+
.object({
|
|
62
72
|
tradingPairId: UUIDSchema,
|
|
63
73
|
side: OrderSideSchema,
|
|
64
74
|
quantity: PositiveDecimalStringSchema,
|
|
@@ -69,13 +79,30 @@ export const PlaceLimitOrderSchema = z.object({
|
|
|
69
79
|
useMasterBalance: z.boolean().optional(),
|
|
70
80
|
expirationDate: ISO8601DateSchema.optional(),
|
|
71
81
|
timeInForce: TimeInForceSchema.optional(),
|
|
82
|
+
marginAccountId: UUIDSchema.optional(),
|
|
83
|
+
positionSide: PositionSideSchema.optional(),
|
|
84
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
85
|
+
reduceOnly: z.boolean().optional(),
|
|
72
86
|
})
|
|
73
87
|
.optional(),
|
|
88
|
+
})
|
|
89
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
|
|
90
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
91
|
+
path: ["options", "marginAccountId"],
|
|
92
|
+
})
|
|
93
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
|
|
94
|
+
message: "positionSide is required for MARGIN orders",
|
|
95
|
+
path: ["options", "positionSide"],
|
|
96
|
+
})
|
|
97
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
98
|
+
message: "leverage is required for MARGIN orders",
|
|
99
|
+
path: ["options", "leverage"],
|
|
74
100
|
});
|
|
75
101
|
/**
|
|
76
102
|
* Place Market Order validation schema
|
|
77
103
|
*/
|
|
78
|
-
export const PlaceMarketOrderSchema = z
|
|
104
|
+
export const PlaceMarketOrderSchema = z
|
|
105
|
+
.object({
|
|
79
106
|
tradingPairId: UUIDSchema,
|
|
80
107
|
side: OrderSideSchema,
|
|
81
108
|
quantity: PositiveDecimalStringSchema,
|
|
@@ -83,8 +110,24 @@ export const PlaceMarketOrderSchema = z.object({
|
|
|
83
110
|
.object({
|
|
84
111
|
tradingMode: TradingModeSchema.optional(),
|
|
85
112
|
slippageTolerance: SlippageToleranceSchema,
|
|
113
|
+
marginAccountId: UUIDSchema.optional(),
|
|
114
|
+
positionSide: PositionSideSchema.optional(),
|
|
115
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
116
|
+
reduceOnly: z.boolean().optional(),
|
|
86
117
|
})
|
|
87
118
|
.optional(),
|
|
119
|
+
})
|
|
120
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
|
|
121
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
122
|
+
path: ["options", "marginAccountId"],
|
|
123
|
+
})
|
|
124
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
|
|
125
|
+
message: "positionSide is required for MARGIN orders",
|
|
126
|
+
path: ["options", "positionSide"],
|
|
127
|
+
})
|
|
128
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
129
|
+
message: "leverage is required for MARGIN orders",
|
|
130
|
+
path: ["options", "leverage"],
|
|
88
131
|
});
|
|
89
132
|
/**
|
|
90
133
|
* Cancel Order validation schema
|
|
@@ -121,6 +164,8 @@ export const ReplaceOrderSchema = z.object({
|
|
|
121
164
|
export const GetPaginatedOrdersSchema = z.object({
|
|
122
165
|
status: z.enum(ORDER_STATUS_VALUES).optional(),
|
|
123
166
|
trading_pair_id: UUIDSchema.optional(),
|
|
167
|
+
trading_mode: TradingModeSchema.optional(),
|
|
168
|
+
margin_account_id: UUIDSchema.optional(),
|
|
124
169
|
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
125
170
|
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
126
171
|
});
|
|
@@ -130,6 +175,66 @@ export const GetPaginatedOrdersSchema = z.object({
|
|
|
130
175
|
export const OrderTypeSchema = z.enum(["LIMIT", "MARKET"], {
|
|
131
176
|
message: 'Order type must be "LIMIT" or "MARKET"',
|
|
132
177
|
});
|
|
178
|
+
export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
|
|
179
|
+
message: 'conditionType must be "STOP_LOSS" or "TAKE_PROFIT"',
|
|
180
|
+
});
|
|
181
|
+
export const ConditionalOrderTriggerSourceSchema = z.enum(["MARK_PRICE"], {
|
|
182
|
+
message: 'triggerSource must be "MARK_PRICE"',
|
|
183
|
+
});
|
|
184
|
+
export const ConditionalOrderStateSchema = z.enum(["ACTIVE", "TRIGGERING", "TRIGGERED", "CANCELLED", "EXPIRED", "FAILED"], {
|
|
185
|
+
message: "Invalid conditional order state",
|
|
186
|
+
});
|
|
187
|
+
export const ClosePositionSideSchema = z.enum(["LONG", "SHORT"], {
|
|
188
|
+
message: 'Position side must be "LONG" or "SHORT"',
|
|
189
|
+
});
|
|
190
|
+
export const SlippageToleranceBpsSchema = z
|
|
191
|
+
.number()
|
|
192
|
+
.int()
|
|
193
|
+
.min(0, "Slippage tolerance must be at least 0 bps")
|
|
194
|
+
.max(10000, "Slippage tolerance cannot exceed 10000 bps");
|
|
195
|
+
export const CreateConditionalOrderSchema = z
|
|
196
|
+
.object({
|
|
197
|
+
tradingPairId: UUIDSchema,
|
|
198
|
+
marginAccountId: UUIDSchema,
|
|
199
|
+
conditionType: ConditionalOrderConditionTypeSchema,
|
|
200
|
+
triggerPrice: PositiveDecimalStringSchema,
|
|
201
|
+
triggerSource: ConditionalOrderTriggerSourceSchema.optional(),
|
|
202
|
+
side: OrderSideSchema,
|
|
203
|
+
positionSide: ClosePositionSideSchema,
|
|
204
|
+
orderType: OrderTypeSchema,
|
|
205
|
+
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
206
|
+
quantity: PositiveDecimalStringSchema.optional(),
|
|
207
|
+
reduceOnly: z.boolean().optional(),
|
|
208
|
+
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
209
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
210
|
+
expiresAt: ISO8601DateSchema.optional(),
|
|
211
|
+
})
|
|
212
|
+
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
213
|
+
message: "limitPrice is required for LIMIT conditional orders",
|
|
214
|
+
path: ["limitPrice"],
|
|
215
|
+
})
|
|
216
|
+
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
217
|
+
message: "limitPrice must not be provided for MARKET conditional orders",
|
|
218
|
+
path: ["limitPrice"],
|
|
219
|
+
})
|
|
220
|
+
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
221
|
+
message: "timeInForce is only allowed for LIMIT conditional orders",
|
|
222
|
+
path: ["timeInForce"],
|
|
223
|
+
})
|
|
224
|
+
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
225
|
+
message: "slippageToleranceBps is only allowed for MARKET conditional orders",
|
|
226
|
+
path: ["slippageToleranceBps"],
|
|
227
|
+
});
|
|
228
|
+
export const CancelConditionalOrderSchema = z.object({
|
|
229
|
+
conditionalOrderId: UUIDSchema,
|
|
230
|
+
});
|
|
231
|
+
export const ListConditionalOrdersSchema = z.object({
|
|
232
|
+
margin_account_id: UUIDSchema.optional(),
|
|
233
|
+
trading_pair_id: UUIDSchema.optional(),
|
|
234
|
+
state: ConditionalOrderStateSchema.optional(),
|
|
235
|
+
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
236
|
+
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
237
|
+
});
|
|
133
238
|
/**
|
|
134
239
|
* Single batch create order item validation schema
|
|
135
240
|
*
|
|
@@ -144,11 +249,15 @@ export const BatchCreateOrderItemSchema = z
|
|
|
144
249
|
side: OrderSideSchema,
|
|
145
250
|
price: PositiveDecimalStringSchema.optional(),
|
|
146
251
|
quantity: PositiveDecimalStringSchema,
|
|
147
|
-
tradingMode:
|
|
252
|
+
tradingMode: TradingModeSchema.optional(),
|
|
148
253
|
slippageTolerance: SlippageToleranceSchema,
|
|
149
254
|
useMasterBalance: z.boolean().optional(),
|
|
150
255
|
expirationDate: ISO8601DateSchema.optional(),
|
|
151
256
|
timeInForce: TimeInForceSchema.optional(),
|
|
257
|
+
marginAccountId: UUIDSchema.optional(),
|
|
258
|
+
positionSide: PositionSideSchema.optional(),
|
|
259
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
260
|
+
reduceOnly: z.boolean().optional(),
|
|
152
261
|
})
|
|
153
262
|
.refine((data) => data.orderType !== "LIMIT" || data.price !== undefined, {
|
|
154
263
|
message: "Price is required for LIMIT orders",
|
|
@@ -157,6 +266,18 @@ export const BatchCreateOrderItemSchema = z
|
|
|
157
266
|
.refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
|
|
158
267
|
message: "Price must not be provided for MARKET orders",
|
|
159
268
|
path: ["price"],
|
|
269
|
+
})
|
|
270
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.marginAccountId !== undefined, {
|
|
271
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
272
|
+
path: ["marginAccountId"],
|
|
273
|
+
})
|
|
274
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
|
|
275
|
+
message: "positionSide is required for MARGIN orders",
|
|
276
|
+
path: ["positionSide"],
|
|
277
|
+
})
|
|
278
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.leverage !== undefined, {
|
|
279
|
+
message: "leverage is required for MARGIN orders",
|
|
280
|
+
path: ["leverage"],
|
|
160
281
|
});
|
|
161
282
|
/**
|
|
162
283
|
* Batch Create Orders validation schema
|