four-flap-meme-sdk 1.2.4 → 1.2.5
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,16 +104,22 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
104
104
|
const extractProfit = shouldExtractProfit(config);
|
|
105
105
|
let totalProfit = 0n;
|
|
106
106
|
let totalBuyAmount = 0n;
|
|
107
|
-
//
|
|
108
|
-
const fundsList =
|
|
107
|
+
// 计算每个买家的实际购买金额和利润
|
|
108
|
+
const fundsList = [];
|
|
109
|
+
const profitList = [];
|
|
110
|
+
buyAmounts.forEach((v) => {
|
|
109
111
|
const originalAmount = ethers.parseEther(v);
|
|
110
112
|
totalBuyAmount += originalAmount;
|
|
111
113
|
if (extractProfit) {
|
|
112
114
|
const { remaining, profit } = calculateProfit(originalAmount, config);
|
|
113
115
|
totalProfit += profit;
|
|
114
|
-
|
|
116
|
+
fundsList.push(remaining); // ✅ 扣除利润后的金额用于购买
|
|
117
|
+
profitList.push(profit); // ✅ 记录每个买家的利润
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
fundsList.push(originalAmount);
|
|
121
|
+
profitList.push(0n);
|
|
115
122
|
}
|
|
116
|
-
return originalAmount;
|
|
117
123
|
});
|
|
118
124
|
const minOuts = new Array(buyers.length).fill(0n);
|
|
119
125
|
const buyPortals = buyers.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
|
|
@@ -141,19 +147,23 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
141
147
|
})));
|
|
142
148
|
signedTxs.push(...signedBuys);
|
|
143
149
|
buyTxs.push(...signedBuys);
|
|
144
|
-
// ✅
|
|
150
|
+
// ✅ 添加利润转账(每个买家单独转自己的利润)
|
|
145
151
|
if (extractProfit && totalProfit > 0n && buyers.length > 0) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
for (let i = 0; i < buyers.length; i++) {
|
|
153
|
+
if (profitList[i] > 0n) {
|
|
154
|
+
const profitNonce = await nonceManager.getNextNonce(buyers[i]);
|
|
155
|
+
const profitTx = await buyers[i].signTransaction({
|
|
156
|
+
to: config.profitRecipient,
|
|
157
|
+
value: profitList[i], // ✅ 每个买家转自己的利润
|
|
158
|
+
nonce: profitNonce,
|
|
159
|
+
gasPrice,
|
|
160
|
+
gasLimit: 21000n,
|
|
161
|
+
chainId,
|
|
162
|
+
type: getTxType(config)
|
|
163
|
+
});
|
|
164
|
+
signedTxs.push(profitTx);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
157
167
|
}
|
|
158
168
|
// ✅ 清理临时 nonce 缓存
|
|
159
169
|
nonceManager.clearTemp();
|