@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.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +40 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9650,6 +9650,18 @@ declare class PriceMarketModule extends BaseModule {
|
|
|
9650
9650
|
* Get the Pyth contract address configured on the Diamond
|
|
9651
9651
|
*/
|
|
9652
9652
|
getPythContract(): Promise<Address>;
|
|
9653
|
+
/**
|
|
9654
|
+
* Mark a stuck price market as Invalid and refund holders 50/50 via the CTF.
|
|
9655
|
+
* Permissionless: anyone can call this once `closeTime + 7 days` has elapsed.
|
|
9656
|
+
*
|
|
9657
|
+
* Use this for markets that never resolve via Pyth — e.g. the feed was
|
|
9658
|
+
* deprecated by the publisher, or Hermes had no in-window VAA at closeTime.
|
|
9659
|
+
* Reports payouts `[1, 1]` to the CTF, so every YES and every NO token
|
|
9660
|
+
* redeems for half the underlying collateral.
|
|
9661
|
+
*
|
|
9662
|
+
* Reverts on chain with `GracePeriodNotElapsed` if called too early.
|
|
9663
|
+
*/
|
|
9664
|
+
markInvalid(marketId: bigint): Promise<`0x${string}`>;
|
|
9653
9665
|
/**
|
|
9654
9666
|
* Set the Pyth oracle contract address. Diamond owner only.
|
|
9655
9667
|
*/
|
|
@@ -9731,9 +9743,15 @@ declare class PriceMarketModule extends BaseModule {
|
|
|
9731
9743
|
private fetchPythHistoricalParsed;
|
|
9732
9744
|
private fetchPythHistoricalRaw;
|
|
9733
9745
|
/**
|
|
9734
|
-
* Fetch a Hermes URL with
|
|
9735
|
-
*
|
|
9736
|
-
*
|
|
9746
|
+
* Fetch a Hermes URL with a short backoff on 429. Returns the response for
|
|
9747
|
+
* 2xx, `null` for 404 (treated as "no VAA at this timestamp, try another"),
|
|
9748
|
+
* and throws on persistent 429 or other non-OK statuses.
|
|
9749
|
+
*
|
|
9750
|
+
* Budget kept intentionally small (2 attempts) so callers that are already
|
|
9751
|
+
* iterating (e.g. multiple sample timestamps in `fetchPythHistoricalRaw`)
|
|
9752
|
+
* don't compound the rate-limit pressure. If Hermes is genuinely rate-
|
|
9753
|
+
* limiting us, retrying within the same request cycle won't help — better
|
|
9754
|
+
* to fail fast and let the caller back off until the next tick.
|
|
9737
9755
|
*/
|
|
9738
9756
|
private hermesFetchWithBackoff;
|
|
9739
9757
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9650,6 +9650,18 @@ declare class PriceMarketModule extends BaseModule {
|
|
|
9650
9650
|
* Get the Pyth contract address configured on the Diamond
|
|
9651
9651
|
*/
|
|
9652
9652
|
getPythContract(): Promise<Address>;
|
|
9653
|
+
/**
|
|
9654
|
+
* Mark a stuck price market as Invalid and refund holders 50/50 via the CTF.
|
|
9655
|
+
* Permissionless: anyone can call this once `closeTime + 7 days` has elapsed.
|
|
9656
|
+
*
|
|
9657
|
+
* Use this for markets that never resolve via Pyth — e.g. the feed was
|
|
9658
|
+
* deprecated by the publisher, or Hermes had no in-window VAA at closeTime.
|
|
9659
|
+
* Reports payouts `[1, 1]` to the CTF, so every YES and every NO token
|
|
9660
|
+
* redeems for half the underlying collateral.
|
|
9661
|
+
*
|
|
9662
|
+
* Reverts on chain with `GracePeriodNotElapsed` if called too early.
|
|
9663
|
+
*/
|
|
9664
|
+
markInvalid(marketId: bigint): Promise<`0x${string}`>;
|
|
9653
9665
|
/**
|
|
9654
9666
|
* Set the Pyth oracle contract address. Diamond owner only.
|
|
9655
9667
|
*/
|
|
@@ -9731,9 +9743,15 @@ declare class PriceMarketModule extends BaseModule {
|
|
|
9731
9743
|
private fetchPythHistoricalParsed;
|
|
9732
9744
|
private fetchPythHistoricalRaw;
|
|
9733
9745
|
/**
|
|
9734
|
-
* Fetch a Hermes URL with
|
|
9735
|
-
*
|
|
9736
|
-
*
|
|
9746
|
+
* Fetch a Hermes URL with a short backoff on 429. Returns the response for
|
|
9747
|
+
* 2xx, `null` for 404 (treated as "no VAA at this timestamp, try another"),
|
|
9748
|
+
* and throws on persistent 429 or other non-OK statuses.
|
|
9749
|
+
*
|
|
9750
|
+
* Budget kept intentionally small (2 attempts) so callers that are already
|
|
9751
|
+
* iterating (e.g. multiple sample timestamps in `fetchPythHistoricalRaw`)
|
|
9752
|
+
* don't compound the rate-limit pressure. If Hermes is genuinely rate-
|
|
9753
|
+
* limiting us, retrying within the same request cycle won't help — better
|
|
9754
|
+
* to fail fast and let the caller back off until the next tick.
|
|
9737
9755
|
*/
|
|
9738
9756
|
private hermesFetchWithBackoff;
|
|
9739
9757
|
}
|
package/dist/index.js
CHANGED
|
@@ -11665,6 +11665,29 @@ var PriceMarketModule = class extends BaseModule {
|
|
|
11665
11665
|
functionName: "getPythContract"
|
|
11666
11666
|
});
|
|
11667
11667
|
}
|
|
11668
|
+
/**
|
|
11669
|
+
* Mark a stuck price market as Invalid and refund holders 50/50 via the CTF.
|
|
11670
|
+
* Permissionless: anyone can call this once `closeTime + 7 days` has elapsed.
|
|
11671
|
+
*
|
|
11672
|
+
* Use this for markets that never resolve via Pyth — e.g. the feed was
|
|
11673
|
+
* deprecated by the publisher, or Hermes had no in-window VAA at closeTime.
|
|
11674
|
+
* Reports payouts `[1, 1]` to the CTF, so every YES and every NO token
|
|
11675
|
+
* redeems for half the underlying collateral.
|
|
11676
|
+
*
|
|
11677
|
+
* Reverts on chain with `GracePeriodNotElapsed` if called too early.
|
|
11678
|
+
*/
|
|
11679
|
+
async markInvalid(marketId) {
|
|
11680
|
+
const wallet = this.walletClient;
|
|
11681
|
+
const account = await this.getSignerAccount();
|
|
11682
|
+
const { request } = await this.publicClient.simulateContract({
|
|
11683
|
+
address: this.config.diamondAddress,
|
|
11684
|
+
abi: PythResolutionFacet_default,
|
|
11685
|
+
functionName: "markPriceMarketInvalid",
|
|
11686
|
+
args: [marketId],
|
|
11687
|
+
account
|
|
11688
|
+
});
|
|
11689
|
+
return wallet.writeContract(request);
|
|
11690
|
+
}
|
|
11668
11691
|
/**
|
|
11669
11692
|
* Set the Pyth oracle contract address. Diamond owner only.
|
|
11670
11693
|
*/
|
|
@@ -11864,15 +11887,12 @@ var PriceMarketModule = class extends BaseModule {
|
|
|
11864
11887
|
}
|
|
11865
11888
|
async fetchPythHistoricalRaw(feedId, publishTime, windowSeconds) {
|
|
11866
11889
|
const window = Math.max(0, Math.floor(windowSeconds));
|
|
11867
|
-
const offsets = window === 0 ? [0] : Array.from(/* @__PURE__ */ new Set([
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
])).sort((a, b) => a - b);
|
|
11874
|
-
for (const offset of offsets) {
|
|
11875
|
-
const t = publishTime + offset;
|
|
11890
|
+
const offsets = window === 0 ? [0] : Array.from(/* @__PURE__ */ new Set([0, Math.floor(window / 2)])).sort((a, b) => a - b);
|
|
11891
|
+
for (let i = 0; i < offsets.length; i++) {
|
|
11892
|
+
if (i > 0) {
|
|
11893
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
11894
|
+
}
|
|
11895
|
+
const t = publishTime + offsets[i];
|
|
11876
11896
|
const url = `${PYTH_HERMES_BASE}/v2/updates/price/${t}?ids[]=${feedId}`;
|
|
11877
11897
|
const response = await this.hermesFetchWithBackoff(url);
|
|
11878
11898
|
if (response === null) continue;
|
|
@@ -11890,13 +11910,19 @@ var PriceMarketModule = class extends BaseModule {
|
|
|
11890
11910
|
return null;
|
|
11891
11911
|
}
|
|
11892
11912
|
/**
|
|
11893
|
-
* Fetch a Hermes URL with
|
|
11894
|
-
*
|
|
11895
|
-
*
|
|
11913
|
+
* Fetch a Hermes URL with a short backoff on 429. Returns the response for
|
|
11914
|
+
* 2xx, `null` for 404 (treated as "no VAA at this timestamp, try another"),
|
|
11915
|
+
* and throws on persistent 429 or other non-OK statuses.
|
|
11916
|
+
*
|
|
11917
|
+
* Budget kept intentionally small (2 attempts) so callers that are already
|
|
11918
|
+
* iterating (e.g. multiple sample timestamps in `fetchPythHistoricalRaw`)
|
|
11919
|
+
* don't compound the rate-limit pressure. If Hermes is genuinely rate-
|
|
11920
|
+
* limiting us, retrying within the same request cycle won't help — better
|
|
11921
|
+
* to fail fast and let the caller back off until the next tick.
|
|
11896
11922
|
*/
|
|
11897
11923
|
async hermesFetchWithBackoff(url, options = {}) {
|
|
11898
|
-
const maxAttempts = options.maxAttempts ??
|
|
11899
|
-
const initialDelayMs = options.initialDelayMs ??
|
|
11924
|
+
const maxAttempts = options.maxAttempts ?? 2;
|
|
11925
|
+
const initialDelayMs = options.initialDelayMs ?? 750;
|
|
11900
11926
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
11901
11927
|
const response = await fetch(url);
|
|
11902
11928
|
if (response.status === 429) {
|