@0xmonaco/core 1.0.56 → 1.0.57
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/base.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils";
|
|
23
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
24
24
|
import { StatusCodes } from "http-status-codes";
|
|
25
25
|
import { buildHttpSignatureHeaders } from "../crypto/http-signatures";
|
|
26
26
|
import { composeSigningString, keypairFromHex, sha256Hex, signMessage } from "../crypto/session";
|
|
@@ -257,6 +257,17 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
257
257
|
* Each order is canceled and re-created with new parameters.
|
|
258
258
|
* Failed replacements do not prevent other orders from being replaced.
|
|
259
259
|
*
|
|
260
|
+
* Pre-sequencing validation is scoped per item too, matching `batchCreate`:
|
|
261
|
+
* a malformed `orderId`, `price`, `quantity` or `clientOrderId`, or a
|
|
262
|
+
* `postOnly` violation, fails only that item — its result slot carries a
|
|
263
|
+
* structured `error.code` (`INVALID_ORDER_ID`, `INVALID_PRICE`,
|
|
264
|
+
* `INVALID_QUANTITY`, `INVALID_CLIENT_ORDER_ID`, `INVALID_POST_ONLY`) and its
|
|
265
|
+
* original is left untouched — while the valid items proceed. A `2xx`
|
|
266
|
+
* response can therefore mix executed replacements and failed items: read
|
|
267
|
+
* `results[]` per item rather than treating the status code as the verdict.
|
|
268
|
+
* Only an empty or oversize (>100) batch rejects the whole request.
|
|
269
|
+
* `totalRequested === totalSucceeded + totalFailed` always holds.
|
|
270
|
+
*
|
|
260
271
|
* @param orders - Array of order replacement parameters
|
|
261
272
|
* @returns Promise resolving to BatchReplaceOrdersResponse with individual results
|
|
262
273
|
* @throws {APIError} When API communication fails
|
|
@@ -281,6 +292,11 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
281
292
|
* Gets orders based on query parameters, cursor-paginated by default.
|
|
282
293
|
*
|
|
283
294
|
* Retrieves orders with optional filtering by status, trading pair, and pagination.
|
|
295
|
+
* Every kind of order comes back in ONE stream ordered by timestamp: book orders,
|
|
296
|
+
* TWAP parents (`orderType: "TWAP"`, detail on `twap`) and conditional orders
|
|
297
|
+
* (`orderType: "CONDITIONAL"`, detail on `conditional`). There is no separate
|
|
298
|
+
* open-orders call — filter `status` to `["SUBMITTED", "PARTIALLY_FILLED"]` for the
|
|
299
|
+
* working set.
|
|
284
300
|
* When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
|
|
285
301
|
* pagination: it starts a cursor walk from the newest (or oldest, for
|
|
286
302
|
* `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Cursor
|
|
@@ -305,6 +321,17 @@ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
|
|
|
305
321
|
*
|
|
306
322
|
* @example
|
|
307
323
|
* ```typescript
|
|
324
|
+
* // Every working order, of every kind, in one page
|
|
325
|
+
* const open = await tradingAPI.getPaginatedOrders({ status: ["SUBMITTED", "PARTIALLY_FILLED"] });
|
|
326
|
+
* for (const order of open.orders) {
|
|
327
|
+
* if (order.orderType === "TWAP") console.log("TWAP parent", order.twap?.slicesPlaced);
|
|
328
|
+
* else if (order.orderType === "CONDITIONAL") console.log("trigger", order.conditional?.triggerPrice);
|
|
329
|
+
* else console.log("resting", order.price);
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
308
335
|
* // Walk full order history with cursor pagination (the default mode)
|
|
309
336
|
* let pageToken: string | undefined;
|
|
310
337
|
* do {
|
package/dist/api/trading/api.js
CHANGED
|
@@ -403,6 +403,17 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
403
403
|
* Each order is canceled and re-created with new parameters.
|
|
404
404
|
* Failed replacements do not prevent other orders from being replaced.
|
|
405
405
|
*
|
|
406
|
+
* Pre-sequencing validation is scoped per item too, matching `batchCreate`:
|
|
407
|
+
* a malformed `orderId`, `price`, `quantity` or `clientOrderId`, or a
|
|
408
|
+
* `postOnly` violation, fails only that item — its result slot carries a
|
|
409
|
+
* structured `error.code` (`INVALID_ORDER_ID`, `INVALID_PRICE`,
|
|
410
|
+
* `INVALID_QUANTITY`, `INVALID_CLIENT_ORDER_ID`, `INVALID_POST_ONLY`) and its
|
|
411
|
+
* original is left untouched — while the valid items proceed. A `2xx`
|
|
412
|
+
* response can therefore mix executed replacements and failed items: read
|
|
413
|
+
* `results[]` per item rather than treating the status code as the verdict.
|
|
414
|
+
* Only an empty or oversize (>100) batch rejects the whole request.
|
|
415
|
+
* `totalRequested === totalSucceeded + totalFailed` always holds.
|
|
416
|
+
*
|
|
406
417
|
* @param orders - Array of order replacement parameters
|
|
407
418
|
* @returns Promise resolving to BatchReplaceOrdersResponse with individual results
|
|
408
419
|
* @throws {APIError} When API communication fails
|
|
@@ -443,6 +454,11 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
443
454
|
* Gets orders based on query parameters, cursor-paginated by default.
|
|
444
455
|
*
|
|
445
456
|
* Retrieves orders with optional filtering by status, trading pair, and pagination.
|
|
457
|
+
* Every kind of order comes back in ONE stream ordered by timestamp: book orders,
|
|
458
|
+
* TWAP parents (`orderType: "TWAP"`, detail on `twap`) and conditional orders
|
|
459
|
+
* (`orderType: "CONDITIONAL"`, detail on `conditional`). There is no separate
|
|
460
|
+
* open-orders call — filter `status` to `["SUBMITTED", "PARTIALLY_FILLED"]` for the
|
|
461
|
+
* working set.
|
|
446
462
|
* When neither `page` nor `pageToken` is passed, the SDK drives cursor (pageToken)
|
|
447
463
|
* pagination: it starts a cursor walk from the newest (or oldest, for
|
|
448
464
|
* `orderBy: "ASC"`) row and the response's `nextPageToken` resumes it. Cursor
|
|
@@ -467,6 +483,17 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
467
483
|
*
|
|
468
484
|
* @example
|
|
469
485
|
* ```typescript
|
|
486
|
+
* // Every working order, of every kind, in one page
|
|
487
|
+
* const open = await tradingAPI.getPaginatedOrders({ status: ["SUBMITTED", "PARTIALLY_FILLED"] });
|
|
488
|
+
* for (const order of open.orders) {
|
|
489
|
+
* if (order.orderType === "TWAP") console.log("TWAP parent", order.twap?.slicesPlaced);
|
|
490
|
+
* else if (order.orderType === "CONDITIONAL") console.log("trigger", order.conditional?.triggerPrice);
|
|
491
|
+
* else console.log("resting", order.price);
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
470
497
|
* // Walk full order history with cursor pagination (the default mode)
|
|
471
498
|
* let pageToken: string | undefined;
|
|
472
499
|
* do {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hexToBytes } from "@noble/hashes/utils";
|
|
1
|
+
import { hexToBytes } from "@noble/hashes/utils.js";
|
|
2
2
|
import { composeWsSigningString, signMessage } from "../../crypto/session";
|
|
3
3
|
import { ALL_MAGNITUDES } from "../../utils";
|
|
4
4
|
import { keysToCamelCase } from "./utils";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Monaco's RFC 9421 Ed25519 profile; key registration remains wallet-authorized. */
|
|
2
2
|
import { ed25519 } from "@noble/curves/ed25519";
|
|
3
|
-
import { sha256 } from "@noble/hashes/sha2";
|
|
4
|
-
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils";
|
|
3
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
5
5
|
function base64(bytes) {
|
|
6
6
|
return btoa(String.fromCharCode(...bytes));
|
|
7
7
|
}
|
package/dist/crypto/session.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* key — it never sees the private key, so it cannot mint requests as the user.
|
|
9
9
|
*/
|
|
10
10
|
import { ed25519 } from "@noble/curves/ed25519";
|
|
11
|
-
import { sha256 } from "@noble/hashes/sha2";
|
|
12
|
-
import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils";
|
|
11
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
12
|
+
import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
13
13
|
/**
|
|
14
14
|
* Generate a fresh ed25519 session keypair.
|
|
15
15
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://docs.0xmonaco.com/sdk/typescript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"viem": "^2.45.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@0xmonaco/contracts": "1.0.
|
|
23
|
-
"@0xmonaco/types": "1.0.
|
|
22
|
+
"@0xmonaco/contracts": "1.0.57",
|
|
23
|
+
"@0xmonaco/types": "1.0.57",
|
|
24
24
|
"@noble/curves": "^1.9.1",
|
|
25
|
-
"@noble/hashes": "^
|
|
25
|
+
"@noble/hashes": "^2.4.0",
|
|
26
26
|
"http-status-codes": "^2.3.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|