four-flap-meme-sdk 1.7.36 → 1.7.37
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.
|
@@ -94,16 +94,34 @@ export async function washVolume(params) {
|
|
|
94
94
|
// 并行获取数据
|
|
95
95
|
// ========================================
|
|
96
96
|
const allAddresses = allWallets.map(w => w.address);
|
|
97
|
-
// ✅ 对 FLAP
|
|
98
|
-
|
|
97
|
+
// ✅ 对 FLAP 模式,使用【总金额报价 + 按比例分配】(与 AA 模式一致)
|
|
98
|
+
// 因为所有钱包在同一笔交易中执行,会累积影响价格
|
|
99
|
+
let estimatedTokenAmounts = [];
|
|
99
100
|
if (poolType === 'FLAP') {
|
|
101
|
+
const totalBuyWei = buyAmountWei * BigInt(wallets.length);
|
|
102
|
+
console.log(`[washVolume] FLAP 总金额报价: ${wallets.length} 个钱包, 每个 ${buyAmountWei} wei, 总计 ${totalBuyWei} wei`);
|
|
100
103
|
try {
|
|
101
104
|
const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
// 使用总金额获取总代币数量
|
|
106
|
+
const totalTokenAmount = await portalContract.quoteBuy(tokenAddress, totalBuyWei);
|
|
107
|
+
console.log(`[washVolume] FLAP quoteBuy 总预估: ${totalBuyWei} wei OKB -> ${totalTokenAmount} wei 代币`);
|
|
108
|
+
// 按每个钱包的买入金额比例分配(由于每个钱包金额相同,均分即可)
|
|
109
|
+
if (totalBuyWei > 0n && totalTokenAmount > 0n) {
|
|
110
|
+
const sharePerWallet = totalTokenAmount / BigInt(wallets.length);
|
|
111
|
+
let allocated = 0n;
|
|
112
|
+
estimatedTokenAmounts = wallets.map((_, i) => {
|
|
113
|
+
if (i === wallets.length - 1) {
|
|
114
|
+
// 最后一个钱包分配剩余的全部(避免精度损失)
|
|
115
|
+
return totalTokenAmount - allocated;
|
|
116
|
+
}
|
|
117
|
+
allocated += sharePerWallet;
|
|
118
|
+
return sharePerWallet;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
console.log(`[washVolume] FLAP 代币分配:`, estimatedTokenAmounts.map(a => a.toString()));
|
|
104
122
|
}
|
|
105
123
|
catch (e) {
|
|
106
|
-
console.warn(`[washVolume] quoteBuy
|
|
124
|
+
console.warn(`[washVolume] quoteBuy 失败:`, e);
|
|
107
125
|
}
|
|
108
126
|
}
|
|
109
127
|
const [nonces, feeData] = await Promise.all([
|
|
@@ -126,10 +144,11 @@ export async function washVolume(params) {
|
|
|
126
144
|
// 买入调用
|
|
127
145
|
const buyCall = buildBuyCall(wallet, buyAmountWei, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
128
146
|
calls.push(buyCall);
|
|
129
|
-
//
|
|
130
|
-
// ✅ FLAP
|
|
131
|
-
const
|
|
132
|
-
|
|
147
|
+
// 卖出调用(使用预估的代币数量)
|
|
148
|
+
// ✅ FLAP 模式使用按比例分配的预估数量
|
|
149
|
+
const estimatedAmount = estimatedTokenAmounts[i] || 0n;
|
|
150
|
+
const sellCall = poolType === 'FLAP' && estimatedAmount > 0n
|
|
151
|
+
? buildSellCallWithAmount(wallet, estimatedAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
133
152
|
: buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
134
153
|
calls.push(sellCall);
|
|
135
154
|
}
|