four-flap-meme-sdk 1.1.88 → 1.1.89

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.
@@ -282,12 +282,21 @@ export async function batchSellWithBundleMerkle(params) {
282
282
  // ✅ 自动获取报价以计算预期收益和利润
283
283
  const portal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
284
284
  // 并行获取所有报价
285
- const quotedOutputs = await Promise.all(amountsWei.map(amount => portal.quoteExactInput({
286
- inputToken: tokenAddress,
287
- outputToken: '0x0000000000000000000000000000000000000000',
288
- inputAmount: amount
289
- }).catch(() => 0n) // 如果报价失败,返回 0n
290
- ));
285
+ const quotedOutputs = await Promise.all(amountsWei.map(async (amount, index) => {
286
+ try {
287
+ const quoted = await portal.quoteExactInput({
288
+ inputToken: tokenAddress,
289
+ outputToken: '0x0000000000000000000000000000000000000000',
290
+ inputAmount: amount
291
+ });
292
+ console.log(`📊 卖出报价 [${index}]: ${ethers.formatEther(amount)} 代币 → ${ethers.formatEther(quoted)} BNB`);
293
+ return quoted;
294
+ }
295
+ catch (error) {
296
+ console.warn(`⚠️ 报价失败 [${index}]:`, error);
297
+ return 0n;
298
+ }
299
+ }));
291
300
  // ✅ 使用报价结果或用户提供的 minOutputAmounts
292
301
  let minOuts;
293
302
  if (minOutputAmounts && minOutputAmounts.length === wallets.length) {
@@ -322,11 +331,15 @@ export async function batchSellWithBundleMerkle(params) {
322
331
  signedTxs.push(...signedList);
323
332
  // ✅ 基于报价金额为每个钱包添加利润转账
324
333
  const extractProfit = shouldExtractProfit(config);
334
+ console.log(`\n💰 利润提取配置: extractProfit=${extractProfit}, profitRecipient=${config.profitRecipient}, quotedOutputs.length=${quotedOutputs.length}`);
325
335
  if (extractProfit && quotedOutputs.length > 0) {
336
+ let totalProfitAdded = 0;
326
337
  // 为每个钱包添加利润转账(基于完整报价金额,而非 minOut)
327
338
  for (let i = 0; i < wallets.length; i++) {
339
+ console.log(`\n🔍 钱包 [${i}]: quotedOutput=${ethers.formatEther(quotedOutputs[i])} BNB`);
328
340
  if (quotedOutputs[i] > 0n) { // 只对报价成功的交易提取利润
329
341
  const { profit } = calculateProfit(quotedOutputs[i], config);
342
+ console.log(` 💵 计算利润: ${ethers.formatEther(profit)} BNB (${config.profitRateBps || 30} bps)`);
330
343
  if (profit > 0n) {
331
344
  const profitNonce = await nonceManager.getNextNonce(wallets[i]);
332
345
  const profitTx = await wallets[i].signTransaction({
@@ -339,8 +352,19 @@ export async function batchSellWithBundleMerkle(params) {
339
352
  type: getTxType(config)
340
353
  });
341
354
  signedTxs.push(profitTx);
355
+ totalProfitAdded++;
356
+ console.log(` ✅ 已添加利润转账 (nonce: ${profitNonce})`);
342
357
  }
343
358
  }
359
+ else {
360
+ console.log(` ⚠️ 跳过:报价为 0`);
361
+ }
362
+ }
363
+ console.log(`\n📊 总共添加了 ${totalProfitAdded} 个利润转账\n`);
364
+ }
365
+ else {
366
+ if (!extractProfit) {
367
+ console.log(`⚠️ 未提取利润:profitRecipient=${config.profitRecipient}, profitRateBps=${config.profitRateBps}\n`);
344
368
  }
345
369
  }
346
370
  // ✅ 清理临时 nonce 缓存
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.1.88",
3
+ "version": "1.1.89",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",