four-flap-meme-sdk 1.4.68 → 1.4.69

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.
@@ -120,8 +120,11 @@ export async function fourBundleBuyFirstMerkle(params) {
120
120
  if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
121
121
  throw new Error('报价失败:无法估算可买入的代币数量');
122
122
  }
123
- // ✅ 直接使用报价的代币数量(与 Flap 一致,不做滑点调整)
124
- const sellAmountWei = estimatedTokenAmount;
123
+ // ✅ 添加安全系数:减少 2% 卖出数量以应对报价误差/税/滑点
124
+ // 原因:Four.meme 报价可能有误差,实际买入的代币可能少于报价
125
+ // 小金额时误差影响更大,需要安全余量
126
+ const SELL_SAFETY_BPS = 200n; // 2% = 200 bps
127
+ const sellAmountWei = estimatedTokenAmount * (10000n - SELL_SAFETY_BPS) / 10000n;
125
128
  // 卖方余额检查
126
129
  if (!sameAddress && sellerTokenBal < sellAmountWei) {
127
130
  throw new Error(`卖方代币余额不足: 需要 ${ethers.formatUnits(sellAmountWei, decimals)},实际 ${ethers.formatUnits(sellerTokenBal, decimals)}`);
@@ -121,10 +121,14 @@ export async function pancakeBundleBuyFirstMerkle(params) {
121
121
  buyerFundsWei: buyerFundsInfo.buyerFundsWei,
122
122
  provider: context.provider
123
123
  });
124
- // ✅ 直接使用报价的代币数量(与 Flap 一致,不做滑点调整)
124
+ // ✅ 添加安全系数:减少 2% 卖出数量以应对报价误差/税/滑点
125
+ // 原因:报价可能有误差,实际买入的代币可能少于报价
126
+ // 小金额时误差影响更大,需要安全余量
127
+ const SELL_SAFETY_BPS = 200n; // 2% = 200 bps
128
+ const adjustedSellAmount = quoteResult.quotedTokenOut * (10000n - SELL_SAFETY_BPS) / 10000n;
125
129
  // ✅ 拆分买入和卖出金额
126
130
  const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
127
- const sellAmountsWei = splitAmount(quoteResult.quotedTokenOut, sellCount);
131
+ const sellAmountsWei = splitAmount(adjustedSellAmount, sellCount);
128
132
  // ✅ 构建多笔买入和卖出交易
129
133
  const swapUnsignedArray = await buildMultiRouteTransactions({
130
134
  routeParams,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.68",
3
+ "version": "1.4.69",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",