@0xmonaco/core 1.0.62 → 1.0.65

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.
@@ -1,12 +1,24 @@
1
1
  import type { AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseAllRequest, BatchCloseAllResponse, ClosePositionRequest, ClosePositionResponse, GetPositionPnlHistoryParams, GetPositionPnlHistoryResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionRisk, PositionsAPI } from "@0xmonaco/types";
2
2
  import { BaseAPI } from "../base";
3
3
  export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
4
+ /**
5
+ * List the caller's positions with page-number pagination. The response
6
+ * `total` is bounded by the listing's pagination reach: exact up to
7
+ * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
8
+ * rejected rather than served past the last page `total` can report.
9
+ */
4
10
  listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
5
11
  getPosition(positionId: string): Promise<GetPositionResponse>;
6
12
  closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
7
13
  batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
8
14
  getPositionRisk(positionId: string): Promise<PositionRisk>;
9
15
  attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
16
+ /**
17
+ * List the caller's position-history events with page-number pagination. The
18
+ * response `total` is bounded by the listing's pagination reach: exact up to
19
+ * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
20
+ * rejected rather than served past the last page `total` can report.
21
+ */
10
22
  listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
11
23
  getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
12
24
  }
@@ -2,6 +2,12 @@ import { AttachPositionTpSlSchema, BatchCloseAllSchema, ClosePositionSchema, Get
2
2
  import { BaseAPI } from "../base";
3
3
  import { perpRoutes } from "../perp";
4
4
  export class PositionsAPIImpl extends BaseAPI {
5
+ /**
6
+ * List the caller's positions with page-number pagination. The response
7
+ * `total` is bounded by the listing's pagination reach: exact up to
8
+ * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
9
+ * rejected rather than served past the last page `total` can report.
10
+ */
5
11
  async listPositions(params) {
6
12
  if (params) {
7
13
  validate(ListPositionsSchema, params);
@@ -73,6 +79,12 @@ export class PositionsAPIImpl extends BaseAPI {
73
79
  }),
74
80
  });
75
81
  }
82
+ /**
83
+ * List the caller's position-history events with page-number pagination. The
84
+ * response `total` is bounded by the listing's pagination reach: exact up to
85
+ * `pageSize` x 10,000 rows and saturating there, so a `page` above 10,000 is
86
+ * rejected rather than served past the last page `total` can report.
87
+ */
76
88
  async listPositionHistory(params) {
77
89
  if (params) {
78
90
  validate(ListPositionHistorySchema, params);
@@ -176,9 +176,10 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
176
176
  *
177
177
  * @param params - Optional query parameters for pagination and filtering
178
178
  * @param params.page - Deprecated: page number for legacy offset pagination (starts
179
- * from 1). Passing it selects legacy page-number mode, which only sees recent (hot)
180
- * history and populates `total`/`totalPages`. Use cursor pagination (`pageToken`)
181
- * instead.
179
+ * from 1, at most 10,000). Passing it selects legacy page-number mode, which only sees
180
+ * recent (hot) history and populates `total`/`totalPages` — bounded at the pagination
181
+ * reach (`total` saturates at `pageSize` × 10,000 rows, `totalPages` at 10,000 pages).
182
+ * Use cursor pagination (`pageToken`) instead.
182
183
  * @param params.pageSize - Number of items per page (default: 20; max 100
183
184
  * in page-number mode, up to 1000 when pageToken is present)
184
185
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
@@ -227,9 +227,10 @@ export class ProfileAPIImpl extends BaseAPI {
227
227
  *
228
228
  * @param params - Optional query parameters for pagination and filtering
229
229
  * @param params.page - Deprecated: page number for legacy offset pagination (starts
230
- * from 1). Passing it selects legacy page-number mode, which only sees recent (hot)
231
- * history and populates `total`/`totalPages`. Use cursor pagination (`pageToken`)
232
- * instead.
230
+ * from 1, at most 10,000). Passing it selects legacy page-number mode, which only sees
231
+ * recent (hot) history and populates `total`/`totalPages` — bounded at the pagination
232
+ * reach (`total` saturates at `pageSize` × 10,000 rows, `totalPages` at 10,000 pages).
233
+ * Use cursor pagination (`pageToken`) instead.
233
234
  * @param params.pageSize - Number of items per page (default: 20; max 100
234
235
  * in page-number mode, up to 1000 when pageToken is present)
235
236
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
@@ -184,6 +184,19 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
184
184
  }): Promise<CancelOrderResponse>;
185
185
  cancelConditionalOrder(conditionalOrderId: string): Promise<CancelConditionalOrderResponse>;
186
186
  getConditionalOrder(conditionalOrderId: string): Promise<ConditionalOrder>;
187
+ /**
188
+ * Lists conditional orders for the authenticated user.
189
+ *
190
+ * The response `total` is bounded by the listing's pagination reach: exact up
191
+ * to `pageSize` x 10,000 rows and saturating there, so a caller with more
192
+ * matching conditional orders than page-number mode can page through reads the
193
+ * cap, not its lifetime total; `page` is capped at 10,000 and a larger page is
194
+ * rejected.
195
+ *
196
+ * @param params - Optional pagination and margin-account / trading-pair / state filters
197
+ * @returns Promise resolving to ListConditionalOrdersResponse with orders and pagination info
198
+ * @throws {APIError} When API communication fails
199
+ */
187
200
  listConditionalOrders(params?: ListConditionalOrdersParams): Promise<ListConditionalOrdersResponse>;
188
201
  /**
189
202
  * Batch cancels specific orders by their IDs.
@@ -302,16 +315,18 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
302
315
  * working set.
303
316
  * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
304
317
  * pagination: it starts a cursor walk from the newest (or oldest, for
305
- * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Cursor
306
- * responses carry no exact totals (`total`/`page`/`totalPages` are 0).
318
+ * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Both modes
319
+ * populate `total`/`totalPages` (bounded by the server count ceiling — see
320
+ * `totalCapped`); only `page` is 0 in cursor mode.
307
321
  *
308
322
  * @param params - Query parameters for filtering orders
309
323
  * @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED"), or by
310
324
  * any of several statuses at once by passing an array (e.g., ["SUBMITTED", "PARTIALLY_FILLED"]) (optional)
311
325
  * @param params.tradingPairId - Filter by trading pair UUID (optional)
312
326
  * @param params.page - Deprecated: page number for legacy offset pagination (must be > 0).
313
- * Passing it selects legacy page-number mode, which only sees recent (hot) history and
314
- * populates `total`/`totalPages`. Use cursor pagination (`pageToken`) instead.
327
+ * Passing it selects legacy page-number mode, which only sees recent (hot) history. Both
328
+ * modes populate `total`/`totalPages` (bounded — see `totalCapped`); use cursor
329
+ * pagination (`pageToken`) instead for full history.
315
330
  * @param params.pageSize - Number of orders per page (defaults to 10, must be > 0; max 100
316
331
  * in page-number mode, up to 1000 when pageToken is present)
317
332
  * @param params.pageToken - Pagination cursor: pass `""` to start a cursor walk from
@@ -503,6 +518,12 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
503
518
  /**
504
519
  * Lists TWAP parent orders for the authenticated user.
505
520
  *
521
+ * The response `total` is bounded by the listing's pagination reach: exact up
522
+ * to `pageSize` x 10,000 rows and saturating there, so a caller with more
523
+ * matching TWAP orders than page-number mode can page through reads the cap,
524
+ * not its lifetime total; `page` is capped at 10,000 and a larger page is
525
+ * rejected.
526
+ *
506
527
  * @param params - Optional pagination and state / trading-pair filters
507
528
  * @returns Promise resolving to ListTwapOrdersResponse with orders and pagination info
508
529
  * @throws {APIError} When API communication fails
@@ -258,6 +258,19 @@ export class TradingAPIImpl extends BaseAPI {
258
258
  method: "GET",
259
259
  });
260
260
  }
261
+ /**
262
+ * Lists conditional orders for the authenticated user.
263
+ *
264
+ * The response `total` is bounded by the listing's pagination reach: exact up
265
+ * to `pageSize` x 10,000 rows and saturating there, so a caller with more
266
+ * matching conditional orders than page-number mode can page through reads the
267
+ * cap, not its lifetime total; `page` is capped at 10,000 and a larger page is
268
+ * rejected.
269
+ *
270
+ * @param params - Optional pagination and margin-account / trading-pair / state filters
271
+ * @returns Promise resolving to ListConditionalOrdersResponse with orders and pagination info
272
+ * @throws {APIError} When API communication fails
273
+ */
261
274
  async listConditionalOrders(params) {
262
275
  if (params) {
263
276
  validate(ListConditionalOrdersSchema, params);
@@ -468,16 +481,18 @@ export class TradingAPIImpl extends BaseAPI {
468
481
  * working set.
469
482
  * When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
470
483
  * pagination: it starts a cursor walk from the newest (or oldest, for
471
- * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Cursor
472
- * responses carry no exact totals (`total`/`page`/`totalPages` are 0).
484
+ * `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Both modes
485
+ * populate `total`/`totalPages` (bounded by the server count ceiling — see
486
+ * `totalCapped`); only `page` is 0 in cursor mode.
473
487
  *
474
488
  * @param params - Query parameters for filtering orders
475
489
  * @param params.status - Filter by order status (e.g., "SUBMITTED", "FILLED"), or by
476
490
  * any of several statuses at once by passing an array (e.g., ["SUBMITTED", "PARTIALLY_FILLED"]) (optional)
477
491
  * @param params.tradingPairId - Filter by trading pair UUID (optional)
478
492
  * @param params.page - Deprecated: page number for legacy offset pagination (must be > 0).
479
- * Passing it selects legacy page-number mode, which only sees recent (hot) history and
480
- * populates `total`/`totalPages`. Use cursor pagination (`pageToken`) instead.
493
+ * Passing it selects legacy page-number mode, which only sees recent (hot) history. Both
494
+ * modes populate `total`/`totalPages` (bounded — see `totalCapped`); use cursor
495
+ * pagination (`pageToken`) instead for full history.
481
496
  * @param params.pageSize - Number of orders per page (defaults to 10, must be > 0; max 100
482
497
  * in page-number mode, up to 1000 when pageToken is present)
483
498
  * @param params.pageToken - Pagination cursor: pass `""` to start a cursor walk from
@@ -791,6 +806,12 @@ export class TradingAPIImpl extends BaseAPI {
791
806
  /**
792
807
  * Lists TWAP parent orders for the authenticated user.
793
808
  *
809
+ * The response `total` is bounded by the listing's pagination reach: exact up
810
+ * to `pageSize` x 10,000 rows and saturating there, so a caller with more
811
+ * matching TWAP orders than page-number mode can page through reads the cap,
812
+ * not its lifetime total; `page` is capped at 10,000 and a larger page is
813
+ * rejected.
814
+ *
794
815
  * @param params - Optional pagination and state / trading-pair filters
795
816
  * @returns Promise resolving to ListTwapOrdersResponse with orders and pagination info
796
817
  * @throws {APIError} When API communication fails
@@ -416,6 +416,15 @@ function parseInstrumentEventData(raw) {
416
416
  maxOrderSize: readString(data, "maxOrderSize"),
417
417
  marketType: readString(data, "marketType"),
418
418
  category: readString(data, "category"),
419
+ // Present-as-null on the wire: the server always sends both keys, carrying an
420
+ // explicit `null` when an asset has no icon. Read tolerantly — a missing key
421
+ // maps to `null` rather than dropping the frame — because the instrument
422
+ // channel must never drop a frame (a dropped frame can hide a market going
423
+ // inactive, 0XM-2628), and a cosmetic icon is safe to treat as absent. Unlike
424
+ // `readNullableString`, this does not reject a missing key; a present
425
+ // non-string value still throws.
426
+ baseIconUrl: readOptionalString(data, "baseIconUrl") ?? null,
427
+ quoteIconUrl: readOptionalString(data, "quoteIconUrl") ?? null,
419
428
  maxLeverage: readOptionalString(data, "maxLeverage"),
420
429
  initialMarginRate: readOptionalString(data, "initialMarginRate"),
421
430
  maintenanceMarginRate: readOptionalString(data, "maintenanceMarginRate"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "1.0.62",
3
+ "version": "1.0.65",
4
4
  "type": "module",
5
5
  "homepage": "https://docs.0xmonaco.com/sdk/typescript",
6
6
  "main": "./dist/index.js",
@@ -19,8 +19,8 @@
19
19
  "viem": "^2.45.2"
20
20
  },
21
21
  "dependencies": {
22
- "@0xmonaco/contracts": "1.0.62",
23
- "@0xmonaco/types": "1.0.62",
22
+ "@0xmonaco/contracts": "1.0.65",
23
+ "@0xmonaco/types": "1.0.65",
24
24
  "@noble/curves": "^1.9.1",
25
25
  "@noble/hashes": "^2.4.0",
26
26
  "http-status-codes": "^2.3.0"