From 4646b12e33506d29960186c53ca0d41ed59de388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Fingen?= Date: Wed, 1 May 2024 11:46:13 +0100 Subject: [PATCH] fix: Remove _getTotalsFromLiquidateTrovesSequence_RecoveryMode --- contracts/src/TroveManager.sol | 70 ---------------------------------- 1 file changed, 70 deletions(-) diff --git a/contracts/src/TroveManager.sol b/contracts/src/TroveManager.sol index cee81b32..533f88c6 100644 --- a/contracts/src/TroveManager.sol +++ b/contracts/src/TroveManager.sol @@ -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. */