four-flap-meme-sdk 4.3.3 → 4.3.4
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.
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import '../tx/wallet-sign-patch.js';
|
|
2
2
|
import { CHAINS } from '../constants/index.js';
|
|
3
|
+
function parseRpcQuantity(value) {
|
|
4
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
5
|
+
return Math.max(0, Math.floor(value));
|
|
6
|
+
if (typeof value === 'bigint') {
|
|
7
|
+
const n = Number(value);
|
|
8
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
9
|
+
}
|
|
10
|
+
const s = String(value ?? '').trim();
|
|
11
|
+
if (!s)
|
|
12
|
+
return 0;
|
|
13
|
+
if (/^0x[0-9a-f]+$/i.test(s))
|
|
14
|
+
return parseInt(s, 16) || 0;
|
|
15
|
+
if (/^\d+$/.test(s))
|
|
16
|
+
return Number(s);
|
|
17
|
+
return parseInt(s, 16) || 0;
|
|
18
|
+
}
|
|
3
19
|
function asBatchSendProvider(provider) {
|
|
4
20
|
return provider;
|
|
5
21
|
}
|
|
@@ -195,7 +211,7 @@ export class NonceManager {
|
|
|
195
211
|
const byId = new Map();
|
|
196
212
|
for (const row of rawResults) {
|
|
197
213
|
const id = Number(row.id);
|
|
198
|
-
byId.set(id,
|
|
214
|
+
byId.set(id, parseRpcQuantity(row.result));
|
|
199
215
|
}
|
|
200
216
|
queryResults = uniqueQueries.map((_, idx) => Math.max(byId.get(idx * 2 + 1) || 0, byId.get(idx * 2 + 2) || 0));
|
|
201
217
|
}
|
|
@@ -61,6 +61,8 @@ async function readGenericTokenTaxBps(token, provider) {
|
|
|
61
61
|
for (const item of reads) {
|
|
62
62
|
if (item.status !== 'fulfilled' || typeof item.value !== 'number')
|
|
63
63
|
continue;
|
|
64
|
+
if (item.value === 100)
|
|
65
|
+
continue;
|
|
64
66
|
if (item.value > maxBps)
|
|
65
67
|
maxBps = item.value;
|
|
66
68
|
}
|
|
@@ -70,6 +72,8 @@ export async function readBscOuterTaxBps(token, rpcUrl) {
|
|
|
70
72
|
try {
|
|
71
73
|
if (await isTaxToken(token, rpcUrl)) {
|
|
72
74
|
const fee = Number((await getTaxTokenInfo(token, rpcUrl)).config.feeRate);
|
|
75
|
+
if (Number.isFinite(fee) && fee > 0 && fee <= 10000)
|
|
76
|
+
return Math.round(fee);
|
|
73
77
|
const bps = normalizeFeeToBps(fee);
|
|
74
78
|
if (bps)
|
|
75
79
|
return bps;
|
|
@@ -34,6 +34,9 @@ describe('normalizeFeeToBps', () => {
|
|
|
34
34
|
expect(normalizeFeeToBps(500)).toBe(500);
|
|
35
35
|
expect(normalizeFeeToBps(0)).toBeUndefined();
|
|
36
36
|
});
|
|
37
|
+
it('does not treat generic leftover 100 as pancake tax in the max fold', () => {
|
|
38
|
+
expect(normalizeFeeToBps(100)).toBe(100);
|
|
39
|
+
});
|
|
37
40
|
});
|
|
38
41
|
describe('flapV8TaxBps', () => {
|
|
39
42
|
it('reads inner flap tax', () => {
|
|
@@ -105,11 +105,14 @@ export async function inspectTokenLP(token, opts) {
|
|
|
105
105
|
price: formatBalance(st.price, shouldFormat),
|
|
106
106
|
taxRate, // ✅ 包含税率
|
|
107
107
|
};
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
108
|
+
const reserveBn = BigInt(st.reserve ?? 0n);
|
|
109
|
+
if (reserveBn > 0n) {
|
|
110
|
+
if (taxRate && taxRate > 0) {
|
|
111
|
+
result.taxRate = taxRate;
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
// 空内盘:继续查外盘,避免假内盘把 allPools 吃掉;Portal 残留税也不写进外盘
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
catch {
|
|
@@ -344,7 +347,7 @@ export async function inspectTokenLP(token, opts) {
|
|
|
344
347
|
const stV7 = await flap.getTokenV7(token);
|
|
345
348
|
taxRate = Number(stV7.taxRate ?? 0n);
|
|
346
349
|
}
|
|
347
|
-
if (taxRate > 0) {
|
|
350
|
+
if (taxRate > 0 && taxRate !== 100) {
|
|
348
351
|
result.taxRate = taxRate;
|
|
349
352
|
}
|
|
350
353
|
}
|