@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/dist/index.mjs CHANGED
@@ -48,7 +48,7 @@ var ApiClient = class {
48
48
  this.fetchImpl = fetchImpl.bind(globalThis);
49
49
  }
50
50
  quote(body, options = {}) {
51
- return this.request("/api/swap/quote", "quote", {
51
+ return this.request("/api/v2/swap/quote", "quote", {
52
52
  ...options,
53
53
  method: "POST",
54
54
  body,
@@ -56,7 +56,7 @@ var ApiClient = class {
56
56
  });
57
57
  }
58
58
  build(body, options = {}) {
59
- return this.request("/api/swap/swap", "build", {
59
+ return this.request("/api/v2/swap/swap", "build", {
60
60
  ...options,
61
61
  method: "POST",
62
62
  body
@@ -1911,7 +1911,6 @@ var McaSwapService = class {
1911
1911
  this.client = client;
1912
1912
  this.relayerReports = /* @__PURE__ */ new Map();
1913
1913
  this.now = config.now ?? Date.now;
1914
- this.maxQuoteAgeMs = config.maxQuoteAgeMs === void 0 ? 3e4 : config.maxQuoteAgeMs;
1915
1914
  this.reportMode = config.reportMode ?? "auto";
1916
1915
  this.onEvent = config.onEvent;
1917
1916
  this.resolveSignerIdentity = config.resolveSignerIdentity;
@@ -1933,7 +1932,6 @@ var McaSwapService = class {
1933
1932
  return normalizeMcaQuote(request, signer, quote);
1934
1933
  }
1935
1934
  async build(input) {
1936
- this.assertQuoteFresh(input.quote);
1937
1935
  if (input.quote.executionMode === "withdraw-relayer") {
1938
1936
  throw new SwapSdkError(
1939
1937
  "INVALID_REQUEST",
@@ -1954,7 +1952,6 @@ var McaSwapService = class {
1954
1952
  };
1955
1953
  }
1956
1954
  async swap(input) {
1957
- this.assertQuoteFresh(input.quote);
1958
1955
  if (input.quote.executionMode === "withdraw-relayer") {
1959
1956
  return this.executeRelayerWithdraw({ ...input, quote: input.quote });
1960
1957
  }
@@ -2270,18 +2267,6 @@ var McaSwapService = class {
2270
2267
  this.onEvent?.(event);
2271
2268
  if (local !== this.onEvent) local?.(event);
2272
2269
  }
2273
- assertQuoteFresh(quote) {
2274
- const now = this.now();
2275
- const expiredByApi = quote.expiresAt !== void 0 && now > quote.expiresAt;
2276
- const expiredByAge = this.maxQuoteAgeMs !== null && now - quote.receivedAt > Math.max(0, this.maxQuoteAgeMs);
2277
- if (expiredByApi || expiredByAge) {
2278
- throw new SwapSdkError(
2279
- "QUOTE_EXPIRED",
2280
- "build",
2281
- "Quote has expired; request a fresh quote"
2282
- );
2283
- }
2284
- }
2285
2270
  };
2286
2271
  function buildRequestFromQuote(quote) {
2287
2272
  const context = quote.buildContext;
@@ -2329,7 +2314,6 @@ var SwapClient = class {
2329
2314
  this.now = config.now ?? Date.now;
2330
2315
  this.managedSwapFlow = new McaSwapService(this, {
2331
2316
  now: this.now,
2332
- maxQuoteAgeMs: config.maxQuoteAgeMs,
2333
2317
  reportMode: this.reportMode,
2334
2318
  resolveSignerIdentity: (chain) => this.registry.getSigner(chain),
2335
2319
  resolveMessageSigner: (chain) => this.registry.getSigner(chain, true),
@@ -2414,7 +2398,6 @@ var SwapClient = class {
2414
2398
  return this.buildStandardSwap(input);
2415
2399
  }
2416
2400
  async buildStandardSwap(input) {
2417
- this.assertQuoteFresh(input.quote);
2418
2401
  const executionId = createExecutionId();
2419
2402
  this.emit({ type: "build-started", executionId });
2420
2403
  const context = input.quote.buildContext;
@@ -2702,19 +2685,6 @@ var SwapClient = class {
2702
2685
  emit(event) {
2703
2686
  this.config.onEvent?.(event);
2704
2687
  }
2705
- assertQuoteFresh(quote) {
2706
- const now = this.now();
2707
- const maxAge = this.config.maxQuoteAgeMs === void 0 ? 3e4 : this.config.maxQuoteAgeMs;
2708
- const expiredByApi = quote.expiresAt !== void 0 && now > quote.expiresAt;
2709
- const expiredByAge = maxAge !== null && now - quote.receivedAt > Math.max(0, maxAge);
2710
- if (expiredByApi || expiredByAge) {
2711
- throw new SwapSdkError(
2712
- "QUOTE_EXPIRED",
2713
- "build",
2714
- "Quote has expired; request a fresh quote"
2715
- );
2716
- }
2717
- }
2718
2688
  createReportRequest(build, result) {
2719
2689
  const request = build.request;
2720
2690
  const reportContext = build.reportContext;