@0xmonaco/core 1.0.24 → 1.0.25-develop.1fab96c

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.
@@ -8,24 +8,37 @@
8
8
  *
9
9
  * @example
10
10
  * ```typescript
11
- * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint();
11
+ * // A valid Cloudflare Turnstile token is required on every mint.
12
+ * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint({ turnstileToken });
12
13
  * ```
13
14
  */
14
- import type { FaucetAPI, MintTokensParams, MintTokensResponse } from "@0xmonaco/types";
15
+ import type { FaucetAPI, GetFaucetInfoResponse, MintTokensParams, MintTokensResponse } from "@0xmonaco/types";
15
16
  import { BaseAPI } from "../base";
16
17
  export declare class FaucetAPIImpl extends BaseAPI implements FaucetAPI {
17
18
  /**
18
19
  * Mints the full set of testnet tokens to the authenticated user.
19
20
  *
20
21
  * Synchronous: resolves only when every faucet transaction confirmed
21
- * on-chain (HTTP 200). Rejects with 429 when the daily quota is exhausted,
22
- * 502 when transactions failed or were only partially confirmed (the error
23
- * details carry the minted/failed breakdown; delivered legs still consume
24
- * the quota), and 503 when the faucet is unavailable (safe to retry).
22
+ * on-chain (HTTP 200). Rejects with 400 when the Turnstile token is missing
23
+ * or invalid, 429 when the daily quota is exhausted, 502 when transactions
24
+ * failed or were only partially confirmed (the error details carry the
25
+ * minted/failed breakdown; delivered legs still consume the quota), and 503
26
+ * when the faucet is unavailable (safe to retry).
25
27
  *
26
- * @param params - Optional parameters (Turnstile captcha token when the
27
- * gateway requires one)
28
+ * @param params - Mint parameters, including the required Turnstile captcha
29
+ * token
28
30
  * @returns Promise resolving to the minted tokens and remaining quota
29
31
  */
30
- mint(params?: MintTokensParams): Promise<MintTokensResponse>;
32
+ mint(params: MintTokensParams): Promise<MintTokensResponse>;
33
+ /**
34
+ * Fetches the authenticated wallet's faucet quota and recent requests.
35
+ *
36
+ * Read-only: remaining requests in the rolling 24h window, when the next
37
+ * request becomes available (`nextAvailableAt`, absent when nothing is in
38
+ * the window), and the 5 most recent requests. Wallet-scoped across apps,
39
+ * matching mint enforcement.
40
+ *
41
+ * @returns Promise resolving to the quota and recent-request history
42
+ */
43
+ getInfo(): Promise<GetFaucetInfoResponse>;
31
44
  }
@@ -8,7 +8,8 @@
8
8
  *
9
9
  * @example
10
10
  * ```typescript
11
- * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint();
11
+ * // A valid Cloudflare Turnstile token is required on every mint.
12
+ * const { minted, failed, remainingRequests24h } = await sdk.faucet.mint({ turnstileToken });
12
13
  * ```
13
14
  */
14
15
  import { BaseAPI } from "../base";
@@ -18,21 +19,35 @@ export class FaucetAPIImpl extends BaseAPI {
18
19
  * Mints the full set of testnet tokens to the authenticated user.
19
20
  *
20
21
  * Synchronous: resolves only when every faucet transaction confirmed
21
- * on-chain (HTTP 200). Rejects with 429 when the daily quota is exhausted,
22
- * 502 when transactions failed or were only partially confirmed (the error
23
- * details carry the minted/failed breakdown; delivered legs still consume
24
- * the quota), and 503 when the faucet is unavailable (safe to retry).
22
+ * on-chain (HTTP 200). Rejects with 400 when the Turnstile token is missing
23
+ * or invalid, 429 when the daily quota is exhausted, 502 when transactions
24
+ * failed or were only partially confirmed (the error details carry the
25
+ * minted/failed breakdown; delivered legs still consume the quota), and 503
26
+ * when the faucet is unavailable (safe to retry).
25
27
  *
26
- * @param params - Optional parameters (Turnstile captcha token when the
27
- * gateway requires one)
28
+ * @param params - Mint parameters, including the required Turnstile captcha
29
+ * token
28
30
  * @returns Promise resolving to the minted tokens and remaining quota
29
31
  */
30
32
  async mint(params) {
31
33
  return await this.makeAuthenticatedRequest(perpRoutes.faucet.mint(), {
32
34
  method: "POST",
33
- ...(params?.turnstileToken !== undefined && {
34
- body: JSON.stringify({ turnstileToken: params.turnstileToken }),
35
- }),
35
+ body: JSON.stringify({ turnstileToken: params.turnstileToken }),
36
+ });
37
+ }
38
+ /**
39
+ * Fetches the authenticated wallet's faucet quota and recent requests.
40
+ *
41
+ * Read-only: remaining requests in the rolling 24h window, when the next
42
+ * request becomes available (`nextAvailableAt`, absent when nothing is in
43
+ * the window), and the 5 most recent requests. Wallet-scoped across apps,
44
+ * matching mint enforcement.
45
+ *
46
+ * @returns Promise resolving to the quota and recent-request history
47
+ */
48
+ async getInfo() {
49
+ return await this.makeAuthenticatedRequest(perpRoutes.faucet.info(), {
50
+ method: "GET",
36
51
  });
37
52
  }
38
53
  }
@@ -142,6 +142,7 @@ export declare const perpRoutes: {
142
142
  };
143
143
  readonly faucet: {
144
144
  readonly mint: () => string;
145
+ readonly info: () => string;
145
146
  };
146
147
  readonly whitelist: {
147
148
  readonly submit: () => string;
@@ -79,6 +79,7 @@ export const perpRoutes = {
79
79
  },
80
80
  faucet: {
81
81
  mint: () => `${API_V1}/faucet/mint`,
82
+ info: () => `${API_V1}/faucet/info`,
82
83
  },
83
84
  whitelist: {
84
85
  submit: () => `${API_V1}/whitelist`,
@@ -70,6 +70,7 @@ export class PositionsAPIImpl extends BaseAPI {
70
70
  orderType: request.takeProfit.orderType,
71
71
  limitPrice: request.takeProfit.limitPrice,
72
72
  quantity: request.takeProfit.quantity,
73
+ closePosition: request.takeProfit.closePosition,
73
74
  timeInForce: request.takeProfit.timeInForce,
74
75
  slippageToleranceBps: request.takeProfit.slippageToleranceBps,
75
76
  expiresAt: request.takeProfit.expiresAt,
@@ -81,11 +82,13 @@ export class PositionsAPIImpl extends BaseAPI {
81
82
  orderType: request.stopLoss.orderType,
82
83
  limitPrice: request.stopLoss.limitPrice,
83
84
  quantity: request.stopLoss.quantity,
85
+ closePosition: request.stopLoss.closePosition,
84
86
  timeInForce: request.stopLoss.timeInForce,
85
87
  slippageToleranceBps: request.stopLoss.slippageToleranceBps,
86
88
  expiresAt: request.stopLoss.expiresAt,
87
89
  }
88
90
  : undefined,
91
+ oco: request.oco,
89
92
  }),
90
93
  });
91
94
  }
@@ -21,6 +21,7 @@ export declare const COVERED: {
21
21
  get_application_stats: string;
22
22
  get_available_collateral: string;
23
23
  get_candles: string;
24
+ get_faucet_info: string;
24
25
  get_funding_state: string;
25
26
  get_index_price: string;
26
27
  get_margin_account_movements: string;
package/dist/coverage.js CHANGED
@@ -21,6 +21,7 @@ export const COVERED = {
21
21
  get_application_stats: "getApplicationStats",
22
22
  get_available_collateral: "getAvailableCollateral",
23
23
  get_candles: "getCandlesticks",
24
+ get_faucet_info: "faucet.getInfo",
24
25
  get_funding_state: "getFundingState",
25
26
  get_index_price: "getIndexPrice",
26
27
  get_margin_account_movements: "getMarginAccountMovements",
package/dist/sdk.js CHANGED
@@ -20,6 +20,13 @@ import { WithdrawalsAPIImpl } from "./api/withdrawals";
20
20
  import { generateSessionKeypair, privateKeyHex, publicKeyHex } from "./crypto/session";
21
21
  import { APIError, InvalidConfigError, InvalidStateError } from "./errors";
22
22
  import { resolveApiUrl, resolveWsUrl } from "./networks";
23
+ /**
24
+ * Default receipt-polling frequency for the SDK's internal viem public client.
25
+ * Sei produces sub-second blocks, so viem's 4000ms default adds seconds of
26
+ * slack to every `waitForTransactionReceipt`; 750ms keeps waits near one to
27
+ * two blocks while staying gentle on public RPC endpoints.
28
+ */
29
+ const DEFAULT_POLLING_INTERVAL_MS = 750;
23
30
  /** Validate a user-supplied URL override, returning it unchanged when valid. */
24
31
  function validateUrl(value, field) {
25
32
  try {
@@ -146,11 +153,15 @@ export class MonacoSDKImpl {
146
153
  // Use Sei mainnet chain only for "mainnet" network, testnet for everything else
147
154
  const chain = this.network === "mainnet" ? sei : seiTestnet;
148
155
  this.chain = chain;
156
+ if (cfg.pollingInterval !== undefined && (!Number.isFinite(cfg.pollingInterval) || cfg.pollingInterval <= 0)) {
157
+ throw new InvalidConfigError(`pollingInterval must be a positive number of milliseconds, got: ${cfg.pollingInterval}`, "pollingInterval");
158
+ }
149
159
  // Create public client with provided RPC URL
150
160
  const transport = http(cfg.seiRpcUrl);
151
161
  this.publicClient = createPublicClient({
152
162
  chain,
153
163
  transport,
164
+ pollingInterval: cfg.pollingInterval ?? DEFAULT_POLLING_INTERVAL_MS,
154
165
  });
155
166
  // Resolve the API URL: explicit override (validated) or network preset.
156
167
  const apiUrl = cfg.apiUrl ? validateUrl(cfg.apiUrl, "apiUrl") : resolveApiUrl(this.network);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "1.0.24",
3
+ "version": "1.0.25-develop.1fab96c",
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.24",
27
- "@0xmonaco/types": "1.0.24",
26
+ "@0xmonaco/contracts": "1.0.25-develop.1fab96c",
27
+ "@0xmonaco/types": "1.0.25-develop.1fab96c",
28
28
  "@noble/curves": "^1.9.1",
29
29
  "@noble/hashes": "^1.8.0",
30
30
  "http-status-codes": "^2.3.0"