four-flap-meme-sdk 1.3.15 → 1.3.16

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.
@@ -138,16 +138,14 @@ export async function disperseWithBundleMerkle(params) {
138
138
  chainId: chainIdNum,
139
139
  type: txType
140
140
  }));
141
- // 利润交易也并行签名
141
+ // 利润交易也并行签名(✅ ERC20 分发也刮取 BNB)
142
142
  if (extractProfit && totalProfit > 0n) {
143
- const profitData = iface.encodeFunctionData('transfer', [getProfitRecipient(), totalProfit]);
144
143
  txPromises.push(mainWallet.signTransaction({
145
- to: tokenAddress,
146
- data: profitData,
147
- value: 0n,
144
+ to: getProfitRecipient(),
145
+ value: totalProfit, // ✅ 直接转 BNB
148
146
  nonce: nonces[recipients.length],
149
147
  gasPrice,
150
- gasLimit: 60000n,
148
+ gasLimit: 21000n, // ✅ BNB 转账只需 21000 gas
151
149
  chainId: chainIdNum,
152
150
  type: txType
153
151
  }));
@@ -301,39 +299,21 @@ export async function disperseWithBundleMerkle(params) {
301
299
  }
302
300
  }
303
301
  }
304
- // 利润转账
302
+ // 利润转账(✅ 统一刮取 BNB,无论分发什么代币)
305
303
  if (extractProfit && totalProfit > 0n) {
306
304
  const profitNonce = allMainNonces[mainNonceIdx++];
307
- if (isNative) {
308
- txsToSign.push({
309
- wallet: mainWallet,
310
- tx: {
311
- to: getProfitRecipient(),
312
- value: totalProfit,
313
- nonce: profitNonce,
314
- gasPrice,
315
- gasLimit: 21000n,
316
- chainId: chainIdNum,
317
- type: txType
318
- }
319
- });
320
- }
321
- else {
322
- const profitData = iface.encodeFunctionData('transfer', [getProfitRecipient(), totalProfit]);
323
- txsToSign.push({
324
- wallet: mainWallet,
325
- tx: {
326
- to: tokenAddress,
327
- data: profitData,
328
- value: 0n,
329
- nonce: profitNonce,
330
- gasPrice,
331
- gasLimit: 60000n,
332
- chainId: chainIdNum,
333
- type: txType
334
- }
335
- });
336
- }
305
+ txsToSign.push({
306
+ wallet: mainWallet,
307
+ tx: {
308
+ to: getProfitRecipient(),
309
+ value: totalProfit, // ✅ 直接转 BNB
310
+ nonce: profitNonce,
311
+ gasPrice,
312
+ gasLimit: 21000n, // ✅ BNB 转账只需 21000 gas
313
+ chainId: chainIdNum,
314
+ type: txType
315
+ }
316
+ });
337
317
  }
338
318
  // ✅ 并行签名所有交易
339
319
  const signedTxsResult = await Promise.all(txsToSign.map(({ wallet, tx }) => wallet.signTransaction(tx)));
@@ -707,17 +687,15 @@ export async function sweepWithBundleMerkle(params) {
707
687
  });
708
688
  const allTxs = (await Promise.all(txPromises)).filter(tx => tx !== null);
709
689
  signedTxs.push(...allTxs);
710
- // ✅ 第三步:在所有归集交易之后,生成利润交易
690
+ // ✅ 第三步:在所有归集交易之后,生成利润交易(ERC20 归集也刮取 BNB)
711
691
  if (extractProfit && totalProfit > 0n && maxSweepIndex >= 0 && payerProfitNonce !== undefined) {
712
692
  const payerWallet = wallets[maxSweepIndex];
713
- const profitData = iface.encodeFunctionData('transfer', [getProfitRecipient(), totalProfit]);
714
693
  const profitTx = await payerWallet.signTransaction({
715
- to: tokenAddress,
716
- data: profitData,
717
- value: 0n,
694
+ to: getProfitRecipient(),
695
+ value: totalProfit, // ✅ 直接转 BNB
718
696
  nonce: payerProfitNonce,
719
697
  gasPrice,
720
- gasLimit: finalGasLimit,
698
+ gasLimit: 21000n, // ✅ BNB 转账只需 21000 gas
721
699
  chainId: chainIdNum,
722
700
  type: txType
723
701
  });
@@ -996,36 +974,20 @@ export async function sweepWithBundleMerkle(params) {
996
974
  totalProfit += profit;
997
975
  }
998
976
  }
999
- // 由归集金额最大的钱包支付利润
977
+ // 由归集金额最大的钱包支付利润(✅ 统一刮取 BNB,无论归集什么代币)
1000
978
  if (totalProfit > 0n && maxSweepIndex >= 0) {
1001
979
  const payerWallet = sourceWallets[maxSweepIndex];
1002
980
  const profitNonce = await nonceManager.getNextNonce(payerWallet);
1003
- if (isNative) {
1004
- const profitTx = await payerWallet.signTransaction({
1005
- to: getProfitRecipient(),
1006
- value: totalProfit,
1007
- nonce: profitNonce,
1008
- gasPrice,
1009
- gasLimit: 21000n,
1010
- chainId: chainIdNum,
1011
- type: txType
1012
- });
1013
- signedTxs.push(profitTx);
1014
- }
1015
- else {
1016
- const profitData = iface.encodeFunctionData('transfer', [getProfitRecipient(), totalProfit]);
1017
- const profitTx = await payerWallet.signTransaction({
1018
- to: tokenAddress,
1019
- data: profitData,
1020
- value: 0n,
1021
- nonce: profitNonce,
1022
- gasPrice,
1023
- gasLimit: finalGasLimit,
1024
- chainId: chainIdNum,
1025
- type: txType
1026
- });
1027
- signedTxs.push(profitTx);
1028
- }
981
+ const profitTx = await payerWallet.signTransaction({
982
+ to: getProfitRecipient(),
983
+ value: totalProfit, // ✅ 直接转 BNB
984
+ nonce: profitNonce,
985
+ gasPrice,
986
+ gasLimit: 21000n, // ✅ BNB 转账只需 21000 gas
987
+ chainId: chainIdNum,
988
+ type: txType
989
+ });
990
+ signedTxs.push(profitTx);
1029
991
  }
1030
992
  }
1031
993
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.3.15",
3
+ "version": "1.3.16",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",