four-flap-meme-sdk 1.7.38 → 1.7.40
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.
|
@@ -102,9 +102,29 @@ export async function washVolume(params) {
|
|
|
102
102
|
console.log(`[washVolume] FLAP 总金额报价: ${wallets.length} 个钱包, 每个 ${buyAmountWei} wei, 总计 ${totalBuyWei} wei`);
|
|
103
103
|
try {
|
|
104
104
|
const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
105
|
-
// ✅ 使用 previewBuy(与 AA
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
// ✅ 使用 previewBuy(与 AA 模式一致),降级到 quoteExactInput
|
|
106
|
+
// 某些代币的 previewBuy 会 revert (0xac5f6092),降级到 quoteExactInput
|
|
107
|
+
let totalTokenAmount = 0n;
|
|
108
|
+
try {
|
|
109
|
+
totalTokenAmount = await portalContract.previewBuy(tokenAddress, totalBuyWei);
|
|
110
|
+
console.log(`[washVolume] FLAP previewBuy 总预估: ${totalBuyWei} wei OKB -> ${totalTokenAmount} wei 代币`);
|
|
111
|
+
}
|
|
112
|
+
catch (previewErr) {
|
|
113
|
+
console.warn(`[washVolume] previewBuy 失败,尝试 quoteExactInput:`, previewErr);
|
|
114
|
+
try {
|
|
115
|
+
// ✅ 降级到 quoteExactInput(与 AA 模式相同的降级策略)
|
|
116
|
+
totalTokenAmount = await portalContract.quoteExactInput.staticCall({
|
|
117
|
+
inputToken: ethers.ZeroAddress, // OKB
|
|
118
|
+
outputToken: tokenAddress, // Token
|
|
119
|
+
inputAmount: totalBuyWei,
|
|
120
|
+
});
|
|
121
|
+
console.log(`[washVolume] FLAP quoteExactInput 总预估: ${totalBuyWei} wei OKB -> ${totalTokenAmount} wei 代币`);
|
|
122
|
+
}
|
|
123
|
+
catch (quoteErr) {
|
|
124
|
+
console.warn(`[washVolume] quoteExactInput 也失败:`, quoteErr);
|
|
125
|
+
totalTokenAmount = 0n;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
108
128
|
// 按每个钱包的买入金额比例分配(由于每个钱包金额相同,均分即可)
|
|
109
129
|
if (totalBuyWei > 0n && totalTokenAmount > 0n) {
|
|
110
130
|
const sharePerWallet = totalTokenAmount / BigInt(wallets.length);
|
|
@@ -121,7 +141,7 @@ export async function washVolume(params) {
|
|
|
121
141
|
console.log(`[washVolume] FLAP 代币分配:`, estimatedTokenAmounts.map(a => a.toString()));
|
|
122
142
|
}
|
|
123
143
|
catch (e) {
|
|
124
|
-
console.warn(`[washVolume]
|
|
144
|
+
console.warn(`[washVolume] 报价失败:`, e);
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
const [nonces, feeData] = await Promise.all([
|
|
@@ -145,12 +165,10 @@ export async function washVolume(params) {
|
|
|
145
165
|
const buyCall = buildBuyCall(wallet, buyAmountWei, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
146
166
|
calls.push(buyCall);
|
|
147
167
|
// 卖出调用(使用预估的代币数量)
|
|
148
|
-
// ✅ FLAP
|
|
149
|
-
// 因为实际买入获得的代币可能略少于预估值
|
|
168
|
+
// ✅ FLAP 模式使用按比例分配的预估数量(全部卖出)
|
|
150
169
|
const estimatedAmount = estimatedTokenAmounts[i] || 0n;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
? buildSellCallWithAmount(wallet, safeAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
170
|
+
const sellCall = poolType === 'FLAP' && estimatedAmount > 0n
|
|
171
|
+
? buildSellCallWithAmount(wallet, estimatedAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
154
172
|
: buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
155
173
|
calls.push(sellCall);
|
|
156
174
|
}
|