Skip to content

Commit

Permalink
fix: support limiting CMs to underlying in v3
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Feb 6, 2024
1 parent 331ae3d commit b6ca446
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/scan/ScanServiceV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CreditAccountData,
IAddressProviderV3__factory,
IDataCompressorV3_00__factory,
tokenSymbolByAddress,
} from "@gearbox-protocol/sdk";
import { ethers, type providers } from "ethers";
import { Inject, Service } from "typedi";
Expand Down Expand Up @@ -61,7 +62,16 @@ export class ScanServiceV3 extends AbstractScanService {
await this.dataCompressor.callStatic.getLiquidatableCreditAccounts([], {
blockTag: atBlock,
});
const accounts = accountsRaw.map(a => new CreditAccountData(a));
let accounts = accountsRaw.map(a => new CreditAccountData(a));

// in optimistic mode, we can limit liquidations to all CM with provided underlying symbol
if (config.underlying) {
accounts = accounts.filter(a => {
const underlying = tokenSymbolByAddress[a.underlyingToken];
return config.underlying?.toLowerCase() === underlying?.toLowerCase();
});
}

this.log.debug(
`v3 accounts to liquidate in ${atBlock}: ${accounts.length}`,
);
Expand Down

0 comments on commit b6ca446

Please sign in to comment.