@pafi-dev/issuer 0.35.1 → 0.38.0

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.cts CHANGED
@@ -3743,6 +3743,16 @@ interface NativePtQuoterConfig {
3743
3743
  fallbackEthPriceUsd?: number;
3744
3744
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Default: 0.1. */
3745
3745
  fallbackPtPriceUsdt?: number;
3746
+ /**
3747
+ * When true, the quoter throws on subgraph/Chainlink miss instead
3748
+ * of returning the fallback price. Security-sensitive callers
3749
+ * (e.g. sponsor-relayer's fee gate) MUST opt in so an attacker-
3750
+ * supplied token with no indexed pool cannot ride the default
3751
+ * fallback to a near-zero required fee. Issuer mint/burn paths
3752
+ * default to the legacy fallback behavior for resilience against
3753
+ * transient oracle hiccups.
3754
+ */
3755
+ failClosed?: boolean;
3746
3756
  fetchImpl?: typeof fetch;
3747
3757
  now?: () => number;
3748
3758
  }
package/dist/index.d.ts CHANGED
@@ -3743,6 +3743,16 @@ interface NativePtQuoterConfig {
3743
3743
  fallbackEthPriceUsd?: number;
3744
3744
  /** Fallback PT price (USDT per 1 PT) when subgraph is unreachable. Default: 0.1. */
3745
3745
  fallbackPtPriceUsdt?: number;
3746
+ /**
3747
+ * When true, the quoter throws on subgraph/Chainlink miss instead
3748
+ * of returning the fallback price. Security-sensitive callers
3749
+ * (e.g. sponsor-relayer's fee gate) MUST opt in so an attacker-
3750
+ * supplied token with no indexed pool cannot ride the default
3751
+ * fallback to a near-zero required fee. Issuer mint/burn paths
3752
+ * default to the legacy fallback behavior for resilience against
3753
+ * transient oracle hiccups.
3754
+ */
3755
+ failClosed?: boolean;
3746
3756
  fetchImpl?: typeof fetch;
3747
3757
  now?: () => number;
3748
3758
  }
package/dist/index.js CHANGED
@@ -4247,6 +4247,7 @@ function createNativePtQuoter(config) {
4247
4247
  cacheTtlMs = 3e4,
4248
4248
  fallbackEthPriceUsd = 3e3,
4249
4249
  fallbackPtPriceUsdt = 0.1,
4250
+ failClosed = false,
4250
4251
  fetchImpl = globalThis.fetch,
4251
4252
  now = () => Date.now()
4252
4253
  } = config;
@@ -4271,6 +4272,11 @@ function createNativePtQuoter(config) {
4271
4272
  ethPriceCache = { value: answer, expiresAt: ts + cacheTtlMs };
4272
4273
  return answer;
4273
4274
  } catch (err) {
4275
+ if (failClosed) {
4276
+ throw new Error(
4277
+ `[nativePtQuoter] Chainlink unavailable in fail-closed mode: ${err.message}`
4278
+ );
4279
+ }
4274
4280
  console.warn("[nativePtQuoter] Chainlink unavailable, using fallback:", err.message);
4275
4281
  return BigInt(Math.round(fallbackEthPriceUsd * 1e8));
4276
4282
  }
@@ -4303,6 +4309,11 @@ function createNativePtQuoter(config) {
4303
4309
  ptPriceCache = { value, expiresAt: ts + cacheTtlMs };
4304
4310
  return value;
4305
4311
  } catch (err) {
4312
+ if (failClosed) {
4313
+ throw new Error(
4314
+ `[nativePtQuoter] subgraph miss for ${pointTokenAddress} in fail-closed mode: ${err.message}`
4315
+ );
4316
+ }
4306
4317
  console.warn("[nativePtQuoter] subgraph unavailable, using fallback:", err.message);
4307
4318
  const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
4308
4319
  return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
@@ -5226,7 +5237,7 @@ var MemoryRedemptionHistoryStore = class {
5226
5237
  };
5227
5238
 
5228
5239
  // src/index.ts
5229
- var PAFI_ISSUER_SDK_VERSION = true ? "0.35.0" : "dev";
5240
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.38.0" : "dev";
5230
5241
  export {
5231
5242
  AdapterMisconfiguredError,
5232
5243
  AuthError,