@0xmonaco/core 0.8.8 → 0.8.11
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/README.md +3 -12
- package/dist/api/applications/api.d.ts +61 -8
- package/dist/api/applications/api.js +71 -7
- package/dist/api/auth/api.d.ts +7 -26
- package/dist/api/auth/api.js +6 -42
- package/dist/api/base.d.ts +35 -0
- package/dist/api/base.js +60 -0
- package/dist/api/delegated-agents/api.d.ts +2 -1
- package/dist/api/delegated-agents/api.js +4 -0
- package/dist/api/faucet/api.d.ts +25 -0
- package/dist/api/faucet/api.js +29 -0
- package/dist/api/faucet/index.d.ts +1 -0
- package/dist/api/faucet/index.js +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +4 -0
- package/dist/api/margin-accounts/api.d.ts +3 -4
- package/dist/api/margin-accounts/api.js +8 -15
- package/dist/api/market/api.d.ts +4 -1
- package/dist/api/market/api.js +14 -0
- package/dist/api/perp/routes.d.ts +64 -4
- package/dist/api/perp/routes.js +28 -4
- package/dist/api/profile/api.d.ts +18 -1
- package/dist/api/profile/api.js +41 -1
- package/dist/api/sub-accounts/api.d.ts +62 -0
- package/dist/api/sub-accounts/api.js +80 -0
- package/dist/api/sub-accounts/index.d.ts +1 -0
- package/dist/api/sub-accounts/index.js +1 -0
- package/dist/api/trades/api.d.ts +12 -1
- package/dist/api/trades/api.js +13 -1
- package/dist/api/trading/api.d.ts +5 -2
- package/dist/api/trading/api.js +7 -24
- package/dist/api/vault/api.d.ts +26 -2
- package/dist/api/vault/api.js +33 -4
- package/dist/api/vault/index.d.ts +1 -1
- package/dist/api/vault/index.js +1 -1
- package/dist/api/whitelist/api.d.ts +27 -0
- package/dist/api/whitelist/api.js +32 -0
- package/dist/api/whitelist/index.d.ts +1 -0
- package/dist/api/whitelist/index.js +1 -0
- package/dist/api/withdrawals/api.d.ts +15 -0
- package/dist/api/withdrawals/api.js +27 -0
- package/dist/api/withdrawals/index.d.ts +1 -0
- package/dist/api/withdrawals/index.js +1 -0
- package/dist/coverage.d.ts +86 -0
- package/dist/coverage.js +86 -0
- package/dist/sdk.d.ts +32 -1
- package/dist/sdk.js +88 -0
- package/package.json +3 -3
package/dist/api/trading/api.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* );
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema,
|
|
24
|
+
import { BatchCreateOrdersSchema, BatchReplaceOrdersSchema, CancelConditionalOrderSchema, CancelOrderSchema, GetPaginatedOrdersSchema, ListConditionalOrdersSchema, PlaceLimitOrderSchema, PlaceMarketOrderSchema, ReplaceOrderSchema, validate, } from "@0xmonaco/types";
|
|
25
25
|
import { BaseAPI } from "../base";
|
|
26
26
|
import { perpRoutes } from "../perp";
|
|
27
27
|
function parentTpSlLegToRequest(leg) {
|
|
@@ -107,6 +107,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
107
107
|
expiration_date: options?.expirationDate,
|
|
108
108
|
time_in_force: options?.timeInForce,
|
|
109
109
|
margin_account_id: options?.marginAccountId,
|
|
110
|
+
margin_bucket_id: options?.marginBucketId,
|
|
111
|
+
margin_bucket_collateral: options?.marginBucketCollateral,
|
|
110
112
|
strategy_key: options?.strategyKey,
|
|
111
113
|
position_side: options?.positionSide,
|
|
112
114
|
leverage: options?.leverage,
|
|
@@ -177,6 +179,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
177
179
|
quantity,
|
|
178
180
|
trading_mode: options?.tradingMode || "SPOT",
|
|
179
181
|
margin_account_id: options?.marginAccountId,
|
|
182
|
+
margin_bucket_id: options?.marginBucketId,
|
|
183
|
+
margin_bucket_collateral: options?.marginBucketCollateral,
|
|
180
184
|
strategy_key: options?.strategyKey,
|
|
181
185
|
position_side: options?.positionSide,
|
|
182
186
|
leverage: options?.leverage,
|
|
@@ -216,29 +220,6 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
216
220
|
body: JSON.stringify(requestBody),
|
|
217
221
|
});
|
|
218
222
|
}
|
|
219
|
-
async createConditionalOrder(params) {
|
|
220
|
-
validate(CreateConditionalOrderSchema, params);
|
|
221
|
-
const requestBody = {
|
|
222
|
-
trading_pair_id: params.tradingPairId,
|
|
223
|
-
margin_account_id: params.marginAccountId,
|
|
224
|
-
condition_type: params.conditionType,
|
|
225
|
-
trigger_price: params.triggerPrice,
|
|
226
|
-
trigger_source: params.triggerSource ?? "MARK_PRICE",
|
|
227
|
-
side: params.side,
|
|
228
|
-
position_side: params.positionSide,
|
|
229
|
-
order_type: params.orderType,
|
|
230
|
-
limit_price: params.limitPrice,
|
|
231
|
-
quantity: params.quantity,
|
|
232
|
-
reduce_only: params.reduceOnly ?? true,
|
|
233
|
-
time_in_force: params.timeInForce,
|
|
234
|
-
slippage_tolerance_bps: params.slippageToleranceBps,
|
|
235
|
-
expires_at: params.expiresAt,
|
|
236
|
-
};
|
|
237
|
-
return await this.makeAuthenticatedRequest(perpRoutes.orders.createConditional(), {
|
|
238
|
-
method: "POST",
|
|
239
|
-
body: JSON.stringify(requestBody),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
223
|
async cancelConditionalOrder(conditionalOrderId) {
|
|
243
224
|
validate(CancelConditionalOrderSchema, { conditionalOrderId });
|
|
244
225
|
return await this.makeAuthenticatedRequest(perpRoutes.orders.cancelConditional(conditionalOrderId), {
|
|
@@ -363,6 +344,8 @@ export class TradingAPIImpl extends BaseAPI {
|
|
|
363
344
|
expiration_date: order.expirationDate,
|
|
364
345
|
time_in_force: order.timeInForce,
|
|
365
346
|
margin_account_id: order.marginAccountId,
|
|
347
|
+
margin_bucket_id: order.marginBucketId,
|
|
348
|
+
margin_bucket_collateral: order.marginBucketCollateral,
|
|
366
349
|
strategy_key: order.strategyKey,
|
|
367
350
|
position_side: order.positionSide,
|
|
368
351
|
leverage: order.leverage,
|
package/dist/api/vault/api.d.ts
CHANGED
|
@@ -23,9 +23,21 @@
|
|
|
23
23
|
* console.log(`Deposit transaction: ${result.hash}`);
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
import type { ApplicationsAPI, Balance, ProfileAPI, TransactionResult, VaultAPI, WithdrawResult } from "@0xmonaco/types";
|
|
26
|
+
import type { ApplicationsAPI, Balance, DepositTarget, ProfileAPI, TransactionResult, VaultAPI, WithdrawResult } from "@0xmonaco/types";
|
|
27
27
|
import { type Address, type Chain, type PublicClient, type WalletClient } from "viem";
|
|
28
28
|
import { BaseAPI } from "../base";
|
|
29
|
+
/**
|
|
30
|
+
* Encode the on-chain `applicationData` for a deposit.
|
|
31
|
+
*
|
|
32
|
+
* For `"spot"` (the default) this stays the bare `clientId` string — byte-for-byte
|
|
33
|
+
* identical to the legacy encoding, so existing deposits are unchanged. For
|
|
34
|
+
* `"margin"` it emits a small JSON routing hint the indexer decodes to credit the
|
|
35
|
+
* deposit to margin collateral.
|
|
36
|
+
*
|
|
37
|
+
* MUST stay in sync with the indexer decoder in
|
|
38
|
+
* `indexer/src/listeners/deposit_routing.rs`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function encodeDepositApplicationData(clientId: string, target: DepositTarget): string;
|
|
29
41
|
export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
|
|
30
42
|
private readonly publicClient;
|
|
31
43
|
private readonly chain;
|
|
@@ -121,6 +133,10 @@ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
|
|
|
121
133
|
* @param assetId - The asset identifier (UUID) to deposit
|
|
122
134
|
* @param amount - The amount of tokens to deposit (as bigint)
|
|
123
135
|
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
136
|
+
* @param target - Destination ledger: `"spot"` (default) credits the spot
|
|
137
|
+
* wallet; `"margin"` routes the deposit into the parent margin account's
|
|
138
|
+
* collateral (auto-creating the account if needed). Margin deposits that
|
|
139
|
+
* cannot be routed safely fall back to spot.
|
|
124
140
|
* @returns Promise resolving to TransactionResult with transaction details
|
|
125
141
|
* @throws {ContractError} When deposit fails or approval is insufficient
|
|
126
142
|
* @throws {APIError} When the asset is not found or the assetId is invalid
|
|
@@ -136,6 +152,14 @@ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
|
|
|
136
152
|
* console.log(`Deposit transaction: ${result.hash}`);
|
|
137
153
|
* console.log(`Status: ${result.status}`); // "confirmed" if successful
|
|
138
154
|
*
|
|
155
|
+
* // Deposit straight into margin collateral
|
|
156
|
+
* const marginDeposit = await vaultAPI.deposit(
|
|
157
|
+
* "123e4567-e89b-12d3-a456-426614174000",
|
|
158
|
+
* parseUnits("100", 6),
|
|
159
|
+
* true,
|
|
160
|
+
* "margin"
|
|
161
|
+
* );
|
|
162
|
+
*
|
|
139
163
|
* // Or skip auto-waiting
|
|
140
164
|
* const result = await vaultAPI.deposit(
|
|
141
165
|
* "123e4567-e89b-12d3-a456-426614174000",
|
|
@@ -146,7 +170,7 @@ export declare class VaultAPIImpl extends BaseAPI implements VaultAPI {
|
|
|
146
170
|
* const receipt = await sdk.waitForTransaction(result.hash);
|
|
147
171
|
* ```
|
|
148
172
|
*/
|
|
149
|
-
deposit(assetId: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
173
|
+
deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
|
|
150
174
|
/**
|
|
151
175
|
* Initiates a withdrawal through the API Gateway and submits the resulting
|
|
152
176
|
* pre-signed calldata on-chain via the connected wallet.
|
package/dist/api/vault/api.js
CHANGED
|
@@ -28,6 +28,20 @@ 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
|
+
/**
|
|
32
|
+
* Encode the on-chain `applicationData` for a deposit.
|
|
33
|
+
*
|
|
34
|
+
* For `"spot"` (the default) this stays the bare `clientId` string — byte-for-byte
|
|
35
|
+
* identical to the legacy encoding, so existing deposits are unchanged. For
|
|
36
|
+
* `"margin"` it emits a small JSON routing hint the indexer decodes to credit the
|
|
37
|
+
* deposit to margin collateral.
|
|
38
|
+
*
|
|
39
|
+
* MUST stay in sync with the indexer decoder in
|
|
40
|
+
* `indexer/src/listeners/deposit_routing.rs`.
|
|
41
|
+
*/
|
|
42
|
+
export function encodeDepositApplicationData(clientId, target) {
|
|
43
|
+
return target === "margin" ? JSON.stringify({ clientId, depositTarget: "MARGIN" }) : clientId;
|
|
44
|
+
}
|
|
31
45
|
export class VaultAPIImpl extends BaseAPI {
|
|
32
46
|
publicClient;
|
|
33
47
|
chain;
|
|
@@ -196,6 +210,10 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
196
210
|
* @param assetId - The asset identifier (UUID) to deposit
|
|
197
211
|
* @param amount - The amount of tokens to deposit (as bigint)
|
|
198
212
|
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
213
|
+
* @param target - Destination ledger: `"spot"` (default) credits the spot
|
|
214
|
+
* wallet; `"margin"` routes the deposit into the parent margin account's
|
|
215
|
+
* collateral (auto-creating the account if needed). Margin deposits that
|
|
216
|
+
* cannot be routed safely fall back to spot.
|
|
199
217
|
* @returns Promise resolving to TransactionResult with transaction details
|
|
200
218
|
* @throws {ContractError} When deposit fails or approval is insufficient
|
|
201
219
|
* @throws {APIError} When the asset is not found or the assetId is invalid
|
|
@@ -211,6 +229,14 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
211
229
|
* console.log(`Deposit transaction: ${result.hash}`);
|
|
212
230
|
* console.log(`Status: ${result.status}`); // "confirmed" if successful
|
|
213
231
|
*
|
|
232
|
+
* // Deposit straight into margin collateral
|
|
233
|
+
* const marginDeposit = await vaultAPI.deposit(
|
|
234
|
+
* "123e4567-e89b-12d3-a456-426614174000",
|
|
235
|
+
* parseUnits("100", 6),
|
|
236
|
+
* true,
|
|
237
|
+
* "margin"
|
|
238
|
+
* );
|
|
239
|
+
*
|
|
214
240
|
* // Or skip auto-waiting
|
|
215
241
|
* const result = await vaultAPI.deposit(
|
|
216
242
|
* "123e4567-e89b-12d3-a456-426614174000",
|
|
@@ -221,14 +247,17 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
221
247
|
* const receipt = await sdk.waitForTransaction(result.hash);
|
|
222
248
|
* ```
|
|
223
249
|
*/
|
|
224
|
-
async deposit(assetId, amount, autoWait = true) {
|
|
250
|
+
async deposit(assetId, amount, autoWait = true, target = "spot") {
|
|
225
251
|
if (!this.walletClient) {
|
|
226
252
|
throw new InvalidConfigError("Wallet client not set. Connect a wallet first.", "walletClient");
|
|
227
253
|
}
|
|
228
254
|
// Validate inputs
|
|
229
|
-
validate(DepositSchema, { assetId, amount, autoWait });
|
|
255
|
+
validate(DepositSchema, { assetId, amount, autoWait, target });
|
|
230
256
|
const vaultAddress = await this.getVaultAddress();
|
|
231
257
|
const clientId = await this.getClientId();
|
|
258
|
+
// The on-chain applicationData carries the client id plus, for margin
|
|
259
|
+
// deposits, the routing hint the indexer decodes.
|
|
260
|
+
const applicationData = encodeDepositApplicationData(clientId, target);
|
|
232
261
|
const { tokenAddress, isNativeToken } = await this.resolveAsset(assetId);
|
|
233
262
|
if (!isNativeToken) {
|
|
234
263
|
// Check if approval is needed before proceeding
|
|
@@ -250,7 +279,7 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
250
279
|
address: vaultAddress,
|
|
251
280
|
abi: CONTRACT_ABIS.vault,
|
|
252
281
|
functionName: "depositNative",
|
|
253
|
-
args: [walletAccount.address,
|
|
282
|
+
args: [walletAccount.address, applicationData],
|
|
254
283
|
account: walletAccount,
|
|
255
284
|
chain: this.chain,
|
|
256
285
|
value: amount,
|
|
@@ -261,7 +290,7 @@ export class VaultAPIImpl extends BaseAPI {
|
|
|
261
290
|
address: vaultAddress,
|
|
262
291
|
abi: CONTRACT_ABIS.vault,
|
|
263
292
|
functionName: "depositERC20",
|
|
264
|
-
args: [walletAccount.address,
|
|
293
|
+
args: [walletAccount.address, applicationData, tokenAddress, amount],
|
|
265
294
|
account: walletAccount,
|
|
266
295
|
chain: this.chain,
|
|
267
296
|
});
|
package/dist/api/vault/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whitelist API Implementation
|
|
3
|
+
*
|
|
4
|
+
* Public (unauthenticated) whitelist/waitlist application submission. The
|
|
5
|
+
* server validates and de-duplicates by wallet address and email, creating an
|
|
6
|
+
* inactive user pending manual approval. This is an onboarding endpoint, not a
|
|
7
|
+
* trading operation.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const { message, user_id } = await sdk.whitelist.submit({
|
|
12
|
+
* wallet_address: "0x...",
|
|
13
|
+
* email: "user@example.com",
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import type { SubmitWhitelistRequest, SubmitWhitelistResponse, WhitelistAPI } from "@0xmonaco/types";
|
|
18
|
+
import { BaseAPI } from "../base";
|
|
19
|
+
export declare class WhitelistAPIImpl extends BaseAPI implements WhitelistAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Submits a whitelist (waitlist) application. Public — no auth required.
|
|
22
|
+
*
|
|
23
|
+
* @param body - Applicant details
|
|
24
|
+
* @returns Promise resolving to the status message and created user id
|
|
25
|
+
*/
|
|
26
|
+
submit(body: SubmitWhitelistRequest): Promise<SubmitWhitelistResponse>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whitelist API Implementation
|
|
3
|
+
*
|
|
4
|
+
* Public (unauthenticated) whitelist/waitlist application submission. The
|
|
5
|
+
* server validates and de-duplicates by wallet address and email, creating an
|
|
6
|
+
* inactive user pending manual approval. This is an onboarding endpoint, not a
|
|
7
|
+
* trading operation.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const { message, user_id } = await sdk.whitelist.submit({
|
|
12
|
+
* wallet_address: "0x...",
|
|
13
|
+
* email: "user@example.com",
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import { BaseAPI } from "../base";
|
|
18
|
+
import { perpRoutes } from "../perp/routes";
|
|
19
|
+
export class WhitelistAPIImpl extends BaseAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Submits a whitelist (waitlist) application. Public — no auth required.
|
|
22
|
+
*
|
|
23
|
+
* @param body - Applicant details
|
|
24
|
+
* @returns Promise resolving to the status message and created user id
|
|
25
|
+
*/
|
|
26
|
+
async submit(body) {
|
|
27
|
+
return await this.makePublicRequest(perpRoutes.whitelist.submit(), {
|
|
28
|
+
method: "POST",
|
|
29
|
+
body: JSON.stringify(body),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhitelistAPIImpl } from "./api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhitelistAPIImpl } from "./api";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InitiateWithdrawalRequest, WithdrawalResponse, WithdrawalsAPI } from "@0xmonaco/types";
|
|
2
|
+
import { BaseAPI } from "../base";
|
|
3
|
+
/**
|
|
4
|
+
* Low-level withdrawals client.
|
|
5
|
+
*
|
|
6
|
+
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
+
* returns the target vault address plus pre-signed `executeSignedWithdrawal`
|
|
8
|
+
* calldata; `getWithdrawal` re-fetches that calldata for a previously-initiated
|
|
9
|
+
* index. Neither submits on-chain — use the high-level vault API for the flow
|
|
10
|
+
* that also broadcasts the transaction.
|
|
11
|
+
*/
|
|
12
|
+
export declare class WithdrawalsAPIImpl extends BaseAPI implements WithdrawalsAPI {
|
|
13
|
+
initiateWithdrawal(request: InitiateWithdrawalRequest): Promise<WithdrawalResponse>;
|
|
14
|
+
getWithdrawal(withdrawalIndex: number): Promise<WithdrawalResponse>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseAPI } from "../base";
|
|
2
|
+
import { perpRoutes } from "../perp";
|
|
3
|
+
/**
|
|
4
|
+
* Low-level withdrawals client.
|
|
5
|
+
*
|
|
6
|
+
* `initiateWithdrawal` debits the caller's balance via the matching engine and
|
|
7
|
+
* returns the target vault address plus pre-signed `executeSignedWithdrawal`
|
|
8
|
+
* calldata; `getWithdrawal` re-fetches that calldata for a previously-initiated
|
|
9
|
+
* index. Neither submits on-chain — use the high-level vault API for the flow
|
|
10
|
+
* that also broadcasts the transaction.
|
|
11
|
+
*/
|
|
12
|
+
export class WithdrawalsAPIImpl extends BaseAPI {
|
|
13
|
+
async initiateWithdrawal(request) {
|
|
14
|
+
return this.makeAuthenticatedRequest(perpRoutes.withdrawals.initiate(), {
|
|
15
|
+
method: "POST",
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
asset_id: request.assetId,
|
|
18
|
+
amount: request.amount,
|
|
19
|
+
destination: request.destination,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async getWithdrawal(withdrawalIndex) {
|
|
24
|
+
// Public lookup — no auth required.
|
|
25
|
+
return this.makePublicRequest(perpRoutes.withdrawals.byIndex(withdrawalIndex));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** operationId → the @0xmonaco/core client method that covers it. */
|
|
2
|
+
export declare const COVERED: {
|
|
3
|
+
add_position_margin: string;
|
|
4
|
+
attach_position_tp_sl: string;
|
|
5
|
+
batch_cancel_all: string;
|
|
6
|
+
batch_cancel_all_by_pair: string;
|
|
7
|
+
batch_cancel_orders: string;
|
|
8
|
+
batch_create_orders: string;
|
|
9
|
+
batch_replace_orders: string;
|
|
10
|
+
cancel_conditional_order: string;
|
|
11
|
+
cancel_order: string;
|
|
12
|
+
close_position: string;
|
|
13
|
+
create_challenge: string;
|
|
14
|
+
create_delegated_session: string;
|
|
15
|
+
create_order: string;
|
|
16
|
+
create_sub_account_limit: string;
|
|
17
|
+
delete_sub_account_limit: string;
|
|
18
|
+
get_application_config: string;
|
|
19
|
+
get_application_stats: string;
|
|
20
|
+
get_available_collateral: string;
|
|
21
|
+
get_candles: string;
|
|
22
|
+
get_funding_state: string;
|
|
23
|
+
get_index_price: string;
|
|
24
|
+
get_margin_account_movements: string;
|
|
25
|
+
get_margin_account_summary: string;
|
|
26
|
+
get_mark_price: string;
|
|
27
|
+
get_market_metadata: string;
|
|
28
|
+
get_market_stats: string;
|
|
29
|
+
get_open_interest: string;
|
|
30
|
+
get_order_by_id: string;
|
|
31
|
+
get_orderbook_snapshot: string;
|
|
32
|
+
get_orders: string;
|
|
33
|
+
get_perp_market_config: string;
|
|
34
|
+
get_perp_market_summary: string;
|
|
35
|
+
get_portfolio_chart: string;
|
|
36
|
+
get_portfolio_stats: string;
|
|
37
|
+
get_position: string;
|
|
38
|
+
get_position_risk: string;
|
|
39
|
+
get_screener: string;
|
|
40
|
+
get_sub_account_limits: string;
|
|
41
|
+
get_trade_by_id: string;
|
|
42
|
+
get_trades: string;
|
|
43
|
+
get_trading_pair_by_id: string;
|
|
44
|
+
get_user_balance_by_asset: string;
|
|
45
|
+
get_user_balances: string;
|
|
46
|
+
get_user_movements: string;
|
|
47
|
+
get_user_profile: string;
|
|
48
|
+
get_user_trades: string;
|
|
49
|
+
get_withdrawal: string;
|
|
50
|
+
initiate_withdrawal: string;
|
|
51
|
+
list_application_balances: string;
|
|
52
|
+
list_application_movements: string;
|
|
53
|
+
list_application_orders: string;
|
|
54
|
+
list_application_users: string;
|
|
55
|
+
list_conditional_orders: string;
|
|
56
|
+
list_delegated_agent_owners: string;
|
|
57
|
+
list_delegated_agents: string;
|
|
58
|
+
list_funding_history: string;
|
|
59
|
+
list_funding_payments: string;
|
|
60
|
+
list_margin_accounts: string;
|
|
61
|
+
list_position_history: string;
|
|
62
|
+
list_positions: string;
|
|
63
|
+
list_sub_accounts_with_balances: string;
|
|
64
|
+
list_trading_pairs: string;
|
|
65
|
+
mint_tokens: string;
|
|
66
|
+
reduce_position_margin: string;
|
|
67
|
+
refresh_session: string;
|
|
68
|
+
replace_order: string;
|
|
69
|
+
revoke_delegated_agent: string;
|
|
70
|
+
revoke_session: string;
|
|
71
|
+
simulate_auto_margin_order_risk: string;
|
|
72
|
+
simulate_fees: string;
|
|
73
|
+
simulate_order_risk: string;
|
|
74
|
+
submit_whitelist: string;
|
|
75
|
+
transfer_collateral_from_margin_account: string;
|
|
76
|
+
transfer_collateral_to_auto_margin_account: string;
|
|
77
|
+
transfer_collateral_to_margin_account: string;
|
|
78
|
+
update_sub_account_limit: string;
|
|
79
|
+
upsert_delegated_agent: string;
|
|
80
|
+
verify_signature: string;
|
|
81
|
+
};
|
|
82
|
+
/** operationId → reason it is intentionally not covered by @0xmonaco/core. */
|
|
83
|
+
export declare const INTENTIONALLY_EXCLUDED: {
|
|
84
|
+
authenticate_backend: string;
|
|
85
|
+
health_check: string;
|
|
86
|
+
};
|
package/dist/coverage.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** operationId → the @0xmonaco/core client method that covers it. */
|
|
2
|
+
export const COVERED = {
|
|
3
|
+
add_position_margin: "addPositionMargin",
|
|
4
|
+
attach_position_tp_sl: "attachPositionTpSl",
|
|
5
|
+
batch_cancel_all: "batchCancelAll",
|
|
6
|
+
batch_cancel_all_by_pair: "batchCancelAll (with tradingPairId)",
|
|
7
|
+
batch_cancel_orders: "batchCancel",
|
|
8
|
+
batch_create_orders: "batchCreate",
|
|
9
|
+
batch_replace_orders: "batchReplace",
|
|
10
|
+
cancel_conditional_order: "cancelConditionalOrder",
|
|
11
|
+
cancel_order: "cancelOrder",
|
|
12
|
+
close_position: "closePosition",
|
|
13
|
+
create_challenge: "createChallenge",
|
|
14
|
+
create_delegated_session: "createDelegatedSession",
|
|
15
|
+
create_order: "placeLimitOrder / placeMarketOrder",
|
|
16
|
+
create_sub_account_limit: "subAccounts.createLimit",
|
|
17
|
+
delete_sub_account_limit: "subAccounts.deleteLimit",
|
|
18
|
+
get_application_config: "getApplicationConfig",
|
|
19
|
+
get_application_stats: "getApplicationStats",
|
|
20
|
+
get_available_collateral: "getAvailableCollateral",
|
|
21
|
+
get_candles: "getCandlesticks",
|
|
22
|
+
get_funding_state: "getFundingState",
|
|
23
|
+
get_index_price: "getIndexPrice",
|
|
24
|
+
get_margin_account_movements: "getMarginAccountMovements",
|
|
25
|
+
get_margin_account_summary: "getMarginAccountSummary",
|
|
26
|
+
get_mark_price: "getMarkPrice",
|
|
27
|
+
get_market_metadata: "getMarketMetadata",
|
|
28
|
+
get_market_stats: "getMarketStats",
|
|
29
|
+
get_open_interest: "getOpenInterest",
|
|
30
|
+
get_order_by_id: "getOrder",
|
|
31
|
+
get_orderbook_snapshot: "getOrderbook",
|
|
32
|
+
get_orders: "getPaginatedOrders",
|
|
33
|
+
get_perp_market_config: "getPerpMarketConfig",
|
|
34
|
+
get_perp_market_summary: "getPerpMarketSummary",
|
|
35
|
+
get_portfolio_chart: "getPortfolioChart",
|
|
36
|
+
get_portfolio_stats: "getPortfolioStats",
|
|
37
|
+
get_position: "getPosition",
|
|
38
|
+
get_position_risk: "getPositionRisk",
|
|
39
|
+
get_screener: "getScreener",
|
|
40
|
+
get_sub_account_limits: "subAccounts.getLimits",
|
|
41
|
+
get_trade_by_id: "getTradeById",
|
|
42
|
+
get_trades: "getTrades",
|
|
43
|
+
get_trading_pair_by_id: "getTradingPair",
|
|
44
|
+
get_user_balance_by_asset: "getUserBalanceByAssetId",
|
|
45
|
+
get_user_balances: "getUserBalances",
|
|
46
|
+
get_user_movements: "getPaginatedUserMovements",
|
|
47
|
+
get_user_profile: "getProfile",
|
|
48
|
+
get_user_trades: "getUserTrades",
|
|
49
|
+
get_withdrawal: "getWithdrawal",
|
|
50
|
+
initiate_withdrawal: "initiateWithdrawal",
|
|
51
|
+
list_application_balances: "listApplicationBalances",
|
|
52
|
+
list_application_movements: "listApplicationMovements",
|
|
53
|
+
list_application_orders: "listApplicationOrders",
|
|
54
|
+
list_application_users: "listApplicationUsers",
|
|
55
|
+
list_conditional_orders: "listConditionalOrders",
|
|
56
|
+
list_delegated_agent_owners: "listDelegatedOwners",
|
|
57
|
+
list_delegated_agents: "listDelegatedAgents",
|
|
58
|
+
list_funding_history: "listFundingHistory",
|
|
59
|
+
list_funding_payments: "listFundingPayments",
|
|
60
|
+
list_margin_accounts: "listMarginAccounts",
|
|
61
|
+
list_position_history: "listPositionHistory",
|
|
62
|
+
list_positions: "listPositions",
|
|
63
|
+
list_sub_accounts_with_balances: "subAccounts.list",
|
|
64
|
+
list_trading_pairs: "getPaginatedTradingPairs",
|
|
65
|
+
mint_tokens: "faucet.mint",
|
|
66
|
+
reduce_position_margin: "reducePositionMargin",
|
|
67
|
+
refresh_session: "refreshSession",
|
|
68
|
+
replace_order: "replaceOrder",
|
|
69
|
+
revoke_delegated_agent: "revokeDelegatedAgent",
|
|
70
|
+
revoke_session: "revokeSession",
|
|
71
|
+
simulate_auto_margin_order_risk: "simulateAutoMarginOrderRisk",
|
|
72
|
+
simulate_fees: "simulateFees",
|
|
73
|
+
simulate_order_risk: "simulateOrderRisk",
|
|
74
|
+
submit_whitelist: "whitelist.submit",
|
|
75
|
+
transfer_collateral_from_margin_account: "transferCollateralFromMarginAccount",
|
|
76
|
+
transfer_collateral_to_auto_margin_account: "transferCollateralToAutoMarginAccount",
|
|
77
|
+
transfer_collateral_to_margin_account: "transferCollateralToMarginAccount",
|
|
78
|
+
update_sub_account_limit: "subAccounts.updateLimit",
|
|
79
|
+
upsert_delegated_agent: "upsertDelegatedAgent",
|
|
80
|
+
verify_signature: "verifySignature",
|
|
81
|
+
};
|
|
82
|
+
/** operationId → reason it is intentionally not covered by @0xmonaco/core. */
|
|
83
|
+
export const INTENTIONALLY_EXCLUDED = {
|
|
84
|
+
authenticate_backend: "Backend auth is header-based via setServerKey()/the x-server-key header, not an endpoint method (MON-1486).",
|
|
85
|
+
health_check: "Infrastructure liveness probe (GET /health); not part of the data SDK surface.",
|
|
86
|
+
};
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApplicationsAPI, AuthAPI, AuthState, DelegatedAgentsAPI, FeesAPI, MarginAccountsAPI, MarketAPI, MonacoSDK, Network, PositionsAPI, ProfileAPI, SDKConfig, TradingAPI, VaultAPI } from "@0xmonaco/types";
|
|
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
2
|
import { 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 {
|
|
@@ -7,10 +7,14 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
7
7
|
applications: ApplicationsAPI;
|
|
8
8
|
fees: FeesAPI;
|
|
9
9
|
vault: VaultAPI;
|
|
10
|
+
withdrawals: WithdrawalsAPI;
|
|
10
11
|
trading: TradingAPI;
|
|
11
12
|
market: MarketAPI;
|
|
12
13
|
marginAccounts: MarginAccountsAPI;
|
|
13
14
|
positions: PositionsAPI;
|
|
15
|
+
subAccounts: SubAccountsAPI;
|
|
16
|
+
faucet: FaucetAPI;
|
|
17
|
+
whitelist: WhitelistAPI;
|
|
14
18
|
profile: ProfileAPI;
|
|
15
19
|
orderbook: OrderbookAPIImpl;
|
|
16
20
|
trades: TradesAPIImpl;
|
|
@@ -25,6 +29,24 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
25
29
|
* the WebSocket client.
|
|
26
30
|
*/
|
|
27
31
|
private propagateSession;
|
|
32
|
+
/**
|
|
33
|
+
* Set (or clear) the application secret key used for backend-authenticated
|
|
34
|
+
* requests (those annotated `#[require_backend]` on the gateway, e.g. the
|
|
35
|
+
* `applications` reporting endpoints).
|
|
36
|
+
*
|
|
37
|
+
* The raw `sk_...` key is sent in the `x-server-key` header on each such
|
|
38
|
+
* request. This is independent of {@link login}/session auth — a client may
|
|
39
|
+
* hold both a session and a server key at once.
|
|
40
|
+
*
|
|
41
|
+
* @param serverKey - The application secret key (`sk_...`), or `undefined` to clear.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* sdk.setServerKey("sk_live_...");
|
|
46
|
+
* const orders = await sdk.applications.listApplicationOrders({ status: "FILLED" });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
setServerKey(serverKey: string | undefined): void;
|
|
28
50
|
/** Extract the session keypair from an auth state. */
|
|
29
51
|
private sessionFromAuthState;
|
|
30
52
|
constructor(cfg: SDKConfig);
|
|
@@ -63,6 +85,15 @@ export declare class MonacoSDKImpl implements MonacoSDK {
|
|
|
63
85
|
login(clientId: string, options?: {
|
|
64
86
|
connectWebSocket?: boolean;
|
|
65
87
|
}): Promise<AuthState>;
|
|
88
|
+
/**
|
|
89
|
+
* Create and adopt an owner-scoped delegated session.
|
|
90
|
+
*
|
|
91
|
+
* This must be called while authenticated as the agent wallet. The delegated
|
|
92
|
+
* session uses a fresh ed25519 keypair generated locally; the current agent
|
|
93
|
+
* session signs the registration request, and subsequent SDK calls use the
|
|
94
|
+
* delegated session keypair.
|
|
95
|
+
*/
|
|
96
|
+
loginAsDelegatedOwner(ownerUserId: string): Promise<AuthState>;
|
|
66
97
|
/**
|
|
67
98
|
* Get the current authentication state
|
|
68
99
|
*
|