|
1 | 1 | import type { |
2 | 2 | CreditAccountData, |
3 | | - CreditAccountServiceOptions, |
4 | | - GearboxSDK, |
5 | 3 | GetCreditAccountsOptions, |
6 | 4 | ICreditAccountsService, |
7 | 5 | NetworkType, |
8 | 6 | } from "@gearbox-protocol/sdk"; |
9 | 7 | import { |
10 | | - AbstractCreditAccountService, |
11 | 8 | AddressSet, |
12 | 9 | hexEq, |
13 | 10 | MAX_UINT256, |
14 | 11 | PERCENTAGE_FACTOR, |
15 | 12 | WAD, |
16 | 13 | } from "@gearbox-protocol/sdk"; |
17 | 14 | import { iBotListV310Abi } from "@gearbox-protocol/sdk/abi/v310"; |
18 | | -import { getAlchemyUrl, getDrpcUrl } from "@gearbox-protocol/sdk/dev"; |
19 | 15 | import { |
20 | 16 | iCreditManagerV3Abi, |
21 | 17 | iPartialLiquidationBotV3Abi, |
22 | 18 | } 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"; |
26 | 21 | import type { Config } from "../config/index.js"; |
27 | 22 | import { DI } from "../di.js"; |
28 | 23 | import { type ILogger, Logger } from "../log/index.js"; |
@@ -64,13 +59,7 @@ export class Scanner { |
64 | 59 | #maxHealthFactor = MAX_UINT256; |
65 | 60 | #minHealthFactor = 0n; |
66 | 61 | #unwatch?: () => void; |
67 | | - |
68 | | - constructor() { |
69 | | - this.#notifyOnZeroHFAccounts = throttle( |
70 | | - this.#notifyOnZeroHFAccounts, |
71 | | - 1000 * 60 * 5, |
72 | | - ); |
73 | | - } |
| 62 | + #lastZeroHFNotification = 0; |
74 | 63 |
|
75 | 64 | public async launch(): Promise<void> { |
76 | 65 | await this.liquidatorService.launch(); |
@@ -403,13 +392,18 @@ export class Scanner { |
403 | 392 | return result; |
404 | 393 | } |
405 | 394 |
|
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; |
407 | 401 | this.log.debug("notifying on zero HF accounts"); |
408 | 402 | this.notifier.alert({ |
409 | 403 | plain: `found ${count} accounts with HF=0, bad tokens: ${badTokens}`, |
410 | 404 | markdown: `found ${count} accounts with HF=0, bad tokens: ${badTokens}`, |
411 | 405 | }); |
412 | | - }; |
| 406 | + } |
413 | 407 |
|
414 | 408 | public get lastUpdated(): bigint { |
415 | 409 | return this.#lastUpdated; |
|
0 commit comments