Skip to content

Commit

Permalink
improve: allow the monitored balances error/warn thresholds to be zero (
Browse files Browse the repository at this point in the history
#2019)

Signed-off-by: bennett <[email protected]>
  • Loading branch information
bmzig authored Jan 27, 2025
1 parent ad198e6 commit 49a0804
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/monitor/MonitorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import winston from "winston";
import { CommonConfig, ProcessEnv } from "../common";
import { ethers, getNativeTokenAddressForChain } from "../utils";
import { ethers, getNativeTokenAddressForChain, isDefined } from "../utils";

// Set modes to true that you want to enable in the AcrossMonitor bot.
export interface BotModes {
Expand Down Expand Up @@ -143,20 +143,20 @@ export class MonitorConfig extends CommonConfig {
if (MONITORED_BALANCES) {
this.monitoredBalances = JSON.parse(MONITORED_BALANCES).map(
({ errorThreshold, warnThreshold, account, token, chainId }) => {
if (!errorThreshold && !warnThreshold) {
if (!isDefined(errorThreshold) && !isDefined(warnThreshold)) {
throw new Error("Must provide either an errorThreshold or a warnThreshold");
}

let parsedErrorThreshold: number | null = null;
if (errorThreshold) {
if (isDefined(errorThreshold)) {
if (Number.isNaN(Number(errorThreshold))) {
throw new Error(`errorThreshold value: ${errorThreshold} cannot be converted to a number`);
}
parsedErrorThreshold = Number(errorThreshold);
}

let parsedWarnThreshold: number | null = null;
if (warnThreshold) {
if (isDefined(warnThreshold)) {
if (Number.isNaN(Number(errorThreshold))) {
throw new Error(`warnThreshold value: ${warnThreshold} cannot be converted to a number`);
}
Expand Down

0 comments on commit 49a0804

Please sign in to comment.