four-flap-meme-sdk 1.4.37 → 1.4.38
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.
|
@@ -360,15 +360,17 @@ export async function disperseWithBundleMerkle(params) {
|
|
|
360
360
|
// - ERC20 转账:通过模拟交易获取最小 gas limit(减少中转钱包 BNB 残留)
|
|
361
361
|
const nativeTransferGasLimit = 21000n;
|
|
362
362
|
// ✅ ERC20 多跳:模拟交易获取精确的 gas limit
|
|
363
|
+
// ⚠️ 注意:多跳时中转钱包是新生成的地址,第一次发送 ERC20 的 gas 消耗可能高于主钱包
|
|
364
|
+
// 因此需要添加 10% 缓冲以确保交易成功
|
|
363
365
|
let erc20TransferGasLimit = finalGasLimit;
|
|
364
366
|
if (!isNative && config.estimateGas !== false) {
|
|
365
367
|
try {
|
|
366
368
|
// 使用第一个接收者模拟一笔转账,获取精确的 gas limit
|
|
367
369
|
const sampleAmount = ethers.parseUnits(normalizedAmounts[0], decimals);
|
|
368
|
-
const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, mainWallet.address, recipients[0], sampleAmount,
|
|
370
|
+
const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, mainWallet.address, recipients[0], sampleAmount, 10 // ✅ 添加 10% 缓冲,因为中转钱包首次发送 ERC20 gas 消耗可能更高
|
|
369
371
|
);
|
|
370
372
|
erc20TransferGasLimit = estimatedGas;
|
|
371
|
-
console.log(`[disperseWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit}`);
|
|
373
|
+
console.log(`[disperseWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit} (+10% buffer)`);
|
|
372
374
|
}
|
|
373
375
|
catch (error) {
|
|
374
376
|
console.warn(`[disperseWithBundleMerkle] 模拟估算失败,使用默认值:`, error);
|
|
@@ -1004,6 +1006,8 @@ export async function sweepWithBundleMerkle(params) {
|
|
|
1004
1006
|
// ✅ Gas limit 设置(与分散函数保持一致)
|
|
1005
1007
|
const nativeTransferGasLimit = 21000n;
|
|
1006
1008
|
// ✅ ERC20 多跳:模拟交易获取精确的 gas limit
|
|
1009
|
+
// ⚠️ 注意:多跳时中转钱包是新生成的地址,第一次发送 ERC20 的 gas 消耗可能高于已有余额的钱包
|
|
1010
|
+
// 因此需要添加 10% 缓冲以确保交易成功
|
|
1007
1011
|
let erc20TransferGasLimit = finalGasLimit;
|
|
1008
1012
|
if (!isNative && config.estimateGas !== false) {
|
|
1009
1013
|
try {
|
|
@@ -1011,10 +1015,10 @@ export async function sweepWithBundleMerkle(params) {
|
|
|
1011
1015
|
const firstWithBalance = balances.findIndex(b => b > 0n);
|
|
1012
1016
|
if (firstWithBalance >= 0) {
|
|
1013
1017
|
const sampleAmount = balances[firstWithBalance] > 0n ? balances[firstWithBalance] / 2n : 1n;
|
|
1014
|
-
const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, sourceAddresses[firstWithBalance], target, sampleAmount,
|
|
1018
|
+
const estimatedGas = await _estimateErc20TransferGas(provider, tokenAddress, sourceAddresses[firstWithBalance], target, sampleAmount, 10 // ✅ 添加 10% 缓冲,因为中转钱包首次发送 ERC20 gas 消耗可能更高
|
|
1015
1019
|
);
|
|
1016
1020
|
erc20TransferGasLimit = estimatedGas;
|
|
1017
|
-
console.log(`[sweepWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit}`);
|
|
1021
|
+
console.log(`[sweepWithBundleMerkle] 使用模拟估算的 ERC20 gas limit: ${erc20TransferGasLimit} (+10% buffer)`);
|
|
1018
1022
|
}
|
|
1019
1023
|
}
|
|
1020
1024
|
catch (error) {
|