@0xmonaco/types 1.0.74 → 1.0.75
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/api/index.d.ts +0 -7
- package/dist/applications/index.d.ts +14 -15
- package/dist/applications/index.js +2 -2
- package/dist/applications/requests.d.ts +70 -15
- package/dist/applications/requests.js +2 -3
- package/dist/applications/responses.d.ts +35 -39
- package/dist/applications/responses.js +1 -1
- package/dist/fees/responses.js +2 -2
- package/dist/margin-accounts/index.d.ts +72 -12
- package/dist/market/index.d.ts +76 -6
- package/dist/pitpass/index.d.ts +16 -11
- package/dist/pitpass/index.js +1 -1
- package/dist/pitpass/responses.d.ts +21 -0
- package/dist/pitpass/responses.js +43 -14
- package/dist/positions/index.d.ts +81 -14
- package/dist/profile/index.d.ts +114 -44
- package/dist/trading/index.d.ts +1 -1
- package/dist/trading/orders.d.ts +6 -32
- package/dist/trading/responses.d.ts +9 -14
- package/dist/validation/applications.d.ts +51 -0
- package/dist/validation/applications.js +45 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/margin-accounts.d.ts +10 -3
- package/dist/validation/margin-accounts.js +17 -6
- package/dist/validation/market.d.ts +24 -0
- package/dist/validation/market.js +22 -0
- package/dist/validation/positions.d.ts +5 -3
- package/dist/validation/positions.js +12 -5
- package/dist/validation/profile.d.ts +19 -2
- package/dist/validation/profile.js +36 -4
- package/dist/validation/trading.d.ts +2 -2
- package/dist/websocket/base.d.ts +56 -6
- package/dist/websocket/client.d.ts +8 -3
- package/dist/websocket/events/index.d.ts +1 -0
- package/dist/websocket/events/index.js +1 -0
- package/dist/websocket/events/position-events.d.ts +15 -0
- package/dist/websocket/events/position-valuation-events.d.ts +60 -0
- package/dist/websocket/events/position-valuation-events.js +15 -0
- package/dist/wire/operations.d.ts +1 -1
- package/dist/wire/operations.js +2 -0
- package/dist/wire/schema.d.ts +748 -235
- package/package.json +2 -2
package/dist/trading/orders.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
-
/**
|
|
38
|
-
orderType:
|
|
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" | "AUTO_DELEVERAGING" | "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
|
|
201
|
-
* - Omitted (`undefined`)
|
|
202
|
-
*
|
|
203
|
-
*
|
|
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
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* the server count ceiling
|
|
213
|
-
* history
|
|
214
|
-
*
|
|
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
|
+
});
|
package/dist/validation/index.js
CHANGED
|
@@ -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.
|
|
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>;
|
|
@@ -70,14 +71,16 @@ export declare const TransferCollateralFromParentMarginAccountSchema: z.ZodObjec
|
|
|
70
71
|
}, z.core.$strip>;
|
|
71
72
|
}, z.core.$strip>;
|
|
72
73
|
export declare const GetMarginAccountMovementsSchema: z.ZodObject<{
|
|
73
|
-
page: z.ZodOptional<z.
|
|
74
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
74
75
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
75
77
|
marginAccountId: z.ZodUUID;
|
|
76
78
|
movementType: z.ZodOptional<z.ZodString>;
|
|
77
79
|
}, z.core.$strip>;
|
|
78
80
|
export declare const GetParentMarginAccountMovementsSchema: z.ZodOptional<z.ZodObject<{
|
|
79
|
-
page: z.ZodOptional<z.
|
|
81
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
80
82
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
81
84
|
movementType: z.ZodOptional<z.ZodString>;
|
|
82
85
|
}, z.core.$strip>>;
|
|
83
86
|
export declare const SimulateOrderRiskSchema: z.ZodObject<{
|
|
@@ -194,6 +197,10 @@ export declare const CreateMarginSubAccountSchema: z.ZodObject<{
|
|
|
194
197
|
export declare const CloseMarginSubAccountSchema: z.ZodObject<{
|
|
195
198
|
marginAccountId: z.ZodUUID;
|
|
196
199
|
}, z.core.$strip>;
|
|
200
|
+
export declare const SubAccountCollateralTransferSchema: z.ZodObject<{
|
|
201
|
+
marginAccountId: z.ZodUUID;
|
|
202
|
+
amount: z.ZodString;
|
|
203
|
+
}, z.core.$strip>;
|
|
197
204
|
export declare const GetMarginAccountPnlSchema: z.ZodObject<{
|
|
198
205
|
marginAccountId: z.ZodUUID;
|
|
199
206
|
}, 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
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
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
|
});
|
|
@@ -121,11 +128,11 @@ export const TransferCollateralToRiskBucketSchema = z.object({
|
|
|
121
128
|
export const TransferCollateralFromParentMarginAccountSchema = z.object({
|
|
122
129
|
request: ParentMarginAccountCollateralRequestSchema,
|
|
123
130
|
});
|
|
124
|
-
export const GetMarginAccountMovementsSchema =
|
|
131
|
+
export const GetMarginAccountMovementsSchema = CursorPaginationSchema.extend({
|
|
125
132
|
marginAccountId: UUIDSchema,
|
|
126
133
|
movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
127
134
|
});
|
|
128
|
-
export const GetParentMarginAccountMovementsSchema =
|
|
135
|
+
export const GetParentMarginAccountMovementsSchema = CursorPaginationSchema.extend({
|
|
129
136
|
movementType: z.string().trim().min(1, "Movement type cannot be empty").optional(),
|
|
130
137
|
}).optional();
|
|
131
138
|
const BaseSimulateOrderRiskRequestSchema = z.object({
|
|
@@ -246,6 +253,10 @@ export const CreateMarginSubAccountSchema = z.object({
|
|
|
246
253
|
export const CloseMarginSubAccountSchema = z.object({
|
|
247
254
|
marginAccountId: UUIDSchema,
|
|
248
255
|
});
|
|
256
|
+
export const SubAccountCollateralTransferSchema = z.object({
|
|
257
|
+
marginAccountId: UUIDSchema,
|
|
258
|
+
amount: PositiveDecimalStringSchema,
|
|
259
|
+
});
|
|
249
260
|
export const GetMarginAccountPnlSchema = z.object({
|
|
250
261
|
marginAccountId: UUIDSchema,
|
|
251
262
|
});
|
|
@@ -220,3 +220,27 @@ 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>;
|
|
@@ -224,3 +224,25 @@ 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;
|
|
@@ -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.
|
|
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.
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
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 =
|
|
110
|
+
export const ListPositionHistorySchema = CursorPaginationSchema.extend({
|
|
104
111
|
positionId: UUIDSchema.optional(),
|
|
105
112
|
marginAccountId: UUIDSchema.optional(),
|
|
106
113
|
tradingPairId: UUIDSchema.optional(),
|
|
@@ -48,8 +48,13 @@ export declare const SetSelfTradePreventionDefaultSchema: z.ZodObject<{
|
|
|
48
48
|
* All fields are optional — an empty object or undefined is valid.
|
|
49
49
|
*/
|
|
50
50
|
export declare const GetUserMovementsSchema: z.ZodObject<{
|
|
51
|
-
page: z.ZodOptional<z.
|
|
51
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
52
52
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
54
|
+
orderBy: z.ZodOptional<z.ZodEnum<{
|
|
55
|
+
ASC: "ASC";
|
|
56
|
+
DESC: "DESC";
|
|
57
|
+
}>>;
|
|
53
58
|
entryType: z.ZodOptional<z.ZodEnum<{
|
|
54
59
|
CREDIT: "CREDIT";
|
|
55
60
|
DEBIT: "DEBIT";
|
|
@@ -81,9 +86,21 @@ export declare const GetUserTradesSchema: z.ZodObject<{
|
|
|
81
86
|
tradingPairId: z.ZodOptional<z.ZodUUID>;
|
|
82
87
|
pageToken: z.ZodOptional<z.ZodString>;
|
|
83
88
|
}, z.core.$strip>;
|
|
89
|
+
/**
|
|
90
|
+
* Get User Balances validation schema
|
|
91
|
+
*
|
|
92
|
+
* Validates parameters for the cursor-paged balances listing. All fields are
|
|
93
|
+
* optional — an empty object or undefined is valid.
|
|
94
|
+
*/
|
|
95
|
+
export declare const GetUserBalancesSchema: z.ZodObject<{
|
|
96
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
97
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strip>;
|
|
84
100
|
export declare const ListFundingPaymentsSchema: z.ZodObject<{
|
|
85
|
-
page: z.ZodOptional<z.
|
|
101
|
+
page: z.ZodOptional<z.ZodNever>;
|
|
86
102
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
87
104
|
tradingPairId: z.ZodOptional<z.ZodUUID>;
|
|
88
105
|
positionId: z.ZodOptional<z.ZodUUID>;
|
|
89
106
|
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
@@ -33,8 +33,16 @@ export const SetSelfTradePreventionDefaultSchema = z.object({
|
|
|
33
33
|
* All fields are optional — an empty object or undefined is valid.
|
|
34
34
|
*/
|
|
35
35
|
export const GetUserMovementsSchema = z.object({
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Rejected, not ignored. A non-strict object would let a JS or `any` caller
|
|
38
|
+
* keep passing `page`, and the request would come back as the first cursor
|
|
39
|
+
* page every time — the same silent duplicate-page failure the REST 400
|
|
40
|
+
* guard exists to prevent (0XM-2788).
|
|
41
|
+
*/
|
|
42
|
+
page: z.never().optional(),
|
|
43
|
+
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(),
|
|
44
|
+
pageToken: z.string().optional(),
|
|
45
|
+
orderBy: z.enum(["ASC", "DESC"]).optional(),
|
|
38
46
|
entryType: LedgerEntryTypeSchema.optional(),
|
|
39
47
|
transactionType: TransactionTypeSchema.optional(),
|
|
40
48
|
assetId: UUIDSchema.optional(),
|
|
@@ -57,9 +65,33 @@ export const GetUserTradesSchema = z.object({
|
|
|
57
65
|
tradingPairId: UUIDSchema.optional(),
|
|
58
66
|
pageToken: z.string().optional(),
|
|
59
67
|
});
|
|
68
|
+
/**
|
|
69
|
+
* Get User Balances validation schema
|
|
70
|
+
*
|
|
71
|
+
* Validates parameters for the cursor-paged balances listing. All fields are
|
|
72
|
+
* optional — an empty object or undefined is valid.
|
|
73
|
+
*/
|
|
74
|
+
export const GetUserBalancesSchema = z.object({
|
|
75
|
+
/**
|
|
76
|
+
* Rejected, not ignored. Without a schema at all a JS or `any` caller's
|
|
77
|
+
* `page` was silently dropped while building the query string, so the call
|
|
78
|
+
* resolved with the FIRST cursor page on every request — the quiet
|
|
79
|
+
* duplicate-page failure the REST 400 guard exists to prevent (0XM-2821).
|
|
80
|
+
*/
|
|
81
|
+
page: z.never().optional(),
|
|
82
|
+
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(),
|
|
83
|
+
pageToken: z.string().optional(),
|
|
84
|
+
});
|
|
60
85
|
export const ListFundingPaymentsSchema = z.object({
|
|
61
|
-
|
|
62
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Rejected, not ignored. A non-strict object would let a JS or `any` caller
|
|
88
|
+
* keep passing `page`, and the request would come back as the first cursor
|
|
89
|
+
* page every time — the same silent duplicate-page failure the REST 400
|
|
90
|
+
* guard exists to prevent (0XM-2788).
|
|
91
|
+
*/
|
|
92
|
+
page: z.never().optional(),
|
|
93
|
+
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(),
|
|
94
|
+
pageToken: z.string().optional(),
|
|
63
95
|
tradingPairId: UUIDSchema.optional(),
|
|
64
96
|
positionId: UUIDSchema.optional(),
|
|
65
97
|
marginAccountId: UUIDSchema.optional(),
|
|
@@ -375,11 +375,11 @@ export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
|
|
|
375
375
|
export declare const ConditionalOrderStateSchema: z.ZodEnum<{
|
|
376
376
|
CANCELLED: "CANCELLED";
|
|
377
377
|
EXPIRED: "EXPIRED";
|
|
378
|
-
FAILED: "FAILED";
|
|
379
378
|
PENDING_PARENT: "PENDING_PARENT";
|
|
380
379
|
ACTIVE: "ACTIVE";
|
|
381
380
|
TRIGGERING: "TRIGGERING";
|
|
382
381
|
TRIGGERED: "TRIGGERED";
|
|
382
|
+
FAILED: "FAILED";
|
|
383
383
|
}>;
|
|
384
384
|
export declare const ClosePositionSideSchema: z.ZodEnum<{
|
|
385
385
|
LONG: "LONG";
|
|
@@ -395,11 +395,11 @@ export declare const ListConditionalOrdersSchema: z.ZodObject<{
|
|
|
395
395
|
state: z.ZodOptional<z.ZodEnum<{
|
|
396
396
|
CANCELLED: "CANCELLED";
|
|
397
397
|
EXPIRED: "EXPIRED";
|
|
398
|
-
FAILED: "FAILED";
|
|
399
398
|
PENDING_PARENT: "PENDING_PARENT";
|
|
400
399
|
ACTIVE: "ACTIVE";
|
|
401
400
|
TRIGGERING: "TRIGGERING";
|
|
402
401
|
TRIGGERED: "TRIGGERED";
|
|
402
|
+
FAILED: "FAILED";
|
|
403
403
|
}>>;
|
|
404
404
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
405
405
|
pageToken: z.ZodOptional<z.ZodString>;
|
package/dist/websocket/base.d.ts
CHANGED
|
@@ -7,8 +7,40 @@
|
|
|
7
7
|
* WebSocket connection status
|
|
8
8
|
*/
|
|
9
9
|
export type WebSocketStatus = "connected" | "connecting" | "disconnected" | "reconnecting";
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Connection-attempt context delivered with every status change.
|
|
12
|
+
*
|
|
13
|
+
* `"reconnecting"` with `hasConnected: false` means the client has never
|
|
14
|
+
* reached the server and is still trying (the first connect failed);
|
|
15
|
+
* `hasConnected: true` means a working connection was lost.
|
|
16
|
+
*/
|
|
17
|
+
export interface WebSocketStatusInfo {
|
|
18
|
+
/**
|
|
19
|
+
* The retry this status refers to. `0` for `"connecting"` and
|
|
20
|
+
* `"connected"`; `1`, `2`, … for `"reconnecting"` (the retry just
|
|
21
|
+
* scheduled); for `"disconnected"`, the number of retries scheduled in the
|
|
22
|
+
* outage before it, counting one still in backoff when `disconnect()` is
|
|
23
|
+
* called (`0` after a clean close of a working connection).
|
|
24
|
+
*/
|
|
25
|
+
attempt: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this client has reached the server at least once since it was
|
|
28
|
+
* created or since the last `disconnect()`.
|
|
29
|
+
*/
|
|
30
|
+
hasConnected: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Set only on `"reconnecting"`: the delay, in milliseconds, before the
|
|
33
|
+
* scheduled retry opens its connection.
|
|
34
|
+
*/
|
|
35
|
+
nextRetryDelayMs?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Handler invoked whenever the WebSocket connection status changes.
|
|
39
|
+
*
|
|
40
|
+
* Inside the handler, `getStatus()` returns the status being reported. A
|
|
41
|
+
* handler that takes only `status` remains valid.
|
|
42
|
+
*/
|
|
43
|
+
export type StatusHandler = (status: WebSocketStatus, info: WebSocketStatusInfo) => void;
|
|
12
44
|
/**
|
|
13
45
|
* Why the connection was re-established. Delivered by
|
|
14
46
|
* {@link MonacoWebSocketConfig.onResync} after the socket reopens and sends its
|
|
@@ -129,9 +161,11 @@ export interface MonacoWebSocketConfig {
|
|
|
129
161
|
/** Enable auto-reconnect on disconnect (default: true) */
|
|
130
162
|
autoReconnect?: boolean;
|
|
131
163
|
/**
|
|
132
|
-
* Maximum reconnection attempts (default: unlimited). Retry
|
|
133
|
-
* full-jitter exponential backoff capped at 30s, so unlimited
|
|
134
|
-
* capped-rate, not a tight loop.
|
|
164
|
+
* Maximum reconnection attempts per outage (default: unlimited). Retry
|
|
165
|
+
* delay is full-jitter exponential backoff capped at 30s, so unlimited
|
|
166
|
+
* retries are capped-rate, not a tight loop. Once the attempts run out the
|
|
167
|
+
* client reports `"disconnected"`; a later `connect()` starts a fresh
|
|
168
|
+
* budget.
|
|
135
169
|
*/
|
|
136
170
|
maxReconnectAttempts?: number;
|
|
137
171
|
/** Base delay for the exponential backoff in milliseconds (default: 1000) */
|
|
@@ -141,7 +175,23 @@ export interface MonacoWebSocketConfig {
|
|
|
141
175
|
* retried, in milliseconds (default: 10000)
|
|
142
176
|
*/
|
|
143
177
|
connectionTimeoutMs?: number;
|
|
144
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Called on every connection status change, with the attempt context in
|
|
180
|
+
* {@link WebSocketStatusInfo}:
|
|
181
|
+
*
|
|
182
|
+
* - `"connecting"` — a connection is opening outside a retry cycle: the
|
|
183
|
+
* first connect, a `connect()` after a terminal `"disconnected"`, or a
|
|
184
|
+
* fresh session's reconnect after terminal authentication loss.
|
|
185
|
+
* - `"connected"` — the connection opened.
|
|
186
|
+
* - `"reconnecting"` — a retry is scheduled, once per retry. It holds until
|
|
187
|
+
* a retry connects or the retries run out; retries do not report
|
|
188
|
+
* `"connecting"`.
|
|
189
|
+
* - `"disconnected"` — terminal: a clean close, retries exhausted, terminal
|
|
190
|
+
* authentication loss, or `disconnect()`.
|
|
191
|
+
*
|
|
192
|
+
* An error thrown by this callback, or a rejection of the promise an async
|
|
193
|
+
* callback returns, is logged and does not affect the connection.
|
|
194
|
+
*/
|
|
145
195
|
onStatusChange?: StatusHandler;
|
|
146
196
|
/**
|
|
147
197
|
* Called after every automatic reconnect sends authentication/subscription
|