four-flap-meme-sdk 1.4.44 → 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.
@@ -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 buyToken(bytes32 origin, address token, address to, uint256 funds, uint256 minAmount) payable'
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,
@@ -149,8 +154,9 @@ export async function holdersMaker(params) {
149
154
  const gasWithBuffer = gasFeePerWallet * BigInt(GAS_BUFFER_MULTIPLIER);
150
155
  const transferAmountPerWallet = buyAmountWei + gasWithBuffer;
151
156
  console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferAmountPerWallet)} BNB (买入 ${buyAmountPerHolder} + Gas ${ethers.formatEther(gasWithBuffer)})`);
152
- // 4. 获取 Gas Price
153
- const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: BigInt(gasPriceGwei) * 1000000000n });
157
+ // 4. 获取 Gas Price(支持小数 Gwei,如 0.1 Gwei)
158
+ const gasPriceWei = BigInt(Math.floor(gasPriceGwei * 1e9));
159
+ const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: gasPriceWei });
154
160
  const bribeAmountWei = ethers.parseEther(String(bribeAmount));
155
161
  // 5. 分批处理
156
162
  const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.44",
3
+ "version": "1.4.46",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",