four-flap-meme-sdk 1.7.84 → 1.7.86
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.
|
@@ -67,6 +67,7 @@ export interface LPInfo {
|
|
|
67
67
|
decimals?: number;
|
|
68
68
|
totalSupply?: string;
|
|
69
69
|
totalSupplyRaw?: bigint;
|
|
70
|
+
taxRate?: number;
|
|
70
71
|
four?: {
|
|
71
72
|
helper: string;
|
|
72
73
|
reserveNative?: string;
|
|
@@ -80,6 +81,7 @@ export interface LPInfo {
|
|
|
80
81
|
reserveNative?: string;
|
|
81
82
|
circulatingSupply?: string;
|
|
82
83
|
price?: string;
|
|
84
|
+
taxRate?: number;
|
|
83
85
|
};
|
|
84
86
|
allPools: DexPoolInfo[];
|
|
85
87
|
bestPools: BestPoolInfo[];
|
package/dist/utils/lp-inspect.js
CHANGED
|
@@ -313,7 +313,23 @@ export async function inspectTokenLP(token, opts) {
|
|
|
313
313
|
if (opts.flapChain) {
|
|
314
314
|
try {
|
|
315
315
|
const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
|
|
316
|
-
|
|
316
|
+
// ✅ 优先尝试 getTokenV7(包含 taxRate),失败则 fallback 到 getTokenV5
|
|
317
|
+
let st = null;
|
|
318
|
+
let taxRate;
|
|
319
|
+
try {
|
|
320
|
+
const stV7 = await flap.getTokenV7(token);
|
|
321
|
+
st = stV7;
|
|
322
|
+
// taxRate 是 bigint,需要转换为 number
|
|
323
|
+
taxRate = typeof stV7.taxRate === 'bigint' ? Number(stV7.taxRate) : Number(stV7.taxRate ?? 0);
|
|
324
|
+
if (opts.debug)
|
|
325
|
+
console.log('[LP Inspect] Flap V7 taxRate:', taxRate);
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
// V7 不支持,fallback 到 V5
|
|
329
|
+
st = await flap.getTokenV5(token);
|
|
330
|
+
if (opts.debug)
|
|
331
|
+
console.log('[LP Inspect] Flap V7 failed, using V5');
|
|
332
|
+
}
|
|
317
333
|
if (st && st.status !== undefined && Number(st.status) !== 4) {
|
|
318
334
|
result.platform = 'FLAP';
|
|
319
335
|
let quoteDecimals = 18;
|
|
@@ -331,7 +347,12 @@ export async function inspectTokenLP(token, opts) {
|
|
|
331
347
|
reserveNative: formatBalance(st.reserve, shouldFormat, quoteDecimals),
|
|
332
348
|
circulatingSupply: formatBalance(st.circulatingSupply, shouldFormat, tokenDecimals ?? 18),
|
|
333
349
|
price: formatBalance(st.price, shouldFormat),
|
|
350
|
+
taxRate, // ✅ 包含税率
|
|
334
351
|
};
|
|
352
|
+
// ✅ 同时设置顶层税率,方便统一读取
|
|
353
|
+
if (taxRate && taxRate > 0) {
|
|
354
|
+
result.taxRate = taxRate;
|
|
355
|
+
}
|
|
335
356
|
return result;
|
|
336
357
|
}
|
|
337
358
|
}
|
|
@@ -494,6 +515,28 @@ export async function inspectTokenLP(token, opts) {
|
|
|
494
515
|
}
|
|
495
516
|
// 确定平台类型
|
|
496
517
|
result.platform = determinePlatform(result.allPools);
|
|
518
|
+
// ========================================
|
|
519
|
+
// 4. 外盘税率查询(仅 Flap 链)
|
|
520
|
+
// ========================================
|
|
521
|
+
// 对于已毕业到外盘的代币,尝试从 Flap Portal 获取税率
|
|
522
|
+
if (opts.flapChain && !result.flap && result.platform !== 'UNKNOWN') {
|
|
523
|
+
try {
|
|
524
|
+
const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
|
|
525
|
+
const stV7 = await flap.getTokenV7(token);
|
|
526
|
+
// taxRate 是 bigint,需要转换为 number
|
|
527
|
+
const taxRate = typeof stV7.taxRate === 'bigint' ? Number(stV7.taxRate) : Number(stV7.taxRate ?? 0);
|
|
528
|
+
if (taxRate > 0) {
|
|
529
|
+
result.taxRate = taxRate;
|
|
530
|
+
if (opts.debug)
|
|
531
|
+
console.log('[LP Inspect] 外盘税率:', taxRate, 'bps');
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
catch (err) {
|
|
535
|
+
// V7 不支持或代币不是 Flap 创建的,忽略
|
|
536
|
+
if (opts.debug)
|
|
537
|
+
console.log('[LP Inspect] 外盘税率查询失败(可忽略):', err);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
497
540
|
return result;
|
|
498
541
|
}
|
|
499
542
|
// ============================================================================
|