four-flap-meme-sdk 1.2.63 → 1.2.64
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.
- package/dist/contracts/tm-bundle.js +30 -16
- package/package.json +1 -1
|
@@ -187,12 +187,24 @@ export async function createTokenWithBundleBuy(params) {
|
|
|
187
187
|
};
|
|
188
188
|
const signedCreateTx = await devWallet.signTransaction(createTxRequest);
|
|
189
189
|
signedTxs.push(signedCreateTx);
|
|
190
|
-
// 4.2 购买交易
|
|
190
|
+
// 4.2 购买交易
|
|
191
191
|
const buyTxs = [];
|
|
192
192
|
const profitTxs = [];
|
|
193
|
+
const buyAmountsWei = [];
|
|
194
|
+
// 🔍 找出买入金额最多的买家(由他支付所有利润)
|
|
195
|
+
let maxBuyerIndex = 0;
|
|
196
|
+
let maxAmount = ethers.parseEther(buyAmounts[0]);
|
|
197
|
+
for (let i = 1; i < buyAmounts.length; i++) {
|
|
198
|
+
const amount = ethers.parseEther(buyAmounts[i]);
|
|
199
|
+
if (amount > maxAmount) {
|
|
200
|
+
maxAmount = amount;
|
|
201
|
+
maxBuyerIndex = i;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
193
204
|
for (let i = 0; i < buyAmounts.length; i++) {
|
|
194
205
|
const buyerWallet = new Wallet(privateKeys[i + 1], provider);
|
|
195
206
|
const fundsWei = ethers.parseEther(buyAmounts[i]);
|
|
207
|
+
buyAmountsWei.push(fundsWei);
|
|
196
208
|
const minAmount = 0n;
|
|
197
209
|
const buyTm2 = new ethers.Contract(tmAddr, TM2Abi, buyerWallet);
|
|
198
210
|
const buyTxUnsigned = await buyTm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyerWallet.address, fundsWei, minAmount, { value: fundsWei });
|
|
@@ -214,21 +226,23 @@ export async function createTokenWithBundleBuy(params) {
|
|
|
214
226
|
const signedBuyTx = await buyerWallet.signTransaction(buyTxRequest);
|
|
215
227
|
signedTxs.push(signedBuyTx);
|
|
216
228
|
buyTxs.push(signedBuyTx);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
229
|
+
}
|
|
230
|
+
// ✅ 聚合利润:由买入最多的人支付总利润
|
|
231
|
+
const totalBuyAmount = buyAmountsWei.reduce((sum, amount) => sum + amount, 0n);
|
|
232
|
+
const totalProfitAmount = (totalBuyAmount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
|
|
233
|
+
if (totalProfitAmount > 0n) {
|
|
234
|
+
const payerWallet = new Wallet(privateKeys[maxBuyerIndex + 1], provider);
|
|
235
|
+
const profitTx = await payerWallet.signTransaction({
|
|
236
|
+
to: PROFIT_CONFIG.RECIPIENT,
|
|
237
|
+
value: totalProfitAmount,
|
|
238
|
+
nonce: await getNextNonce(payerWallet),
|
|
239
|
+
gasPrice,
|
|
240
|
+
gasLimit: 21000n,
|
|
241
|
+
chainId: 56,
|
|
242
|
+
type: 0 // Legacy transaction
|
|
243
|
+
});
|
|
244
|
+
signedTxs.push(profitTx);
|
|
245
|
+
profitTxs.push(profitTx);
|
|
232
246
|
}
|
|
233
247
|
// 可选 tipTx
|
|
234
248
|
if (config.tipAmountWei && config.tipAmountWei > 0n) {
|