four-flap-meme-sdk 1.3.70 → 1.3.71

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.
@@ -87,6 +87,7 @@ export interface PancakeBatchSwapSignParams {
87
87
  sellPercentage?: number;
88
88
  buyerPrivateKeys: string[];
89
89
  buyerAmounts?: string[];
90
+ buyerRatios?: number[];
90
91
  tokenAddress: string;
91
92
  routeParams: RouteParams;
92
93
  slippageTolerance?: number;
@@ -458,15 +458,27 @@ export async function pancakeBatchSwapMerkle(params) {
458
458
  console.log('📊 预估卖出所得:', ethers.formatEther(estimatedBNBOut), 'BNB');
459
459
  // ✅ 计算每个买方的买入金额
460
460
  let buyAmountsWei;
461
+ const totalBuyAmount = applySlippage(estimatedBNBOut, slippageTolerance);
461
462
  if (buyerAmounts && buyerAmounts.length === buyers.length) {
462
- // 使用指定的买入金额
463
+ // 方式1:使用指定的买入金额(USDT)
463
464
  buyAmountsWei = buyerAmounts.map(amt => useNativeToken
464
465
  ? ethers.parseEther(amt)
465
466
  : ethers.parseUnits(amt, quoteTokenDecimals));
466
467
  }
468
+ else if (params.buyerRatios && params.buyerRatios.length === buyers.length) {
469
+ // ✅ 方式2:按比例分配卖出所得
470
+ // buyerRatios 如 [0.3, 0.5, 0.2] 表示第一个买方分 30%,第二个 50%,第三个 20%
471
+ console.log('📊 使用比例分配,卖出所得:', ethers.formatEther(totalBuyAmount), 'BNB');
472
+ console.log('📊 买方比例:', params.buyerRatios);
473
+ buyAmountsWei = params.buyerRatios.map((ratio, index) => {
474
+ // 按比例计算每个买方的金额
475
+ const amount = (totalBuyAmount * BigInt(Math.round(ratio * 10000))) / 10000n;
476
+ console.log(` 买方 ${index + 1}: ${(ratio * 100).toFixed(1)}% = ${ethers.formatEther(amount)} BNB`);
477
+ return amount;
478
+ });
479
+ }
467
480
  else {
468
- // 平均分配(考虑滑点)
469
- const totalBuyAmount = applySlippage(estimatedBNBOut, slippageTolerance);
481
+ // 方式3:平均分配
470
482
  const amountPerBuyer = totalBuyAmount / BigInt(buyers.length);
471
483
  buyAmountsWei = buyers.map(() => amountPerBuyer);
472
484
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.3.70",
3
+ "version": "1.3.71",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",