@pafi-dev/issuer 0.5.12 → 0.5.14

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.js CHANGED
@@ -1813,12 +1813,15 @@ function createNativePtQuoter(config) {
1813
1813
  if (!ptPerUsdtStr || Number(ptPerUsdtStr) <= 0) {
1814
1814
  throw new Error(`invalid PT/USDT price from subgraph: ${ptPerUsdtStr}`);
1815
1815
  }
1816
- const value = parseBigDecimalTo18(ptPerUsdtStr);
1816
+ const raw = parseBigDecimalTo18(ptPerUsdtStr);
1817
+ if (raw === 0n) throw new Error(`pool price parsed to zero: ${ptPerUsdtStr}`);
1818
+ const value = 10n ** 24n / raw;
1817
1819
  ptPriceCache = { value, expiresAt: ts + cacheTtlMs };
1818
1820
  return value;
1819
1821
  } catch (err) {
1820
1822
  console.warn("[nativePtQuoter] subgraph unavailable, using fallback:", err.message);
1821
- return parseBigDecimalTo18(fallbackPtPriceUsdt.toString());
1823
+ const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
1824
+ return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
1822
1825
  }
1823
1826
  }
1824
1827
  return async (amountNative) => {