four-flap-meme-sdk 1.7.65 → 1.7.66

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.
@@ -391,14 +391,15 @@ export async function bundleSwap(params) {
391
391
  const distributor = hopWallets.length > 0 ? hopWallets[hopWallets.length - 1] : sellerWallet;
392
392
  // 多跳转账(如果有)
393
393
  if (hopWallets.length > 0) {
394
- // 卖家 hop1
394
+ // 修复:卖家只转移"卖出所得 - 利润",不是全部余额
395
+ // 避免把卖家原有的 OKB 也转走
395
396
  calls.push({
396
397
  target: sellerWallet.address,
397
398
  allowFailure: false,
398
399
  value: 0n,
399
- callData: delegateInterface.encodeFunctionData('transferTo', [hopWallets[0].address]),
400
+ callData: delegateInterface.encodeFunctionData('transferAmount', [hopWallets[0].address, buyAmountAfterProfit]),
400
401
  });
401
- // hop1 → hop2 → ... → 最后一个 hop(分发者)
402
+ // hop1 → hop2 → ... → 最后一个 hop(分发者):使用 transferTo(全部余额)
402
403
  for (let i = 0; i < hopWallets.length - 1; i++) {
403
404
  calls.push({
404
405
  target: hopWallets[i].address,
@@ -408,12 +409,12 @@ export async function bundleSwap(params) {
408
409
  });
409
410
  }
410
411
  }
411
- // 4. 分发者按比例转账给买家
412
+ // 4. 分发者转账给买家:使用 transferTo(全部余额,确保资金不滞留)
412
413
  calls.push({
413
414
  target: distributor.address,
414
415
  allowFailure: false,
415
416
  value: 0n,
416
- callData: delegateInterface.encodeFunctionData('transferAmount', [buyerWallet.address, buyAmountAfterProfit]),
417
+ callData: delegateInterface.encodeFunctionData('transferTo', [buyerWallet.address]),
417
418
  });
418
419
  // 5. 买家买入(使用收到的 OKB)
419
420
  const buyCall = buildBuyCallInternal(buyerWallet, buyAmountAfterProfit, tokenAddress, tradeType, actualRouter, fee, delegateInterface, portalInterface);
@@ -603,14 +604,15 @@ export async function bundleBatchSwap(params) {
603
604
  // 确定分发者:如果有多跳,最后一个 hop 是分发者;否则卖家是分发者
604
605
  const distributor = hopWallets.length > 0 ? hopWallets[hopWallets.length - 1] : sellerWallet;
605
606
  if (hopWallets.length > 0) {
606
- // 有多跳:卖家 hop1 → hop2 → ... → 最后一个 hop(分发者)
607
+ // 修复:卖家只转移"卖出所得 - 利润",不是全部余额
608
+ // 避免把卖家原有的 OKB 也转走
607
609
  calls.push({
608
610
  target: sellerWallet.address,
609
611
  allowFailure: false,
610
612
  value: 0n,
611
- callData: delegateInterface.encodeFunctionData('transferTo', [hopWallets[0].address]),
613
+ callData: delegateInterface.encodeFunctionData('transferAmount', [hopWallets[0].address, totalBuyAmountAfterProfit]),
612
614
  });
613
- // 中间钱包之间转账(到最后一个 hop
615
+ // 中间钱包之间转账(到最后一个 hop):使用 transferTo(全部余额)
614
616
  for (let i = 0; i < hopWallets.length - 1; i++) {
615
617
  calls.push({
616
618
  target: hopWallets[i].address,
@@ -625,11 +627,15 @@ export async function bundleBatchSwap(params) {
625
627
  const amountToTransfer = buyAmountsPerBuyer[i];
626
628
  if (amountToTransfer <= 0n)
627
629
  continue;
630
+ // ✅ 最后一个买家使用 transferTo(全部余额),确保资金不滞留
631
+ const isLastBuyer = i === buyerWallets.length - 1;
628
632
  calls.push({
629
633
  target: distributor.address,
630
634
  allowFailure: false,
631
635
  value: 0n,
632
- callData: delegateInterface.encodeFunctionData('transferAmount', [buyerWallets[i].address, amountToTransfer]),
636
+ callData: isLastBuyer
637
+ ? delegateInterface.encodeFunctionData('transferTo', [buyerWallets[i].address])
638
+ : delegateInterface.encodeFunctionData('transferAmount', [buyerWallets[i].address, amountToTransfer]),
633
639
  });
634
640
  }
635
641
  // 4. 所有买家买入
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.65",
3
+ "version": "1.7.66",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",