Skip to content

Commit

Permalink
fix: Remove _getTotalsFromLiquidateTrovesSequence_RecoveryMode
Browse files Browse the repository at this point in the history
  • Loading branch information
bingen committed May 1, 2024
1 parent b407fe8 commit 4646b12
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions contracts/src/TroveManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -530,76 +530,6 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager {
singleLiquidation.collToRedistribute = 0;
}

/*
* This function is used when the liquidateTroves sequence starts during Recovery Mode. However, it
* handle the case where the system *leaves* Recovery Mode, part way through the liquidation sequence
*/
function _getTotalsFromLiquidateTrovesSequence_RecoveryMode(
ContractsCache memory _contractsCache,
uint256 _price,
uint256 _boldInStabPool,
uint256 _n
) internal returns (LiquidationTotals memory totals) {
LocalVariables_LiquidationSequence memory vars;
LiquidationValues memory singleLiquidation;

vars.remainingBoldInStabPool = _boldInStabPool;
vars.backToNormalMode = false;
vars.entireSystemDebt = getEntireSystemDebt();
vars.entireSystemColl = getEntireSystemColl();

vars.troveId = _contractsCache.sortedTroves.getLast();
uint256 firstUser = _contractsCache.sortedTroves.getFirst();
for (vars.i = 0; vars.i < _n && vars.troveId != firstUser; vars.i++) {
// we need to cache it, because current trove is likely going to be deleted
uint256 nextUser = _contractsCache.sortedTroves.getPrev(vars.troveId);

vars.ICR = getCurrentICR(vars.troveId, _price);

if (!vars.backToNormalMode) {
// Break the loop if ICR is greater than MCR and Stability Pool is empty
if (vars.ICR >= MCR && vars.remainingBoldInStabPool == 0) break;

uint256 TCR = LiquityMath._computeCR(vars.entireSystemColl, vars.entireSystemDebt, _price);

singleLiquidation = _liquidateRecoveryMode(
_contractsCache.activePool,
_contractsCache.defaultPool,
vars.troveId,
vars.ICR,
vars.remainingBoldInStabPool,
TCR,
_price
);

// Update aggregate trackers
vars.remainingBoldInStabPool = vars.remainingBoldInStabPool - singleLiquidation.debtToOffset;
vars.entireSystemDebt = vars.entireSystemDebt - singleLiquidation.debtToOffset;
vars.entireSystemColl = vars.entireSystemColl - singleLiquidation.collToSendToSP
- singleLiquidation.collGasCompensation - singleLiquidation.collSurplus;

// Add liquidation values to their respective running totals
totals = _addLiquidationValuesToTotals(totals, singleLiquidation);

vars.backToNormalMode =
!_checkPotentialRecoveryMode(vars.entireSystemColl, vars.entireSystemDebt, _price);
} else if (vars.backToNormalMode && vars.ICR < MCR) {
singleLiquidation = _liquidateNormalMode(
_contractsCache.activePool, _contractsCache.defaultPool, vars.troveId, vars.remainingBoldInStabPool
);

vars.remainingBoldInStabPool = vars.remainingBoldInStabPool - singleLiquidation.debtToOffset;

// Add liquidation values to their respective running totals
totals = _addLiquidationValuesToTotals(totals, singleLiquidation);
} else {
break;
} // break if the loop reaches a Trove with ICR >= MCR

vars.troveId = nextUser;
}
}

/*
* Attempt to liquidate a custom list of troves provided by the caller.
*/
Expand Down

0 comments on commit 4646b12

Please sign in to comment.