four-flap-meme-sdk 1.7.66 → 1.7.67
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.
|
@@ -36,10 +36,13 @@ export declare function estimateErc20TransferGas(provider: JsonRpcProvider, toke
|
|
|
36
36
|
export declare function estimateMaxErc20TransferGas(provider: JsonRpcProvider, tokenAddress: string, from: string, recipients: string[], amounts: bigint[], bufferPercent?: number): Promise<bigint>;
|
|
37
37
|
/**
|
|
38
38
|
* 计算 Gas Limit
|
|
39
|
-
* - 原生代币转账:
|
|
39
|
+
* - 原生代币转账:
|
|
40
|
+
* - BSC: 21000 gas(固定)
|
|
41
|
+
* - XLayer: 50000 gas(EIP-7702 授权地址需要更多 gas)
|
|
40
42
|
* - ERC20 标准 transfer:约 45000-55000 gas,使用 55000 作为安全值
|
|
41
43
|
*
|
|
42
44
|
* ✅ 优化:降低 ERC20 gas limit,减少中转钱包 BNB 残留
|
|
45
|
+
* ✅ XLayer 特殊处理:EIP-7702 授权的地址接收 OKB 时会触发 delegate 代码,需要更多 gas
|
|
43
46
|
*/
|
|
44
47
|
export declare function calculateGasLimit(config: any, isNative: boolean, hasHops: boolean, hopCount?: number): bigint;
|
|
45
48
|
export declare function isNativeTokenAddress(tokenAddress?: string): boolean;
|
|
@@ -195,17 +195,25 @@ export async function estimateMaxErc20TransferGas(provider, tokenAddress, from,
|
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* 计算 Gas Limit
|
|
198
|
-
* - 原生代币转账:
|
|
198
|
+
* - 原生代币转账:
|
|
199
|
+
* - BSC: 21000 gas(固定)
|
|
200
|
+
* - XLayer: 50000 gas(EIP-7702 授权地址需要更多 gas)
|
|
199
201
|
* - ERC20 标准 transfer:约 45000-55000 gas,使用 55000 作为安全值
|
|
200
202
|
*
|
|
201
203
|
* ✅ 优化:降低 ERC20 gas limit,减少中转钱包 BNB 残留
|
|
204
|
+
* ✅ XLayer 特殊处理:EIP-7702 授权的地址接收 OKB 时会触发 delegate 代码,需要更多 gas
|
|
202
205
|
*/
|
|
203
206
|
export function calculateGasLimit(config, isNative, hasHops, hopCount = 0) {
|
|
204
207
|
if (config.gasLimit !== undefined) {
|
|
205
208
|
return BigInt(config.gasLimit);
|
|
206
209
|
}
|
|
207
|
-
// ✅
|
|
208
|
-
const
|
|
210
|
+
// ✅ XLayer 链(chainId=196)原生代币需要更多 gas(EIP-7702 delegate 执行)
|
|
211
|
+
const isXLayer = config.chainId === 196;
|
|
212
|
+
// ✅ 原生代币: BSC 21000, XLayer 50000(EIP-7702 安全)
|
|
213
|
+
// ✅ ERC20 标准 transfer: 48000(USDT 最低约 46815)
|
|
214
|
+
const baseGas = isNative
|
|
215
|
+
? (isXLayer ? 50000 : 21000)
|
|
216
|
+
: 46815;
|
|
209
217
|
// ✅ 多跳时只需要累加单次转账的 gas,不需要额外乘数
|
|
210
218
|
// 每个中转钱包只执行一笔 transfer
|
|
211
219
|
if (hasHops && hopCount > 0) {
|