four-flap-meme-sdk 1.4.45 → 1.4.46
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.
- package/dist/utils/holders-maker.js +13 -8
- package/package.json +1 -1
|
@@ -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,
|