From 5cb245035b19f0df4c1f7790c44732aa5dc868dc Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Wed, 20 Nov 2024 18:01:28 +0000 Subject: [PATCH] update --- src/account.ts | 9 --------- src/cli.ts | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/account.ts b/src/account.ts index 9c13819b..0c3cec5a 100644 --- a/src/account.ts +++ b/src/account.ts @@ -157,15 +157,6 @@ export async function manageAccounts( ) { const removedWallets: ViemClient[] = []; let accountsToAdd = 0; - try { - const balances = await getBatchEthBalance( - config.accounts.map((v) => v.account.address), - config.viemClient as any as ViemClient, - ); - config.accounts.forEach((v, i) => (v.BALANCE = balances[i])); - } catch { - /**/ - } for (let i = config.accounts.length - 1; i >= 0; i--) { if (config.accounts[i].BALANCE.lt(avgGasCost.mul(4))) { try { diff --git a/src/cli.ts b/src/cli.ts index 4be3575a..4e3cc6da 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -13,7 +13,13 @@ import { BotConfig, CliOptions, ViemClient } from "./types"; import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions"; -import { manageAccounts, rotateProviders, sweepToMainWallet, sweepToEth } from "./account"; +import { + sweepToEth, + manageAccounts, + rotateProviders, + sweepToMainWallet, + getBatchEthBalance, +} from "./account"; import { diag, trace, @@ -627,6 +633,19 @@ export const main = async (argv: any, version?: string) => { roundSpan.setAttribute("didClear", false); } + // fecth account's balances + if (foundOpp && config.accounts.length) { + try { + const balances = await getBatchEthBalance( + config.accounts.map((v) => v.account.address), + config.viemClient as any as ViemClient, + ); + config.accounts.forEach((v, i) => (v.BALANCE = balances[i])); + } catch { + /**/ + } + } + // keep avg gas cost if (roundAvgGasCost) { const _now = Date.now();