four-flap-meme-sdk 1.2.97 → 1.2.98
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/utils/lp-inspect.js +11 -3
- package/package.json +1 -1
package/dist/utils/lp-inspect.js
CHANGED
|
@@ -150,11 +150,19 @@ export async function inspectTokenLP(token, opts) {
|
|
|
150
150
|
if (Number(st.status) !== 4) {
|
|
151
151
|
out.platform = 'FLAP';
|
|
152
152
|
out.decimals = tokenDecimals;
|
|
153
|
+
// ✅ 动态获取 quoteToken 的精度
|
|
154
|
+
// 如果 quoteToken 是零地址,则使用原生代币精度 (18)
|
|
155
|
+
// 否则查询 quoteToken 的精度(如 USDC 是 6 位)
|
|
156
|
+
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
157
|
+
let quoteDecimals = 18;
|
|
158
|
+
if (st.quoteTokenAddress && st.quoteTokenAddress.toLowerCase() !== ZERO_ADDRESS) {
|
|
159
|
+
quoteDecimals = await getTokenDecimals(st.quoteTokenAddress, provider);
|
|
160
|
+
}
|
|
153
161
|
out.flap = {
|
|
154
162
|
quoteToken: st.quoteTokenAddress,
|
|
155
|
-
reserveNative: formatBalance(st.reserve, shouldFormat),
|
|
156
|
-
circulatingSupply: formatBalance(st.circulatingSupply, shouldFormat),
|
|
157
|
-
price: formatBalance(st.price, shouldFormat),
|
|
163
|
+
reserveNative: formatBalance(st.reserve, shouldFormat, quoteDecimals),
|
|
164
|
+
circulatingSupply: formatBalance(st.circulatingSupply, shouldFormat, tokenDecimals ?? 18),
|
|
165
|
+
price: formatBalance(st.price, shouldFormat), // price 保持 18 位(合约返回的是 18 位精度)
|
|
158
166
|
};
|
|
159
167
|
return out;
|
|
160
168
|
}
|