@0xmonaco/types 0.7.8 → 0.8.1
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/trading/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { BaseAPI } from "../api/index";
|
|
7
7
|
import type { OrderSide, PositionSide, TimeInForce, TradingMode } from "./orders";
|
|
8
|
-
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ReplaceOrderResponse } from "./responses";
|
|
8
|
+
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ParentTpSlLegParams, ReplaceOrderResponse } from "./responses";
|
|
9
9
|
/**
|
|
10
10
|
* Trading API interface.
|
|
11
11
|
* Provides methods for placing and managing orders.
|
|
@@ -32,6 +32,8 @@ export interface TradingAPI extends BaseAPI {
|
|
|
32
32
|
positionSide?: PositionSide;
|
|
33
33
|
leverage?: string;
|
|
34
34
|
reduceOnly?: boolean;
|
|
35
|
+
takeProfit?: ParentTpSlLegParams;
|
|
36
|
+
stopLoss?: ParentTpSlLegParams;
|
|
35
37
|
}): Promise<CreateOrderResponse>;
|
|
36
38
|
/**
|
|
37
39
|
* Places a market order for immediate execution.
|
|
@@ -50,6 +52,8 @@ export interface TradingAPI extends BaseAPI {
|
|
|
50
52
|
positionSide?: PositionSide;
|
|
51
53
|
leverage?: string;
|
|
52
54
|
reduceOnly?: boolean;
|
|
55
|
+
takeProfit?: ParentTpSlLegParams;
|
|
56
|
+
stopLoss?: ParentTpSlLegParams;
|
|
53
57
|
}): Promise<CreateOrderResponse>;
|
|
54
58
|
/**
|
|
55
59
|
* Cancels an existing order.
|
|
@@ -129,4 +133,4 @@ export interface TradingAPI extends BaseAPI {
|
|
|
129
133
|
}
|
|
130
134
|
export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode, } from "./orders";
|
|
131
135
|
export { ORDER_STATUS_VALUES } from "./orders";
|
|
132
|
-
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, ConditionalOrder, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, MatchResult, ReplaceOrderResponse, UpdatedFields, } from "./responses";
|
|
136
|
+
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, ConditionalOrder, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, MatchResult, ParentTpSlLegParams, ReplaceOrderResponse, UpdatedFields, } from "./responses";
|
package/dist/trading/orders.d.ts
CHANGED
|
@@ -134,4 +134,4 @@ export type ConditionalOrderTriggerSource = "MARK_PRICE";
|
|
|
134
134
|
/**
|
|
135
135
|
* Conditional TP/SL lifecycle state.
|
|
136
136
|
*/
|
|
137
|
-
export type ConditionalOrderState = "ACTIVE" | "TRIGGERING" | "TRIGGERED" | "CANCELLED" | "EXPIRED" | "FAILED";
|
|
137
|
+
export type ConditionalOrderState = "PENDING_PARENT" | "ACTIVE" | "TRIGGERING" | "TRIGGERED" | "CANCELLED" | "EXPIRED" | "FAILED";
|
|
@@ -36,6 +36,26 @@ export interface MatchResult {
|
|
|
36
36
|
worst_price: string;
|
|
37
37
|
} | null;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Parent TP/SL leg attached to a normal margin order.
|
|
41
|
+
*
|
|
42
|
+
* Parent TP/SL follows the parent order quantity and becomes active once the
|
|
43
|
+
* parent order creates or extends a position.
|
|
44
|
+
*/
|
|
45
|
+
export interface ParentTpSlLegParams {
|
|
46
|
+
/** Mark price that arms the close order */
|
|
47
|
+
triggerPrice: string;
|
|
48
|
+
/** Triggered close order type */
|
|
49
|
+
orderType: OrderType;
|
|
50
|
+
/** Required for LIMIT TP/SL, omitted for MARKET TP/SL */
|
|
51
|
+
limitPrice?: string;
|
|
52
|
+
/** LIMIT-only time in force */
|
|
53
|
+
timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
|
|
54
|
+
/** MARKET-only slippage tolerance in basis points */
|
|
55
|
+
slippageToleranceBps?: number;
|
|
56
|
+
/** Optional conditional order expiry timestamp (ISO 8601) */
|
|
57
|
+
expiresAt?: string;
|
|
58
|
+
}
|
|
39
59
|
/**
|
|
40
60
|
* Response from creating an order.
|
|
41
61
|
*
|
|
@@ -52,6 +72,10 @@ export interface CreateOrderResponse {
|
|
|
52
72
|
message: string;
|
|
53
73
|
/** Match result information if order was processed by matching engine */
|
|
54
74
|
match_result?: MatchResult;
|
|
75
|
+
/** Conditional order ID for an attached take-profit leg */
|
|
76
|
+
take_profit_order_id?: string;
|
|
77
|
+
/** Conditional order ID for an attached stop-loss leg */
|
|
78
|
+
stop_loss_order_id?: string;
|
|
55
79
|
}
|
|
56
80
|
/**
|
|
57
81
|
* Response from cancelling an order.
|
|
@@ -318,6 +342,8 @@ export interface ConditionalOrder {
|
|
|
318
342
|
trading_pair_id: string;
|
|
319
343
|
margin_account_id: string;
|
|
320
344
|
position_id?: string;
|
|
345
|
+
parent_order_id?: string;
|
|
346
|
+
association_type?: "POSITION" | "PARENT_ORDER";
|
|
321
347
|
linked_group_id?: string;
|
|
322
348
|
condition_type: ConditionalOrderConditionType;
|
|
323
349
|
trigger_source: ConditionalOrderTriggerSource;
|
|
@@ -333,6 +359,7 @@ export interface ConditionalOrder {
|
|
|
333
359
|
state: ConditionalOrderState;
|
|
334
360
|
triggered_order_id?: string;
|
|
335
361
|
triggered_at?: string;
|
|
362
|
+
activated_at?: string;
|
|
336
363
|
cancelled_at?: string;
|
|
337
364
|
expires_at?: string;
|
|
338
365
|
failure_reason?: string;
|
|
@@ -39,6 +39,13 @@ export declare const ConditionalTimeInForceSchema: z.ZodEnum<{
|
|
|
39
39
|
GTC: "GTC";
|
|
40
40
|
IOC: "IOC";
|
|
41
41
|
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Order type validation
|
|
44
|
+
*/
|
|
45
|
+
export declare const OrderTypeSchema: z.ZodEnum<{
|
|
46
|
+
LIMIT: "LIMIT";
|
|
47
|
+
MARKET: "MARKET";
|
|
48
|
+
}>;
|
|
42
49
|
/**
|
|
43
50
|
* Positive decimal string validation (for quantities and prices)
|
|
44
51
|
*/
|
|
@@ -55,6 +62,21 @@ export declare const ISO8601DateSchema: z.ZodISODateTime;
|
|
|
55
62
|
* Slippage tolerance validation (0 to 1, where 0.01 = 1%)
|
|
56
63
|
*/
|
|
57
64
|
export declare const SlippageToleranceSchema: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
export declare const SlippageToleranceBpsSchema: z.ZodNumber;
|
|
66
|
+
export declare const ParentTpSlLegSchema: z.ZodObject<{
|
|
67
|
+
triggerPrice: z.ZodString;
|
|
68
|
+
orderType: z.ZodEnum<{
|
|
69
|
+
LIMIT: "LIMIT";
|
|
70
|
+
MARKET: "MARKET";
|
|
71
|
+
}>;
|
|
72
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
73
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
GTC: "GTC";
|
|
75
|
+
IOC: "IOC";
|
|
76
|
+
}>>;
|
|
77
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
79
|
+
}, z.core.$strip>;
|
|
58
80
|
/**
|
|
59
81
|
* Place Limit Order validation schema
|
|
60
82
|
*/
|
|
@@ -86,6 +108,34 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
|
|
|
86
108
|
}>>;
|
|
87
109
|
leverage: z.ZodOptional<z.ZodString>;
|
|
88
110
|
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
takeProfit: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
triggerPrice: z.ZodString;
|
|
113
|
+
orderType: z.ZodEnum<{
|
|
114
|
+
LIMIT: "LIMIT";
|
|
115
|
+
MARKET: "MARKET";
|
|
116
|
+
}>;
|
|
117
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
118
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
119
|
+
GTC: "GTC";
|
|
120
|
+
IOC: "IOC";
|
|
121
|
+
}>>;
|
|
122
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
stopLoss: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
triggerPrice: z.ZodString;
|
|
127
|
+
orderType: z.ZodEnum<{
|
|
128
|
+
LIMIT: "LIMIT";
|
|
129
|
+
MARKET: "MARKET";
|
|
130
|
+
}>;
|
|
131
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
132
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
133
|
+
GTC: "GTC";
|
|
134
|
+
IOC: "IOC";
|
|
135
|
+
}>>;
|
|
136
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
89
139
|
}, z.core.$strip>>;
|
|
90
140
|
}, z.core.$strip>;
|
|
91
141
|
/**
|
|
@@ -112,6 +162,34 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
|
|
|
112
162
|
}>>;
|
|
113
163
|
leverage: z.ZodOptional<z.ZodString>;
|
|
114
164
|
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
takeProfit: z.ZodOptional<z.ZodObject<{
|
|
166
|
+
triggerPrice: z.ZodString;
|
|
167
|
+
orderType: z.ZodEnum<{
|
|
168
|
+
LIMIT: "LIMIT";
|
|
169
|
+
MARKET: "MARKET";
|
|
170
|
+
}>;
|
|
171
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
172
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
173
|
+
GTC: "GTC";
|
|
174
|
+
IOC: "IOC";
|
|
175
|
+
}>>;
|
|
176
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
stopLoss: z.ZodOptional<z.ZodObject<{
|
|
180
|
+
triggerPrice: z.ZodString;
|
|
181
|
+
orderType: z.ZodEnum<{
|
|
182
|
+
LIMIT: "LIMIT";
|
|
183
|
+
MARKET: "MARKET";
|
|
184
|
+
}>;
|
|
185
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
186
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
187
|
+
GTC: "GTC";
|
|
188
|
+
IOC: "IOC";
|
|
189
|
+
}>>;
|
|
190
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
191
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
115
193
|
}, z.core.$strip>>;
|
|
116
194
|
}, z.core.$strip>;
|
|
117
195
|
/**
|
|
@@ -166,13 +244,6 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
|
|
|
166
244
|
page: z.ZodOptional<z.ZodNumber>;
|
|
167
245
|
page_size: z.ZodOptional<z.ZodNumber>;
|
|
168
246
|
}, z.core.$strip>;
|
|
169
|
-
/**
|
|
170
|
-
* Order type validation
|
|
171
|
-
*/
|
|
172
|
-
export declare const OrderTypeSchema: z.ZodEnum<{
|
|
173
|
-
LIMIT: "LIMIT";
|
|
174
|
-
MARKET: "MARKET";
|
|
175
|
-
}>;
|
|
176
247
|
export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
|
|
177
248
|
STOP_LOSS: "STOP_LOSS";
|
|
178
249
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
@@ -183,6 +254,7 @@ export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
|
|
|
183
254
|
export declare const ConditionalOrderStateSchema: z.ZodEnum<{
|
|
184
255
|
CANCELLED: "CANCELLED";
|
|
185
256
|
EXPIRED: "EXPIRED";
|
|
257
|
+
PENDING_PARENT: "PENDING_PARENT";
|
|
186
258
|
ACTIVE: "ACTIVE";
|
|
187
259
|
TRIGGERING: "TRIGGERING";
|
|
188
260
|
TRIGGERED: "TRIGGERED";
|
|
@@ -192,7 +264,6 @@ export declare const ClosePositionSideSchema: z.ZodEnum<{
|
|
|
192
264
|
LONG: "LONG";
|
|
193
265
|
SHORT: "SHORT";
|
|
194
266
|
}>;
|
|
195
|
-
export declare const SlippageToleranceBpsSchema: z.ZodNumber;
|
|
196
267
|
export declare const CreateConditionalOrderSchema: z.ZodObject<{
|
|
197
268
|
tradingPairId: z.ZodUUID;
|
|
198
269
|
marginAccountId: z.ZodUUID;
|
|
@@ -235,6 +306,7 @@ export declare const ListConditionalOrdersSchema: z.ZodObject<{
|
|
|
235
306
|
state: z.ZodOptional<z.ZodEnum<{
|
|
236
307
|
CANCELLED: "CANCELLED";
|
|
237
308
|
EXPIRED: "EXPIRED";
|
|
309
|
+
PENDING_PARENT: "PENDING_PARENT";
|
|
238
310
|
ACTIVE: "ACTIVE";
|
|
239
311
|
TRIGGERING: "TRIGGERING";
|
|
240
312
|
TRIGGERED: "TRIGGERED";
|
|
@@ -33,6 +33,12 @@ export const TimeInForceSchema = z.enum(["GTC", "IOC", "FOK"], {
|
|
|
33
33
|
export const ConditionalTimeInForceSchema = z.enum(["GTC", "IOC"], {
|
|
34
34
|
message: 'Conditional order time in force must be "GTC" or "IOC"',
|
|
35
35
|
});
|
|
36
|
+
/**
|
|
37
|
+
* Order type validation
|
|
38
|
+
*/
|
|
39
|
+
export const OrderTypeSchema = z.enum(["LIMIT", "MARKET"], {
|
|
40
|
+
message: 'Order type must be "LIMIT" or "MARKET"',
|
|
41
|
+
});
|
|
36
42
|
/**
|
|
37
43
|
* Positive decimal string validation (for quantities and prices)
|
|
38
44
|
*/
|
|
@@ -64,6 +70,37 @@ export const SlippageToleranceSchema = z
|
|
|
64
70
|
.min(0, "Slippage tolerance must be at least 0 (no slippage)")
|
|
65
71
|
.max(1, "Slippage tolerance cannot exceed 1 (100%)")
|
|
66
72
|
.optional();
|
|
73
|
+
export const SlippageToleranceBpsSchema = z
|
|
74
|
+
.number()
|
|
75
|
+
.int()
|
|
76
|
+
.min(0, "Slippage tolerance must be at least 0 bps")
|
|
77
|
+
.max(10000, "Slippage tolerance cannot exceed 10000 bps");
|
|
78
|
+
export const ParentTpSlLegSchema = z
|
|
79
|
+
.object({
|
|
80
|
+
triggerPrice: PositiveDecimalStringSchema,
|
|
81
|
+
orderType: OrderTypeSchema,
|
|
82
|
+
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
83
|
+
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
84
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
85
|
+
expiresAt: ISO8601DateSchema.optional(),
|
|
86
|
+
})
|
|
87
|
+
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
88
|
+
message: "limitPrice is required for LIMIT parent TP/SL",
|
|
89
|
+
path: ["limitPrice"],
|
|
90
|
+
})
|
|
91
|
+
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
92
|
+
message: "limitPrice must not be provided for MARKET parent TP/SL",
|
|
93
|
+
path: ["limitPrice"],
|
|
94
|
+
})
|
|
95
|
+
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
96
|
+
message: "timeInForce is only allowed for LIMIT parent TP/SL",
|
|
97
|
+
path: ["timeInForce"],
|
|
98
|
+
})
|
|
99
|
+
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
100
|
+
message: "slippageToleranceBps is only allowed for MARKET parent TP/SL",
|
|
101
|
+
path: ["slippageToleranceBps"],
|
|
102
|
+
});
|
|
103
|
+
const hasParentTpSl = (options) => options?.takeProfit !== undefined || options?.stopLoss !== undefined;
|
|
67
104
|
/**
|
|
68
105
|
* Place Limit Order validation schema
|
|
69
106
|
*/
|
|
@@ -83,6 +120,8 @@ export const PlaceLimitOrderSchema = z
|
|
|
83
120
|
positionSide: PositionSideSchema.optional(),
|
|
84
121
|
leverage: PositiveDecimalStringSchema.optional(),
|
|
85
122
|
reduceOnly: z.boolean().optional(),
|
|
123
|
+
takeProfit: ParentTpSlLegSchema.optional(),
|
|
124
|
+
stopLoss: ParentTpSlLegSchema.optional(),
|
|
86
125
|
})
|
|
87
126
|
.optional(),
|
|
88
127
|
})
|
|
@@ -97,6 +136,18 @@ export const PlaceLimitOrderSchema = z
|
|
|
97
136
|
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
98
137
|
message: "leverage is required for MARGIN orders",
|
|
99
138
|
path: ["options", "leverage"],
|
|
139
|
+
})
|
|
140
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
|
|
141
|
+
message: "Parent TP/SL is only supported for MARGIN orders",
|
|
142
|
+
path: ["options", "tradingMode"],
|
|
143
|
+
})
|
|
144
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.positionSide !== "NONE", {
|
|
145
|
+
message: "Parent TP/SL requires positionSide to be LONG or SHORT",
|
|
146
|
+
path: ["options", "positionSide"],
|
|
147
|
+
})
|
|
148
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
|
|
149
|
+
message: "Parent TP/SL cannot be attached to reduceOnly orders",
|
|
150
|
+
path: ["options", "reduceOnly"],
|
|
100
151
|
});
|
|
101
152
|
/**
|
|
102
153
|
* Place Market Order validation schema
|
|
@@ -114,6 +165,8 @@ export const PlaceMarketOrderSchema = z
|
|
|
114
165
|
positionSide: PositionSideSchema.optional(),
|
|
115
166
|
leverage: PositiveDecimalStringSchema.optional(),
|
|
116
167
|
reduceOnly: z.boolean().optional(),
|
|
168
|
+
takeProfit: ParentTpSlLegSchema.optional(),
|
|
169
|
+
stopLoss: ParentTpSlLegSchema.optional(),
|
|
117
170
|
})
|
|
118
171
|
.optional(),
|
|
119
172
|
})
|
|
@@ -128,6 +181,18 @@ export const PlaceMarketOrderSchema = z
|
|
|
128
181
|
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
129
182
|
message: "leverage is required for MARGIN orders",
|
|
130
183
|
path: ["options", "leverage"],
|
|
184
|
+
})
|
|
185
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
|
|
186
|
+
message: "Parent TP/SL is only supported for MARGIN orders",
|
|
187
|
+
path: ["options", "tradingMode"],
|
|
188
|
+
})
|
|
189
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.positionSide !== "NONE", {
|
|
190
|
+
message: "Parent TP/SL requires positionSide to be LONG or SHORT",
|
|
191
|
+
path: ["options", "positionSide"],
|
|
192
|
+
})
|
|
193
|
+
.refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
|
|
194
|
+
message: "Parent TP/SL cannot be attached to reduceOnly orders",
|
|
195
|
+
path: ["options", "reduceOnly"],
|
|
131
196
|
});
|
|
132
197
|
/**
|
|
133
198
|
* Cancel Order validation schema
|
|
@@ -169,29 +234,18 @@ export const GetPaginatedOrdersSchema = z.object({
|
|
|
169
234
|
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
170
235
|
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
171
236
|
});
|
|
172
|
-
/**
|
|
173
|
-
* Order type validation
|
|
174
|
-
*/
|
|
175
|
-
export const OrderTypeSchema = z.enum(["LIMIT", "MARKET"], {
|
|
176
|
-
message: 'Order type must be "LIMIT" or "MARKET"',
|
|
177
|
-
});
|
|
178
237
|
export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
|
|
179
238
|
message: 'conditionType must be "STOP_LOSS" or "TAKE_PROFIT"',
|
|
180
239
|
});
|
|
181
240
|
export const ConditionalOrderTriggerSourceSchema = z.enum(["MARK_PRICE"], {
|
|
182
241
|
message: 'triggerSource must be "MARK_PRICE"',
|
|
183
242
|
});
|
|
184
|
-
export const ConditionalOrderStateSchema = z.enum(["ACTIVE", "TRIGGERING", "TRIGGERED", "CANCELLED", "EXPIRED", "FAILED"], {
|
|
243
|
+
export const ConditionalOrderStateSchema = z.enum(["PENDING_PARENT", "ACTIVE", "TRIGGERING", "TRIGGERED", "CANCELLED", "EXPIRED", "FAILED"], {
|
|
185
244
|
message: "Invalid conditional order state",
|
|
186
245
|
});
|
|
187
246
|
export const ClosePositionSideSchema = z.enum(["LONG", "SHORT"], {
|
|
188
247
|
message: 'Position side must be "LONG" or "SHORT"',
|
|
189
248
|
});
|
|
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
249
|
export const CreateConditionalOrderSchema = z
|
|
196
250
|
.object({
|
|
197
251
|
tradingPairId: UUIDSchema,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, OrderSide, OrderType, PositionSide, TimeInForce } from "../../trading";
|
|
2
|
-
export type ConditionalOrderEventReason = "created" | "cancelled" | "triggered" | "failed" | "oco_cancelled";
|
|
2
|
+
export type ConditionalOrderEventReason = "created" | "activated" | "cancelled" | "parent_cancelled" | "triggered" | "failed" | "oco_cancelled";
|
|
3
3
|
export interface ConditionalOrderEventData {
|
|
4
4
|
conditionalOrderId: string;
|
|
5
5
|
tradingPairId: string;
|
|
6
6
|
marginAccountId: string;
|
|
7
7
|
positionId?: string;
|
|
8
|
+
parentOrderId?: string;
|
|
9
|
+
associationType?: "POSITION" | "PARENT_ORDER";
|
|
8
10
|
linkedGroupId?: string;
|
|
9
11
|
conditionType: ConditionalOrderConditionType;
|
|
10
12
|
triggerSource: ConditionalOrderTriggerSource;
|
|
@@ -20,6 +22,7 @@ export interface ConditionalOrderEventData {
|
|
|
20
22
|
state: ConditionalOrderState;
|
|
21
23
|
triggeredOrderId?: string;
|
|
22
24
|
triggeredAt?: string;
|
|
25
|
+
activatedAt?: string;
|
|
23
26
|
cancelledAt?: string;
|
|
24
27
|
expiresAt?: string;
|
|
25
28
|
failureReason?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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.
|
|
23
|
+
"@0xmonaco/contracts": "0.8.1",
|
|
24
24
|
"zod": "^4.1.12"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|