four-flap-meme-sdk 1.7.28 → 1.7.30

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.
@@ -34,9 +34,15 @@ function buildFlapBuyCalls(wallets, buyAmounts, tokenAddress) {
34
34
  const amount = buyAmounts[i];
35
35
  if (amount <= 0n)
36
36
  continue;
37
- // 通过 executeBatch 让钱包调用 Flap Portal buy 函数
38
- // 这样代币会发送到调用者(钱包地址)
39
- const portalCallData = portalInterface.encodeFunctionData('buy', [tokenAddress]);
37
+ // 修复:使用 swapExactInput 代替 buy 函数,与 bundle-create.ts 保持一致
38
+ // buy(token) 是旧 API,swapExactInput 是新的标准 API
39
+ const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
40
+ inputToken: ethers.ZeroAddress, // 0x0 = OKB (原生代币)
41
+ outputToken: tokenAddress,
42
+ inputAmount: amount,
43
+ minOutputAmount: 0n, // 无滑点保护
44
+ permitData: '0x',
45
+ }]);
40
46
  const batchCalls = [{
41
47
  target: FLAP_PORTAL_ADDRESS,
42
48
  value: amount,
@@ -46,7 +52,7 @@ function buildFlapBuyCalls(wallets, buyAmounts, tokenAddress) {
46
52
  calls.push({
47
53
  target: wallet.address, // 以钱包身份调用,代币会到钱包
48
54
  allowFailure: false,
49
- value: amount,
55
+ value: 0n, // ✅ 修复:不通过 msg.value 传递资金,executeBatch 内部会使用钱包自己的余额
50
56
  callData,
51
57
  });
52
58
  }
@@ -74,7 +80,7 @@ function buildV2BuyCalls(wallets, buyAmounts, tokenAddress, routerAddress) {
74
80
  calls.push({
75
81
  target: wallet.address,
76
82
  allowFailure: false,
77
- value: amount, // 传入买入金额
83
+ value: 0n, // ✅ 修复:不通过 msg.value 传递资金,executeBuyV2 会使用钱包自己的余额
78
84
  callData,
79
85
  });
80
86
  }
@@ -102,7 +108,7 @@ function buildV3BuyCalls(wallets, buyAmounts, tokenAddress, routerAddress, fee)
102
108
  calls.push({
103
109
  target: wallet.address,
104
110
  allowFailure: false,
105
- value: amount, // 传入买入金额
111
+ value: 0n, // ✅ 修复:不通过 msg.value 传递资金,executeBuy 会使用钱包自己的余额
106
112
  callData,
107
113
  });
108
114
  }
@@ -224,7 +230,8 @@ export async function bundleBuy(params) {
224
230
  if (profitCall) {
225
231
  calls.push(profitCall);
226
232
  }
227
- const totalValue = totalBuyAmount + profitAmount;
233
+ // 修复:各钱包使用自己的余额买入,主交易只需要支付利润
234
+ const totalValue = profitAmount;
228
235
  // ========================================
229
236
  // 同步构建并签名交易(已有 nonce 和 feeData)
230
237
  // ========================================
@@ -330,11 +330,12 @@ export async function sweep(params) {
330
330
  // 直接归集:源钱包 → 目标地址
331
331
  // ========================================
332
332
  if (isNative) {
333
+ // ✅ 修复:使用 transferAmount 替代 transferTo,支持百分比归集
333
334
  calls.push({
334
335
  target: sourceWallet.address,
335
336
  allowFailure: false,
336
337
  value: callValue,
337
- callData: delegateInterface.encodeFunctionData('transferTo', [targetAddress]),
338
+ callData: delegateInterface.encodeFunctionData('transferAmount', [targetAddress, amount]),
338
339
  });
339
340
  }
340
341
  else {
@@ -358,11 +359,12 @@ export async function sweep(params) {
358
359
  const lastHop = hopWallets[hopWallets.length - 1];
359
360
  if (isNative) {
360
361
  // 源钱包 → 第一个中间钱包
362
+ // ✅ 修复:使用 transferAmount 替代 transferTo,支持百分比归集
361
363
  calls.push({
362
364
  target: sourceWallet.address,
363
365
  allowFailure: false,
364
366
  value: callValue,
365
- callData: delegateInterface.encodeFunctionData('transferTo', [firstHop.address]),
367
+ callData: delegateInterface.encodeFunctionData('transferAmount', [firstHop.address, amount]),
366
368
  });
367
369
  // 中间钱包之间转账
368
370
  for (let j = 0; j < hopWallets.length - 1; j++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.28",
3
+ "version": "1.7.30",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",