Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Nov 20, 2024
1 parent 4bb6a6c commit 5cb2450
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
9 changes: 0 additions & 9 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 20 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5cb2450

Please sign in to comment.