File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed
Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ import type {
33 GearboxSDK ,
44 ICreditAccountsService ,
55 MultiCall ,
6+ VersionRange ,
67} from "@gearbox-protocol/sdk" ;
7- import { filterDust } from "@gearbox-protocol/sdk" ;
8+ import { filterDust , isVersionRange } from "@gearbox-protocol/sdk" ;
89import { ierc20MetadataAbi } from "@gearbox-protocol/types/abi" ;
910import type { OptimisticResult } from "@gearbox-protocol/types/optimist" ;
1011import type { Address , TransactionReceipt } from "viem" ;
@@ -160,4 +161,14 @@ export default abstract class AbstractLiquidator<TConfig extends CommonSchema> {
160161 }
161162 return this . #errorHandler;
162163 }
164+
165+ protected checkAccountVersion (
166+ ca : CreditAccountData ,
167+ v : VersionRange ,
168+ ) : boolean {
169+ return isVersionRange (
170+ this . sdk . contracts . mustGet ( ca . creditFacade ) . version ,
171+ v ,
172+ ) ;
173+ }
163174}
Original file line number Diff line number Diff line change 1- import type { CreditAccountData } from "@gearbox-protocol/sdk" ;
1+ import {
2+ type CreditAccountData ,
3+ VERSION_RANGE_310 ,
4+ } from "@gearbox-protocol/sdk" ;
25import { iCreditFacadeV3Abi } from "@gearbox-protocol/types/abi" ;
36import { decodeFunctionData , type SimulateContractReturnType } from "viem" ;
47import type { FullLiquidatorSchema } from "../../config/index.js" ;
@@ -35,13 +38,15 @@ export default class SingularFullLiquidator extends SingularLiquidator<
3538
3639 public async preview ( ca : CreditAccountData ) : Promise < FullLiquidationPreview > {
3740 try {
41+ const isV310 = this . checkAccountVersion ( ca , VERSION_RANGE_310 ) ;
42+ const ignoreReservePrices = ! this . config . updateReservePrices && isV310 ;
3843 const { tx, routerCloseResult, calls } =
3944 await this . creditAccountService . fullyLiquidate ( {
4045 account : ca ,
4146 to : this . client . address ,
4247 slippage : BigInt ( this . config . slippage ) ,
4348 keepAssets : this . config . keepAssets ,
44- ignoreReservePrices : ! this . config . updateReservePrices ,
49+ ignoreReservePrices,
4550 } ) ;
4651 return { ...routerCloseResult , calls, rawTx : tx } ;
4752 } catch ( e ) {
Original file line number Diff line number Diff line change 1- import type { CreditAccountData } from "@gearbox-protocol/sdk" ;
1+ import {
2+ type CreditAccountData ,
3+ VERSION_RANGE_310 ,
4+ } from "@gearbox-protocol/sdk" ;
25import {
36 calcLiquidatableLTs ,
47 createAnvilClient ,
@@ -143,13 +146,16 @@ export default class SingularPartialLiquidator extends SingularLiquidator<
143146 async #preview( ca : CreditAccountData ) : Promise < PartialLiquidationPreview > {
144147 const logger = this . caLogger ( ca ) ;
145148 const cm = this . sdk . marketRegister . findCreditManager ( ca . creditManager ) ;
149+ const isV310 = this . checkAccountVersion ( ca , VERSION_RANGE_310 ) ;
150+ const ignoreReservePrices =
151+ isV310 &&
152+ ! this . config . updateReservePrices &&
153+ this . config . liquidationMode !== "deleverage" ;
146154 const priceUpdates =
147155 await this . creditAccountService . getOnDemandPriceUpdates ( {
148156 creditManager : ca . creditManager ,
149157 creditAccount : ca ,
150- ignoreReservePrices :
151- ! this . config . updateReservePrices &&
152- this . config . liquidationMode !== "deleverage" ,
158+ ignoreReservePrices,
153159 } ) ;
154160 const liquidatorContract = this . liquidatorForCA ( ca ) ;
155161 if ( ! liquidatorContract ) {
You can’t perform that action at this time.
0 commit comments