@0xmonaco/types 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/auth/index.d.ts +3 -3
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2 -0
  4. package/dist/margin-accounts/index.d.ts +106 -0
  5. package/dist/margin-accounts/index.js +0 -0
  6. package/dist/market/index.d.ts +104 -15
  7. package/dist/positions/index.d.ts +128 -0
  8. package/dist/positions/index.js +0 -0
  9. package/dist/profile/index.d.ts +2 -2
  10. package/dist/sdk/index.d.ts +8 -1
  11. package/dist/trading/index.d.ts +25 -5
  12. package/dist/trading/orders.d.ts +27 -1
  13. package/dist/trading/responses.d.ts +84 -15
  14. package/dist/validation/index.d.ts +2 -0
  15. package/dist/validation/index.js +2 -0
  16. package/dist/validation/margin-accounts.d.ts +55 -0
  17. package/dist/validation/margin-accounts.js +59 -0
  18. package/dist/validation/positions.d.ts +89 -0
  19. package/dist/validation/positions.js +93 -0
  20. package/dist/validation/trading.d.ts +123 -2
  21. package/dist/validation/trading.js +126 -5
  22. package/dist/websocket/events/conditional-order-events.d.ts +33 -0
  23. package/dist/websocket/events/conditional-order-events.js +0 -0
  24. package/dist/websocket/events/index.d.ts +1 -0
  25. package/dist/websocket/events/index.js +1 -0
  26. package/dist/websocket/events/orders-events.d.ts +2 -2
  27. package/package.json +1 -1
  28. package/dist/api/index.d.ts.map +0 -1
  29. package/dist/api/index.js.map +0 -1
  30. package/dist/applications/index.d.ts.map +0 -1
  31. package/dist/applications/index.js.map +0 -1
  32. package/dist/applications/responses.d.ts.map +0 -1
  33. package/dist/applications/responses.js.map +0 -1
  34. package/dist/auth/index.d.ts.map +0 -1
  35. package/dist/auth/index.js.map +0 -1
  36. package/dist/auth/responses.d.ts.map +0 -1
  37. package/dist/auth/responses.js.map +0 -1
  38. package/dist/contracts/balances.d.ts.map +0 -1
  39. package/dist/contracts/balances.js.map +0 -1
  40. package/dist/contracts/index.d.ts.map +0 -1
  41. package/dist/contracts/index.js.map +0 -1
  42. package/dist/fees/index.d.ts.map +0 -1
  43. package/dist/fees/index.js.map +0 -1
  44. package/dist/fees/responses.d.ts.map +0 -1
  45. package/dist/fees/responses.js.map +0 -1
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/index.js.map +0 -1
  48. package/dist/market/index.d.ts.map +0 -1
  49. package/dist/market/index.js.map +0 -1
  50. package/dist/profile/index.d.ts.map +0 -1
  51. package/dist/profile/index.js.map +0 -1
  52. package/dist/sdk/index.d.ts.map +0 -1
  53. package/dist/sdk/index.js.map +0 -1
  54. package/dist/sdk/network.d.ts.map +0 -1
  55. package/dist/sdk/network.js.map +0 -1
  56. package/dist/trading/index.d.ts.map +0 -1
  57. package/dist/trading/index.js.map +0 -1
  58. package/dist/trading/orders.d.ts.map +0 -1
  59. package/dist/trading/orders.js.map +0 -1
  60. package/dist/trading/responses.d.ts.map +0 -1
  61. package/dist/trading/responses.js.map +0 -1
  62. package/dist/validation/common.d.ts.map +0 -1
  63. package/dist/validation/common.js.map +0 -1
  64. package/dist/validation/index.d.ts.map +0 -1
  65. package/dist/validation/index.js.map +0 -1
  66. package/dist/validation/market.d.ts.map +0 -1
  67. package/dist/validation/market.js.map +0 -1
  68. package/dist/validation/profile.d.ts.map +0 -1
  69. package/dist/validation/profile.js.map +0 -1
  70. package/dist/validation/trading.d.ts.map +0 -1
  71. package/dist/validation/trading.js.map +0 -1
  72. package/dist/validation/vault.d.ts.map +0 -1
  73. package/dist/validation/vault.js.map +0 -1
  74. package/dist/vault/index.d.ts.map +0 -1
  75. package/dist/vault/index.js.map +0 -1
  76. package/dist/vault/responses.d.ts.map +0 -1
  77. package/dist/vault/responses.js.map +0 -1
  78. package/dist/websocket/base.d.ts.map +0 -1
  79. package/dist/websocket/base.js.map +0 -1
  80. package/dist/websocket/clients/orderbook-client.d.ts.map +0 -1
  81. package/dist/websocket/clients/orderbook-client.js.map +0 -1
  82. package/dist/websocket/events/balance-events.d.ts.map +0 -1
  83. package/dist/websocket/events/balance-events.js.map +0 -1
  84. package/dist/websocket/events/index.d.ts.map +0 -1
  85. package/dist/websocket/events/index.js.map +0 -1
  86. package/dist/websocket/events/movement-events.d.ts.map +0 -1
  87. package/dist/websocket/events/movement-events.js.map +0 -1
  88. package/dist/websocket/events/ohlcv-events.d.ts.map +0 -1
  89. package/dist/websocket/events/ohlcv-events.js.map +0 -1
  90. package/dist/websocket/events/orderbook-events.d.ts.map +0 -1
  91. package/dist/websocket/events/orderbook-events.js.map +0 -1
  92. package/dist/websocket/events/orders-events.d.ts.map +0 -1
  93. package/dist/websocket/events/orders-events.js.map +0 -1
  94. package/dist/websocket/events/trade-events.d.ts.map +0 -1
  95. package/dist/websocket/events/trade-events.js.map +0 -1
  96. package/dist/websocket/index.d.ts.map +0 -1
  97. package/dist/websocket/index.js.map +0 -1
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Response types for trading operations.
5
5
  */
6
- import type { Order, OrderSide, OrderStatus, OrderType, TimeInForce, TradingMode } from "./orders";
6
+ import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode } from "./orders";
7
7
  /**
8
8
  * Match result information for order execution.
9
9
  * Contains detailed information about trades, fills, and execution quality.
@@ -97,7 +97,11 @@ export interface GetPaginatedOrdersParams {
97
97
  /** Filter by order status */
98
98
  status?: OrderStatus;
99
99
  /** Filter by trading pair UUID */
100
- trading_pair?: string;
100
+ trading_pair_id?: string;
101
+ /** Filter by trading mode */
102
+ trading_mode?: TradingMode;
103
+ /** Filter by margin account UUID */
104
+ margin_account_id?: string;
101
105
  /** Page number for pagination (default: 1) */
102
106
  page?: number;
103
107
  /** Number of orders per page (default: 10, max: 100) */
@@ -147,8 +151,6 @@ export interface BatchCancelError {
147
151
  export interface BatchCancelResult {
148
152
  /** Order identifier */
149
153
  order_id: string;
150
- /** Whether the cancellation was successful */
151
- success: boolean;
152
154
  /** Timestamp when the order was canceled (ISO 8601 format) */
153
155
  cancelled_at?: string;
154
156
  /** Error details if the cancellation failed */
@@ -158,8 +160,6 @@ export interface BatchCancelResult {
158
160
  * Response from batch cancelling orders
159
161
  */
160
162
  export interface BatchCancelOrdersResponse {
161
- /** Overall operation success */
162
- success: boolean;
163
163
  /** Total number of orders requested to cancel */
164
164
  total_requested: number;
165
165
  /** Total number of orders successfully canceled */
@@ -184,8 +184,6 @@ export interface BatchError {
184
184
  export interface BatchCreateResult {
185
185
  /** Order identifier (empty string if creation failed before ID assignment) */
186
186
  order_id: string;
187
- /** Whether the order was successfully created */
188
- success: boolean;
189
187
  /** Match result information if the order was processed */
190
188
  match_result?: MatchResult;
191
189
  /** Error details if the creation failed */
@@ -195,8 +193,6 @@ export interface BatchCreateResult {
195
193
  * Response from batch creating orders
196
194
  */
197
195
  export interface BatchCreateOrdersResponse {
198
- /** Overall operation success */
199
- success: boolean;
200
196
  /** Total number of orders requested to create */
201
197
  total_requested: number;
202
198
  /** Total number of orders successfully created */
@@ -212,8 +208,6 @@ export interface BatchCreateOrdersResponse {
212
208
  export interface BatchReplaceResult {
213
209
  /** Original order identifier */
214
210
  original_order_id: string;
215
- /** Whether the order was successfully replaced */
216
- success: boolean;
217
211
  /** New order identifier (if successful) */
218
212
  new_order_id?: string;
219
213
  /** Fields that were updated (if successful) */
@@ -227,8 +221,6 @@ export interface BatchReplaceResult {
227
221
  * Response from batch replacing orders
228
222
  */
229
223
  export interface BatchReplaceOrdersResponse {
230
- /** Overall operation success */
231
- success: boolean;
232
224
  /** Total number of orders requested to replace */
233
225
  total_requested: number;
234
226
  /** Total number of orders successfully replaced */
@@ -253,7 +245,7 @@ export interface BatchCreateOrderParams {
253
245
  /** Order quantity */
254
246
  quantity: string;
255
247
  /** Trading mode (defaults to "SPOT") */
256
- tradingMode?: Extract<TradingMode, "SPOT">;
248
+ tradingMode?: TradingMode;
257
249
  /** Maximum slippage for market orders as decimal (e.g., 0.01 for 1%) */
258
250
  slippageTolerance?: number;
259
251
  /** For sub-accounts: use master's balance */
@@ -262,6 +254,14 @@ export interface BatchCreateOrderParams {
262
254
  expirationDate?: string;
263
255
  /** Time in force: "GTC", "IOC", or "FOK" */
264
256
  timeInForce?: Extract<TimeInForce, "GTC" | "IOC" | "FOK">;
257
+ /** Margin account UUID for margin/perp orders */
258
+ marginAccountId?: string;
259
+ /** Position side for margin/perp orders */
260
+ positionSide?: PositionSide;
261
+ /** Leverage for margin/perp orders */
262
+ leverage?: string;
263
+ /** Whether the order can only reduce existing exposure */
264
+ reduceOnly?: boolean;
265
265
  }
266
266
  /**
267
267
  * Parameters for a single order in a batch replace request
@@ -276,3 +276,72 @@ export interface BatchReplaceOrderParams {
276
276
  /** For sub-accounts: use master's balance (optional) */
277
277
  useMasterBalance?: boolean;
278
278
  }
279
+ /**
280
+ * Parameters for creating a standalone conditional TP/SL order.
281
+ */
282
+ export interface CreateConditionalOrderParams {
283
+ tradingPairId: string;
284
+ marginAccountId: string;
285
+ conditionType: ConditionalOrderConditionType;
286
+ triggerPrice: string;
287
+ triggerSource?: ConditionalOrderTriggerSource;
288
+ side: OrderSide;
289
+ positionSide: Exclude<PositionSide, "NONE">;
290
+ orderType: OrderType;
291
+ limitPrice?: string;
292
+ quantity?: string;
293
+ reduceOnly?: boolean;
294
+ timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
295
+ slippageToleranceBps?: number;
296
+ expiresAt?: string;
297
+ }
298
+ export interface CreateConditionalOrderResponse {
299
+ conditional_order_id: string;
300
+ status: "SUCCESS" | "FAILED";
301
+ message: string;
302
+ state: ConditionalOrderState;
303
+ }
304
+ export interface CancelConditionalOrderResponse {
305
+ conditional_order_id: string;
306
+ status: "SUCCESS" | "FAILED";
307
+ message: string;
308
+ }
309
+ export interface ListConditionalOrdersParams {
310
+ margin_account_id?: string;
311
+ trading_pair_id?: string;
312
+ state?: ConditionalOrderState;
313
+ page?: number;
314
+ page_size?: number;
315
+ }
316
+ export interface ConditionalOrder {
317
+ conditional_order_id: string;
318
+ trading_pair_id: string;
319
+ margin_account_id: string;
320
+ position_id?: string;
321
+ linked_group_id?: string;
322
+ condition_type: ConditionalOrderConditionType;
323
+ trigger_source: ConditionalOrderTriggerSource;
324
+ trigger_price: string;
325
+ side: OrderSide;
326
+ position_side: PositionSide;
327
+ order_type: OrderType;
328
+ limit_price?: string;
329
+ quantity?: string;
330
+ slippage_tolerance_bps?: number;
331
+ reduce_only: boolean;
332
+ time_in_force?: TimeInForce;
333
+ state: ConditionalOrderState;
334
+ triggered_order_id?: string;
335
+ triggered_at?: string;
336
+ cancelled_at?: string;
337
+ expires_at?: string;
338
+ failure_reason?: string;
339
+ created_at: string;
340
+ updated_at: string;
341
+ }
342
+ export interface ListConditionalOrdersResponse {
343
+ orders: ConditionalOrder[];
344
+ total: number;
345
+ page: number;
346
+ page_size: number;
347
+ }
@@ -14,7 +14,9 @@
14
14
  * - Market schemas (trading pairs, candlesticks)
15
15
  */
16
16
  export * from "./common.js";
17
+ export * from "./margin-accounts.js";
17
18
  export * from "./market.js";
19
+ export * from "./positions.js";
18
20
  export * from "./profile.js";
19
21
  export * from "./trading.js";
20
22
  export * from "./vault.js";
@@ -15,7 +15,9 @@
15
15
  */
16
16
  // Export validation utilities
17
17
  export * from "./common.js";
18
+ export * from "./margin-accounts.js";
18
19
  export * from "./market.js";
20
+ export * from "./positions.js";
19
21
  // Export module-specific schemas
20
22
  export * from "./profile.js";
21
23
  export * from "./trading.js";
@@ -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
  /**
@@ -114,7 +142,7 @@ export declare const ReplaceOrderSchema: z.ZodObject<{
114
142
  * Validates parameters for fetching paginated orders.
115
143
  * Matches the getPaginatedOrders method signature which accepts:
116
144
  * - status: OrderStatus (optional filter)
117
- * - trading_pair: trading pair UUID (optional filter)
145
+ * - trading_pair_id: trading pair UUID (optional filter)
118
146
  * - page: number (default: 1)
119
147
  * - page_size: number (default: 10, max: 100)
120
148
  */
@@ -129,7 +157,12 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
129
157
  REJECTED: "REJECTED";
130
158
  EXPIRED: "EXPIRED";
131
159
  }>>;
132
- trading_pair: z.ZodOptional<z.ZodUUID>;
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
  /**