four-flap-meme-sdk 1.4.70 → 1.4.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.
@@ -47,6 +47,8 @@ export type FourBuyFirstResult = {
47
47
  profitAmount?: string;
48
48
  buyCount?: number;
49
49
  sellCount?: number;
50
+ buyAmounts?: string[];
51
+ sellAmounts?: string[];
50
52
  };
51
53
  };
52
54
  export declare function fourBundleBuyFirstMerkle(params: FourBundleBuyFirstSignParams): Promise<FourBuyFirstResult>;
@@ -139,11 +139,14 @@ export async function fourBundleBuyFirstMerkle(params) {
139
139
  if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
140
140
  throw new Error('报价失败:无法估算可买入的代币数量');
141
141
  }
142
- // ✅ 添加安全系数:减少 2% 卖出数量以应对报价误差/税/滑点
143
- // 原因:Four.meme 报价可能有误差,实际买入的代币可能少于报价
144
- // 小金额时误差影响更大,需要安全余量
145
- const SELL_SAFETY_BPS = 200n; // 2% = 200 bps
146
- const sellAmountWei = estimatedTokenAmount * (10000n - SELL_SAFETY_BPS) / 10000n;
142
+ // ✅ 多笔买入时添加安全系数:减少 1% 卖出数量以应对报价误差/税/滑点
143
+ // 原因:多笔买入会产生滑点累积,实际获得的代币可能少于报价
144
+ // 单笔买入时不需要安全系数(与普通捆绑换手一致)
145
+ let sellAmountWei = estimatedTokenAmount;
146
+ if (buyCount > 1) {
147
+ const SELL_SAFETY_BPS = 100n; // 1% = 100 bps(仅多笔时)
148
+ sellAmountWei = estimatedTokenAmount * (10000n - SELL_SAFETY_BPS) / 10000n;
149
+ }
147
150
  // 卖方余额检查
148
151
  if (!sameAddress && sellerTokenBal < sellAmountWei) {
149
152
  throw new Error(`卖方代币余额不足: 需要 ${ethers.formatUnits(sellAmountWei, decimals)},实际 ${ethers.formatUnits(sellerTokenBal, decimals)}`);
@@ -252,7 +255,10 @@ export async function fourBundleBuyFirstMerkle(params) {
252
255
  profitAmount: extractProfit ? ethers.formatEther(profitAmount) : undefined,
253
256
  // ✅ 返回多笔买卖信息
254
257
  buyCount,
255
- sellCount
258
+ sellCount,
259
+ // ✅ 返回每笔交易的具体金额(随机分配后的数组)
260
+ buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
261
+ sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, decimals))
256
262
  }
257
263
  };
258
264
  }
@@ -54,6 +54,8 @@ export type FlapBuyFirstResult = {
54
54
  profitAmount?: string;
55
55
  buyCount?: number;
56
56
  sellCount?: number;
57
+ buyAmounts?: string[];
58
+ sellAmounts?: string[];
57
59
  };
58
60
  };
59
61
  export declare function flapBundleBuyFirstMerkle(params: FlapBundleBuyFirstSignParams): Promise<FlapBuyFirstResult>;
@@ -279,7 +279,10 @@ export async function flapBundleBuyFirstMerkle(params) {
279
279
  profitAmount: nativeProfitAmount > 0n ? ethers.formatEther(nativeProfitAmount) : undefined,
280
280
  // ✅ 返回多笔买卖信息
281
281
  buyCount,
282
- sellCount
282
+ sellCount,
283
+ // ✅ 返回每笔交易的具体金额(随机分配后的数组)
284
+ buyAmounts: buyAmountsWei.map(amt => ethers.formatEther(amt)),
285
+ sellAmounts: sellAmountsWei.map(amt => ethers.formatUnits(amt, sellerInfo.decimals))
283
286
  }
284
287
  };
285
288
  }
@@ -79,6 +79,8 @@ export type PancakeBuyFirstResult = {
79
79
  profitAmount?: string;
80
80
  buyCount?: number;
81
81
  sellCount?: number;
82
+ buyAmounts?: string[];
83
+ sellAmounts?: string[];
82
84
  };
83
85
  };
84
86
  export declare function pancakeBundleBuyFirstMerkle(params: PancakeBundleBuyFirstSignParams): Promise<PancakeBuyFirstResult>;
@@ -140,11 +140,14 @@ export async function pancakeBundleBuyFirstMerkle(params) {
140
140
  buyerFundsWei: buyerFundsInfo.buyerFundsWei,
141
141
  provider: context.provider
142
142
  });
143
- // ✅ 添加安全系数:减少 2% 卖出数量以应对报价误差/税/滑点
144
- // 原因:报价可能有误差,实际买入的代币可能少于报价
145
- // 小金额时误差影响更大,需要安全余量
146
- const SELL_SAFETY_BPS = 200n; // 2% = 200 bps
147
- const adjustedSellAmount = quoteResult.quotedTokenOut * (10000n - SELL_SAFETY_BPS) / 10000n;
143
+ // ✅ 多笔买入时添加安全系数:减少 1% 卖出数量以应对报价误差/税/滑点
144
+ // 原因:多笔买入会产生滑点累积,实际获得的代币可能少于报价
145
+ // 单笔买入时不需要安全系数(与普通捆绑换手一致)
146
+ let adjustedSellAmount = quoteResult.quotedTokenOut;
147
+ if (buyCount > 1) {
148
+ const SELL_SAFETY_BPS = 100n; // 1% = 100 bps(仅多笔时)
149
+ adjustedSellAmount = quoteResult.quotedTokenOut * (10000n - SELL_SAFETY_BPS) / 10000n;
150
+ }
148
151
  // ✅ 拆分买入和卖出金额
149
152
  const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
150
153
  const sellAmountsWei = splitAmount(adjustedSellAmount, sellCount);
@@ -278,7 +281,12 @@ export async function pancakeBundleBuyFirstMerkle(params) {
278
281
  profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
279
282
  // ✅ 返回多笔买卖信息
280
283
  buyCount,
281
- sellCount
284
+ sellCount,
285
+ // ✅ 返回每笔交易的具体金额(随机分配后的数组)
286
+ buyAmounts: buyAmountsWei.map(amt => useNativeToken
287
+ ? ethers.formatEther(amt)
288
+ : ethers.formatUnits(amt, quoteTokenDecimals)),
289
+ sellAmounts: sellAmountsWei.map(amt => amt.toString())
282
290
  }
283
291
  };
284
292
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.70",
3
+ "version": "1.4.71",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",