@0xmonaco/types 1.0.73 → 1.0.74-develop.367860f

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 (60) hide show
  1. package/dist/api/index.d.ts +0 -7
  2. package/dist/applications/index.d.ts +14 -15
  3. package/dist/applications/index.js +2 -2
  4. package/dist/applications/requests.d.ts +70 -15
  5. package/dist/applications/requests.js +2 -3
  6. package/dist/applications/responses.d.ts +35 -39
  7. package/dist/applications/responses.js +1 -1
  8. package/dist/buildercodes/index.d.ts +3 -4
  9. package/dist/buildercodes/responses.d.ts +12 -6
  10. package/dist/buildercodes/responses.js +26 -7
  11. package/dist/copy-trading/index.d.ts +7 -7
  12. package/dist/delegated-agents/index.d.ts +15 -5
  13. package/dist/fees/responses.js +2 -2
  14. package/dist/managed-markets/index.d.ts +21 -2
  15. package/dist/margin-accounts/index.d.ts +185 -21
  16. package/dist/market/index.d.ts +76 -6
  17. package/dist/pitpass/index.d.ts +31 -11
  18. package/dist/pitpass/index.js +1 -1
  19. package/dist/pitpass/responses.d.ts +67 -0
  20. package/dist/pitpass/responses.js +92 -8
  21. package/dist/portfolio/index.d.ts +36 -14
  22. package/dist/positions/index.d.ts +81 -14
  23. package/dist/profile/index.d.ts +114 -44
  24. package/dist/sdk/index.d.ts +12 -4
  25. package/dist/trading/index.d.ts +1 -1
  26. package/dist/trading/orders.d.ts +6 -32
  27. package/dist/trading/responses.d.ts +9 -14
  28. package/dist/validation/applications.d.ts +51 -0
  29. package/dist/validation/applications.js +45 -0
  30. package/dist/validation/index.d.ts +2 -0
  31. package/dist/validation/index.js +2 -0
  32. package/dist/validation/managed-markets.d.ts +17 -0
  33. package/dist/validation/managed-markets.js +17 -0
  34. package/dist/validation/margin-accounts.d.ts +44 -3
  35. package/dist/validation/margin-accounts.js +57 -6
  36. package/dist/validation/market.d.ts +45 -0
  37. package/dist/validation/market.js +43 -0
  38. package/dist/validation/positions.d.ts +5 -3
  39. package/dist/validation/positions.js +12 -5
  40. package/dist/validation/profile.d.ts +19 -2
  41. package/dist/validation/profile.js +36 -4
  42. package/dist/validation/trading.d.ts +2 -2
  43. package/dist/validation/vault.d.ts +14 -0
  44. package/dist/validation/vault.js +14 -0
  45. package/dist/websocket/base.d.ts +56 -6
  46. package/dist/websocket/client.d.ts +8 -3
  47. package/dist/websocket/events/index.d.ts +1 -0
  48. package/dist/websocket/events/index.js +1 -0
  49. package/dist/websocket/events/liquidation-events.d.ts +3 -3
  50. package/dist/websocket/events/market-stats-events.d.ts +33 -3
  51. package/dist/websocket/events/market-stats-events.js +3 -2
  52. package/dist/websocket/events/orders-events.d.ts +36 -3
  53. package/dist/websocket/events/position-events.d.ts +33 -15
  54. package/dist/websocket/events/position-valuation-events.d.ts +60 -0
  55. package/dist/websocket/events/position-valuation-events.js +15 -0
  56. package/dist/wire/operations.d.ts +1 -1
  57. package/dist/wire/operations.js +7 -0
  58. package/dist/wire/schema.d.ts +1595 -352
  59. package/dist/withdrawals/index.d.ts +27 -6
  60. package/package.json +2 -2
@@ -267,6 +267,6 @@ export interface TradingAPI extends BaseAPI {
267
267
  */
268
268
  listTwapOrders(params?: ListTwapOrdersParams): Promise<ListTwapOrdersResponse>;
269
269
  }
270
- export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, ListedOrderType, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
270
+ export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
271
271
  export { ORDER_STATUS_VALUES } from "./orders";
272
272
  export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * Types for trading operations and order management.
5
5
  */
6
- import type { ConditionalOrder, TwapOrder } from "./responses";
7
6
  /**
8
7
  * Standard order structure used across all order-related responses.
9
8
  * This represents the complete order information as returned by the API.
@@ -14,12 +13,9 @@ import type { ConditionalOrder, TwapOrder } from "./responses";
14
13
  * Orders can transition to `CANCELLED`, `REJECTED`, or `EXPIRED` at various stages.
15
14
  * Fee fields are only populated after order fills occur.
16
15
  *
17
- * The order listing returns every kind of order in one stream, so a row here
18
- * may be a book order, a TWAP parent (`orderType: "TWAP"`) or a conditional
19
- * order (`orderType: "CONDITIONAL"`). Switch on `orderType`: the kind-specific
20
- * detail hangs off `twap` / `conditional`, and the fields above are populated
21
- * for every kind — a parent's `quantity` is its total, `filledQuantity` what
22
- * it has executed so far, and `status` its state expressed as an order status.
16
+ * Every row is a book order: the order listing carries `LIMIT` and `MARKET`
17
+ * orders only. TWAP parents and conditional (TP/SL) orders are listed by
18
+ * `listTwapOrders` and `listConditionalOrders`, never here.
23
19
  *
24
20
  * @example
25
21
  * To calculate remaining quantity:
@@ -34,8 +30,8 @@ export interface Order {
34
30
  tradingPairId: string;
35
31
  /** Order side (BUY or SELL) */
36
32
  side: OrderSide;
37
- /** What kind of order this row is - see ListedOrderType */
38
- orderType: ListedOrderType;
33
+ /** Order type (LIMIT or MARKET) */
34
+ orderType: OrderType;
39
35
  /** Order status - see OrderStatus for lifecycle details */
40
36
  status: OrderStatus;
41
37
  /** Order price - null for market orders, required for limit orders */
@@ -98,18 +94,6 @@ export interface Order {
98
94
  clientOrderId?: string;
99
95
  /** Position ID linked to the order, when available */
100
96
  positionId?: string;
101
- /**
102
- * The TWAP parent behind this row - its schedule, slice counters and
103
- * progress - present only when `orderType` is `"TWAP"`. Identical to what
104
- * `getTwapOrder` returns for the same id.
105
- */
106
- twap?: TwapOrder;
107
- /**
108
- * The conditional order behind this row - its trigger and the order it fires
109
- * - present only when `orderType` is `"CONDITIONAL"`. Identical to what the
110
- * conditional-order endpoints return for the same id.
111
- */
112
- conditional?: ConditionalOrder;
113
97
  /** Stable cause when status is CANCELLED */
114
98
  terminalReason?: OrderTerminalReason;
115
99
  /**
@@ -178,7 +162,7 @@ export interface Order {
178
162
  version?: number;
179
163
  }
180
164
  /** Stable terminal causes for accepted orders that end as CANCELLED. */
181
- export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "SYSTEM";
165
+ export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "AUTO_DELEVERAGING" | "PRICE_BAND" | "SLIPPAGE_TOLERANCE" | "SYSTEM";
182
166
  /**
183
167
  * Role of the creator or order
184
168
  */
@@ -201,16 +185,6 @@ export type PositionSide = "LONG" | "SHORT" | "NONE";
201
185
  * - TRAILING_STOP: Stop order that trails the market price
202
186
  */
203
187
  export type OrderType = "LIMIT" | "MARKET";
204
- /**
205
- * What kind of order a listed row is.
206
- *
207
- * Wider than {@link OrderType}, which is what you can place: the order listing
208
- * serves book orders, TWAP parents and conditional orders as one stream, and
209
- * `"TWAP"` / `"CONDITIONAL"` name the two kinds that are created through their
210
- * own endpoints rather than `createOrder`. A row of either kind carries its
211
- * detail on {@link Order.twap} or {@link Order.conditional}.
212
- */
213
- export type ListedOrderType = OrderType | "TWAP" | "CONDITIONAL";
214
188
  /**
215
189
  * Source-of-truth order status values used by runtime validation schemas.
216
190
  */
@@ -197,23 +197,18 @@ export interface GetPaginatedOrdersParams {
197
197
  /** Number of orders per page (default: 10; max 1000) */
198
198
  pageSize?: number;
199
199
  /**
200
- * Pagination cursor with three distinct states:
201
- * - Omitted (`undefined`): the SDK starts a cursor walk (it sends
202
- * `pageToken=""`) unless the deprecated `page` param was passed, in
203
- * which case the request uses legacy page-number pagination, limited to
204
- * recent history once the archive window is enabled.
205
- * - Empty string (`""`): start a cursor walk with no prior position, from
206
- * the newest row (or the oldest, when `orderBy` is `"ASC"`).
200
+ * Pagination cursor with two states:
201
+ * - Omitted (`undefined`) or empty string (`""`): start a cursor walk with
202
+ * no prior position, from the newest row (or the oldest, when `orderBy`
203
+ * is `"ASC"`).
207
204
  * - Non-empty: an opaque cursor from a previous response's
208
205
  * `nextPageToken`; results resume immediately after that position.
209
206
  *
210
- * In either cursor-walk state (empty or non-empty), `page` is ignored (it
211
- * comes back as 0), but `total` and `totalPages` ARE populated — bounded by
212
- * the server count ceiling, see `totalCapped`. Results cover full order
213
- * history — hot and archived rows merged — unlike page-number mode, which
214
- * only ever sees recent history. Clients that need complete order history
215
- * must use the cursor form (pass `""` to start, then follow `nextPageToken`)
216
- * rather than `page`.
207
+ * Page-number pagination was removed (0XM-2788): there is no `page`, and
208
+ * sending one is a `400`. `total` and `totalPages` are still populated,
209
+ * bounded by the server count ceiling — see `totalCapped`. Every walk
210
+ * covers full order history, hot and archived rows merged. Filters and
211
+ * `orderBy` must match the request that minted the token.
217
212
  */
218
213
  pageToken?: string;
219
214
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Public application listing validation schemas
3
+ *
4
+ * The four reporting listings are cursor paged (0XM-2822). Each schema
5
+ * REJECTS `page` rather than omitting it: forwarding the params field by
6
+ * field drops a stray `page` before it reaches the wire, which means a
7
+ * JavaScript or `any` caller looping on `{ page: n }` would be handed the
8
+ * FIRST cursor page on every call and would export the same rows forever —
9
+ * the exact failure the REST 400 exists to surface. Validating here turns
10
+ * that into an immediate `ValidationError`, which is what the 400 would have
11
+ * done before the field-by-field forwarding hid it.
12
+ */
13
+ import { z } from "zod";
14
+ export declare const ListAppOrdersSchema: z.ZodObject<{
15
+ clientId: z.ZodString;
16
+ page: z.ZodOptional<z.ZodNever>;
17
+ pageSize: z.ZodOptional<z.ZodNumber>;
18
+ pageToken: z.ZodOptional<z.ZodString>;
19
+ status: z.ZodOptional<z.ZodString>;
20
+ userId: z.ZodOptional<z.ZodUUID>;
21
+ tradingPairId: z.ZodOptional<z.ZodUUID>;
22
+ side: z.ZodOptional<z.ZodString>;
23
+ orderType: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>;
25
+ export declare const ListAppUsersSchema: z.ZodObject<{
26
+ clientId: z.ZodString;
27
+ page: z.ZodOptional<z.ZodNever>;
28
+ pageSize: z.ZodOptional<z.ZodNumber>;
29
+ pageToken: z.ZodOptional<z.ZodString>;
30
+ isActive: z.ZodOptional<z.ZodBoolean>;
31
+ accountType: z.ZodOptional<z.ZodString>;
32
+ address: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ export declare const ListAppMovementsSchema: z.ZodObject<{
35
+ clientId: z.ZodString;
36
+ page: z.ZodOptional<z.ZodNever>;
37
+ pageSize: z.ZodOptional<z.ZodNumber>;
38
+ pageToken: z.ZodOptional<z.ZodString>;
39
+ userId: z.ZodOptional<z.ZodUUID>;
40
+ transactionType: z.ZodOptional<z.ZodString>;
41
+ entryType: z.ZodOptional<z.ZodString>;
42
+ assetId: z.ZodOptional<z.ZodUUID>;
43
+ }, z.core.$strip>;
44
+ export declare const ListAppBalancesSchema: z.ZodObject<{
45
+ clientId: z.ZodString;
46
+ page: z.ZodOptional<z.ZodNever>;
47
+ pageSize: z.ZodOptional<z.ZodNumber>;
48
+ pageToken: z.ZodOptional<z.ZodString>;
49
+ userId: z.ZodOptional<z.ZodUUID>;
50
+ assetId: z.ZodOptional<z.ZodUUID>;
51
+ }, z.core.$strip>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Public application listing validation schemas
3
+ *
4
+ * The four reporting listings are cursor paged (0XM-2822). Each schema
5
+ * REJECTS `page` rather than omitting it: forwarding the params field by
6
+ * field drops a stray `page` before it reaches the wire, which means a
7
+ * JavaScript or `any` caller looping on `{ page: n }` would be handed the
8
+ * FIRST cursor page on every call and would export the same rows forever —
9
+ * the exact failure the REST 400 exists to surface. Validating here turns
10
+ * that into an immediate `ValidationError`, which is what the 400 would have
11
+ * done before the field-by-field forwarding hid it.
12
+ */
13
+ import { z } from "zod";
14
+ import { UUIDSchema } from "./trading";
15
+ /** A client ID is required; `page` is gone; a page size is bounded; a cursor may be `""` to start. */
16
+ const AppCursorPaginationSchema = z.object({
17
+ /** The application's public client ID; the listings are selected by it. */
18
+ clientId: z.string().trim().min(1, "Client ID is required"),
19
+ page: z.never().optional(),
20
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
21
+ pageToken: z.string().optional(),
22
+ });
23
+ export const ListAppOrdersSchema = AppCursorPaginationSchema.extend({
24
+ status: z.string().trim().min(1, "Status cannot be empty").optional(),
25
+ userId: UUIDSchema.optional(),
26
+ tradingPairId: UUIDSchema.optional(),
27
+ side: z.string().trim().min(1, "Side cannot be empty").optional(),
28
+ orderType: z.string().trim().min(1, "Order type cannot be empty").optional(),
29
+ });
30
+ export const ListAppUsersSchema = AppCursorPaginationSchema.extend({
31
+ isActive: z.boolean().optional(),
32
+ accountType: z.string().trim().min(1, "Account type cannot be empty").optional(),
33
+ // A partial, case-insensitive match, so not a full address.
34
+ address: z.string().trim().min(1, "Address filter cannot be empty").optional(),
35
+ });
36
+ export const ListAppMovementsSchema = AppCursorPaginationSchema.extend({
37
+ userId: UUIDSchema.optional(),
38
+ transactionType: z.string().trim().min(1, "Transaction type cannot be empty").optional(),
39
+ entryType: z.string().trim().min(1, "Entry type cannot be empty").optional(),
40
+ assetId: UUIDSchema.optional(),
41
+ });
42
+ export const ListAppBalancesSchema = AppCursorPaginationSchema.extend({
43
+ userId: UUIDSchema.optional(),
44
+ assetId: UUIDSchema.optional(),
45
+ });
@@ -13,8 +13,10 @@
13
13
  * - Vault schemas (deposits, withdrawals)
14
14
  * - Market schemas (trading pairs, candlesticks)
15
15
  */
16
+ export * from "./applications.js";
16
17
  export * from "./common.js";
17
18
  export * from "./copy-trading.js";
19
+ export * from "./managed-markets.js";
18
20
  export * from "./margin-accounts.js";
19
21
  export * from "./market.js";
20
22
  export * from "./positions.js";
@@ -14,8 +14,10 @@
14
14
  * - Market schemas (trading pairs, candlesticks)
15
15
  */
16
16
  // Export validation utilities
17
+ export * from "./applications.js";
17
18
  export * from "./common.js";
18
19
  export * from "./copy-trading.js";
20
+ export * from "./managed-markets.js";
19
21
  export * from "./margin-accounts.js";
20
22
  export * from "./market.js";
21
23
  export * from "./positions.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Managed Markets API Validation Schemas
3
+ */
4
+ import { z } from "zod";
5
+ /**
6
+ * Managed market assignments listing validation schema.
7
+ *
8
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted: the client
9
+ * builds the query string field by field, so a stray `page` never reaches the
10
+ * REST guard, and a caller looping `{ page: 1 }`, `{ page: 2 }` would send
11
+ * identical cursorless requests and reread the first page forever.
12
+ */
13
+ export declare const ListManagedMarketAssignmentsSchema: z.ZodObject<{
14
+ page: z.ZodOptional<z.ZodNever>;
15
+ pageSize: z.ZodOptional<z.ZodNumber>;
16
+ pageToken: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Managed Markets API Validation Schemas
3
+ */
4
+ import { z } from "zod";
5
+ /**
6
+ * Managed market assignments listing validation schema.
7
+ *
8
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted: the client
9
+ * builds the query string field by field, so a stray `page` never reaches the
10
+ * REST guard, and a caller looping `{ page: 1 }`, `{ page: 2 }` would send
11
+ * identical cursorless requests and reread the first page forever.
12
+ */
13
+ export const ListManagedMarketAssignmentsSchema = z.object({
14
+ page: z.never().optional(),
15
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
16
+ pageToken: z.string().optional(),
17
+ });
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  export declare const ListMarginAccountsSchema: z.ZodObject<{
6
- page: z.ZodOptional<z.ZodNumber>;
6
+ page: z.ZodOptional<z.ZodNever>;
7
7
  pageSize: z.ZodOptional<z.ZodNumber>;
8
+ pageToken: z.ZodOptional<z.ZodString>;
8
9
  state: z.ZodOptional<z.ZodString>;
9
10
  tradingPairId: z.ZodOptional<z.ZodUUID>;
10
11
  }, z.core.$strip>;
@@ -50,12 +51,14 @@ export declare const TransferCollateralToRiskBucketSchema: z.ZodObject<{
50
51
  tradingPairId: z.ZodUUID;
51
52
  strategyKey: z.ZodOptional<z.ZodString>;
52
53
  marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
54
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
53
55
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
54
56
  applyToPositionMargin: z.ZodOptional<z.ZodBoolean>;
55
57
  }, z.core.$strict>, z.ZodObject<{
56
58
  asset: z.ZodString;
57
59
  amount: z.ZodString;
58
60
  marginMode: z.ZodLiteral<"CROSS">;
61
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
59
62
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
60
63
  strategyKey: z.ZodOptional<z.ZodNever>;
61
64
  tradingPairId: z.ZodOptional<z.ZodNever>;
@@ -68,14 +71,16 @@ export declare const TransferCollateralFromParentMarginAccountSchema: z.ZodObjec
68
71
  }, z.core.$strip>;
69
72
  }, z.core.$strip>;
70
73
  export declare const GetMarginAccountMovementsSchema: z.ZodObject<{
71
- page: z.ZodOptional<z.ZodNumber>;
74
+ page: z.ZodOptional<z.ZodNever>;
72
75
  pageSize: z.ZodOptional<z.ZodNumber>;
76
+ pageToken: z.ZodOptional<z.ZodString>;
73
77
  marginAccountId: z.ZodUUID;
74
78
  movementType: z.ZodOptional<z.ZodString>;
75
79
  }, z.core.$strip>;
76
80
  export declare const GetParentMarginAccountMovementsSchema: z.ZodOptional<z.ZodObject<{
77
- page: z.ZodOptional<z.ZodNumber>;
81
+ page: z.ZodOptional<z.ZodNever>;
78
82
  pageSize: z.ZodOptional<z.ZodNumber>;
83
+ pageToken: z.ZodOptional<z.ZodString>;
79
84
  movementType: z.ZodOptional<z.ZodString>;
80
85
  }, z.core.$strip>>;
81
86
  export declare const SimulateOrderRiskSchema: z.ZodObject<{
@@ -154,6 +159,7 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
154
159
  tradingPairId: z.ZodUUID;
155
160
  strategyKey: z.ZodOptional<z.ZodString>;
156
161
  marginMode: z.ZodOptional<z.ZodLiteral<"ISOLATED">>;
162
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
157
163
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
158
164
  applyToPositionMargin: z.ZodOptional<z.ZodBoolean>;
159
165
  }, z.core.$strict>, z.ZodObject<{
@@ -177,7 +183,42 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
177
183
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
178
184
  slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
179
185
  marginMode: z.ZodLiteral<"CROSS">;
186
+ marginAccountId: z.ZodOptional<z.ZodUUID>;
180
187
  selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
181
188
  strategyKey: z.ZodOptional<z.ZodNever>;
182
189
  }, z.core.$strict>]>>;
183
190
  }, z.core.$strip>;
191
+ export declare const CreateMarginSubAccountSchema: z.ZodObject<{
192
+ request: z.ZodObject<{
193
+ subaccountKey: z.ZodString;
194
+ label: z.ZodOptional<z.ZodString>;
195
+ }, z.core.$strict>;
196
+ }, z.core.$strip>;
197
+ export declare const CloseMarginSubAccountSchema: z.ZodObject<{
198
+ marginAccountId: z.ZodUUID;
199
+ }, z.core.$strip>;
200
+ export declare const SubAccountCollateralTransferSchema: z.ZodObject<{
201
+ marginAccountId: z.ZodUUID;
202
+ amount: z.ZodString;
203
+ }, z.core.$strip>;
204
+ export declare const GetMarginAccountPnlSchema: z.ZodObject<{
205
+ marginAccountId: z.ZodUUID;
206
+ }, z.core.$strip>;
207
+ export declare const TransferMarginCollateralSchema: z.ZodObject<{
208
+ request: z.ZodObject<{
209
+ asset: z.ZodString;
210
+ amount: z.ZodString;
211
+ from: z.ZodUnion<readonly [z.ZodObject<{
212
+ wallet: z.ZodLiteral<true>;
213
+ }, z.core.$strict>, z.ZodObject<{
214
+ marginAccountId: z.ZodUUID;
215
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
216
+ }, z.core.$strict>]>;
217
+ to: z.ZodUnion<readonly [z.ZodObject<{
218
+ wallet: z.ZodLiteral<true>;
219
+ }, z.core.$strict>, z.ZodObject<{
220
+ marginAccountId: z.ZodUUID;
221
+ riskBucketId: z.ZodOptional<z.ZodUUID>;
222
+ }, z.core.$strict>]>;
223
+ }, z.core.$strict>;
224
+ }, z.core.$strip>;
@@ -3,11 +3,18 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  import { MarketSlippageToleranceBpsSchema, 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
- pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
6
+ const CursorPaginationSchema = z.object({
7
+ /**
8
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
9
+ * keep passing `page`, and the request would then come back as the first
10
+ * cursor page every time — the same silent duplicate-page failure the REST
11
+ * 400 guard exists to prevent (0XM-2788).
12
+ */
13
+ page: z.never().optional(),
14
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
15
+ pageToken: z.string().optional(),
9
16
  });
10
- export const ListMarginAccountsSchema = PaginationSchema.extend({
17
+ export const ListMarginAccountsSchema = CursorPaginationSchema.extend({
11
18
  state: z.string().trim().min(1, "State cannot be empty").optional(),
12
19
  tradingPairId: UUIDSchema.optional(),
13
20
  });
@@ -49,6 +56,9 @@ const RiskBucketRequestSchema = z.object({
49
56
  });
50
57
  const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
51
58
  marginMode: z.literal("ISOLATED").optional(),
59
+ // A sub-account funds and previews its own risk buckets; omitted means the
60
+ // default margin account.
61
+ marginAccountId: UUIDSchema.optional(),
52
62
  selectedTradingPairIds: z.never().optional(),
53
63
  // Omitted defaults server-side to true (the Adjust Margin gesture); false
54
64
  // is the plain allocation programmatic funding loops need. The CROSS form
@@ -64,6 +74,7 @@ const IsolatedRiskBucketRequestSchema = RiskBucketRequestSchema.extend({
64
74
  // the pair being previewed, not a scope declaration.
65
75
  const CrossRiskBucketSimulateRequestSchema = z.object({
66
76
  marginMode: z.literal("CROSS"),
77
+ marginAccountId: UUIDSchema.optional(),
67
78
  selectedTradingPairIds: z.never().optional(),
68
79
  strategyKey: z.never().optional(),
69
80
  });
@@ -74,6 +85,7 @@ const CrossRiskBucketSimulateRequestSchema = z.object({
74
85
  // it does nothing rather than believing it took effect.
75
86
  const CrossRiskBucketRequestSchema = z.object({
76
87
  marginMode: z.literal("CROSS"),
88
+ marginAccountId: UUIDSchema.optional(),
77
89
  selectedTradingPairIds: z.never().optional(),
78
90
  strategyKey: z.never().optional(),
79
91
  tradingPairId: z.never().optional(),
@@ -116,11 +128,11 @@ export const TransferCollateralToRiskBucketSchema = z.object({
116
128
  export const TransferCollateralFromParentMarginAccountSchema = z.object({
117
129
  request: ParentMarginAccountCollateralRequestSchema,
118
130
  });
119
- export const GetMarginAccountMovementsSchema = PaginationSchema.extend({
131
+ export const GetMarginAccountMovementsSchema = CursorPaginationSchema.extend({
120
132
  marginAccountId: UUIDSchema,
121
133
  movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
122
134
  });
123
- export const GetParentMarginAccountMovementsSchema = PaginationSchema.extend({
135
+ export const GetParentMarginAccountMovementsSchema = CursorPaginationSchema.extend({
124
136
  movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
125
137
  }).optional();
126
138
  const BaseSimulateOrderRiskRequestSchema = z.object({
@@ -223,3 +235,42 @@ export const SimulateRiskBucketOrderRiskSchema = z
223
235
  message: "price is required for LIMIT risk simulations",
224
236
  path: ["request", "price"],
225
237
  });
238
+ export const CreateMarginSubAccountSchema = z.object({
239
+ request: z
240
+ .object({
241
+ subaccountKey: z
242
+ .string()
243
+ .trim()
244
+ .min(1, "subaccountKey is required")
245
+ .max(64, "subaccountKey must be at most 64 characters")
246
+ .regex(/^[A-Za-z0-9_.:-]+$/, "subaccountKey may contain only letters, digits, '_', '-', '.' and ':'")
247
+ .refine((key) => !key.toLowerCase().startsWith("copy:"), "sub-account keys starting with copy: are reserved")
248
+ .refine((key) => key !== "default", "default names the default margin account"),
249
+ label: z.string().optional(),
250
+ })
251
+ .strict(),
252
+ });
253
+ export const CloseMarginSubAccountSchema = z.object({
254
+ marginAccountId: UUIDSchema,
255
+ });
256
+ export const SubAccountCollateralTransferSchema = z.object({
257
+ marginAccountId: UUIDSchema,
258
+ amount: PositiveDecimalStringSchema,
259
+ });
260
+ export const GetMarginAccountPnlSchema = z.object({
261
+ marginAccountId: UUIDSchema,
262
+ });
263
+ const CollateralTransferEndpointSchema = z.union([
264
+ z.object({ wallet: z.literal(true) }).strict(),
265
+ z.object({ marginAccountId: UUIDSchema, riskBucketId: UUIDSchema.optional() }).strict(),
266
+ ]);
267
+ export const TransferMarginCollateralSchema = z.object({
268
+ request: z
269
+ .object({
270
+ asset: z.string().trim().min(1, "Asset is required"),
271
+ amount: PositiveDecimalStringSchema,
272
+ from: CollateralTransferEndpointSchema,
273
+ to: CollateralTransferEndpointSchema,
274
+ })
275
+ .strict(),
276
+ });
@@ -220,3 +220,48 @@ export declare const SearchTradingPairsSchema: z.ZodObject<{
220
220
  export declare const GetMarketMetadataSchema: z.ZodObject<{
221
221
  tradingPairId: z.ZodUUID;
222
222
  }, z.core.$strip>;
223
+ /** Per-pair funding history; the pair id is path-bound and validated separately. */
224
+ export declare const ListFundingHistorySchema: z.ZodObject<{
225
+ page: z.ZodOptional<z.ZodNever>;
226
+ startTime: z.ZodOptional<z.ZodString>;
227
+ endTime: z.ZodOptional<z.ZodString>;
228
+ pageSize: z.ZodOptional<z.ZodNumber>;
229
+ pageToken: z.ZodOptional<z.ZodString>;
230
+ orderBy: z.ZodOptional<z.ZodEnum<{
231
+ ASC: "ASC";
232
+ DESC: "DESC";
233
+ }>>;
234
+ }, z.core.$strip>;
235
+ /** All-markets funding history. */
236
+ export declare const ListAllFundingHistorySchema: z.ZodObject<{
237
+ page: z.ZodOptional<z.ZodNever>;
238
+ startTime: z.ZodOptional<z.ZodString>;
239
+ endTime: z.ZodOptional<z.ZodString>;
240
+ pageSize: z.ZodOptional<z.ZodNumber>;
241
+ pageToken: z.ZodOptional<z.ZodString>;
242
+ orderBy: z.ZodOptional<z.ZodEnum<{
243
+ ASC: "ASC";
244
+ DESC: "DESC";
245
+ }>>;
246
+ }, z.core.$strip>;
247
+ /**
248
+ * Public trades-feed listing validation schema.
249
+ *
250
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted, but NOT for
251
+ * the same reason as {@link ListFundingHistorySchema}. That one is built on a
252
+ * query builder that serializes whatever keys the params object carries, so a
253
+ * leftover `page` reaches the wire and comes back as the server's `400`.
254
+ * `getTrades` instead sets `pageSize` and `pageToken` explicitly, so a stray
255
+ * `page` never leaves the client at all — which makes rejecting it more
256
+ * important here, not less. Stripped silently, it would leave the caller
257
+ * requesting page 2, 3, 4 and receiving the FIRST cursor page every time, with
258
+ * no error from either side to reveal the loop. `z.never()` turns that silent
259
+ * non-advancing walk into an immediate `ValidationError`.
260
+ *
261
+ * The ceiling is the cursor-mode 1000; the historical default of 25 stays.
262
+ */
263
+ export declare const GetTradesSchema: z.ZodObject<{
264
+ page: z.ZodOptional<z.ZodNever>;
265
+ pageSize: z.ZodOptional<z.ZodNumber>;
266
+ pageToken: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$strip>;
@@ -224,3 +224,46 @@ export const SearchTradingPairsSchema = z.object({
224
224
  export const GetMarketMetadataSchema = z.object({
225
225
  tradingPairId: UUIDSchema,
226
226
  });
227
+ /**
228
+ * Funding-history listing validation schemas.
229
+ *
230
+ * Cursor paged (0XM-2818). `page` is REJECTED rather than omitted: `withQuery`
231
+ * builds the query string from `Object.entries(params)`, so an untyped caller's
232
+ * leftover `page` would otherwise reach the wire and come back as a server
233
+ * `400` — a round trip to learn what the SDK already knows. Rejecting here
234
+ * fails the call immediately with a `ValidationError`, and the `deny_unknown_fields`
235
+ * 400 stays as the server-side backstop.
236
+ */
237
+ const FundingHistoryCursorSchema = z.object({
238
+ page: z.never().optional(),
239
+ startTime: z.string().optional(),
240
+ endTime: z.string().optional(),
241
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
242
+ pageToken: z.string().optional(),
243
+ orderBy: z.enum(["ASC", "DESC"], { message: 'orderBy must be "ASC" or "DESC"' }).optional(),
244
+ });
245
+ /** Per-pair funding history; the pair id is path-bound and validated separately. */
246
+ export const ListFundingHistorySchema = FundingHistoryCursorSchema;
247
+ /** All-markets funding history. */
248
+ export const ListAllFundingHistorySchema = FundingHistoryCursorSchema;
249
+ /**
250
+ * Public trades-feed listing validation schema.
251
+ *
252
+ * Cursor paged (0XM-2821). `page` is REJECTED rather than omitted, but NOT for
253
+ * the same reason as {@link ListFundingHistorySchema}. That one is built on a
254
+ * query builder that serializes whatever keys the params object carries, so a
255
+ * leftover `page` reaches the wire and comes back as the server's `400`.
256
+ * `getTrades` instead sets `pageSize` and `pageToken` explicitly, so a stray
257
+ * `page` never leaves the client at all — which makes rejecting it more
258
+ * important here, not less. Stripped silently, it would leave the caller
259
+ * requesting page 2, 3, 4 and receiving the FIRST cursor page every time, with
260
+ * no error from either side to reveal the loop. `z.never()` turns that silent
261
+ * non-advancing walk into an immediate `ValidationError`.
262
+ *
263
+ * The ceiling is the cursor-mode 1000; the historical default of 25 stays.
264
+ */
265
+ export const GetTradesSchema = z.object({
266
+ page: z.never().optional(),
267
+ pageSize: z.number().int("Page size must be an integer").min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
268
+ pageToken: z.string().optional(),
269
+ });
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  export declare const ListPositionsSchema: z.ZodObject<{
6
- page: z.ZodOptional<z.ZodNumber>;
6
+ page: z.ZodOptional<z.ZodNever>;
7
7
  pageSize: z.ZodOptional<z.ZodNumber>;
8
+ pageToken: z.ZodOptional<z.ZodString>;
8
9
  marginAccountId: z.ZodOptional<z.ZodUUID>;
9
10
  tradingPairId: z.ZodOptional<z.ZodUUID>;
10
11
  status: z.ZodOptional<z.ZodEnum<{
@@ -21,9 +22,9 @@ export declare const ClosePositionSchema: z.ZodObject<{
21
22
  positionId: z.ZodUUID;
22
23
  request: z.ZodObject<{
23
24
  closeType: z.ZodEnum<{
24
- IOC: "IOC";
25
25
  LIMIT: "LIMIT";
26
26
  MARKET: "MARKET";
27
+ IOC: "IOC";
27
28
  }>;
28
29
  limitPrice: z.ZodOptional<z.ZodString>;
29
30
  slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
@@ -84,8 +85,9 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
84
85
  }, z.core.$strip>;
85
86
  }, z.core.$strip>;
86
87
  export declare const ListPositionHistorySchema: z.ZodObject<{
87
- page: z.ZodOptional<z.ZodNumber>;
88
+ page: z.ZodOptional<z.ZodNever>;
88
89
  pageSize: z.ZodOptional<z.ZodNumber>;
90
+ pageToken: z.ZodOptional<z.ZodString>;
89
91
  positionId: z.ZodOptional<z.ZodUUID>;
90
92
  marginAccountId: z.ZodOptional<z.ZodUUID>;
91
93
  tradingPairId: z.ZodOptional<z.ZodUUID>;
@@ -3,9 +3,16 @@
3
3
  */
4
4
  import { z } from "zod";
5
5
  import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, TrailingStopLegSchema, UUIDSchema, } from "./trading";
6
- const PaginationSchema = z.object({
7
- page: z.number().int().min(1, "Page must be at least 1").optional(),
8
- pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
6
+ const CursorPaginationSchema = z.object({
7
+ /**
8
+ * Rejected, not ignored. A non-strict object would let a JS or `any` caller
9
+ * keep passing `page`, and the request would then come back as the first
10
+ * cursor page every time — the same silent duplicate-page failure the REST
11
+ * 400 guard exists to prevent (0XM-2788).
12
+ */
13
+ page: z.never().optional(),
14
+ pageSize: z.number().int().min(1, "Page size must be at least 1").max(1000, "Page size cannot exceed 1000").optional(),
15
+ pageToken: z.string().optional(),
9
16
  });
10
17
  // Filter values accepted by the list-positions endpoint. Narrower than the
11
18
  // returned PositionStatus: the backend folds EXPIRED positions under CLOSED, so
@@ -19,7 +26,7 @@ const ClosePositionTypeSchema = z.enum(["MARKET", "LIMIT", "IOC"], {
19
26
  const PositionIdSchema = z.object({
20
27
  positionId: UUIDSchema,
21
28
  });
22
- export const ListPositionsSchema = PaginationSchema.extend({
29
+ export const ListPositionsSchema = CursorPaginationSchema.extend({
23
30
  marginAccountId: UUIDSchema.optional(),
24
31
  tradingPairId: UUIDSchema.optional(),
25
32
  status: PositionStatusSchema.optional(),
@@ -100,7 +107,7 @@ export const AttachPositionTpSlSchema = PositionIdSchema.extend({
100
107
  path: ["oco"],
101
108
  }),
102
109
  });
103
- export const ListPositionHistorySchema = PaginationSchema.extend({
110
+ export const ListPositionHistorySchema = CursorPaginationSchema.extend({
104
111
  positionId: UUIDSchema.optional(),
105
112
  marginAccountId: UUIDSchema.optional(),
106
113
  tradingPairId: UUIDSchema.optional(),