four-flap-meme-sdk 1.2.49 → 1.2.50
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 +13 -8
- package/package.json +1 -1
package/dist/utils/lp-inspect.js
CHANGED
|
@@ -30,6 +30,15 @@ export async function inspectTokenLP(token, opts) {
|
|
|
30
30
|
const out = { platform: 'UNKNOWN' };
|
|
31
31
|
// 默认格式化余额为 Ether 单位
|
|
32
32
|
const shouldFormat = opts.formatBalances !== false;
|
|
33
|
+
// ✅ 优先查询代币精度(在所有逻辑之前)
|
|
34
|
+
let tokenDecimals;
|
|
35
|
+
try {
|
|
36
|
+
const tokenContract = new Contract(token, I_ERC20_ABI, provider);
|
|
37
|
+
tokenDecimals = await tokenContract.decimals();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// 如果查询失败,保持 undefined
|
|
41
|
+
}
|
|
33
42
|
// 解析 Multicall3 地址
|
|
34
43
|
let multicall3 = opts.multicall3 || '';
|
|
35
44
|
if (!multicall3) {
|
|
@@ -41,14 +50,6 @@ export async function inspectTokenLP(token, opts) {
|
|
|
41
50
|
multicall3 = '0xca11bde05977b3631167028862be2a173976ca11';
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
|
-
// 查询代币精度
|
|
45
|
-
try {
|
|
46
|
-
const tokenContract = new Contract(token, I_ERC20_ABI, provider);
|
|
47
|
-
out.decimals = await tokenContract.decimals();
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
// 如果查询失败,不设置 decimals(保持 undefined)
|
|
51
|
-
}
|
|
52
53
|
async function resolveFactories() {
|
|
53
54
|
// 1) 直接给出工厂
|
|
54
55
|
if (opts.factoryV2 && opts.factoryV3)
|
|
@@ -93,6 +94,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
93
94
|
// status: 1=Tradable(内盘),4=DEX(已外盘)
|
|
94
95
|
if (Number(st.status) !== 4) {
|
|
95
96
|
out.platform = 'FLAP';
|
|
97
|
+
out.decimals = tokenDecimals;
|
|
96
98
|
out.flap = {
|
|
97
99
|
quoteToken: st.quoteTokenAddress,
|
|
98
100
|
reserveNative: formatBalance(st.reserve, shouldFormat),
|
|
@@ -119,6 +121,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
119
121
|
// 若已添加流动性(已上 DEX),则继续外盘检测
|
|
120
122
|
if (!liquidityAdded) {
|
|
121
123
|
out.platform = 'FOUR';
|
|
124
|
+
out.decimals = tokenDecimals;
|
|
122
125
|
const reserveNative = info.funds !== undefined ? formatBalance(info.funds, shouldFormat) : undefined;
|
|
123
126
|
const offerTokens = info.offers !== undefined ? formatBalance(info.offers, shouldFormat) : undefined;
|
|
124
127
|
const lastPrice = info.lastPrice !== undefined ? formatBalance(info.lastPrice, shouldFormat) : undefined;
|
|
@@ -336,5 +339,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
336
339
|
else if (hasV2) {
|
|
337
340
|
out.platform = 'PANCAKE_V2';
|
|
338
341
|
}
|
|
342
|
+
// ✅ 确保返回 decimals
|
|
343
|
+
out.decimals = tokenDecimals;
|
|
339
344
|
return out;
|
|
340
345
|
}
|