four-flap-meme-sdk 1.2.5 → 1.2.7

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.
@@ -104,10 +104,16 @@ export async function createTokenWithBundleBuyMerkle(params) {
104
104
  const extractProfit = shouldExtractProfit(config);
105
105
  let totalProfit = 0n;
106
106
  let totalBuyAmount = 0n;
107
+ console.log('🔍 创建+跟买 利润提取检查:', {
108
+ extractProfit,
109
+ profitRecipient: config.profitRecipient,
110
+ profitRateBps: config.profitRateBps,
111
+ buyersCount: privateKeys.length - 1
112
+ });
107
113
  // 计算每个买家的实际购买金额和利润
108
114
  const fundsList = [];
109
115
  const profitList = [];
110
- buyAmounts.forEach((v) => {
116
+ buyAmounts.forEach((v, idx) => {
111
117
  const originalAmount = ethers.parseEther(v);
112
118
  totalBuyAmount += originalAmount;
113
119
  if (extractProfit) {
@@ -115,10 +121,12 @@ export async function createTokenWithBundleBuyMerkle(params) {
115
121
  totalProfit += profit;
116
122
  fundsList.push(remaining); // ✅ 扣除利润后的金额用于购买
117
123
  profitList.push(profit); // ✅ 记录每个买家的利润
124
+ console.log(` 买家 ${idx}: 原金额 ${ethers.formatEther(originalAmount)} BNB, 购买 ${ethers.formatEther(remaining)} BNB, 利润 ${ethers.formatEther(profit)} BNB`);
118
125
  }
119
126
  else {
120
127
  fundsList.push(originalAmount);
121
128
  profitList.push(0n);
129
+ console.log(` 买家 ${idx}: 购买 ${ethers.formatEther(originalAmount)} BNB (无利润提取)`);
122
130
  }
123
131
  });
124
132
  const minOuts = new Array(buyers.length).fill(0n);
@@ -149,7 +157,10 @@ export async function createTokenWithBundleBuyMerkle(params) {
149
157
  buyTxs.push(...signedBuys);
150
158
  // ✅ 添加利润转账(每个买家单独转自己的利润)
151
159
  if (extractProfit && totalProfit > 0n && buyers.length > 0) {
160
+ console.log(`💰 开始添加利润转账...`);
161
+ console.log(` 总利润: ${ethers.formatEther(totalProfit)} BNB → ${config.profitRecipient}`);
152
162
  for (let i = 0; i < buyers.length; i++) {
163
+ console.log(` 买家 ${i}: profitList[${i}] = ${profitList[i] ? ethers.formatEther(profitList[i]) : 'undefined'} BNB`);
153
164
  if (profitList[i] > 0n) {
154
165
  const profitNonce = await nonceManager.getNextNonce(buyers[i]);
155
166
  const profitTx = await buyers[i].signTransaction({
@@ -162,11 +173,25 @@ export async function createTokenWithBundleBuyMerkle(params) {
162
173
  type: getTxType(config)
163
174
  });
164
175
  signedTxs.push(profitTx);
176
+ console.log(` ✅ 买家 ${i}: 已添加利润转账 ${ethers.formatEther(profitList[i])} BNB`);
165
177
  }
166
178
  }
179
+ console.log(`✅ 利润转账添加完成,共 ${profitList.filter(p => p > 0n).length} 笔\n`);
180
+ }
181
+ else {
182
+ console.log(`⚠️ 跳过利润转账:`, {
183
+ extractProfit,
184
+ totalProfit: totalProfit ? ethers.formatEther(totalProfit) : '0',
185
+ buyersLength: buyers.length
186
+ });
167
187
  }
168
188
  // ✅ 清理临时 nonce 缓存
169
189
  nonceManager.clearTemp();
190
+ console.log(`\n📦 交易汇总:`);
191
+ console.log(` - 创建代币: 1 笔`);
192
+ console.log(` - 购买交易: ${buyTxs.length} 笔`);
193
+ console.log(` - 利润转账: ${signedTxs.length - 1 - buyTxs.length} 笔`);
194
+ console.log(` - 总交易数: ${signedTxs.length} 笔\n`);
170
195
  // ✅ 简化返回:只返回签名交易和代币地址
171
196
  return {
172
197
  signedTransactions: signedTxs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",