@0xmonaco/core 0.8.11 → 0.8.15
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/applications/api.js +4 -4
- package/dist/api/auth/api.d.ts +1 -1
- package/dist/api/auth/api.js +10 -10
- package/dist/api/base.d.ts +2 -2
- package/dist/api/base.js +2 -2
- package/dist/api/delegated-agents/api.js +12 -12
- package/dist/api/faucet/api.d.ts +1 -1
- package/dist/api/faucet/api.js +1 -1
- package/dist/api/fees/api.d.ts +13 -13
- package/dist/api/fees/api.js +18 -18
- package/dist/api/margin-accounts/api.d.ts +8 -3
- package/dist/api/margin-accounts/api.js +69 -25
- package/dist/api/market/api.d.ts +2 -2
- package/dist/api/market/api.js +19 -17
- package/dist/api/orderbook/api.js +13 -13
- package/dist/api/perp/routes.d.ts +68 -52
- package/dist/api/perp/routes.js +9 -2
- package/dist/api/positions/api.d.ts +2 -1
- package/dist/api/positions/api.js +30 -18
- package/dist/api/profile/api.d.ts +23 -23
- package/dist/api/profile/api.js +46 -46
- package/dist/api/sub-accounts/api.d.ts +2 -2
- package/dist/api/sub-accounts/api.js +2 -2
- package/dist/api/trades/api.d.ts +11 -11
- package/dist/api/trades/api.js +10 -10
- package/dist/api/trading/api.d.ts +10 -10
- package/dist/api/trading/api.js +69 -69
- package/dist/api/vault/api.d.ts +71 -28
- package/dist/api/vault/api.js +139 -39
- package/dist/api/whitelist/api.d.ts +2 -2
- package/dist/api/whitelist/api.js +2 -2
- package/dist/api/withdrawals/api.d.ts +8 -5
- package/dist/api/withdrawals/api.js +13 -5
- package/dist/coverage.d.ts +9 -2
- package/dist/coverage.js +9 -2
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.js +3 -3
- package/package.json +3 -3
package/dist/api/vault/api.js
CHANGED
|
@@ -28,6 +28,17 @@ import { ApproveTokenSchema, DepositSchema, validate, WithdrawSchema } from "@0x
|
|
|
28
28
|
import { erc20Abi, zeroAddress } from "viem";
|
|
29
29
|
import { APIError, ContractError, InvalidConfigError } from "../../errors";
|
|
30
30
|
import { BaseAPI } from "../base";
|
|
31
|
+
/** Default delay between polls while waiting for a withdrawal's proof. */
|
|
32
|
+
const DEFAULT_WITHDRAWAL_POLL_INTERVAL_MS = 5_000;
|
|
33
|
+
/**
|
|
34
|
+
* Default total wait for a withdrawal's proof (5 minutes). A withdrawal's merkle
|
|
35
|
+
* proof only lands after its root is confirmed on-chain, which on a healthy
|
|
36
|
+
* pipeline takes ~20s but can lag behind a brief proposer hiccup; the previous
|
|
37
|
+
* 60s tripped too eagerly. On timeout the SDK returns `awaiting_proof` rather
|
|
38
|
+
* than throwing, so the caller never loses the index — it just retries later.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_WITHDRAWAL_TIMEOUT_MS = 300_000;
|
|
41
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
31
42
|
/**
|
|
32
43
|
* Encode the on-chain `applicationData` for a deposit.
|
|
33
44
|
*
|
|
@@ -304,21 +315,80 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
304
315
|
return await this.waitForTransaction(txResult, autoWait);
|
|
305
316
|
}
|
|
306
317
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
318
|
+
* Polls `GET /api/v1/withdrawals/{index}` until the gateway can serve the
|
|
319
|
+
* `executeWithdrawal` calldata, then returns it with the vault address.
|
|
320
|
+
*
|
|
321
|
+
* The calldata only exists once the withdrawal's root is confirmed on-chain
|
|
322
|
+
* and its merkle proof is persisted. Until then the gateway returns 404 (the
|
|
323
|
+
* row is written asynchronously by the persistor after `initiate`) or 409
|
|
324
|
+
* (the proof is not confirmed yet); both are transient for a freshly-allocated
|
|
325
|
+
* index, so we retry on each until ready or the timeout elapses.
|
|
309
326
|
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
327
|
+
* Returns `null` when the timeout elapses before the proof is available — the
|
|
328
|
+
* index is still valid and the balance already debited, so callers surface
|
|
329
|
+
* this as `awaiting_proof` (with the index intact) rather than as a thrown
|
|
330
|
+
* error that would strand the index. Only non-transient errors (anything
|
|
331
|
+
* other than 404/409) throw.
|
|
332
|
+
*
|
|
333
|
+
* @throws {APIError} On non-transient errors while polling.
|
|
334
|
+
*/
|
|
335
|
+
async pollWithdrawalCalldata(withdrawalIndex, retry) {
|
|
336
|
+
const pollIntervalMs = retry?.pollIntervalMs ?? DEFAULT_WITHDRAWAL_POLL_INTERVAL_MS;
|
|
337
|
+
const timeoutMs = retry?.timeoutMs ?? DEFAULT_WITHDRAWAL_TIMEOUT_MS;
|
|
338
|
+
const deadline = Date.now() + timeoutMs;
|
|
339
|
+
for (;;) {
|
|
340
|
+
try {
|
|
341
|
+
const { vaultAddress, calldata } = await this.makePublicRequest(`/api/v1/withdrawals/${withdrawalIndex}`);
|
|
342
|
+
// Ready: non-empty calldata. (Defensively treat an empty/`0x` body as
|
|
343
|
+
// not-ready too, though the gateway returns an error in that case.)
|
|
344
|
+
if (calldata && calldata !== "0x") {
|
|
345
|
+
return { vaultAddress, calldata };
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
// 404 (row not persisted yet) and 409 (proof not confirmed yet) are
|
|
350
|
+
// transient for a valid index — keep polling. Anything else is fatal.
|
|
351
|
+
const isTransient = error instanceof APIError && (error.statusCode === 404 || error.statusCode === 409);
|
|
352
|
+
if (!isTransient) {
|
|
353
|
+
throw error;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (Date.now() + pollIntervalMs > deadline) {
|
|
357
|
+
// Timed out waiting for the proof. Signal not-ready; the caller keeps the
|
|
358
|
+
// index and retries later rather than losing it inside a thrown error.
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
await sleep(pollIntervalMs);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Initiates a withdrawal through the API Gateway, waits for its on-chain
|
|
366
|
+
* confirmation, then submits the resulting `executeWithdrawal` calldata via
|
|
367
|
+
* the connected wallet.
|
|
368
|
+
*
|
|
369
|
+
* The gateway allocates a `withdrawalIndex` via the matching engine and debits
|
|
370
|
+
* the balance immediately, but the executable calldata needs the withdrawal's
|
|
371
|
+
* merkle proof, which only exists once its root is confirmed on-chain. This
|
|
372
|
+
* method polls until the calldata is available (see `retry`), then submits it.
|
|
373
|
+
* The connected wallet pays gas; the contract authorises the withdrawal
|
|
374
|
+
* against the merkle proof embedded in the calldata. The wallet's address is
|
|
375
|
+
* sent as the on-chain `destination`.
|
|
376
|
+
*
|
|
377
|
+
* If the proof does not become available within the poll window, this method
|
|
378
|
+
* does NOT throw — it returns `{ withdrawalIndex, status: "awaiting_proof" }`
|
|
379
|
+
* with nothing submitted on-chain. The balance is already debited, so losing
|
|
380
|
+
* the index would strand the funds; the caller keeps it and finishes the
|
|
381
|
+
* withdrawal later with `retryWithdrawal(withdrawalIndex)`.
|
|
316
382
|
*
|
|
317
383
|
* @param assetId - The asset identifier (UUID) to withdraw
|
|
318
384
|
* @param amount - The raw token amount to withdraw (as bigint)
|
|
319
385
|
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
320
|
-
* @
|
|
321
|
-
* @
|
|
386
|
+
* @param sourceOrRetry - Source ledger (`"spot"` or `"margin"`) or legacy retry options
|
|
387
|
+
* @param retry - Polling cadence/timeout while waiting for the proof when a source is supplied
|
|
388
|
+
* @returns Promise resolving to a [`WithdrawResult`]: on success the submitted
|
|
389
|
+
* transaction plus `withdrawalIndex`; on poll-timeout `{ withdrawalIndex,
|
|
390
|
+
* status: "awaiting_proof" }`.
|
|
391
|
+
* @throws {APIError} When the asset is not found or the initiate request is rejected
|
|
322
392
|
* @throws {ContractError} When the on-chain submission fails
|
|
323
393
|
* @throws {InvalidConfigError} When wallet account is not available
|
|
324
394
|
*
|
|
@@ -330,18 +400,23 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
330
400
|
* parseUnits("50", 6),
|
|
331
401
|
* );
|
|
332
402
|
* console.log(`Withdrawal index: ${result.withdrawalIndex}`);
|
|
333
|
-
*
|
|
403
|
+
* if (result.status === "awaiting_proof") {
|
|
404
|
+
* // Proof not ready yet — balance already debited. Finish later:
|
|
405
|
+
* await vaultAPI.retryWithdrawal(result.withdrawalIndex);
|
|
406
|
+
* } else {
|
|
407
|
+
* console.log(`Tx hash: ${result.hash}, status: ${result.status}`);
|
|
408
|
+
* }
|
|
334
409
|
*
|
|
335
|
-
* //
|
|
410
|
+
* // Custom polling (check every 10s, wait up to an hour)
|
|
336
411
|
* const result = await vaultAPI.withdraw(
|
|
337
412
|
* "123e4567-e89b-12d3-a456-426614174000",
|
|
338
413
|
* parseUnits("50", 6),
|
|
339
|
-
*
|
|
414
|
+
* true,
|
|
415
|
+
* { pollIntervalMs: 10_000, timeoutMs: 3_600_000 },
|
|
340
416
|
* );
|
|
341
|
-
* const receipt = await sdk.waitForTransaction(result.hash);
|
|
342
417
|
* ```
|
|
343
418
|
*/
|
|
344
|
-
async withdraw(assetId, amount, autoWait = true) {
|
|
419
|
+
async withdraw(assetId, amount, autoWait = true, sourceOrRetry, retry) {
|
|
345
420
|
if (!this.walletClient) {
|
|
346
421
|
throw new InvalidConfigError("Wallet client not set. Connect a wallet first.", "walletClient");
|
|
347
422
|
}
|
|
@@ -350,21 +425,33 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
350
425
|
throw new InvalidConfigError("No account available in wallet client", "account");
|
|
351
426
|
}
|
|
352
427
|
const destination = walletAccount.address.toLowerCase();
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
const {
|
|
428
|
+
const source = typeof sourceOrRetry === "string" ? sourceOrRetry : "spot";
|
|
429
|
+
const retryOptions = typeof sourceOrRetry === "string" ? retry : sourceOrRetry;
|
|
430
|
+
validate(WithdrawSchema, { assetId, amount, destination, autoWait, source });
|
|
431
|
+
// 1. Gateway allocates the withdrawalIndex and debits the balance. No
|
|
432
|
+
// executable calldata yet — it needs the merkle proof, available only once
|
|
433
|
+
// the withdrawal root is confirmed on-chain.
|
|
434
|
+
const { withdrawalIndex } = await this.makeAuthenticatedRequest("/api/v1/withdrawals", {
|
|
360
435
|
method: "POST",
|
|
361
436
|
body: JSON.stringify({
|
|
362
|
-
|
|
437
|
+
assetId: assetId,
|
|
363
438
|
amount: amount.toString(),
|
|
364
439
|
destination,
|
|
440
|
+
source,
|
|
365
441
|
}),
|
|
366
442
|
});
|
|
367
|
-
// 2.
|
|
443
|
+
// 2. Poll for the executeWithdrawal calldata until the proof is confirmed.
|
|
444
|
+
// The vault address comes back with it, keeping calldata + target contract
|
|
445
|
+
// in lockstep.
|
|
446
|
+
const poll = await this.pollWithdrawalCalldata(withdrawalIndex, retryOptions);
|
|
447
|
+
if (!poll) {
|
|
448
|
+
// Proof not available within the poll window. The balance is already
|
|
449
|
+
// debited and the index is valid; return it (without submitting anything
|
|
450
|
+
// on-chain) so the caller can finish later via retryWithdrawal(index).
|
|
451
|
+
return { withdrawalIndex, status: "awaiting_proof" };
|
|
452
|
+
}
|
|
453
|
+
const { vaultAddress, calldata } = poll;
|
|
454
|
+
// 3. Submit the calldata on-chain through the connected wallet.
|
|
368
455
|
let hash;
|
|
369
456
|
try {
|
|
370
457
|
hash = await this.walletClient.sendTransaction({
|
|
@@ -375,7 +462,7 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
375
462
|
});
|
|
376
463
|
}
|
|
377
464
|
catch (error) {
|
|
378
|
-
throw new ContractError(`Failed to submit
|
|
465
|
+
throw new ContractError(`Failed to submit executeWithdrawal for withdrawal ${withdrawalIndex}: ${error instanceof Error ? error.message : "unknown error"}`, { cause: error instanceof Error ? error : undefined });
|
|
379
466
|
}
|
|
380
467
|
const nonce = walletAccount.getNonce ? await walletAccount.getNonce() : 0n;
|
|
381
468
|
const txResult = {
|
|
@@ -387,25 +474,32 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
387
474
|
return { ...settled, withdrawalIndex };
|
|
388
475
|
}
|
|
389
476
|
/**
|
|
390
|
-
*
|
|
391
|
-
* landed — e.g. the wallet rejected the tx, the page reloaded before the
|
|
392
|
-
* receipt came back, or a stuck mempool entry needs resending.
|
|
477
|
+
* Submits (or resubmits) a previously-initiated withdrawal on-chain.
|
|
393
478
|
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
479
|
+
* Use this when the original `withdraw()` could not complete — e.g. the proof
|
|
480
|
+
* was not yet confirmed within its polling window, the wallet rejected the tx,
|
|
481
|
+
* the page reloaded before the receipt came back, or a stuck mempool entry
|
|
482
|
+
* needs resending. Polls `GET /withdrawals/{index}` for the
|
|
483
|
+
* `executeWithdrawal` calldata (retrying while it is not yet confirmed), then
|
|
484
|
+
* submits it through the connected wallet. Does NOT initiate a new withdrawal
|
|
485
|
+
* — the matching engine already debited the balance and allocated the index.
|
|
486
|
+
* The contract is idempotent against double-submission of a settled
|
|
487
|
+
* withdrawal: it reverts once the index is consumed on-chain.
|
|
488
|
+
*
|
|
489
|
+
* Like `withdraw()`, if the proof is still unavailable within the poll window
|
|
490
|
+
* this returns `{ withdrawalIndex, status: "awaiting_proof" }` instead of
|
|
491
|
+
* throwing, so the caller can simply retry again later.
|
|
400
492
|
*
|
|
401
493
|
* @param withdrawalIndex - The index returned by the original `withdraw()` call
|
|
402
494
|
* @param autoWait - Whether to await on-chain confirmation (defaults to true)
|
|
403
|
-
* @
|
|
404
|
-
* @
|
|
495
|
+
* @param retry - Polling cadence/timeout while waiting for the proof
|
|
496
|
+
* @returns Promise resolving to a [`WithdrawResult`]: the submitted transaction
|
|
497
|
+
* plus `withdrawalIndex`, or `{ withdrawalIndex, status: "awaiting_proof" }`
|
|
498
|
+
* if the proof did not arrive within the poll window.
|
|
405
499
|
* @throws {ContractError} When the on-chain submission fails
|
|
406
500
|
* @throws {InvalidConfigError} When wallet account is not available
|
|
407
501
|
*/
|
|
408
|
-
async retryWithdrawal(withdrawalIndex, autoWait = true) {
|
|
502
|
+
async retryWithdrawal(withdrawalIndex, autoWait = true, retry) {
|
|
409
503
|
if (!this.walletClient) {
|
|
410
504
|
throw new InvalidConfigError("Wallet client not set. Connect a wallet first.", "walletClient");
|
|
411
505
|
}
|
|
@@ -413,7 +507,13 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
413
507
|
if (!walletAccount) {
|
|
414
508
|
throw new InvalidConfigError("No account available in wallet client", "account");
|
|
415
509
|
}
|
|
416
|
-
const
|
|
510
|
+
const poll = await this.pollWithdrawalCalldata(withdrawalIndex, retry);
|
|
511
|
+
if (!poll) {
|
|
512
|
+
// Still not confirmed on-chain within the poll window — return the index
|
|
513
|
+
// so the caller can retry again later, rather than throwing.
|
|
514
|
+
return { withdrawalIndex, status: "awaiting_proof" };
|
|
515
|
+
}
|
|
516
|
+
const { vaultAddress, calldata } = poll;
|
|
417
517
|
let hash;
|
|
418
518
|
try {
|
|
419
519
|
hash = await this.walletClient.sendTransaction({
|
|
@@ -424,7 +524,7 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
424
524
|
});
|
|
425
525
|
}
|
|
426
526
|
catch (error) {
|
|
427
|
-
throw new ContractError(`Failed to resubmit
|
|
527
|
+
throw new ContractError(`Failed to resubmit executeWithdrawal for withdrawal ${withdrawalIndex}: ${error instanceof Error ? error.message : "unknown error"}`, { cause: error instanceof Error ? error : undefined });
|
|
428
528
|
}
|
|
429
529
|
const nonce = walletAccount.getNonce ? await walletAccount.getNonce() : 0n;
|
|
430
530
|
const txResult = {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* const { message,
|
|
12
|
-
*
|
|
11
|
+
* const { message, userId } = await sdk.whitelist.submit({
|
|
12
|
+
* walletAddress: "0x...",
|
|
13
13
|
* email: "user@example.com",
|
|
14
14
|
* });
|
|
15
15
|
* ```
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* const { message,
|
|
12
|
-
*
|
|
11
|
+
* const { message, userId } = await sdk.whitelist.submit({
|
|
12
|
+
* walletAddress: "0x...",
|
|
13
13
|
* email: "user@example.com",
|
|
14
14
|
* });
|
|
15
15
|
* ```
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { InitiateWithdrawalRequest, WithdrawalResponse, WithdrawalsAPI } from "@0xmonaco/types";
|
|
1
|
+
import type { InitiateWithdrawalRequest, ListPendingWithdrawalsParams, ListPendingWithdrawalsResponse, WithdrawalResponse, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
/**
|
|
4
4
|
* Low-level withdrawals client.
|
|
5
5
|
*
|
|
6
6
|
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* allocates a `withdrawalIndex` (its `calldata` is empty — the proof is not
|
|
8
|
+
* available until the withdrawal root is confirmed on-chain). `getWithdrawal`
|
|
9
|
+
* returns the `executeWithdrawal` calldata once that proof is ready, and throws
|
|
10
|
+
* an `APIError` (404 not-persisted-yet / 409 not-confirmed-yet) while it is not.
|
|
11
|
+
* Neither submits on-chain — use the high-level vault API, which polls for the
|
|
12
|
+
* calldata and broadcasts the transaction.
|
|
11
13
|
*/
|
|
12
14
|
export declare class WithdrawalsAPIImpl extends BaseAPI implements WithdrawalsAPI {
|
|
13
15
|
initiateWithdrawal(request: InitiateWithdrawalRequest): Promise<WithdrawalResponse>;
|
|
14
16
|
getWithdrawal(withdrawalIndex: number): Promise<WithdrawalResponse>;
|
|
17
|
+
listPendingWithdrawals(params?: ListPendingWithdrawalsParams): Promise<ListPendingWithdrawalsResponse>;
|
|
15
18
|
}
|
|
@@ -4,19 +4,22 @@ import { perpRoutes } from "../perp";
|
|
|
4
4
|
* Low-level withdrawals client.
|
|
5
5
|
*
|
|
6
6
|
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* allocates a `withdrawalIndex` (its `calldata` is empty — the proof is not
|
|
8
|
+
* available until the withdrawal root is confirmed on-chain). `getWithdrawal`
|
|
9
|
+
* returns the `executeWithdrawal` calldata once that proof is ready, and throws
|
|
10
|
+
* an `APIError` (404 not-persisted-yet / 409 not-confirmed-yet) while it is not.
|
|
11
|
+
* Neither submits on-chain — use the high-level vault API, which polls for the
|
|
12
|
+
* calldata and broadcasts the transaction.
|
|
11
13
|
*/
|
|
12
14
|
export class WithdrawalsAPIImpl extends BaseAPI {
|
|
13
15
|
async initiateWithdrawal(request) {
|
|
14
16
|
return this.makeAuthenticatedRequest(perpRoutes.withdrawals.initiate(), {
|
|
15
17
|
method: "POST",
|
|
16
18
|
body: JSON.stringify({
|
|
17
|
-
|
|
19
|
+
assetId: request.assetId,
|
|
18
20
|
amount: request.amount,
|
|
19
21
|
destination: request.destination,
|
|
22
|
+
source: request.source ?? "spot",
|
|
20
23
|
}),
|
|
21
24
|
});
|
|
22
25
|
}
|
|
@@ -24,4 +27,9 @@ export class WithdrawalsAPIImpl extends BaseAPI {
|
|
|
24
27
|
// Public lookup — no auth required.
|
|
25
28
|
return this.makePublicRequest(perpRoutes.withdrawals.byIndex(withdrawalIndex));
|
|
26
29
|
}
|
|
30
|
+
async listPendingWithdrawals(params) {
|
|
31
|
+
// The gateway serves camelCase (the REST wire format), which matches the
|
|
32
|
+
// public surface, so the response is returned directly with no remapping.
|
|
33
|
+
return this.makeAuthenticatedRequest(perpRoutes.withdrawals.list({ page: params?.page, pageSize: params?.pageSize }));
|
|
34
|
+
}
|
|
27
35
|
}
|
package/dist/coverage.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const COVERED: {
|
|
|
5
5
|
batch_cancel_all: string;
|
|
6
6
|
batch_cancel_all_by_pair: string;
|
|
7
7
|
batch_cancel_orders: string;
|
|
8
|
+
batch_close_all_positions: string;
|
|
8
9
|
batch_create_orders: string;
|
|
9
10
|
batch_replace_orders: string;
|
|
10
11
|
cancel_conditional_order: string;
|
|
@@ -36,6 +37,8 @@ export declare const COVERED: {
|
|
|
36
37
|
get_portfolio_stats: string;
|
|
37
38
|
get_position: string;
|
|
38
39
|
get_position_risk: string;
|
|
40
|
+
get_parent_margin_account_movements: string;
|
|
41
|
+
get_parent_margin_account_summary: string;
|
|
39
42
|
get_screener: string;
|
|
40
43
|
get_sub_account_limits: string;
|
|
41
44
|
get_trade_by_id: string;
|
|
@@ -48,6 +51,7 @@ export declare const COVERED: {
|
|
|
48
51
|
get_user_trades: string;
|
|
49
52
|
get_withdrawal: string;
|
|
50
53
|
initiate_withdrawal: string;
|
|
54
|
+
list_pending_withdrawals: string;
|
|
51
55
|
list_application_balances: string;
|
|
52
56
|
list_application_movements: string;
|
|
53
57
|
list_application_orders: string;
|
|
@@ -68,13 +72,16 @@ export declare const COVERED: {
|
|
|
68
72
|
replace_order: string;
|
|
69
73
|
revoke_delegated_agent: string;
|
|
70
74
|
revoke_session: string;
|
|
71
|
-
|
|
75
|
+
simulate_risk_bucket_order_risk: string;
|
|
72
76
|
simulate_fees: string;
|
|
73
77
|
simulate_order_risk: string;
|
|
78
|
+
simulate_parent_margin_order_risk: string;
|
|
74
79
|
submit_whitelist: string;
|
|
80
|
+
transfer_collateral_from_parent_margin_account: string;
|
|
75
81
|
transfer_collateral_from_margin_account: string;
|
|
76
|
-
transfer_collateral_to_auto_margin_account: string;
|
|
77
82
|
transfer_collateral_to_margin_account: string;
|
|
83
|
+
transfer_collateral_to_parent_margin_account: string;
|
|
84
|
+
transfer_collateral_to_risk_bucket: string;
|
|
78
85
|
update_sub_account_limit: string;
|
|
79
86
|
upsert_delegated_agent: string;
|
|
80
87
|
verify_signature: string;
|
package/dist/coverage.js
CHANGED
|
@@ -5,6 +5,7 @@ export const COVERED = {
|
|
|
5
5
|
batch_cancel_all: "batchCancelAll",
|
|
6
6
|
batch_cancel_all_by_pair: "batchCancelAll (with tradingPairId)",
|
|
7
7
|
batch_cancel_orders: "batchCancel",
|
|
8
|
+
batch_close_all_positions: "batchCloseAllPositions",
|
|
8
9
|
batch_create_orders: "batchCreate",
|
|
9
10
|
batch_replace_orders: "batchReplace",
|
|
10
11
|
cancel_conditional_order: "cancelConditionalOrder",
|
|
@@ -36,6 +37,8 @@ export const COVERED = {
|
|
|
36
37
|
get_portfolio_stats: "getPortfolioStats",
|
|
37
38
|
get_position: "getPosition",
|
|
38
39
|
get_position_risk: "getPositionRisk",
|
|
40
|
+
get_parent_margin_account_movements: "getParentMarginAccountMovements",
|
|
41
|
+
get_parent_margin_account_summary: "getParentMarginAccountSummary",
|
|
39
42
|
get_screener: "getScreener",
|
|
40
43
|
get_sub_account_limits: "subAccounts.getLimits",
|
|
41
44
|
get_trade_by_id: "getTradeById",
|
|
@@ -48,6 +51,7 @@ export const COVERED = {
|
|
|
48
51
|
get_user_trades: "getUserTrades",
|
|
49
52
|
get_withdrawal: "getWithdrawal",
|
|
50
53
|
initiate_withdrawal: "initiateWithdrawal",
|
|
54
|
+
list_pending_withdrawals: "listPendingWithdrawals",
|
|
51
55
|
list_application_balances: "listApplicationBalances",
|
|
52
56
|
list_application_movements: "listApplicationMovements",
|
|
53
57
|
list_application_orders: "listApplicationOrders",
|
|
@@ -68,13 +72,16 @@ export const COVERED = {
|
|
|
68
72
|
replace_order: "replaceOrder",
|
|
69
73
|
revoke_delegated_agent: "revokeDelegatedAgent",
|
|
70
74
|
revoke_session: "revokeSession",
|
|
71
|
-
|
|
75
|
+
simulate_risk_bucket_order_risk: "simulateRiskBucketOrderRisk",
|
|
72
76
|
simulate_fees: "simulateFees",
|
|
73
77
|
simulate_order_risk: "simulateOrderRisk",
|
|
78
|
+
simulate_parent_margin_order_risk: "simulateParentMarginOrderRisk",
|
|
74
79
|
submit_whitelist: "whitelist.submit",
|
|
80
|
+
transfer_collateral_from_parent_margin_account: "transferCollateralFromParentMarginAccount",
|
|
75
81
|
transfer_collateral_from_margin_account: "transferCollateralFromMarginAccount",
|
|
76
|
-
transfer_collateral_to_auto_margin_account: "transferCollateralToAutoMarginAccount",
|
|
77
82
|
transfer_collateral_to_margin_account: "transferCollateralToMarginAccount",
|
|
83
|
+
transfer_collateral_to_parent_margin_account: "transferCollateralToParentMarginAccount",
|
|
84
|
+
transfer_collateral_to_risk_bucket: "transferCollateralToRiskBucket",
|
|
78
85
|
update_sub_account_limit: "subAccounts.updateLimit",
|
|
79
86
|
upsert_delegated_agent: "upsertDelegatedAgent",
|
|
80
87
|
verify_signature: "verifySignature",
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationsAPI, AuthAPI, AuthState, DelegatedAgentsAPI, FaucetAPI, FeesAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PositionsAPI, ProfileAPI, SDKConfig, SubAccountsAPI, TradingAPI, VaultAPI, WhitelistAPI, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
|
-
import { type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
|
|
2
|
+
import { type Address, type PublicClient, type TransactionReceipt, type WalletClient } from "viem";
|
|
3
3
|
import { type MonacoWebSocket, OrderbookAPIImpl, TradesAPIImpl } from "./api";
|
|
4
4
|
export declare class MonacoSDKImpl implements MonacoSDK {
|
|
5
5
|
auth: AuthAPI;
|
|
@@ -147,7 +147,7 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
147
147
|
/**
|
|
148
148
|
* Get the current account address
|
|
149
149
|
*/
|
|
150
|
-
getAccountAddress():
|
|
150
|
+
getAccountAddress(): Address;
|
|
151
151
|
/**
|
|
152
152
|
* Get the current network
|
|
153
153
|
*/
|
package/dist/sdk.js
CHANGED
|
@@ -242,10 +242,10 @@ export class MonacoSDKImpl {
|
|
|
242
242
|
this.authState = {
|
|
243
243
|
sessionPublicKey: session.publicKey,
|
|
244
244
|
sessionPrivateKey: session.privateKey,
|
|
245
|
-
expiresAt: delegatedSession.
|
|
245
|
+
expiresAt: delegatedSession.expiresAt,
|
|
246
246
|
user: {
|
|
247
|
-
id: delegatedSession.
|
|
248
|
-
address: delegatedSession.
|
|
247
|
+
id: delegatedSession.ownerUserId,
|
|
248
|
+
address: delegatedSession.agentAddress,
|
|
249
249
|
},
|
|
250
250
|
};
|
|
251
251
|
this.propagateSession(this.sessionFromAuthState(this.authState));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.15",
|
|
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": "0.8.
|
|
27
|
-
"@0xmonaco/types": "0.8.
|
|
26
|
+
"@0xmonaco/contracts": "0.8.15",
|
|
27
|
+
"@0xmonaco/types": "0.8.15",
|
|
28
28
|
"@noble/curves": "^1.9.1",
|
|
29
29
|
"@noble/hashes": "^1.8.0",
|
|
30
30
|
"http-status-codes": "^2.3.0"
|