four-flap-meme-sdk 1.4.45 → 1.4.47
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.
|
@@ -386,8 +386,8 @@ export async function buildProfitHopTransactions(config) {
|
|
|
386
386
|
if (profitAmount <= 0n) {
|
|
387
387
|
return { signedTransactions: [], hopWallets: [], totalNonceUsed: 0 };
|
|
388
388
|
}
|
|
389
|
-
// 固定 gas limit
|
|
390
|
-
const nativeTransferGasLimit =
|
|
389
|
+
// 固定 gas limit(原生代币转账,预留少量缓冲)
|
|
390
|
+
const nativeTransferGasLimit = 21055n;
|
|
391
391
|
const gasFeePerHop = nativeTransferGasLimit * gasPrice;
|
|
392
392
|
// 生成中转钱包
|
|
393
393
|
const hopWallets = [];
|
|
@@ -62,19 +62,24 @@ async function buildNativeTransferTx(wallet, to, amount, nonce, gasPrice, chainI
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* 构建 Flap 买入交易
|
|
65
|
+
* 使用 swapExactInput 方法
|
|
65
66
|
*/
|
|
66
67
|
async function buildFlapBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, chain) {
|
|
67
68
|
const portalAddress = FLAP_PORTAL_ADDRESSES[chain];
|
|
69
|
+
// ✅ 使用正确的 Flap Portal ABI
|
|
68
70
|
const iface = new ethers.Interface([
|
|
69
|
-
'function
|
|
70
|
-
]);
|
|
71
|
-
const data = iface.encodeFunctionData('buyToken', [
|
|
72
|
-
ethers.ZeroHash, // origin
|
|
73
|
-
tokenAddress,
|
|
74
|
-
wallet.address, // to
|
|
75
|
-
buyAmount,
|
|
76
|
-
0n // minAmount (no slippage protection)
|
|
71
|
+
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)'
|
|
77
72
|
]);
|
|
73
|
+
// ✅ 构建 swapExactInput 参数
|
|
74
|
+
// inputToken = 0x0 表示原生代币(BNB)
|
|
75
|
+
// outputToken = tokenAddress(要买入的代币)
|
|
76
|
+
const data = iface.encodeFunctionData('swapExactInput', [{
|
|
77
|
+
inputToken: ethers.ZeroAddress, // 原生代币(BNB)
|
|
78
|
+
outputToken: tokenAddress, // 要买入的代币
|
|
79
|
+
inputAmount: buyAmount,
|
|
80
|
+
minOutputAmount: 0n, // 不设滑点保护
|
|
81
|
+
permitData: '0x'
|
|
82
|
+
}]);
|
|
78
83
|
const tx = {
|
|
79
84
|
to: portalAddress,
|
|
80
85
|
data,
|