Skip to content

Commit a55e122

Browse files
committed
fix: remove throttle from es-toolkit
1 parent b9ae8e7 commit a55e122

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"axios-retry": "^4.5.0",
4141
"date-fns": "^4.1.0",
4242
"di-at-home": "^0.0.7",
43-
"es-toolkit": "^1.39.10",
4443
"esbuild": "^0.25.9",
4544
"husky": "^9.1.7",
4645
"lint-staged": "^16.1.6",

src/services/Scanner.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
import type {
22
CreditAccountData,
3-
CreditAccountServiceOptions,
4-
GearboxSDK,
53
GetCreditAccountsOptions,
64
ICreditAccountsService,
75
NetworkType,
86
} from "@gearbox-protocol/sdk";
97
import {
10-
AbstractCreditAccountService,
118
AddressSet,
129
hexEq,
1310
MAX_UINT256,
1411
PERCENTAGE_FACTOR,
1512
WAD,
1613
} from "@gearbox-protocol/sdk";
1714
import { iBotListV310Abi } from "@gearbox-protocol/sdk/abi/v310";
18-
import { getAlchemyUrl, getDrpcUrl } from "@gearbox-protocol/sdk/dev";
1915
import {
2016
iCreditManagerV3Abi,
2117
iPartialLiquidationBotV3Abi,
2218
} from "@gearbox-protocol/types/abi";
23-
import { throttle } from "es-toolkit";
24-
import type { Address, Block, HttpTransportConfig, PublicClient } from "viem";
25-
import { createPublicClient, getContract, http } from "viem";
19+
import type { Address, Block } from "viem";
20+
import { getContract } from "viem";
2621
import type { Config } from "../config/index.js";
2722
import { DI } from "../di.js";
2823
import { type ILogger, Logger } from "../log/index.js";
@@ -64,13 +59,7 @@ export class Scanner {
6459
#maxHealthFactor = MAX_UINT256;
6560
#minHealthFactor = 0n;
6661
#unwatch?: () => void;
67-
68-
constructor() {
69-
this.#notifyOnZeroHFAccounts = throttle(
70-
this.#notifyOnZeroHFAccounts,
71-
1000 * 60 * 5,
72-
);
73-
}
62+
#lastZeroHFNotification = 0;
7463

7564
public async launch(): Promise<void> {
7665
await this.liquidatorService.launch();
@@ -403,13 +392,18 @@ export class Scanner {
403392
return result;
404393
}
405394

406-
#notifyOnZeroHFAccounts = (count: number, badTokens: string): void => {
395+
#notifyOnZeroHFAccounts(count: number, badTokens: string): void {
396+
const now = Date.now();
397+
if (now - this.#lastZeroHFNotification < 1000 * 60 * 5) {
398+
return;
399+
}
400+
this.#lastZeroHFNotification = now;
407401
this.log.debug("notifying on zero HF accounts");
408402
this.notifier.alert({
409403
plain: `found ${count} accounts with HF=0, bad tokens: ${badTokens}`,
410404
markdown: `found ${count} accounts with HF=0, bad tokens: ${badTokens}`,
411405
});
412-
};
406+
}
413407

414408
public get lastUpdated(): bigint {
415409
return this.#lastUpdated;

yarn.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,6 @@ __metadata:
17891789
axios-retry: "npm:^4.5.0"
17901790
date-fns: "npm:^4.1.0"
17911791
di-at-home: "npm:^0.0.7"
1792-
es-toolkit: "npm:^1.39.10"
17931792
esbuild: "npm:^0.25.9"
17941793
husky: "npm:^9.1.7"
17951794
lint-staged: "npm:^16.1.6"
@@ -3866,18 +3865,6 @@ __metadata:
38663865
languageName: node
38673866
linkType: hard
38683867

3869-
"es-toolkit@npm:^1.39.10":
3870-
version: 1.39.10
3871-
resolution: "es-toolkit@npm:1.39.10"
3872-
dependenciesMeta:
3873-
"@trivago/prettier-plugin-sort-imports@4.3.0":
3874-
unplugged: true
3875-
prettier-plugin-sort-re-exports@0.0.1:
3876-
unplugged: true
3877-
checksum: 10c0/244dd6be25bc8c7af9f085f5b9aae08169eca760fc7d4735020f8f711b6a572e0bf205400326fa85a7924e20747d315756dba1b3a5f0d2887231374ec3651a98
3878-
languageName: node
3879-
linkType: hard
3880-
38813868
"esbuild@npm:^0.25.0, esbuild@npm:^0.25.9, esbuild@npm:~0.25.0":
38823869
version: 0.25.9
38833870
resolution: "esbuild@npm:0.25.9"

0 commit comments

Comments
 (0)