@0xmonaco/core 1.0.26 → 1.0.28

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.
@@ -36,7 +36,7 @@ export declare class FeesAPIImpl extends BaseAPI implements FeesAPI {
36
36
  * @param params.price - The price per unit as string
37
37
  * @param params.quantity - The quantity to trade as string
38
38
  * @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
39
- * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
39
+ * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 1000)
40
40
  * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
41
  *
42
42
  * @example
@@ -36,7 +36,7 @@ export class FeesAPIImpl extends BaseAPI {
36
36
  * @param params.price - The price per unit as string
37
37
  * @param params.quantity - The quantity to trade as string
38
38
  * @param params.orderType - Order type: "LIMIT" (default) or "MARKET"
39
- * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 500)
39
+ * @param params.slippageToleranceBps - Slippage tolerance in bps (0–1000, MARKET only, default 1000)
40
40
  * @returns Promise resolving to SimulateFeeResponse with fee breakdown
41
41
  *
42
42
  * @example
@@ -173,6 +173,11 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
173
173
  * @param params.page - Page number (starts from 1, default: 1)
174
174
  * @param params.pageSize - Number of items per page (default: 20, max: 100)
175
175
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
176
+ * @param params.pageToken - Pagination cursor (optional): omit for legacy page-number
177
+ * pagination; pass `""` to start a cursor walk from the newest row; pass a previous
178
+ * response's `nextPageToken` to resume. Any cursor-walk value (`""` or non-empty)
179
+ * ignores `page` and covers full trade history (hot and archived rows merged), unlike
180
+ * page-number mode.
176
181
  * @returns Promise resolving to paginated trades response
177
182
  * @throws {ValidationError} When the provided params fail client-side validation
178
183
  * @throws {APIError} When the request fails or user is not authenticated
@@ -224,6 +224,11 @@ export class ProfileAPIImpl extends BaseAPI {
224
224
  * @param params.page - Page number (starts from 1, default: 1)
225
225
  * @param params.pageSize - Number of items per page (default: 20, max: 100)
226
226
  * @param params.tradingPairId - Filter by trading pair ID (UUID)
227
+ * @param params.pageToken - Pagination cursor (optional): omit for legacy page-number
228
+ * pagination; pass `""` to start a cursor walk from the newest row; pass a previous
229
+ * response's `nextPageToken` to resume. Any cursor-walk value (`""` or non-empty)
230
+ * ignores `page` and covers full trade history (hot and archived rows merged), unlike
231
+ * page-number mode.
227
232
  * @returns Promise resolving to paginated trades response
228
233
  * @throws {ValidationError} When the provided params fail client-side validation
229
234
  * @throws {APIError} When the request fails or user is not authenticated
@@ -252,6 +257,9 @@ export class ProfileAPIImpl extends BaseAPI {
252
257
  if (params?.tradingPairId !== undefined) {
253
258
  searchParams.append("tradingPairId", params.tradingPairId);
254
259
  }
260
+ if (params?.pageToken !== undefined) {
261
+ searchParams.append("pageToken", params.pageToken);
262
+ }
255
263
  const queryString = searchParams.toString();
256
264
  const url = queryString ? `/api/v1/accounts/trades?${queryString}` : "/api/v1/accounts/trades";
257
265
  return await this.makeAuthenticatedRequest(url);
@@ -93,15 +93,17 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
93
93
  /**
94
94
  * Places a market order for immediate execution.
95
95
  *
96
- * Market orders execute immediately at the current market price. They provide
97
- * immediate execution but may experience slippage.
96
+ * Market orders execute immediately against available liquidity, inside a
97
+ * mandatory 1,000 bps server-side protective price band. Fills beyond the band
98
+ * are cut off, so an order may partially fill and cancel the remainder, or be
99
+ * rejected when no liquidity sits inside the band.
98
100
  *
99
101
  * @param tradingPairId - The trading pair UUID
100
102
  * @param side - The order side ("BUY" or "SELL")
101
103
  * @param quantity - The order quantity as string
102
104
  * @param options - Optional parameters for the market order
103
105
  * @param options.tradingMode - Trading mode (e.g., "SPOT")
104
- * @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage)
106
+ * @param options.slippageTolerance - Tightens the mandatory 1,000 bps price band, as a decimal (e.g., 0.01 for 1%; 0 for best price only). It can only tighten the band, never widen it; omitting it applies the full 1,000 bps band.
105
107
  * @returns Promise resolving to CreateOrderResponse with order details
106
108
  *
107
109
  * @example
@@ -122,12 +124,12 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
122
124
  * { slippageTolerance: 0 } // Only execute at best ask price
123
125
  * );
124
126
  *
125
- * // Market order with unlimited slippage
127
+ * // Market order with the default protective band (no client tightening)
126
128
  * const order3 = await tradingAPI.placeMarketOrder(
127
129
  * "123e4567-e89b-12d3-a456-426614174000",
128
130
  * "BUY",
129
131
  * "1.0"
130
- * // No slippageTolerance specified = unlimited slippage
132
+ * // No slippageTolerance specified = full 1,000 bps band applies
131
133
  * );
132
134
  * ```
133
135
  */
@@ -268,6 +270,11 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
268
270
  * @param params.tradingPairId - Filter by trading pair UUID (optional)
269
271
  * @param params.page - Page number for pagination (defaults to 1, must be > 0)
270
272
  * @param params.pageSize - Number of orders per page (defaults to 10, max 100, must be > 0)
273
+ * @param params.pageToken - Pagination cursor (optional): omit for legacy page-number
274
+ * pagination; pass `""` to start a cursor walk from the newest (or oldest, for
275
+ * `orderBy: "ASC"`) row; pass a previous response's `nextPageToken` to resume. Any
276
+ * cursor-walk value (`""` or non-empty) ignores `page` and covers full order history
277
+ * (hot and archived rows merged), unlike page-number mode.
271
278
  * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
272
279
  * @throws {APIError} When API communication fails
273
280
  *
@@ -125,15 +125,17 @@ export class TradingAPIImpl extends BaseAPI {
125
125
  /**
126
126
  * Places a market order for immediate execution.
127
127
  *
128
- * Market orders execute immediately at the current market price. They provide
129
- * immediate execution but may experience slippage.
128
+ * Market orders execute immediately against available liquidity, inside a
129
+ * mandatory 1,000 bps server-side protective price band. Fills beyond the band
130
+ * are cut off, so an order may partially fill and cancel the remainder, or be
131
+ * rejected when no liquidity sits inside the band.
130
132
  *
131
133
  * @param tradingPairId - The trading pair UUID
132
134
  * @param side - The order side ("BUY" or "SELL")
133
135
  * @param quantity - The order quantity as string
134
136
  * @param options - Optional parameters for the market order
135
137
  * @param options.tradingMode - Trading mode (e.g., "SPOT")
136
- * @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage)
138
+ * @param options.slippageTolerance - Tightens the mandatory 1,000 bps price band, as a decimal (e.g., 0.01 for 1%; 0 for best price only). It can only tighten the band, never widen it; omitting it applies the full 1,000 bps band.
137
139
  * @returns Promise resolving to CreateOrderResponse with order details
138
140
  *
139
141
  * @example
@@ -154,12 +156,12 @@ export class TradingAPIImpl extends BaseAPI {
154
156
  * { slippageTolerance: 0 } // Only execute at best ask price
155
157
  * );
156
158
  *
157
- * // Market order with unlimited slippage
159
+ * // Market order with the default protective band (no client tightening)
158
160
  * const order3 = await tradingAPI.placeMarketOrder(
159
161
  * "123e4567-e89b-12d3-a456-426614174000",
160
162
  * "BUY",
161
163
  * "1.0"
162
- * // No slippageTolerance specified = unlimited slippage
164
+ * // No slippageTolerance specified = full 1,000 bps band applies
163
165
  * );
164
166
  * ```
165
167
  */
@@ -417,6 +419,11 @@ export class TradingAPIImpl extends BaseAPI {
417
419
  * @param params.tradingPairId - Filter by trading pair UUID (optional)
418
420
  * @param params.page - Page number for pagination (defaults to 1, must be > 0)
419
421
  * @param params.pageSize - Number of orders per page (defaults to 10, max 100, must be > 0)
422
+ * @param params.pageToken - Pagination cursor (optional): omit for legacy page-number
423
+ * pagination; pass `""` to start a cursor walk from the newest (or oldest, for
424
+ * `orderBy: "ASC"`) row; pass a previous response's `nextPageToken` to resume. Any
425
+ * cursor-walk value (`""` or non-empty) ignores `page` and covers full order history
426
+ * (hot and archived rows merged), unlike page-number mode.
420
427
  * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
421
428
  * @throws {APIError} When API communication fails
422
429
  *
@@ -441,7 +448,7 @@ export class TradingAPIImpl extends BaseAPI {
441
448
  validate(GetPaginatedOrdersSchema, params);
442
449
  }
443
450
  // Set pagination defaults with destructuring and validation
444
- const { page = 1, pageSize: requestedPageSize = 10, status, tradingPairId, tradingMode, marginAccountId } = params || {};
451
+ const { page = 1, pageSize: requestedPageSize = 10, status, tradingPairId, tradingMode, marginAccountId, pageToken } = params || {};
445
452
  const validPage = page > 0 ? page : 1;
446
453
  const validPageSize = requestedPageSize > 0 ? requestedPageSize : 10;
447
454
  const pageSize = Math.min(validPageSize, 100);
@@ -461,6 +468,13 @@ export class TradingAPIImpl extends BaseAPI {
461
468
  if (marginAccountId) {
462
469
  searchParams.append("marginAccountId", marginAccountId);
463
470
  }
471
+ // `!== undefined` (not a truthy check): an explicitly-provided empty
472
+ // string is the documented way to start a cursor walk (distinct from
473
+ // omitting `pageToken` entirely), so it must still be sent rather than
474
+ // silently dropped like a falsy value would be.
475
+ if (pageToken !== undefined) {
476
+ searchParams.append("pageToken", pageToken);
477
+ }
464
478
  const endpoint = `/api/v1/orders?${searchParams.toString()}`;
465
479
  return await this.makeAuthenticatedRequest(endpoint, {
466
480
  method: "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "viem": "^2.45.2"
24
24
  },
25
25
  "dependencies": {
26
- "@0xmonaco/contracts": "1.0.26",
27
- "@0xmonaco/types": "1.0.26",
26
+ "@0xmonaco/contracts": "1.0.28",
27
+ "@0xmonaco/types": "1.0.28",
28
28
  "@noble/curves": "^1.9.1",
29
29
  "@noble/hashes": "^1.8.0",
30
30
  "http-status-codes": "^2.3.0"