four-flap-meme-sdk 1.7.35 → 1.7.36
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.
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* 只生成签名,由调用方决定如何提交
|
|
14
14
|
*/
|
|
15
|
-
import { ethers } from 'ethers';
|
|
15
|
+
import { ethers, Contract } from 'ethers';
|
|
16
16
|
import { getCachedProvider, createWallet, signAuthorizationsWithNonces, batchGetNonces, buildEIP7702TransactionSync, calculateProfitAmountByTxCount, getProfitRecipient, } from './utils.js';
|
|
17
17
|
import { UNIFIED_DELEGATE_ADDRESS, UNIFIED_DELEGATE_ABI, FLAP_PORTAL_ABI, FLAP_PORTAL_ADDRESS, POTATOSWAP_V2_ROUTER, POTATOSWAP_V3_ROUTER, WOKB_ADDRESS, V3_FEE_TIERS, ERC20_ABI, } from './constants.js';
|
|
18
18
|
import { bundleBuy } from './bundle-buy.js';
|
|
@@ -94,6 +94,18 @@ export async function washVolume(params) {
|
|
|
94
94
|
// 并行获取数据
|
|
95
95
|
// ========================================
|
|
96
96
|
const allAddresses = allWallets.map(w => w.address);
|
|
97
|
+
// ✅ 对 FLAP 模式,预估买入会得到多少代币(用于卖出调用)
|
|
98
|
+
let estimatedTokenAmount = 0n;
|
|
99
|
+
if (poolType === 'FLAP') {
|
|
100
|
+
try {
|
|
101
|
+
const portalContract = new Contract(FLAP_PORTAL_ADDRESS, FLAP_PORTAL_ABI, provider);
|
|
102
|
+
estimatedTokenAmount = await portalContract.quoteBuy(tokenAddress, buyAmountWei);
|
|
103
|
+
console.log(`[washVolume] FLAP quoteBuy 预估: ${buyAmountWei} wei OKB -> ${estimatedTokenAmount} wei 代币`);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
console.warn(`[washVolume] quoteBuy 失败,使用 0 作为卖出金额:`, e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
97
109
|
const [nonces, feeData] = await Promise.all([
|
|
98
110
|
batchGetNonces(allAddresses, provider),
|
|
99
111
|
provider.getFeeData(),
|
|
@@ -114,8 +126,11 @@ export async function washVolume(params) {
|
|
|
114
126
|
// 买入调用
|
|
115
127
|
const buyCall = buildBuyCall(wallet, buyAmountWei, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
116
128
|
calls.push(buyCall);
|
|
117
|
-
//
|
|
118
|
-
|
|
129
|
+
// 卖出调用(使用预估的代币数量或 sellPercent)
|
|
130
|
+
// ✅ FLAP 模式使用 buildSellCallWithAmount,其他模式使用 buildSellCall
|
|
131
|
+
const sellCall = poolType === 'FLAP' && estimatedTokenAmount > 0n
|
|
132
|
+
? buildSellCallWithAmount(wallet, estimatedTokenAmount, tokenAddress, poolType, actualRouter, fee, delegateInterface, portalInterface)
|
|
133
|
+
: buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolType, actualRouter, fee, delegateInterface, portalInterface);
|
|
119
134
|
calls.push(sellCall);
|
|
120
135
|
}
|
|
121
136
|
// 利润刮取(放在最后,与 bundleBuy 一致)
|