File tree Expand file tree Collapse file tree 4 files changed +287
-260
lines changed
Expand file tree Collapse file tree 4 files changed +287
-260
lines changed Original file line number Diff line number Diff line change 2121 "pino-pretty" : " ^13.1.3"
2222 },
2323 "devDependencies" : {
24- "@aws-sdk/client-s3" : " ^3.956 .0" ,
24+ "@aws-sdk/client-s3" : " ^3.957 .0" ,
2525 "@biomejs/biome" : " ^2.3.10" ,
2626 "@commander-js/extra-typings" : " ^14.0.0" ,
2727 "@commitlint/cli" : " ^20.2.0" ,
Original file line number Diff line number Diff line change @@ -12,6 +12,20 @@ export const FullLiquidatorSchema = z.object({
1212 description : "Liquidator mode (full/partial/batch/deleverage)" ,
1313 env : "LIQUIDATION_MODE" ,
1414 } ) ,
15+ /**
16+ * Debt policy
17+ * full - liquidate fully
18+ * debt-only - try to liquidate only debt
19+ * debt-expired - try to liquidate only debt for expired accounts
20+ */
21+ debtPolicy : z
22+ . enum ( [ "full" , "debt-only" , "debt-expired" ] )
23+ . default ( "full" )
24+ . register ( zommandRegistry , {
25+ flags : "--debt-policy <policy>" ,
26+ description : "Liquidate fully/debt only/debt only for expired accounts" ,
27+ env : "DEBT_POLICY" ,
28+ } ) ,
1529 /**
1630 * Whether we should apply loss policy on full liquidation of accounts with bad debt
1731 */
Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ 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+ const debtOnly =
173+ this . config . debtPolicy === "debt-only" ||
174+ ( this . config . debtPolicy === "debt-expired" && cm . isExpired ) ;
172175 const { tx, routerCloseResult, calls } =
173176 await this . creditAccountService . fullyLiquidate ( {
174177 account : ca ,
@@ -177,8 +180,7 @@ export default class LiquidationStrategyFull
177180 keepAssets : this . config . keepAssets ,
178181 ignoreReservePrices,
179182 applyLossPolicy : this . #applyLossPolicy,
180- // TODO: try to liquidate with debt only, then normally as a fallback
181- debtOnly : cm . isExpired ,
183+ debtOnly,
182184 } ) ;
183185 return { ...routerCloseResult , calls, rawTx : tx } ;
184186 } catch ( e ) {
You can’t perform that action at this time.
0 commit comments