Skip to content

Commit

Permalink
Merge branch 'master' into pxrl/cleanupConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Dec 8, 2024
2 parents 0dfdbd5 + e32d3de commit ed11c49
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/monitor/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ import {
getWidestPossibleExpectedBlockRange,
utils,
} from "../utils";

import { MonitorClients, updateMonitorClients } from "./MonitorClientHelper";
import { MonitorConfig } from "./MonitorConfig";
import { CombinedRefunds } from "../dataworker/DataworkerUtils";
import { PUBLIC_NETWORKS } from "@across-protocol/constants";

// 60 minutes, which is the length of the challenge window, so if a rebalance takes longer than this to finalize,
// then its finalizing after the subsequent challenge period has started, which is sub-optimal.
Expand Down Expand Up @@ -296,17 +296,20 @@ export class Monitor {
message: `Balance report for ${relayer} 📖`,
mrkdwn,
});

// Note: types are here for clarity, not necessity.

Object.entries(reports).forEach(([relayer, balanceTable]) => {
Object.entries(balanceTable).forEach(([tokenSymbol, columns]) => {
const decimals = allL1Tokens.find((token) => token.symbol === tokenSymbol)?.decimals;
if (!decimals) {
throw new Error(`No decimals found for ${tokenSymbol}`);
}
Object.entries(columns).forEach(([chainName, cell]) => {
}
Object.entries(reports).forEach(([relayer, balanceTable]) => {
Object.entries(balanceTable).forEach(([tokenSymbol, columns]) => {
const decimals = allL1Tokens.find((token) => token.symbol === tokenSymbol)?.decimals;
if (!decimals) {
throw new Error(`No decimals found for ${tokenSymbol}`);
}
Object.entries(columns).forEach(([chainName, cell]) => {
if (this._tokenEnabledForNetwork(tokenSymbol, chainName)) {
Object.entries(cell).forEach(([balanceType, balance]) => {
// Don't log zero balances.
if (balance.isZero()) {
return;
}
this.logger.debug({
at: "Monitor#reportRelayerBalances",
message: "Machine-readable single balance report",
Expand All @@ -320,10 +323,10 @@ export class Monitor {
datadog: true,
});
});
});
}
});
});
}
});
}

// Update current balances of all tokens on each supported chain for each relayer.
Expand Down Expand Up @@ -1289,4 +1292,13 @@ export class Monitor {
})
);
}

private _tokenEnabledForNetwork(tokenSymbol: string, networkName: string): boolean {
for (const [chainId, network] of Object.entries(PUBLIC_NETWORKS)) {
if (network.name === networkName) {
return isDefined(TOKEN_SYMBOLS_MAP[tokenSymbol]?.addresses[chainId]);
}
}
return false;
}
}

0 comments on commit ed11c49

Please sign in to comment.