four-flap-meme-sdk 1.1.95 → 1.1.96
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.
|
@@ -322,44 +322,27 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
322
322
|
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
323
323
|
const sellers = privateKeys.map((k) => new Wallet(k, provider));
|
|
324
324
|
const amountsWei = sellAmounts.map((a) => ethers.parseUnits(a, 18));
|
|
325
|
-
//
|
|
326
|
-
|
|
327
|
-
const ROUTER_ABI = [
|
|
328
|
-
'function getAmountsOut(uint amountIn, address[] memory path) view returns (uint[] memory amounts)'
|
|
329
|
-
];
|
|
330
|
-
const WBNB = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c';
|
|
331
|
-
const router = new ethers.Contract(PANCAKE_ROUTER, ROUTER_ABI, provider);
|
|
332
|
-
// 并行获取所有报价
|
|
333
|
-
console.log(`📊 开始获取 ${amountsWei.length} 个卖单的报价...`);
|
|
334
|
-
const quotedOutputs = await Promise.all(amountsWei.map(async (amount, index) => {
|
|
335
|
-
try {
|
|
336
|
-
const path = [tokenAddress, WBNB];
|
|
337
|
-
const amounts = await router.getAmountsOut(amount, path);
|
|
338
|
-
const bnbAmount = amounts[1];
|
|
339
|
-
console.log(` ✅ 钱包 ${index}: 卖出 ${ethers.formatUnits(amount, 18)} 代币 → 预计获得 ${ethers.formatEther(bnbAmount)} BNB`);
|
|
340
|
-
return bnbAmount; // 返回 BNB 数量
|
|
341
|
-
}
|
|
342
|
-
catch (error) {
|
|
343
|
-
console.log(` ❌ 钱包 ${index}: 报价失败 - ${error}`);
|
|
344
|
-
return 0n;
|
|
345
|
-
}
|
|
346
|
-
}));
|
|
347
|
-
// ✅ 使用报价结果或用户提供的 minOutputAmounts
|
|
325
|
+
// ⚠️ Four.meme 内盘代币通过 TokenManager bonding curve 定价,不在 PancakeSwap 上
|
|
326
|
+
// ✅ 使用用户提供的 minOutputAmounts,或默认为 0(不限制最小输出)
|
|
348
327
|
let minOuts;
|
|
328
|
+
let quotedOutputs = [];
|
|
349
329
|
if (minOutputAmounts && minOutputAmounts.length === sellers.length) {
|
|
350
330
|
// 用户提供了 minOutputAmounts,优先使用
|
|
351
331
|
minOuts = minOutputAmounts.map(m => typeof m === 'string' ? ethers.parseEther(m) : m);
|
|
332
|
+
quotedOutputs = minOuts.map(m => m * 100n / 95n); // 反推报价(用于利润计算)
|
|
352
333
|
console.log(`📝 使用用户提供的 minOutputAmounts`);
|
|
334
|
+
console.log(`💰 minOutputAmounts:`);
|
|
335
|
+
minOuts.forEach((minOut, i) => {
|
|
336
|
+
console.log(` 钱包 ${i}: ${ethers.formatEther(minOut)} BNB`);
|
|
337
|
+
});
|
|
353
338
|
}
|
|
354
339
|
else {
|
|
355
|
-
//
|
|
356
|
-
minOuts =
|
|
357
|
-
|
|
340
|
+
// Four.meme 内盘代币:默认 minOutputAmount = 0(不限制),不提取利润
|
|
341
|
+
minOuts = new Array(sellers.length).fill(0n);
|
|
342
|
+
quotedOutputs = new Array(sellers.length).fill(0n);
|
|
343
|
+
console.log(`📝 Four.meme 内盘代币:minOutputAmount = 0(不限制最小输出)`);
|
|
344
|
+
console.log(`⚠️ 无法自动计算卖出收益,建议手动传入 minOutputAmounts 以提取利润`);
|
|
358
345
|
}
|
|
359
|
-
console.log(`💰 最终 minOutputAmounts:`);
|
|
360
|
-
minOuts.forEach((minOut, i) => {
|
|
361
|
-
console.log(` 钱包 ${i}: ${ethers.formatEther(minOut)} BNB`);
|
|
362
|
-
});
|
|
363
346
|
console.log('');
|
|
364
347
|
// ✅ Step 1: 检查代币余额和授权状态
|
|
365
348
|
const ERC20_ABI = [
|