four-flap-meme-sdk 4.0.10 → 4.0.11

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.
@@ -8,6 +8,7 @@ import { Contract, formatEther } from 'ethers';
8
8
  import { ADDRESSES, ZERO_ADDRESS } from '../../core/constants/index.js';
9
9
  import { Helper3 } from '../four/contracts/helper3.js';
10
10
  import { FlapPortal } from '../flap/portal.js';
11
+ import { getTaxTokenInfo, isTaxToken } from '../four/tax-token.js';
11
12
  import { DEFAULT_V3_FEE_TIERS } from './lp-inspect-helpers.js';
12
13
  import { getChainConfig } from './registry.js';
13
14
  import { determinePlatform, formatBalance, getProvider, getTokenDecimals, normalizeLiquidity, queryV2Pairs, queryV3Pools, } from './inspect-helpers.js';
@@ -15,6 +16,12 @@ import { determinePlatform, formatBalance, getProvider, getTokenDecimals, normal
15
16
  // 常量(从公共模块导入)
16
17
  // ============================================================================
17
18
  const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
19
+ /** BSC V8 买卖税;status=0 说明不是 Flap 币,slot 里常见残留 100 bps(1%)不能当当前税。 */
20
+ function flapV8TaxBps(st) {
21
+ if (!Number(st.status))
22
+ return 0;
23
+ return Math.max(Number(st.buyTaxRate ?? 0n), Number(st.sellTaxRate ?? 0n));
24
+ }
18
25
  // ============================================================================
19
26
  // 主查询函数
20
27
  // ============================================================================
@@ -64,24 +71,25 @@ export async function inspectTokenLP(token, opts) {
64
71
  if (opts.flapChain) {
65
72
  try {
66
73
  const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
67
- // ✅ 优先尝试 getTokenV7(包含 taxRate),失败则 fallback 到 getTokenV5
68
74
  let st = null;
69
75
  let taxRate;
70
- if (opts.flapChain === 'BSC') {
76
+ const useBscV8 = opts.flapChain === 'BSC';
77
+ if (useBscV8) {
71
78
  try {
72
79
  const stV8 = await flap.getTokenV8Safe(token);
73
80
  st = stV8;
74
- taxRate = Math.max(Number(stV8.buyTaxRate ?? 0n), Number(stV8.sellTaxRate ?? 0n));
81
+ taxRate = flapV8TaxBps(stV8);
75
82
  }
76
83
  catch {
77
- // V8 不可用时走 V7
84
+ // V8 不可用时只借 V7/V5 读盘面,不用 V7 残留 taxRate(常见 100 bps)
78
85
  }
79
86
  }
80
87
  if (!st) {
81
88
  try {
82
89
  const stV7 = await flap.getTokenV7(token);
83
90
  st = stV7;
84
- taxRate = Number(stV7.taxRate ?? 0n);
91
+ if (!useBscV8)
92
+ taxRate = Number(stV7.taxRate ?? 0n);
85
93
  }
86
94
  catch {
87
95
  st = await flap.getTokenV5(token);
@@ -190,6 +198,17 @@ export async function inspectTokenLP(token, opts) {
190
198
  const offerTokens = formatBalance(info.offers, shouldFormat);
191
199
  const lastPrice = formatBalance(info.lastPrice, shouldFormat);
192
200
  result.four = { helper: ADDRESSES.BSC.TokenManagerHelper3, reserveNative, offerTokens, lastPrice };
201
+ try {
202
+ if (await isTaxToken(token, opts.rpcUrl)) {
203
+ const fee = Number((await getTaxTokenInfo(token, opts.rpcUrl)).config.feeRate);
204
+ const taxRate = fee > 0 && fee <= 10 ? fee * 100 : fee;
205
+ if (taxRate > 0)
206
+ result.taxRate = taxRate;
207
+ }
208
+ }
209
+ catch {
210
+ // 非 TaxToken 或读费率失败
211
+ }
193
212
  return result;
194
213
  }
195
214
  }
@@ -331,14 +350,8 @@ export async function inspectTokenLP(token, opts) {
331
350
  const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
332
351
  let taxRate = 0;
333
352
  if (opts.flapChain === 'BSC') {
334
- try {
335
- const stV8 = await flap.getTokenV8Safe(token);
336
- taxRate = Math.max(Number(stV8.buyTaxRate ?? 0n), Number(stV8.sellTaxRate ?? 0n));
337
- }
338
- catch {
339
- const stV7 = await flap.getTokenV7(token);
340
- taxRate = Number(stV7.taxRate ?? 0n);
341
- }
353
+ const stV8 = await flap.getTokenV8Safe(token);
354
+ taxRate = flapV8TaxBps(stV8);
342
355
  }
343
356
  else {
344
357
  const stV7 = await flap.getTokenV7(token);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "4.0.10",
3
+ "version": "4.0.11",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",