@0xmonaco/types 0.8.4 → 0.8.5
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.
|
@@ -3,6 +3,8 @@ import type { OrderSide, OrderType, PositionSide } from "../trading";
|
|
|
3
3
|
export interface MarginAccountSummary {
|
|
4
4
|
margin_account_id: string;
|
|
5
5
|
label?: string;
|
|
6
|
+
trading_pair_id?: string;
|
|
7
|
+
strategy_key?: string;
|
|
6
8
|
account_state: string;
|
|
7
9
|
equity: string;
|
|
8
10
|
initial_margin_required: string;
|
|
@@ -18,6 +20,7 @@ export interface ListMarginAccountsParams {
|
|
|
18
20
|
page?: number;
|
|
19
21
|
page_size?: number;
|
|
20
22
|
state?: string;
|
|
23
|
+
tradingPairId?: string;
|
|
21
24
|
}
|
|
22
25
|
export interface ListMarginAccountsResponse {
|
|
23
26
|
accounts: MarginAccountSummary[];
|
|
@@ -49,9 +52,14 @@ export interface TransferCollateralRequest {
|
|
|
49
52
|
asset: string;
|
|
50
53
|
amount: string;
|
|
51
54
|
}
|
|
55
|
+
export interface TransferCollateralToAutoMarginAccountRequest extends TransferCollateralRequest {
|
|
56
|
+
tradingPairId: string;
|
|
57
|
+
strategyKey?: string;
|
|
58
|
+
}
|
|
52
59
|
export interface TransferCollateralResponse {
|
|
53
60
|
movement_id: string;
|
|
54
61
|
margin_account_id: string;
|
|
62
|
+
strategy_key?: string;
|
|
55
63
|
asset: string;
|
|
56
64
|
amount: string;
|
|
57
65
|
status: string;
|
|
@@ -80,6 +88,7 @@ export interface GetMarginAccountMovementsResponse {
|
|
|
80
88
|
}
|
|
81
89
|
export interface SimulateOrderRiskRequest {
|
|
82
90
|
tradingPairId: string;
|
|
91
|
+
strategyKey?: string;
|
|
83
92
|
side: OrderSide;
|
|
84
93
|
positionSide: PositionSide;
|
|
85
94
|
orderType: OrderType;
|
|
@@ -91,6 +100,8 @@ export interface SimulateOrderRiskRequest {
|
|
|
91
100
|
export interface SimulateOrderRiskResponse {
|
|
92
101
|
accepted: boolean;
|
|
93
102
|
reject_reason?: string;
|
|
103
|
+
margin_account_id: string;
|
|
104
|
+
strategy_key?: string;
|
|
94
105
|
equity_after: string;
|
|
95
106
|
initial_margin_required_after: string;
|
|
96
107
|
maintenance_margin_required_after: string;
|
|
@@ -104,7 +115,9 @@ export interface MarginAccountsAPI extends BaseAPI {
|
|
|
104
115
|
getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
|
|
105
116
|
getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
|
|
106
117
|
transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
118
|
+
transferCollateralToAutoMarginAccount(request: TransferCollateralToAutoMarginAccountRequest): Promise<TransferCollateralResponse>;
|
|
107
119
|
transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
|
|
108
120
|
getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
|
|
109
121
|
simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
122
|
+
simulateAutoMarginOrderRisk(request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
|
|
110
123
|
}
|
|
@@ -6,6 +6,7 @@ export declare const ListMarginAccountsSchema: z.ZodObject<{
|
|
|
6
6
|
page: z.ZodOptional<z.ZodNumber>;
|
|
7
7
|
page_size: z.ZodOptional<z.ZodNumber>;
|
|
8
8
|
state: z.ZodOptional<z.ZodString>;
|
|
9
|
+
tradingPairId: z.ZodOptional<z.ZodUUID>;
|
|
9
10
|
}, z.core.$strip>;
|
|
10
11
|
export declare const CreateMarginAccountSchema: z.ZodOptional<z.ZodObject<{
|
|
11
12
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -24,6 +25,14 @@ export declare const TransferCollateralSchema: z.ZodObject<{
|
|
|
24
25
|
amount: z.ZodString;
|
|
25
26
|
}, z.core.$strip>;
|
|
26
27
|
}, z.core.$strip>;
|
|
28
|
+
export declare const TransferCollateralToAutoMarginAccountSchema: z.ZodObject<{
|
|
29
|
+
request: z.ZodObject<{
|
|
30
|
+
asset: z.ZodString;
|
|
31
|
+
amount: z.ZodString;
|
|
32
|
+
tradingPairId: z.ZodUUID;
|
|
33
|
+
strategyKey: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
}, z.core.$strip>;
|
|
27
36
|
export declare const GetMarginAccountMovementsSchema: z.ZodObject<{
|
|
28
37
|
page: z.ZodOptional<z.ZodNumber>;
|
|
29
38
|
page_size: z.ZodOptional<z.ZodNumber>;
|
|
@@ -34,6 +43,30 @@ export declare const SimulateOrderRiskSchema: z.ZodObject<{
|
|
|
34
43
|
marginAccountId: z.ZodUUID;
|
|
35
44
|
request: z.ZodObject<{
|
|
36
45
|
tradingPairId: z.ZodUUID;
|
|
46
|
+
strategyKey: z.ZodOptional<z.ZodString>;
|
|
47
|
+
side: z.ZodEnum<{
|
|
48
|
+
BUY: "BUY";
|
|
49
|
+
SELL: "SELL";
|
|
50
|
+
}>;
|
|
51
|
+
positionSide: z.ZodEnum<{
|
|
52
|
+
LONG: "LONG";
|
|
53
|
+
SHORT: "SHORT";
|
|
54
|
+
NONE: "NONE";
|
|
55
|
+
}>;
|
|
56
|
+
orderType: z.ZodEnum<{
|
|
57
|
+
LIMIT: "LIMIT";
|
|
58
|
+
MARKET: "MARKET";
|
|
59
|
+
}>;
|
|
60
|
+
price: z.ZodOptional<z.ZodString>;
|
|
61
|
+
quantity: z.ZodString;
|
|
62
|
+
leverage: z.ZodString;
|
|
63
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export declare const SimulateAutoMarginOrderRiskSchema: z.ZodObject<{
|
|
67
|
+
request: z.ZodObject<{
|
|
68
|
+
tradingPairId: z.ZodUUID;
|
|
69
|
+
strategyKey: z.ZodOptional<z.ZodString>;
|
|
37
70
|
side: z.ZodEnum<{
|
|
38
71
|
BUY: "BUY";
|
|
39
72
|
SELL: "SELL";
|
|
@@ -9,6 +9,7 @@ const PaginationSchema = z.object({
|
|
|
9
9
|
});
|
|
10
10
|
export const ListMarginAccountsSchema = PaginationSchema.extend({
|
|
11
11
|
state: z.string().trim().min(1, "State cannot be empty").optional(),
|
|
12
|
+
tradingPairId: UUIDSchema.optional(),
|
|
12
13
|
});
|
|
13
14
|
export const CreateMarginAccountSchema = z
|
|
14
15
|
.object({
|
|
@@ -24,36 +25,50 @@ export const GetAvailableCollateralSchema = z
|
|
|
24
25
|
asset: z.string().trim().min(1, "Asset cannot be empty").optional(),
|
|
25
26
|
})
|
|
26
27
|
.optional();
|
|
28
|
+
const TransferCollateralRequestSchema = z.object({
|
|
29
|
+
asset: z.string().trim().min(1, "Asset cannot be empty"),
|
|
30
|
+
amount: PositiveDecimalStringSchema,
|
|
31
|
+
});
|
|
32
|
+
const AutoMarginBucketRequestSchema = z.object({
|
|
33
|
+
tradingPairId: UUIDSchema,
|
|
34
|
+
strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
|
|
35
|
+
});
|
|
27
36
|
export const TransferCollateralSchema = z.object({
|
|
28
37
|
marginAccountId: UUIDSchema,
|
|
29
|
-
request:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
request: TransferCollateralRequestSchema,
|
|
39
|
+
});
|
|
40
|
+
export const TransferCollateralToAutoMarginAccountSchema = z.object({
|
|
41
|
+
request: TransferCollateralRequestSchema.merge(AutoMarginBucketRequestSchema),
|
|
33
42
|
});
|
|
34
43
|
export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
|
|
35
44
|
marginAccountId: UUIDSchema,
|
|
36
45
|
movement_type: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
37
46
|
});
|
|
47
|
+
const SimulateOrderRiskRequestSchema = z.object({
|
|
48
|
+
tradingPairId: UUIDSchema,
|
|
49
|
+
strategyKey: z.string().trim().min(1, "Strategy key cannot be empty").optional(),
|
|
50
|
+
side: OrderSideSchema,
|
|
51
|
+
positionSide: PositionSideSchema,
|
|
52
|
+
orderType: OrderTypeSchema,
|
|
53
|
+
price: PositiveDecimalStringSchema.optional(),
|
|
54
|
+
quantity: PositiveDecimalStringSchema,
|
|
55
|
+
leverage: PositiveDecimalStringSchema,
|
|
56
|
+
reduceOnly: z.boolean().optional(),
|
|
57
|
+
});
|
|
38
58
|
export const SimulateOrderRiskSchema = z
|
|
39
59
|
.object({
|
|
40
60
|
marginAccountId: UUIDSchema,
|
|
41
|
-
request:
|
|
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
|
-
}),
|
|
61
|
+
request: SimulateOrderRiskRequestSchema,
|
|
51
62
|
})
|
|
52
63
|
.refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
|
|
53
64
|
message: "price is required for LIMIT risk simulations",
|
|
54
65
|
path: ["request", "price"],
|
|
66
|
+
});
|
|
67
|
+
export const SimulateAutoMarginOrderRiskSchema = z
|
|
68
|
+
.object({
|
|
69
|
+
request: SimulateOrderRiskRequestSchema,
|
|
55
70
|
})
|
|
56
|
-
.refine((data) => data.request.orderType !== "
|
|
57
|
-
message: "price
|
|
71
|
+
.refine((data) => data.request.orderType !== "LIMIT" || data.request.price !== undefined, {
|
|
72
|
+
message: "price is required for LIMIT risk simulations",
|
|
58
73
|
path: ["request", "price"],
|
|
59
74
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/types",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint": "biome lint ."
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@0xmonaco/contracts": "0.8.
|
|
23
|
+
"@0xmonaco/contracts": "0.8.5",
|
|
24
24
|
"zod": "^4.1.12"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|