four-flap-meme-sdk 1.3.3 → 1.3.4
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.
|
@@ -230,15 +230,17 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
230
230
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
231
231
|
const readOnlyPortal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
|
|
232
232
|
const gasLimits = buildGasLimitList(wallets.length, config);
|
|
233
|
+
const portals = wallets.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
|
|
233
234
|
// ✅ 确定 outputToken:如果传入了 quoteToken 且非零地址,则使用它;否则使用零地址(原生代币)
|
|
234
235
|
const outputToken = quoteToken && quoteToken !== ZERO_ADDRESS ? quoteToken : ZERO_ADDRESS;
|
|
235
|
-
// ✅ 优化:并行执行 gasPrice 和
|
|
236
|
-
const [gasPrice, quotedOutputs] = await Promise.all([
|
|
236
|
+
// ✅ 优化:并行执行 gasPrice、quoteSellOutputs 和 nonces(三个最耗时的 RPC 操作)
|
|
237
|
+
const [gasPrice, quotedOutputs, nonces] = await Promise.all([
|
|
237
238
|
resolveGasPrice(provider, config),
|
|
238
|
-
quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken)
|
|
239
|
+
quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken),
|
|
240
|
+
Promise.all(wallets.map(w => nonceManager.getNextNonce(w)))
|
|
239
241
|
]);
|
|
240
242
|
const minOuts = resolveMinOutputs(minOutputAmounts, wallets.length, quotedOutputs);
|
|
241
|
-
|
|
243
|
+
// ✅ 优化:构建未签名交易(这里是本地操作,但仍然并行执行以提高效率)
|
|
242
244
|
const unsignedList = await Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
|
|
243
245
|
inputToken: tokenAddress,
|
|
244
246
|
outputToken, // ✅ 使用动态 outputToken
|
|
@@ -246,7 +248,7 @@ export async function batchSellWithBundleMerkle(params) {
|
|
|
246
248
|
minOutputAmount: minOuts[i],
|
|
247
249
|
permitData: '0x'
|
|
248
250
|
})));
|
|
249
|
-
|
|
251
|
+
// ✅ 签名所有交易(并行)
|
|
250
252
|
const signedList = await Promise.all(unsignedList.map((unsigned, i) => wallets[i].signTransaction({
|
|
251
253
|
...unsigned,
|
|
252
254
|
from: wallets[i].address,
|