@pafi-dev/issuer 0.5.12 → 0.5.13
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.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -1854,12 +1854,15 @@ function createNativePtQuoter(config) {
|
|
|
1854
1854
|
if (!ptPerUsdtStr || Number(ptPerUsdtStr) <= 0) {
|
|
1855
1855
|
throw new Error(`invalid PT/USDT price from subgraph: ${ptPerUsdtStr}`);
|
|
1856
1856
|
}
|
|
1857
|
-
const
|
|
1857
|
+
const raw = parseBigDecimalTo18(ptPerUsdtStr);
|
|
1858
|
+
if (raw === 0n) throw new Error(`pool price parsed to zero: ${ptPerUsdtStr}`);
|
|
1859
|
+
const value = 10n ** 24n / raw;
|
|
1858
1860
|
ptPriceCache = { value, expiresAt: ts + cacheTtlMs };
|
|
1859
1861
|
return value;
|
|
1860
1862
|
} catch (err) {
|
|
1861
1863
|
console.warn("[nativePtQuoter] subgraph unavailable, using fallback:", err.message);
|
|
1862
|
-
|
|
1864
|
+
const ptPerUsdtHuman = 1 / fallbackPtPriceUsdt;
|
|
1865
|
+
return parseBigDecimalTo18(ptPerUsdtHuman.toFixed(18));
|
|
1863
1866
|
}
|
|
1864
1867
|
}
|
|
1865
1868
|
return async (amountNative) => {
|