Skip to content

Commit f8adbb1

Browse files
committed
fix: correct isExpired check
1 parent 433a13e commit f8adbb1

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@gearbox-protocol/cli-utils": "^5.61.1",
3131
"@gearbox-protocol/liquidator-contracts": "^1.36.0-experimental.67",
3232
"@gearbox-protocol/liquidator-v2-contracts": "^2.4.0",
33-
"@gearbox-protocol/sdk": "11.9.0",
33+
"@gearbox-protocol/sdk": "11.10.0",
3434
"@gearbox-protocol/types": "^1.14.8",
3535
"@types/node": "^24.10.1",
3636
"@uniswap/sdk-core": "^7.9.0",

src/services/Scanner.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export class Scanner {
269269
): Promise<CreditAccountData[]> {
270270
const timestamp = this.caService.sdk.timestamp;
271271
const expiredCMs = new AddressSet();
272+
const expiredCmNames: string[] = [];
272273

273274
for (const m of this.caService.sdk.marketRegister.markets) {
274275
// nothing borrowed === no accounts
@@ -279,20 +280,17 @@ export class Scanner {
279280
const borrowed =
280281
m.pool.pool.creditManagerDebtParams.get(cm.creditManager.address)
281282
?.borrowed ?? 0n;
282-
const expired =
283-
cm.creditFacade.expirable &&
284-
cm.creditFacade.expirationDate < timestamp;
285283

286-
if (expired && borrowed > 0n) {
284+
if (cm.isExpired && borrowed > 0n) {
287285
expiredCMs.add(cm.creditManager.address);
286+
expiredCmNames.push(`${m.pool.pool.name} - ${cm.creditManager.name}`);
288287
}
289288
}
290289
}
291290

292291
if (expiredCMs.size === 0) {
293292
return [];
294293
}
295-
this.log.info(`found ${expiredCMs.size} expired credit managers`);
296294

297295
let result: CreditAccountData[] = [];
298296
if (this.config.optimistic) {

src/services/liquidate/LiquidationStrategyFull.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ export default class LiquidationStrategyFull
169169
const isV310 = this.checkAccountVersion(ca, VERSION_RANGE_310);
170170
const ignoreReservePrices = !this.config.updateReservePrices && isV310;
171171
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
172-
// TODO: try to liquidate with debt only, then normally as a fallback
173-
const expired =
174-
cm.creditFacade.expirable &&
175-
cm.creditFacade.expirationDate < this.sdk.timestamp;
176172
const { tx, routerCloseResult, calls } =
177173
await this.creditAccountService.fullyLiquidate({
178174
account: ca,
@@ -181,7 +177,8 @@ export default class LiquidationStrategyFull
181177
keepAssets: this.config.keepAssets,
182178
ignoreReservePrices,
183179
applyLossPolicy: this.#applyLossPolicy,
184-
debtOnly: expired,
180+
// TODO: try to liquidate with debt only, then normally as a fallback
181+
debtOnly: cm.isExpired,
185182
});
186183
return { ...routerCloseResult, calls, rawTx: tx };
187184
} catch (e) {

yarn.lock

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ __metadata:
19291929
"@gearbox-protocol/cli-utils": "npm:^5.61.1"
19301930
"@gearbox-protocol/liquidator-contracts": "npm:^1.36.0-experimental.67"
19311931
"@gearbox-protocol/liquidator-v2-contracts": "npm:^2.4.0"
1932-
"@gearbox-protocol/sdk": "npm:11.9.0"
1932+
"@gearbox-protocol/sdk": "npm:11.10.0"
19331933
"@gearbox-protocol/types": "npm:^1.14.8"
19341934
"@types/node": "npm:^24.10.1"
19351935
"@uniswap/sdk-core": "npm:^7.9.0"
@@ -1956,7 +1956,30 @@ __metadata:
19561956
languageName: unknown
19571957
linkType: soft
19581958

1959-
"@gearbox-protocol/sdk@npm:11.9.0, @gearbox-protocol/sdk@npm:>=11.8.4":
1959+
"@gearbox-protocol/sdk@npm:11.10.0":
1960+
version: 11.10.0
1961+
resolution: "@gearbox-protocol/sdk@npm:11.10.0"
1962+
dependencies:
1963+
"@gearbox-protocol/integrations-v3": "npm:1.51.1"
1964+
"@redstone-finance/evm-connector": "npm:^0.9.0"
1965+
"@redstone-finance/protocol": "npm:^0.9.0"
1966+
"@redstone-finance/sdk": "npm:^0.9.0"
1967+
"@types/bn.js": "npm:^5.2.0"
1968+
abitype: "npm:^1.2.0"
1969+
bn.js: "npm:^5.2.2"
1970+
buffer: "npm:^6.0.3"
1971+
date-fns: "npm:^4.1.0"
1972+
decimal.js-light: "npm:^2.5.1"
1973+
viem: "npm:>=2.23.15 <3.0.0"
1974+
zod: "npm:^4.1.13"
1975+
peerDependencies:
1976+
axios: ^1.0.0
1977+
viem-deal: ^2.0.4
1978+
checksum: 10c0/c79c252294028088eb4f86dc0b5b6ecc798bf8e79c91c8e553f0e3b3ccbafe28aa9c6b92ecaa956ed8d0ae388987b8ef0e1a459d5750fa264617ded3a73773b4
1979+
languageName: node
1980+
linkType: hard
1981+
1982+
"@gearbox-protocol/sdk@npm:>=11.8.4":
19601983
version: 11.9.0
19611984
resolution: "@gearbox-protocol/sdk@npm:11.9.0"
19621985
dependencies:

0 commit comments

Comments
 (0)