@rhea-finance/cross-chain-aggregation-dex 2.0.6 → 2.0.7

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 CHANGED
@@ -314,7 +314,7 @@ const quoteRequest: QuoteRequest = {
314
314
  const quote = await client.quote(quoteRequest);
315
315
  ```
316
316
 
317
- `quote()` calls `POST /api/swap/quote`. The frontend can configure the Near Intents wait plus the same-chain and cross-chain route timeouts on every `QuoteRequest`. The SDK sends the defaults shown above when fields are omitted.
317
+ `quote()` calls `POST /api/v2/swap/quote`. The frontend can configure the Near Intents wait plus the same-chain and cross-chain route timeouts on every `QuoteRequest`. The SDK sends the defaults shown above when fields are omitted.
318
318
 
319
319
  Set `confidentiality: "basic"` to use the confidential 1Click route. The SDK preserves it through quote and build, and includes it in automatic or manual report payloads. Omit the field for public swaps:
320
320
 
@@ -345,7 +345,7 @@ const quote = await client.quote({
345
345
  | `sameChainTimeoutMs` | `500` | Timeout budget supplied to same-chain quote routing. |
346
346
  | `crossChainTimeoutMs` | `3000` | Timeout budget supplied to cross-chain quote routing. |
347
347
 
348
- All three values use milliseconds and must be non-negative integers. They affect only `POST /api/swap/quote`; the SDK removes them from the subsequent build request. They do **not** control the SDK HTTP timeout, wallet signing, source-chain confirmation, bridge settlement, or order polling. Keep the client's `timeoutMs` above the configured quote budget plus network overhead.
348
+ All three values use milliseconds and must be non-negative integers. They affect only `POST /api/v2/swap/quote`; the SDK removes them from the subsequent build request. They do **not** control the SDK HTTP timeout, wallet signing, source-chain confirmation, bridge settlement, or order polling. Keep the client's `timeoutMs` above the configured quote budget plus network overhead.
349
349
 
350
350
  ### 3.4 Execute the swap directly
351
351
 
@@ -431,7 +431,6 @@ Terminal statuses are `completed`, `failed`, `refunded`, and `expired`.
431
431
  | `retry` | `Partial<RetryConfig>` | No | Retry policy for retryable quote/read operations. Defaults: 2 retries, 250ms base delay, 2000ms maximum delay, and jitter enabled. |
432
432
  | `logger` | `SdkLogger` | No | Receives structured `api.request`, `api.response`, and `api.retry` entries. |
433
433
  | `executors` | `readonly ChainExecutor[]` | Required for execution | Wallet executors. May be omitted when only calling `quote()` or `buildSwap()`. |
434
- | `maxQuoteAgeMs` | `number \| null` | No | Maximum local quote age in milliseconds. Default: `30000`. Set to `null` to disable the local age check; an API-provided `expiresAt` still applies. |
435
434
  | `tokenListCacheTtlMs` | `number` | No | Successful token-list cache lifetime in milliseconds. Default: `600000` (10 minutes). Set to `0` to disable. |
436
435
  | `reportMode` | `"auto" \| "manual" \| "disabled"` | No | Reporting policy. Default: `"auto"`. A reporting failure does not turn a submitted swap into a failed swap. |
437
436
  | `onEvent` | `(event) => void` | No | Receives all lifecycle events. |
@@ -753,7 +752,7 @@ try {
753
752
  }
754
753
  ```
755
754
 
756
- Common `stage` values are `quote`, `build`, `approve`, `sign`, `broadcast`, `submit`, `report`, `status`, and `history`. Common `code` values include `QUOTE_EXPIRED`, `USER_REJECTED`, `APPROVAL_FAILED`, `SIGNING_FAILED`, `BROADCAST_FAILED`, and `ORDER_TIMEOUT`.
755
+ Common `stage` values are `quote`, `build`, `approve`, `sign`, `broadcast`, `submit`, `report`, `status`, and `history`. Common `code` values include `USER_REJECTED`, `APPROVAL_FAILED`, `SIGNING_FAILED`, `BROADCAST_FAILED`, and `ORDER_TIMEOUT`.
757
756
 
758
757
  Pass an `AbortSignal` to stop an unfinished request or wait:
759
758
 
package/dist/index.d.mts CHANGED
@@ -231,7 +231,6 @@ interface SwapTokenListItem extends AssetRef {
231
231
  }
232
232
 
233
233
  interface SwapClientConfig extends ApiClientConfig {
234
- maxQuoteAgeMs?: number | null;
235
234
  reportMode?: "auto" | "manual" | "disabled";
236
235
  executors?: readonly ChainExecutor[];
237
236
  onEvent?: (event: SwapLifecycleEvent) => void;
@@ -287,7 +286,6 @@ declare class SwapClient {
287
286
  authorizeConfidentialHistory(request: SwapHistoryAuthChallengeRequestRaw, signChallenge: (challenge: SwapHistoryAuthChallengeRaw) => SwapHistoryAuthProofRaw | Promise<SwapHistoryAuthProofRaw>, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
288
287
  getHistory(request: HistoryRequest, options?: ApiRequestOptions): Promise<SwapHistoryPage>;
289
288
  protected emit(event: SwapLifecycleEvent): void;
290
- private assertQuoteFresh;
291
289
  private createReportRequest;
292
290
  }
293
291
 
package/dist/index.d.ts CHANGED
@@ -231,7 +231,6 @@ interface SwapTokenListItem extends AssetRef {
231
231
  }
232
232
 
233
233
  interface SwapClientConfig extends ApiClientConfig {
234
- maxQuoteAgeMs?: number | null;
235
234
  reportMode?: "auto" | "manual" | "disabled";
236
235
  executors?: readonly ChainExecutor[];
237
236
  onEvent?: (event: SwapLifecycleEvent) => void;
@@ -287,7 +286,6 @@ declare class SwapClient {
287
286
  authorizeConfidentialHistory(request: SwapHistoryAuthChallengeRequestRaw, signChallenge: (challenge: SwapHistoryAuthChallengeRaw) => SwapHistoryAuthProofRaw | Promise<SwapHistoryAuthProofRaw>, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
288
287
  getHistory(request: HistoryRequest, options?: ApiRequestOptions): Promise<SwapHistoryPage>;
289
288
  protected emit(event: SwapLifecycleEvent): void;
290
- private assertQuoteFresh;
291
289
  private createReportRequest;
292
290
  }
293
291
 
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ var ApiClient = class {
50
50
  this.fetchImpl = fetchImpl.bind(globalThis);
51
51
  }
52
52
  quote(body, options = {}) {
53
- return this.request("/api/swap/quote", "quote", {
53
+ return this.request("/api/v2/swap/quote", "quote", {
54
54
  ...options,
55
55
  method: "POST",
56
56
  body,
@@ -58,7 +58,7 @@ var ApiClient = class {
58
58
  });
59
59
  }
60
60
  build(body, options = {}) {
61
- return this.request("/api/swap/swap", "build", {
61
+ return this.request("/api/v2/swap/swap", "build", {
62
62
  ...options,
63
63
  method: "POST",
64
64
  body
@@ -1913,7 +1913,6 @@ var McaSwapService = class {
1913
1913
  this.client = client;
1914
1914
  this.relayerReports = /* @__PURE__ */ new Map();
1915
1915
  this.now = config.now ?? Date.now;
1916
- this.maxQuoteAgeMs = config.maxQuoteAgeMs === void 0 ? 3e4 : config.maxQuoteAgeMs;
1917
1916
  this.reportMode = config.reportMode ?? "auto";
1918
1917
  this.onEvent = config.onEvent;
1919
1918
  this.resolveSignerIdentity = config.resolveSignerIdentity;
@@ -1935,7 +1934,6 @@ var McaSwapService = class {
1935
1934
  return normalizeMcaQuote(request, signer, quote);
1936
1935
  }
1937
1936
  async build(input) {
1938
- this.assertQuoteFresh(input.quote);
1939
1937
  if (input.quote.executionMode === "withdraw-relayer") {
1940
1938
  throw new SwapSdkError(
1941
1939
  "INVALID_REQUEST",
@@ -1956,7 +1954,6 @@ var McaSwapService = class {
1956
1954
  };
1957
1955
  }
1958
1956
  async swap(input) {
1959
- this.assertQuoteFresh(input.quote);
1960
1957
  if (input.quote.executionMode === "withdraw-relayer") {
1961
1958
  return this.executeRelayerWithdraw({ ...input, quote: input.quote });
1962
1959
  }
@@ -2272,18 +2269,6 @@ var McaSwapService = class {
2272
2269
  this.onEvent?.(event);
2273
2270
  if (local !== this.onEvent) local?.(event);
2274
2271
  }
2275
- assertQuoteFresh(quote) {
2276
- const now = this.now();
2277
- const expiredByApi = quote.expiresAt !== void 0 && now > quote.expiresAt;
2278
- const expiredByAge = this.maxQuoteAgeMs !== null && now - quote.receivedAt > Math.max(0, this.maxQuoteAgeMs);
2279
- if (expiredByApi || expiredByAge) {
2280
- throw new SwapSdkError(
2281
- "QUOTE_EXPIRED",
2282
- "build",
2283
- "Quote has expired; request a fresh quote"
2284
- );
2285
- }
2286
- }
2287
2272
  };
2288
2273
  function buildRequestFromQuote(quote) {
2289
2274
  const context = quote.buildContext;
@@ -2331,7 +2316,6 @@ var SwapClient = class {
2331
2316
  this.now = config.now ?? Date.now;
2332
2317
  this.managedSwapFlow = new McaSwapService(this, {
2333
2318
  now: this.now,
2334
- maxQuoteAgeMs: config.maxQuoteAgeMs,
2335
2319
  reportMode: this.reportMode,
2336
2320
  resolveSignerIdentity: (chain) => this.registry.getSigner(chain),
2337
2321
  resolveMessageSigner: (chain) => this.registry.getSigner(chain, true),
@@ -2416,7 +2400,6 @@ var SwapClient = class {
2416
2400
  return this.buildStandardSwap(input);
2417
2401
  }
2418
2402
  async buildStandardSwap(input) {
2419
- this.assertQuoteFresh(input.quote);
2420
2403
  const executionId = createExecutionId();
2421
2404
  this.emit({ type: "build-started", executionId });
2422
2405
  const context = input.quote.buildContext;
@@ -2704,19 +2687,6 @@ var SwapClient = class {
2704
2687
  emit(event) {
2705
2688
  this.config.onEvent?.(event);
2706
2689
  }
2707
- assertQuoteFresh(quote) {
2708
- const now = this.now();
2709
- const maxAge = this.config.maxQuoteAgeMs === void 0 ? 3e4 : this.config.maxQuoteAgeMs;
2710
- const expiredByApi = quote.expiresAt !== void 0 && now > quote.expiresAt;
2711
- const expiredByAge = maxAge !== null && now - quote.receivedAt > Math.max(0, maxAge);
2712
- if (expiredByApi || expiredByAge) {
2713
- throw new SwapSdkError(
2714
- "QUOTE_EXPIRED",
2715
- "build",
2716
- "Quote has expired; request a fresh quote"
2717
- );
2718
- }
2719
- }
2720
2690
  createReportRequest(build, result) {
2721
2691
  const request = build.request;
2722
2692
  const reportContext = build.reportContext;