Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: only log relayer balances for tokens on supported chains #1938

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 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 @@ -306,20 +306,22 @@ export class Monitor {
throw new Error(`No decimals found for ${tokenSymbol}`);
}
Object.entries(columns).forEach(([chainName, cell]) => {
Object.entries(cell).forEach(([balanceType, balance]) => {
this.logger.debug({
at: "Monitor#reportRelayerBalances",
message: "Machine-readable single balance report",
relayer,
tokenSymbol,
decimals,
chainName,
balanceType,
balanceInWei: balance.toString(),
balance: Number(utils.formatUnits(balance, decimals)),
datadog: true,
if (this._tokenEnabledForNetwork(tokenSymbol, chainName)) {
Object.entries(cell).forEach(([balanceType, balance]) => {
this.logger.debug({
at: "Monitor#reportRelayerBalances",
message: "Machine-readable single balance report",
relayer,
tokenSymbol,
decimals,
chainName,
balanceType,
balanceInWei: balance.toString(),
balance: Number(utils.formatUnits(balance, decimals)),
datadog: true,
});
});
});
}
});
});
});
Expand Down Expand Up @@ -1289,4 +1291,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;
}
}
Loading