@0xmonaco/types 0.7.7 → 0.7.8

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 (81) hide show
  1. package/dist/api/index.d.ts +18 -0
  2. package/dist/api/index.js +6 -0
  3. package/dist/applications/index.d.ts +23 -0
  4. package/dist/applications/index.js +5 -0
  5. package/dist/applications/responses.d.ts +22 -0
  6. package/dist/applications/responses.js +5 -0
  7. package/dist/auth/index.d.ts +81 -0
  8. package/dist/auth/index.js +6 -0
  9. package/dist/auth/responses.d.ts +67 -0
  10. package/dist/auth/responses.js +5 -0
  11. package/dist/contracts/balances.d.ts +43 -0
  12. package/dist/contracts/balances.js +5 -0
  13. package/dist/contracts/index.d.ts +27 -0
  14. package/dist/contracts/index.js +5 -0
  15. package/dist/fees/index.d.ts +39 -0
  16. package/dist/fees/index.js +6 -0
  17. package/dist/fees/responses.d.ts +54 -0
  18. package/dist/fees/responses.js +86 -0
  19. package/dist/index.d.ts +20 -0
  20. package/dist/index.js +21 -0
  21. package/dist/margin-accounts/index.d.ts +110 -0
  22. package/dist/margin-accounts/index.js +0 -0
  23. package/dist/market/index.d.ts +312 -0
  24. package/dist/market/index.js +5 -0
  25. package/dist/positions/index.d.ts +128 -0
  26. package/dist/positions/index.js +0 -0
  27. package/dist/profile/index.d.ts +405 -0
  28. package/dist/profile/index.js +5 -0
  29. package/dist/sdk/index.d.ts +131 -0
  30. package/dist/sdk/index.js +0 -0
  31. package/dist/sdk/network.d.ts +25 -0
  32. package/dist/sdk/network.js +5 -0
  33. package/dist/trading/index.d.ts +132 -0
  34. package/dist/trading/index.js +6 -0
  35. package/dist/trading/orders.d.ts +137 -0
  36. package/dist/trading/orders.js +9 -0
  37. package/dist/trading/responses.d.ts +347 -0
  38. package/dist/trading/responses.js +5 -0
  39. package/dist/validation/common.d.ts +179 -0
  40. package/dist/validation/common.js +199 -0
  41. package/dist/validation/index.d.ts +22 -0
  42. package/dist/validation/index.js +24 -0
  43. package/dist/validation/margin-accounts.d.ts +55 -0
  44. package/dist/validation/margin-accounts.js +59 -0
  45. package/dist/validation/market.d.ts +214 -0
  46. package/dist/validation/market.js +225 -0
  47. package/dist/validation/positions.d.ts +89 -0
  48. package/dist/validation/positions.js +93 -0
  49. package/dist/validation/profile.d.ts +69 -0
  50. package/dist/validation/profile.js +44 -0
  51. package/dist/validation/trading.d.ts +350 -0
  52. package/dist/validation/trading.js +313 -0
  53. package/dist/validation/vault.d.ts +66 -0
  54. package/dist/validation/vault.js +79 -0
  55. package/dist/vault/index.d.ts +84 -0
  56. package/dist/vault/index.js +5 -0
  57. package/dist/vault/responses.d.ts +51 -0
  58. package/dist/vault/responses.js +5 -0
  59. package/dist/websocket/base.d.ts +31 -0
  60. package/dist/websocket/base.js +5 -0
  61. package/dist/websocket/clients/orderbook-client.d.ts +14 -0
  62. package/dist/websocket/clients/orderbook-client.js +3 -0
  63. package/dist/websocket/events/balance-events.d.ts +48 -0
  64. package/dist/websocket/events/balance-events.js +6 -0
  65. package/dist/websocket/events/conditional-order-events.d.ts +33 -0
  66. package/dist/websocket/events/conditional-order-events.js +0 -0
  67. package/dist/websocket/events/index.d.ts +7 -0
  68. package/dist/websocket/events/index.js +7 -0
  69. package/dist/websocket/events/movement-events.d.ts +64 -0
  70. package/dist/websocket/events/movement-events.js +6 -0
  71. package/dist/websocket/events/ohlcv-events.d.ts +31 -0
  72. package/dist/websocket/events/ohlcv-events.js +5 -0
  73. package/dist/websocket/events/orderbook-events.d.ts +72 -0
  74. package/dist/websocket/events/orderbook-events.js +5 -0
  75. package/dist/websocket/events/orders-events.d.ts +284 -0
  76. package/dist/websocket/events/orders-events.js +0 -0
  77. package/dist/websocket/events/trade-events.d.ts +34 -0
  78. package/dist/websocket/events/trade-events.js +5 -0
  79. package/dist/websocket/index.d.ts +8 -0
  80. package/dist/websocket/index.js +8 -0
  81. package/package.json +2 -2
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Common Validation Utilities
3
+ *
4
+ * Shared utilities for runtime validation across all SDK modules.
5
+ * These utilities work with any Zod schema and provide consistent
6
+ * error handling throughout the SDK.
7
+ */
8
+ import type { z } from "zod";
9
+ /**
10
+ * Validation error class for user-friendly error messages.
11
+ *
12
+ * Wraps Zod validation errors to provide better error formatting and
13
+ * structured error access for API consumers. This error is thrown when
14
+ * validation fails on any SDK parameters.
15
+ *
16
+ * **Features:**
17
+ * - Human-readable error message with field paths
18
+ * - Access to raw Zod issues for detailed error handling
19
+ * - Structured error object via `getErrors()` method
20
+ *
21
+ * **Example Usage:**
22
+ * ```typescript
23
+ * import { validate, PlaceLimitOrderSchema } from '@0xmonaco/types';
24
+ *
25
+ * try {
26
+ * const validated = validate(PlaceLimitOrderSchema, {
27
+ * tradingPairId: "invalid-uuid",
28
+ * side: "BUY",
29
+ * quantity: "-10", // Invalid: negative
30
+ * price: "100"
31
+ * });
32
+ * } catch (error) {
33
+ * if (error instanceof ValidationError) {
34
+ * // Human-readable message
35
+ * console.log(error.message);
36
+ * // "Validation failed:
37
+ * // - tradingPairId: Invalid uuid
38
+ * // - quantity: Number must be greater than 0"
39
+ *
40
+ * // Structured errors for form validation
41
+ * const errors = error.getErrors();
42
+ * console.log(errors);
43
+ * // {
44
+ * // "tradingPairId": "Invalid uuid",
45
+ * // "quantity": "Number must be greater than 0"
46
+ * // }
47
+ *
48
+ * // Raw Zod issues for advanced handling
49
+ * console.log(error.issues);
50
+ * }
51
+ * }
52
+ * ```
53
+ *
54
+ * @see {@link validate} - Helper function that throws ValidationError
55
+ */
56
+ export declare class ValidationError extends Error {
57
+ /**
58
+ * Array of Zod validation issues containing detailed error information.
59
+ * Each issue includes the field path, error code, and message.
60
+ */
61
+ readonly issues: z.core.$ZodIssue[];
62
+ /**
63
+ * Creates a new ValidationError from a Zod validation error.
64
+ *
65
+ * Automatically formats all validation issues into a human-readable
66
+ * message and stores the raw issues for programmatic access.
67
+ *
68
+ * @param zodError - The Zod validation error to wrap
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const result = schema.safeParse(data);
73
+ * if (!result.success) {
74
+ * throw new ValidationError(result.error);
75
+ * }
76
+ * ```
77
+ */
78
+ constructor(zodError: z.ZodError);
79
+ /**
80
+ * Get validation errors as a structured object for easy field-level error display.
81
+ *
82
+ * Converts the array of Zod issues into a simple key-value object where
83
+ * keys are field paths (dot-notation) and values are error messages.
84
+ * Root-level errors (no path) are stored under the "root" key.
85
+ *
86
+ * **Use Cases:**
87
+ * - Form validation (map errors to input fields)
88
+ * - API error responses (structured JSON)
89
+ * - Error aggregation and reporting
90
+ *
91
+ * @returns Object mapping field paths to error messages
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // Single field errors
96
+ * error.getErrors();
97
+ * // { "price": "Number must be greater than 0" }
98
+ *
99
+ * // Multiple field errors
100
+ * error.getErrors();
101
+ * // {
102
+ * // "tradingPairId": "Invalid uuid",
103
+ * // "quantity": "Required",
104
+ * // "options.timeInForce": "Invalid enum value"
105
+ * // }
106
+ *
107
+ * // Root-level error (no specific field)
108
+ * error.getErrors();
109
+ * // { "root": "At least one field is required" }
110
+ *
111
+ * // Use in React form
112
+ * const errors = validationError.getErrors();
113
+ * <input error={errors.price} />
114
+ * ```
115
+ */
116
+ getErrors(): Record<string, string>;
117
+ }
118
+ /**
119
+ * Validates data against a Zod schema and throws user-friendly errors on failure.
120
+ *
121
+ * This is a convenience wrapper around Zod's `safeParse` that automatically
122
+ * throws a {@link ValidationError} with formatted error messages when validation fails.
123
+ *
124
+ * **When to Use:**
125
+ * - Validating user input before API calls
126
+ * - Runtime type checking for dynamic data
127
+ * - Ensuring data integrity before processing
128
+ *
129
+ * **Error Handling:**
130
+ * On validation failure, throws {@link ValidationError} which provides:
131
+ * - Human-readable error message
132
+ * - Structured errors via `getErrors()`
133
+ * - Raw Zod issues for advanced handling
134
+ *
135
+ * @template T - The expected type after validation
136
+ * @param schema - Zod schema to validate against
137
+ * @param data - Data to validate (unknown type for safety)
138
+ * @returns Validated and typed data
139
+ * @throws {@link ValidationError} When validation fails
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * import { validate, PlaceLimitOrderSchema } from '@0xmonaco/types';
144
+ *
145
+ * // Basic validation
146
+ * try {
147
+ * const validatedOrder = validate(PlaceLimitOrderSchema, userInput);
148
+ * // validatedOrder is now typed and guaranteed valid
149
+ * await sdk.trading.placeLimitOrder(...validatedOrder);
150
+ * } catch (error) {
151
+ * if (error instanceof ValidationError) {
152
+ * // Show user-friendly errors
153
+ * console.error(error.message);
154
+ * const fieldErrors = error.getErrors();
155
+ * // Display errors next to form fields
156
+ * }
157
+ * }
158
+ *
159
+ * // With custom error handling
160
+ * function safeValidate<T>(schema: z.ZodSchema<T>, data: unknown) {
161
+ * try {
162
+ * return { success: true, data: validate(schema, data) };
163
+ * } catch (error) {
164
+ * if (error instanceof ValidationError) {
165
+ * return { success: false, errors: error.getErrors() };
166
+ * }
167
+ * throw error; // Re-throw unexpected errors
168
+ * }
169
+ * }
170
+ *
171
+ * const result = safeValidate(PlaceLimitOrderSchema, input);
172
+ * if (result.success) {
173
+ * // Use result.data
174
+ * } else {
175
+ * // Handle result.errors
176
+ * }
177
+ * ```
178
+ */
179
+ export declare function validate<T>(schema: z.ZodSchema<T>, data: unknown): T;
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Common Validation Utilities
3
+ *
4
+ * Shared utilities for runtime validation across all SDK modules.
5
+ * These utilities work with any Zod schema and provide consistent
6
+ * error handling throughout the SDK.
7
+ */
8
+ /**
9
+ * Validation error class for user-friendly error messages.
10
+ *
11
+ * Wraps Zod validation errors to provide better error formatting and
12
+ * structured error access for API consumers. This error is thrown when
13
+ * validation fails on any SDK parameters.
14
+ *
15
+ * **Features:**
16
+ * - Human-readable error message with field paths
17
+ * - Access to raw Zod issues for detailed error handling
18
+ * - Structured error object via `getErrors()` method
19
+ *
20
+ * **Example Usage:**
21
+ * ```typescript
22
+ * import { validate, PlaceLimitOrderSchema } from '@0xmonaco/types';
23
+ *
24
+ * try {
25
+ * const validated = validate(PlaceLimitOrderSchema, {
26
+ * tradingPairId: "invalid-uuid",
27
+ * side: "BUY",
28
+ * quantity: "-10", // Invalid: negative
29
+ * price: "100"
30
+ * });
31
+ * } catch (error) {
32
+ * if (error instanceof ValidationError) {
33
+ * // Human-readable message
34
+ * console.log(error.message);
35
+ * // "Validation failed:
36
+ * // - tradingPairId: Invalid uuid
37
+ * // - quantity: Number must be greater than 0"
38
+ *
39
+ * // Structured errors for form validation
40
+ * const errors = error.getErrors();
41
+ * console.log(errors);
42
+ * // {
43
+ * // "tradingPairId": "Invalid uuid",
44
+ * // "quantity": "Number must be greater than 0"
45
+ * // }
46
+ *
47
+ * // Raw Zod issues for advanced handling
48
+ * console.log(error.issues);
49
+ * }
50
+ * }
51
+ * ```
52
+ *
53
+ * @see {@link validate} - Helper function that throws ValidationError
54
+ */
55
+ export class ValidationError extends Error {
56
+ /**
57
+ * Array of Zod validation issues containing detailed error information.
58
+ * Each issue includes the field path, error code, and message.
59
+ */
60
+ issues;
61
+ /**
62
+ * Creates a new ValidationError from a Zod validation error.
63
+ *
64
+ * Automatically formats all validation issues into a human-readable
65
+ * message and stores the raw issues for programmatic access.
66
+ *
67
+ * @param zodError - The Zod validation error to wrap
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = schema.safeParse(data);
72
+ * if (!result.success) {
73
+ * throw new ValidationError(result.error);
74
+ * }
75
+ * ```
76
+ */
77
+ constructor(zodError) {
78
+ const messages = zodError.issues.map((issue) => {
79
+ const path = issue.path.join(".");
80
+ return `${path ? `${path}: ` : ""}${issue.message}`;
81
+ });
82
+ super(`Validation failed:\n - ${messages.join("\n - ")}`);
83
+ this.name = "ValidationError";
84
+ this.issues = zodError.issues;
85
+ }
86
+ /**
87
+ * Get validation errors as a structured object for easy field-level error display.
88
+ *
89
+ * Converts the array of Zod issues into a simple key-value object where
90
+ * keys are field paths (dot-notation) and values are error messages.
91
+ * Root-level errors (no path) are stored under the "root" key.
92
+ *
93
+ * **Use Cases:**
94
+ * - Form validation (map errors to input fields)
95
+ * - API error responses (structured JSON)
96
+ * - Error aggregation and reporting
97
+ *
98
+ * @returns Object mapping field paths to error messages
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // Single field errors
103
+ * error.getErrors();
104
+ * // { "price": "Number must be greater than 0" }
105
+ *
106
+ * // Multiple field errors
107
+ * error.getErrors();
108
+ * // {
109
+ * // "tradingPairId": "Invalid uuid",
110
+ * // "quantity": "Required",
111
+ * // "options.timeInForce": "Invalid enum value"
112
+ * // }
113
+ *
114
+ * // Root-level error (no specific field)
115
+ * error.getErrors();
116
+ * // { "root": "At least one field is required" }
117
+ *
118
+ * // Use in React form
119
+ * const errors = validationError.getErrors();
120
+ * <input error={errors.price} />
121
+ * ```
122
+ */
123
+ getErrors() {
124
+ const errors = {};
125
+ for (const issue of this.issues) {
126
+ const path = issue.path.join(".");
127
+ errors[path || "root"] = issue.message;
128
+ }
129
+ return errors;
130
+ }
131
+ }
132
+ /**
133
+ * Validates data against a Zod schema and throws user-friendly errors on failure.
134
+ *
135
+ * This is a convenience wrapper around Zod's `safeParse` that automatically
136
+ * throws a {@link ValidationError} with formatted error messages when validation fails.
137
+ *
138
+ * **When to Use:**
139
+ * - Validating user input before API calls
140
+ * - Runtime type checking for dynamic data
141
+ * - Ensuring data integrity before processing
142
+ *
143
+ * **Error Handling:**
144
+ * On validation failure, throws {@link ValidationError} which provides:
145
+ * - Human-readable error message
146
+ * - Structured errors via `getErrors()`
147
+ * - Raw Zod issues for advanced handling
148
+ *
149
+ * @template T - The expected type after validation
150
+ * @param schema - Zod schema to validate against
151
+ * @param data - Data to validate (unknown type for safety)
152
+ * @returns Validated and typed data
153
+ * @throws {@link ValidationError} When validation fails
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * import { validate, PlaceLimitOrderSchema } from '@0xmonaco/types';
158
+ *
159
+ * // Basic validation
160
+ * try {
161
+ * const validatedOrder = validate(PlaceLimitOrderSchema, userInput);
162
+ * // validatedOrder is now typed and guaranteed valid
163
+ * await sdk.trading.placeLimitOrder(...validatedOrder);
164
+ * } catch (error) {
165
+ * if (error instanceof ValidationError) {
166
+ * // Show user-friendly errors
167
+ * console.error(error.message);
168
+ * const fieldErrors = error.getErrors();
169
+ * // Display errors next to form fields
170
+ * }
171
+ * }
172
+ *
173
+ * // With custom error handling
174
+ * function safeValidate<T>(schema: z.ZodSchema<T>, data: unknown) {
175
+ * try {
176
+ * return { success: true, data: validate(schema, data) };
177
+ * } catch (error) {
178
+ * if (error instanceof ValidationError) {
179
+ * return { success: false, errors: error.getErrors() };
180
+ * }
181
+ * throw error; // Re-throw unexpected errors
182
+ * }
183
+ * }
184
+ *
185
+ * const result = safeValidate(PlaceLimitOrderSchema, input);
186
+ * if (result.success) {
187
+ * // Use result.data
188
+ * } else {
189
+ * // Handle result.errors
190
+ * }
191
+ * ```
192
+ */
193
+ export function validate(schema, data) {
194
+ const result = schema.safeParse(data);
195
+ if (!result.success) {
196
+ throw new ValidationError(result.error);
197
+ }
198
+ return result.data;
199
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Validation Schemas
3
+ *
4
+ * Runtime validation using Zod for all SDK inputs.
5
+ * Catches errors before making API calls.
6
+ *
7
+ * **Shared Utilities:**
8
+ * - {@link ValidationError} - User-friendly validation error class
9
+ * - {@link validate} - Helper function for schema validation
10
+ *
11
+ * **Schema Modules:**
12
+ * - Trading schemas (orders, trading pairs)
13
+ * - Vault schemas (deposits, withdrawals)
14
+ * - Market schemas (trading pairs, candlesticks)
15
+ */
16
+ export * from "./common.js";
17
+ export * from "./margin-accounts.js";
18
+ export * from "./market.js";
19
+ export * from "./positions.js";
20
+ export * from "./profile.js";
21
+ export * from "./trading.js";
22
+ export * from "./vault.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Validation Schemas
3
+ *
4
+ * Runtime validation using Zod for all SDK inputs.
5
+ * Catches errors before making API calls.
6
+ *
7
+ * **Shared Utilities:**
8
+ * - {@link ValidationError} - User-friendly validation error class
9
+ * - {@link validate} - Helper function for schema validation
10
+ *
11
+ * **Schema Modules:**
12
+ * - Trading schemas (orders, trading pairs)
13
+ * - Vault schemas (deposits, withdrawals)
14
+ * - Market schemas (trading pairs, candlesticks)
15
+ */
16
+ // Export validation utilities
17
+ export * from "./common.js";
18
+ export * from "./margin-accounts.js";
19
+ export * from "./market.js";
20
+ export * from "./positions.js";
21
+ // Export module-specific schemas
22
+ export * from "./profile.js";
23
+ export * from "./trading.js";
24
+ export * from "./vault.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
+ });