@oddmaki-protocol/sdk 1.10.1 → 1.11.1

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
@@ -11664,6 +11664,29 @@ var PriceMarketModule = class extends BaseModule {
11664
11664
  functionName: "getPythContract"
11665
11665
  });
11666
11666
  }
11667
+ /**
11668
+ * Mark a stuck price market as Invalid and refund holders 50/50 via the CTF.
11669
+ * Permissionless: anyone can call this once `closeTime + 7 days` has elapsed.
11670
+ *
11671
+ * Use this for markets that never resolve via Pyth — e.g. the feed was
11672
+ * deprecated by the publisher, or Hermes had no in-window VAA at closeTime.
11673
+ * Reports payouts `[1, 1]` to the CTF, so every YES and every NO token
11674
+ * redeems for half the underlying collateral.
11675
+ *
11676
+ * Reverts on chain with `GracePeriodNotElapsed` if called too early.
11677
+ */
11678
+ async markInvalid(marketId) {
11679
+ const wallet = this.walletClient;
11680
+ const account = await this.getSignerAccount();
11681
+ const { request } = await this.publicClient.simulateContract({
11682
+ address: this.config.diamondAddress,
11683
+ abi: PythResolutionFacet_default,
11684
+ functionName: "markPriceMarketInvalid",
11685
+ args: [marketId],
11686
+ account
11687
+ });
11688
+ return wallet.writeContract(request);
11689
+ }
11667
11690
  /**
11668
11691
  * Set the Pyth oracle contract address. Diamond owner only.
11669
11692
  */
@@ -11863,15 +11886,12 @@ var PriceMarketModule = class extends BaseModule {
11863
11886
  }
11864
11887
  async fetchPythHistoricalRaw(feedId, publishTime, windowSeconds) {
11865
11888
  const window = Math.max(0, Math.floor(windowSeconds));
11866
- const offsets = window === 0 ? [0] : Array.from(/* @__PURE__ */ new Set([
11867
- 0,
11868
- Math.floor(window / 4),
11869
- Math.floor(window / 2),
11870
- Math.floor(3 * window / 4),
11871
- window
11872
- ])).sort((a, b) => a - b);
11873
- for (const offset of offsets) {
11874
- const t = publishTime + offset;
11889
+ const offsets = window === 0 ? [0] : Array.from(/* @__PURE__ */ new Set([0, Math.floor(window / 2)])).sort((a, b) => a - b);
11890
+ for (let i = 0; i < offsets.length; i++) {
11891
+ if (i > 0) {
11892
+ await new Promise((r) => setTimeout(r, 200));
11893
+ }
11894
+ const t = publishTime + offsets[i];
11875
11895
  const url = `${PYTH_HERMES_BASE}/v2/updates/price/${t}?ids[]=${feedId}`;
11876
11896
  const response = await this.hermesFetchWithBackoff(url);
11877
11897
  if (response === null) continue;
@@ -11889,13 +11909,19 @@ var PriceMarketModule = class extends BaseModule {
11889
11909
  return null;
11890
11910
  }
11891
11911
  /**
11892
- * Fetch a Hermes URL with exponential backoff on 429. Returns the response
11893
- * for 2xx, `null` for 404 (treated as "no VAA at this timestamp, try
11894
- * another"), and throws for other errors.
11912
+ * Fetch a Hermes URL with a short backoff on 429. Returns the response for
11913
+ * 2xx, `null` for 404 (treated as "no VAA at this timestamp, try another"),
11914
+ * and throws on persistent 429 or other non-OK statuses.
11915
+ *
11916
+ * Budget kept intentionally small (2 attempts) so callers that are already
11917
+ * iterating (e.g. multiple sample timestamps in `fetchPythHistoricalRaw`)
11918
+ * don't compound the rate-limit pressure. If Hermes is genuinely rate-
11919
+ * limiting us, retrying within the same request cycle won't help — better
11920
+ * to fail fast and let the caller back off until the next tick.
11895
11921
  */
11896
11922
  async hermesFetchWithBackoff(url, options = {}) {
11897
- const maxAttempts = options.maxAttempts ?? 4;
11898
- const initialDelayMs = options.initialDelayMs ?? 500;
11923
+ const maxAttempts = options.maxAttempts ?? 2;
11924
+ const initialDelayMs = options.initialDelayMs ?? 750;
11899
11925
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
11900
11926
  const response = await fetch(url);
11901
11927
  if (response.status === 429) {