four-flap-meme-sdk 1.7.53 → 1.7.55

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.
@@ -365,14 +365,12 @@ export async function bundleSwap(params) {
365
365
  });
366
366
  }
367
367
  // 3. 买家买入(使用买家自己的 OKB)
368
- const buyAmount = estimatedOkbOut - profitAmount;
369
368
  const buyCall = buildBuyCallInternal(buyerWallet, buyAmount, tokenAddress, tradeType, actualRouter, fee, delegateInterface, portalInterface);
370
369
  calls.push(buyCall);
371
370
  }
372
371
  else {
373
- // 资金利用率模式:卖出 -> 扣利润 -> 转账 -> 买入
372
+ // 资金利用率模式:卖出 -> 扣利润 -> 转账 -> 买入
374
373
  const firstRecipient = hopWallets.length > 0 ? hopWallets[0].address : buyerWallet.address;
375
- const buyAmount = estimatedOkbOut - profitAmount;
376
374
  // 1. 卖家卖出 (独立卖出,不包含转账)
377
375
  const sellCall = buildSellCallWithAmountInternal(sellerWallet, sellAmountWei, tokenAddress, tradeType, actualRouter, fee, delegateInterface, portalInterface);
378
376
  calls.push(sellCall);
@@ -811,8 +809,8 @@ function buildSellCallWithAmountInternal(wallet, amount, tokenAddress, tradeType
811
809
  target: wallet.address,
812
810
  allowFailure: false,
813
811
  value: 0n,
814
- // ✅ 传 0 让合约自动查询余额
815
- callData: delegateInterface.encodeFunctionData('executeSellV2', [routerAddress, path, 0]),
812
+ // ✅ 修复:传入实际数量,避免卖出全部
813
+ callData: delegateInterface.encodeFunctionData('executeSellV2', [routerAddress, path, amount]),
816
814
  };
817
815
  }
818
816
  case 'V3': {
@@ -820,9 +818,9 @@ function buildSellCallWithAmountInternal(wallet, amount, tokenAddress, tradeType
820
818
  target: wallet.address,
821
819
  allowFailure: false,
822
820
  value: 0n,
823
- // ✅ 传 0 让合约自动查询余额
821
+ // ✅ 修复:传入实际数量,避免卖出全部
824
822
  callData: delegateInterface.encodeFunctionData('executeSell', [
825
- routerAddress, tokenAddress, WOKB_ADDRESS, fee, 0
823
+ routerAddress, tokenAddress, WOKB_ADDRESS, fee, amount
826
824
  ]),
827
825
  };
828
826
  }
@@ -219,7 +219,7 @@ export async function washVolume(params) {
219
219
  const estimatedAmount = estimatedTokenAmounts[i] || 0n;
220
220
  const sellCall = estimatedAmount > 0n
221
221
  ? buildSellCallWithAmount(wallet, estimatedAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
222
- : buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
222
+ : buildSellCall(wallet, 0n, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
223
223
  calls.push(sellCall);
224
224
  }
225
225
  // ✅ 修复:利润刮取从第一个参与刷量的钱包扣取(卖出后有OKB)
@@ -414,10 +414,10 @@ export async function bundleVolume(params) {
414
414
  catch (e) {
415
415
  console.warn(`[bundleVolume] 报价预估失败:`, e);
416
416
  }
417
- // ✅ 修正卖出数量计算逻辑:每个钱包应卖出的代币 = (原有余额 + 本次买入预估数量) * sellPercent / 100
417
+ // ✅ 修正卖出数量计算逻辑:卖出数额仅基于本次交易买入的代币预估值,忽略原有余额
418
418
  const percentBigInt = BigInt(Math.min(100, Math.max(0, sellPercent)));
419
- // 1. 初始化每个钱包的预期持仓
420
- const walletTotalExpectedBalances = balances.map(b => b);
419
+ // 1. 初始化每个钱包的预期卖出数量为 0n
420
+ const walletTotalExpectedBalances = balances.map(() => 0n);
421
421
  // 2. 将本次预估买入的代币分配给买家(买家也可能是卖家)
422
422
  if (estimatedTokenAmount > 0n && totalBuyAmount > 0n) {
423
423
  // 按买家买入金额比例分配预估代币
@@ -652,7 +652,8 @@ function buildBuyCall(wallet, amount, tokenAddress, poolType, routerAddress, fee
652
652
  }
653
653
  }
654
654
  }
655
- function buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, routerAddress, fee, delegateInterface, portalInterface) {
655
+ function buildSellCall(wallet, amount, // 传入具体数量,用于非 100% 卖出时的占位或精确值
656
+ tokenAddress, sellPercent, tokenDecimals, poolType, routerAddress, fee, delegateInterface, portalInterface) {
656
657
  // 使用 executeTransferAll 卖出全部(sellPercent=100)
657
658
  // 或者使用 executeSell 指定百分比
658
659
  switch (poolType) {
@@ -677,20 +678,22 @@ function buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolTyp
677
678
  }
678
679
  case 'V2': {
679
680
  const path = [tokenAddress, WOKB_ADDRESS];
681
+ // ✅ 修复:传入实际数量,避免卖出全部
680
682
  return {
681
683
  target: wallet.address,
682
684
  allowFailure: false,
683
685
  value: 0n,
684
- callData: delegateInterface.encodeFunctionData('executeSellV2', [routerAddress, path, 0]),
686
+ callData: delegateInterface.encodeFunctionData('executeSellV2', [routerAddress, path, sellPercent === 100 ? 0 : amount]),
685
687
  };
686
688
  }
687
689
  case 'V3': {
690
+ // ✅ 修复:传入实际数量,避免卖出全部
688
691
  return {
689
692
  target: wallet.address,
690
693
  allowFailure: false,
691
694
  value: 0n,
692
695
  callData: delegateInterface.encodeFunctionData('executeSell', [
693
- routerAddress, tokenAddress, WOKB_ADDRESS, fee, 0
696
+ routerAddress, tokenAddress, WOKB_ADDRESS, fee, sellPercent === 100 ? 0 : amount
694
697
  ]),
695
698
  };
696
699
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.53",
3
+ "version": "1.7.55",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",