four-flap-meme-sdk 1.4.37 → 1.4.39

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.
@@ -2,7 +2,7 @@ import { ethers, Wallet } from 'ethers';
2
2
  import { getOptimizedGasPrice, NonceManager } from '../../utils/bundle-helpers.js';
3
3
  import { PROFIT_CONFIG, ZERO_ADDRESS } from '../../utils/constants.js';
4
4
  import { getTxType, getGasPriceConfig, shouldExtractProfit, getProfitRecipient } from './config.js';
5
- import { getErc20DecimalsMerkle as _getErc20DecimalsMerkle, generateHopWallets as _generateHopWallets, normalizeAmounts as _normalizeAmounts, batchGetBalances as _batchGetBalances, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress, estimateErc20TransferGas as _estimateErc20TransferGas } from './internal.js';
5
+ import { getErc20DecimalsMerkle as _getErc20DecimalsMerkle, generateHopWallets as _generateHopWallets, normalizeAmounts as _normalizeAmounts, batchGetBalances as _batchGetBalances, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress } from './internal.js';
6
6
  // ==================== 本地利润计算(万分之三)====================
7
7
  /**
8
8
  * 计算利润金额(万分之三)
@@ -357,23 +357,9 @@ export async function disperseWithBundleMerkle(params) {
357
357
  const iface = isNative ? null : new ethers.Interface(['function transfer(address,uint256) returns (bool)']);
358
358
  // ✅ Gas limit 设置
359
359
  // - 原生代币转账:21000(固定)
360
- // - ERC20 转账:通过模拟交易获取最小 gas limit(减少中转钱包 BNB 残留)
360
+ // - ERC20 转账:65000(固定,因为 gas 波动较大,不再使用模拟预估)
361
361
  const nativeTransferGasLimit = 21000n;
362
- // ERC20 多跳:模拟交易获取精确的 gas limit
363
- let erc20TransferGasLimit = finalGasLimit;
364
- if (!isNative && config.estimateGas !== false) {
365
- try {
366
- // 使用第一个接收者模拟一笔转账,获取精确的 gas limit
367
- const sampleAmount = ethers.parseUnits(normalizedAmounts[0], decimals);
368
- const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, mainWallet.address, recipients[0], sampleAmount, 0 // ✅ 不加缓冲,最大化减少多跳钱包残留
369
- );
370
- erc20TransferGasLimit = estimatedGas;
371
- console.log(`[disperseWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit}`);
372
- }
373
- catch (error) {
374
- console.warn(`[disperseWithBundleMerkle] 模拟估算失败,使用默认值:`, error);
375
- }
376
- }
362
+ const erc20TransferGasLimit = 65000n;
377
363
  // ✅ 原生代币多跳的 gas 费(每跳只需要 21000)
378
364
  const nativeHopGasFee = nativeTransferGasLimit * gasPrice;
379
365
  // ✅ ERC20 多跳时,中转钱包需要执行 2 笔交易(转 gas + 转 ERC20)
@@ -1002,25 +988,10 @@ export async function sweepWithBundleMerkle(params) {
1002
988
  ]);
1003
989
  const iface = isNative ? null : new ethers.Interface(['function transfer(address,uint256) returns (bool)']);
1004
990
  // ✅ Gas limit 设置(与分散函数保持一致)
991
+ // - 原生代币转账:21000(固定)
992
+ // - ERC20 转账:65000(固定,因为 gas 波动较大,不再使用模拟预估)
1005
993
  const nativeTransferGasLimit = 21000n;
1006
- // ERC20 多跳:模拟交易获取精确的 gas limit
1007
- let erc20TransferGasLimit = finalGasLimit;
1008
- if (!isNative && config.estimateGas !== false) {
1009
- try {
1010
- // 找到第一个有余额的钱包来模拟转账
1011
- const firstWithBalance = balances.findIndex(b => b > 0n);
1012
- if (firstWithBalance >= 0) {
1013
- const sampleAmount = balances[firstWithBalance] > 0n ? balances[firstWithBalance] / 2n : 1n;
1014
- const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, sourceAddresses[firstWithBalance], target, sampleAmount, 0 // ✅ 不加缓冲,最大化减少多跳钱包残留
1015
- );
1016
- erc20TransferGasLimit = estimatedGas;
1017
- console.log(`[sweepWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit}`);
1018
- }
1019
- }
1020
- catch (error) {
1021
- console.warn(`[sweepWithBundleMerkle] 模拟估算失败,使用默认值:`, error);
1022
- }
1023
- }
994
+ const erc20TransferGasLimit = 65000n;
1024
995
  // ✅ 原生代币多跳的 gas 费(每跳只需要 21000)
1025
996
  const nativeHopGasFee = nativeTransferGasLimit * gasPrice;
1026
997
  // ✅ ERC20 多跳时,中转钱包需要执行 2 笔交易(转 gas + 转 ERC20)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",