diff --git a/contracts/src/BorrowerOperations.sol b/contracts/src/BorrowerOperations.sol index 7c5fac10..3063f82f 100644 --- a/contracts/src/BorrowerOperations.sol +++ b/contracts/src/BorrowerOperations.sol @@ -284,7 +284,7 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe // TODO: Use oldDebt and assert in fuzzing, remove before deployment uint256 oldDebt = troveManager.getTroveEntireDebt(_troveId); _adjustTrove(msg.sender, _troveId, 0, false, _boldAmount, false, 0, contractsCache); - assert(troveManager.getTroveEntireDebt(_troveId) < oldDebt); + assert(troveManager.getTroveEntireDebt(_troveId) < oldDebt); } function adjustTrove( @@ -298,12 +298,19 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe ContractsCacheTMAPBT memory contractsCache = ContractsCacheTMAPBT(troveManager, activePool, boldToken); _requireTroveIsActive(contractsCache.troveManager, _troveId); _adjustTrove( - msg.sender, _troveId, _collChange, _isCollIncrease, _boldChange, _isDebtIncrease, _maxFeePercentage, contractsCache + msg.sender, + _troveId, + _collChange, + _isCollIncrease, + _boldChange, + _isDebtIncrease, + _maxFeePercentage, + contractsCache ); } function adjustUnredeemableTrove( - uint256 _troveId, + uint256 _troveId, uint256 _maxFeePercentage, uint256 _collChange, bool _isCollIncrease, @@ -314,12 +321,21 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe ) external override { ContractsCacheTMAPBT memory contractsCache = ContractsCacheTMAPBT(troveManager, activePool, boldToken); _requireTroveIsUnredeemable(contractsCache.troveManager, _troveId); - // TODO: Gas - pass the cached TM down here, since we fetch it again inside _adjustTrove? + // TODO: Gas - pass the cached TM down here, since we fetch it again inside _adjustTrove? _adjustTrove( - msg.sender, _troveId, _collChange, _isCollIncrease, _boldChange, _isDebtIncrease, _maxFeePercentage, contractsCache + msg.sender, + _troveId, + _collChange, + _isCollIncrease, + _boldChange, + _isDebtIncrease, + _maxFeePercentage, + contractsCache ); troveManager.setTroveStatusToActive(_troveId); - sortedTroves.insert(_troveId, contractsCache.troveManager.getTroveAnnualInterestRate(_troveId), _upperHint, _lowerHint); + sortedTroves.insert( + _troveId, contractsCache.troveManager.getTroveAnnualInterestRate(_troveId), _upperHint, _lowerHint + ); } function adjustTroveInterestRate( @@ -636,17 +652,19 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe uint256 _boldChange, bool _isDebtIncrease ) internal { - if (_isDebtIncrease) { // implies _boldChange > 0 + if (_isDebtIncrease) { + // implies _boldChange > 0 address borrower = _troveManager.ownerOf(_troveId); _boldToken.mint(borrower, _boldChange); - } else if (_boldChange > 0 ){ + } else if (_boldChange > 0) { _boldToken.burn(msg.sender, _boldChange); } - if (_isCollIncrease) { // implies _collChange > 0 + if (_isCollIncrease) { + // implies _collChange > 0 // Pull ETH tokens from sender and move them to the Active Pool _pullETHAndSendToActivePool(_activePool, _collChange); - } else if (_collChange > 0 ){ + } else if (_collChange > 0) { address borrower = _troveManager.ownerOf(_troveId); // Pull ETH from Active Pool and decrease its recorded ETH balance _activePool.sendETH(borrower, _collChange); @@ -713,11 +731,13 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe } function _requireTroveIsUnredeemable(ITroveManager _troveManager, uint256 _troveId) internal view { - require(_troveManager.checkTroveIsUnredeemable(_troveId), "BorrowerOps: Trove does not have unredeemable status"); + require( + _troveManager.checkTroveIsUnredeemable(_troveId), "BorrowerOps: Trove does not have unredeemable status" + ); } - function _requireTroveIsNotOpen(ITroveManager _troveManager, uint256 _troveId) internal view { - require(!_troveManager.checkTroveIsOpen(_troveId),"BorrowerOps: Trove is open"); + function _requireTroveIsNotOpen(ITroveManager _troveManager, uint256 _troveId) internal view { + require(!_troveManager.checkTroveIsOpen(_troveId), "BorrowerOps: Trove is open"); } function _requireNonZeroCollChange(uint256 _collChange) internal pure { diff --git a/contracts/src/HintHelpers.sol b/contracts/src/HintHelpers.sol index 89540cca..97baf19a 100644 --- a/contracts/src/HintHelpers.sol +++ b/contracts/src/HintHelpers.sol @@ -69,7 +69,7 @@ contract HintHelpers is LiquityBase, Ownable, CheckContract { uint256 currentId = troveManager.getTroveFromTroveIdsArray(arrayIndex); // Skip this Trove if it's unredeeamable and not in the sorted list - if (!sortedTroves.contains(currentId)) { continue; } + if (!sortedTroves.contains(currentId)) continue; uint256 currentInterestRate = troveManager.getTroveAnnualInterestRate(currentId); diff --git a/contracts/src/TroveManager.sol b/contracts/src/TroveManager.sol index 01d1f620..b07ce69f 100644 --- a/contracts/src/TroveManager.sol +++ b/contracts/src/TroveManager.sol @@ -555,7 +555,9 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager { if (collRedistributionPortion > 0) { (collToRedistribute, collSurplus) = _getCollPenaltyAndSurplus( collRedistributionPortion + collSurplus, // Coll surplus from offset can be eaten up by red. penalty - debtToRedistribute, LIQUIDATION_PENALTY_REDISTRIBUTION, _price + debtToRedistribute, + LIQUIDATION_PENALTY_REDISTRIBUTION, + _price ); } } @@ -1045,7 +1047,7 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager { uint256 snapshotETH = rewardSnapshots[_troveId].ETH; uint256 rewardPerUnitStaked = L_ETH - snapshotETH; - if (rewardPerUnitStaked == 0 || !checkTroveIsOpen(_troveId)) {return 0;} + if (rewardPerUnitStaked == 0 || !checkTroveIsOpen(_troveId)) return 0; uint256 stake = Troves[_troveId].stake; @@ -1059,7 +1061,7 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager { uint256 snapshotBoldDebt = rewardSnapshots[_troveId].boldDebt; uint256 rewardPerUnitStaked = L_boldDebt - snapshotBoldDebt; - if (rewardPerUnitStaked == 0 || !checkTroveIsOpen(_troveId)) {return 0;} + if (rewardPerUnitStaked == 0 || !checkTroveIsOpen(_troveId)) return 0; uint256 stake = Troves[_troveId].stake; @@ -1074,7 +1076,7 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager { * this indicates that rewards have occured since the snapshot was made, and the user therefore has * redistribution gains */ - if (!checkTroveIsOpen(_troveId)) {return false;} + if (!checkTroveIsOpen(_troveId)) return false; return (rewardSnapshots[_troveId].ETH < L_ETH); } @@ -1224,7 +1226,7 @@ contract TroveManager is ERC721, LiquityBase, Ownable, ITroveManager { rewardSnapshots[_troveId].boldDebt = 0; _removeTroveId(_troveId, TroveIdsArrayLength); - if (prevStatus == Status.active) {sortedTroves.remove(_troveId);} + if (prevStatus == Status.active) sortedTroves.remove(_troveId); // burn ERC721 // TODO: Should we do it? diff --git a/contracts/src/test/SortedTroves.t.sol b/contracts/src/test/SortedTroves.t.sol index 7f19ef76..258545ab 100644 --- a/contracts/src/test/SortedTroves.t.sol +++ b/contracts/src/test/SortedTroves.t.sol @@ -199,7 +199,7 @@ contract MockTroveManager { function _sortedTroves_removeFromBatch(TroveId id) external { _sortedTroves.removeFromBatch(TroveId.unwrap(id)); } - + function _sortedTroves_findInsertPosition(uint256 annualInterestRate, Hints memory hints) external view diff --git a/contracts/src/test/TestContracts/DevTestSetup.sol b/contracts/src/test/TestContracts/DevTestSetup.sol index e73a2481..7097e71e 100644 --- a/contracts/src/test/TestContracts/DevTestSetup.sol +++ b/contracts/src/test/TestContracts/DevTestSetup.sol @@ -168,7 +168,10 @@ contract DevTestSetup is BaseTest { return (ATroveId, BTroveId, CTroveId, DTroveId); } - function _setupForRedemption(TroveInterestRates memory _troveInterestRates) internal returns (uint256, uint256, TroveIDs memory) { + function _setupForRedemption(TroveInterestRates memory _troveInterestRates) + internal + returns (uint256, uint256, TroveIDs memory) + { TroveIDs memory troveIDs; priceFeed.setPrice(2000e18); @@ -202,11 +205,14 @@ contract DevTestSetup is BaseTest { return _setupForRedemption(troveInterestRates); } - - function _redeemAndCreateZombieTrovesAAndB(TroveIDs memory _troveIDs) internal returns (uint256, uint256, TroveIDs memory) { + function _redeemAndCreateZombieTrovesAAndB(TroveIDs memory _troveIDs) + internal + returns (uint256, uint256, TroveIDs memory) + { // Redeem enough to leave to leave A with 0 debt and B with debt < MIN_NET_DEBT uint256 redeemFromA = troveManager.getTroveEntireDebt(_troveIDs.A) - troveManager.BOLD_GAS_COMPENSATION(); - uint256 redeemFromB = troveManager.getTroveEntireDebt(_troveIDs.B) - troveManager.BOLD_GAS_COMPENSATION() - troveManager.MIN_NET_DEBT() / 2; + uint256 redeemFromB = troveManager.getTroveEntireDebt(_troveIDs.B) - troveManager.BOLD_GAS_COMPENSATION() + - troveManager.MIN_NET_DEBT() / 2; uint256 redeemAmount = redeemFromA + redeemFromB; // Fully redeem A and leave B with debt < MIN_NET_DEBT @@ -216,17 +222,21 @@ contract DevTestSetup is BaseTest { assertEq(troveManager.getTroveEntireDebt(_troveIDs.A), BOLD_GAS_COMP); assertLt(troveManager.getTroveEntireDebt(_troveIDs.B) - BOLD_GAS_COMP, troveManager.MIN_NET_DEBT()); - // Check A and B tagged as Zombie troves + // Check A and B tagged as Zombie troves assertEq(troveManager.getTroveStatus(_troveIDs.A), 5); // status 'unredeemable' assertEq(troveManager.getTroveStatus(_troveIDs.A), 5); // status 'unredeemable' } - function _redeemAndCreateZombieTroveAAndHitB(TroveIDs memory _troveIDs) internal returns (uint256, uint256, TroveIDs memory) { + function _redeemAndCreateZombieTroveAAndHitB(TroveIDs memory _troveIDs) + internal + returns (uint256, uint256, TroveIDs memory) + { // Redeem enough to leave to leave A with 0 debt and B with debt < MIN_NET_DEBT uint256 redeemFromA = troveManager.getTroveEntireDebt(_troveIDs.A) - troveManager.BOLD_GAS_COMPENSATION(); // Leave B with net_debt > min_net_debt - uint256 redeemFromB = troveManager.getTroveEntireDebt(_troveIDs.B) - troveManager.BOLD_GAS_COMPENSATION() - troveManager.MIN_NET_DEBT() - 37; - + uint256 redeemFromB = troveManager.getTroveEntireDebt(_troveIDs.B) - troveManager.BOLD_GAS_COMPENSATION() + - troveManager.MIN_NET_DEBT() - 37; + uint256 redeemAmount = redeemFromA + redeemFromB; // Fully redeem A and leave B with debt > MIN_NET_DEBT diff --git a/contracts/src/test/interestRateAggregate.t.sol b/contracts/src/test/interestRateAggregate.t.sol index b3a613e9..a9e198fe 100644 --- a/contracts/src/test/interestRateAggregate.t.sol +++ b/contracts/src/test/interestRateAggregate.t.sol @@ -2570,7 +2570,7 @@ contract InterestRateAggregate is DevTestSetup { // Check recorded debt sum has changed correctly assertEq(activePool.aggWeightedDebtSum(), expectedAggWeightedRecordedDebt); } - + // TODO: mixed collateral & debt adjustment opps // TODO: tests with pending debt redist. gain >0 // TODO: tests that show total debt change under user ops diff --git a/contracts/src/test/multicollateral.t.sol b/contracts/src/test/multicollateral.t.sol index ab208d8f..2017a3e1 100644 --- a/contracts/src/test/multicollateral.t.sol +++ b/contracts/src/test/multicollateral.t.sol @@ -176,13 +176,11 @@ contract MulticollateralTest is DevTestSetup { _spBoldAmount2 = bound(_spBoldAmount2, 0, boldAmount - 200e18); _spBoldAmount3 = bound(_spBoldAmount3, 0, boldAmount - 200e18); _spBoldAmount4 = bound(_spBoldAmount4, 0, boldAmount - 200e18 - minBoldBalance); - _redemptionFraction = bound( - _redemptionFraction, - DECIMAL_PRECISION / minBoldBalance, - DECIMAL_PRECISION - ); + _redemptionFraction = bound(_redemptionFraction, DECIMAL_PRECISION / minBoldBalance, DECIMAL_PRECISION); - _testMultiCollateralRedemption(boldAmount, _spBoldAmount1, _spBoldAmount2, _spBoldAmount3, _spBoldAmount4, _redemptionFraction); + _testMultiCollateralRedemption( + boldAmount, _spBoldAmount1, _spBoldAmount2, _spBoldAmount3, _spBoldAmount4, _redemptionFraction + ); } function testMultiCollateralRedemptionMaxSPAmount() public { @@ -225,7 +223,6 @@ contract MulticollateralTest is DevTestSetup { testValues3.price = contractsArray[2].priceFeed.getPrice(); testValues4.price = contractsArray[3].priceFeed.getPrice(); - // First collateral openMulticollateralTroveNoHints100pctMaxFeeWithIndex(0, A, 0, 10e18, _boldAmount, 5e16); if (_spBoldAmount1 > 0) makeMulticollateralSPDeposit(0, A, _spBoldAmount1); diff --git a/contracts/src/test/redemptions.t.sol b/contracts/src/test/redemptions.t.sol index 6acdb972..2cbeed4b 100644 --- a/contracts/src/test/redemptions.t.sol +++ b/contracts/src/test/redemptions.t.sol @@ -4,7 +4,7 @@ import "./TestContracts/DevTestSetup.sol"; contract Redemptions is DevTestSetup { function testRedemptionIsInOrderOfInterestRate() public { - (uint256 coll, , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (uint256 coll,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); uint256 debt_A = troveManager.getTroveEntireDebt(troveIDs.A); uint256 debt_B = troveManager.getTroveEntireDebt(troveIDs.B); @@ -43,7 +43,7 @@ contract Redemptions is DevTestSetup { // - Troves can be redeemed down to gas comp function testFullRedemptionDoesntCloseTroves() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); uint256 debt_A = troveManager.getTroveEntireDebt(troveIDs.A); uint256 debt_B = troveManager.getTroveEntireDebt(troveIDs.B); @@ -58,7 +58,7 @@ contract Redemptions is DevTestSetup { } function testFullRedemptionLeavesTrovesWithDebtEqualToGasComp() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); uint256 debt_A = troveManager.getTroveEntireDebt(troveIDs.A); uint256 debt_B = troveManager.getTroveEntireDebt(troveIDs.B); @@ -73,7 +73,7 @@ contract Redemptions is DevTestSetup { } function testFullRedemptionSkipsTrovesAtGasCompDebt() public { - (uint256 coll, , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (uint256 coll,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); uint256 debt_A = troveManager.getTroveEntireDebt(troveIDs.A); uint256 debt_B = troveManager.getTroveEntireDebt(troveIDs.B); @@ -105,7 +105,7 @@ contract Redemptions is DevTestSetup { // - Accrued Trove interest contributes to redee into debt of a redeemed trove function testRedemptionIncludesAccruedTroveInterest() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); // Fast-forward to generate interest vm.warp(block.timestamp + 1 days); @@ -132,7 +132,7 @@ contract Redemptions is DevTestSetup { // --- Zombie Troves --- function testFullyRedeemedTroveBecomesZombieTrove() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -140,7 +140,7 @@ contract Redemptions is DevTestSetup { } function testTroveRedeemedToBelowMIN_NET_DEBTBecomesZombieTrove() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -148,7 +148,7 @@ contract Redemptions is DevTestSetup { } function testTroveRedeemedToAboveMIN_NET_DEBTDoesNotBecomesZombieTrove() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTroveAAndHitB(troveIDs); @@ -156,7 +156,7 @@ contract Redemptions is DevTestSetup { } function testZombieTrovesRemovedFromSortedList() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); // Check A,B,C,D in sorted list assertTrue(sortedTroves.contains(troveIDs.A)); @@ -177,7 +177,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveCantBeRedeemedFrom() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -201,11 +201,11 @@ contract Redemptions is DevTestSetup { function testZombieTrovesCanReceiveRedistGains() public { uint256 interestRate_E = 5e16; // 5% uint256 troveDebtRequest_E = 2250e18; - uint256 troveColl_E = 25e17; + uint256 troveColl_E = 25e17; uint256 price = 2000e18; priceFeed.setPrice(price); - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -236,7 +236,7 @@ contract Redemptions is DevTestSetup { troveInterestRates.C = 3e17; // 30% troveInterestRates.D = 4e17; // 40% - ( , , TroveIDs memory troveIDs) = _setupForRedemption(troveInterestRates); + (,, TroveIDs memory troveIDs) = _setupForRedemption(troveInterestRates); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -254,7 +254,7 @@ contract Redemptions is DevTestSetup { uint256 expectedDebt_B = debt_B * (1e18 + troveInterestRates.B) / 1e18; // 20% increase assertEq(troveManager.getTroveEntireDebt(troveIDs.A), expectedDebt_A); // 10% increase - assertEq(troveManager.getTroveEntireDebt(troveIDs.B), expectedDebt_B); // 20% increase + assertEq(troveManager.getTroveEntireDebt(troveIDs.B), expectedDebt_B); // 20% increase } function testZombieTrovesCanAccrueInterestThatBringThemAboveMIN_NET_DEBT() public { @@ -264,18 +264,18 @@ contract Redemptions is DevTestSetup { troveInterestRates.C = 3e17; // 30% troveInterestRates.D = 4e17; // 40% - ( , , TroveIDs memory troveIDs) = _setupForRedemption(troveInterestRates); + (,, TroveIDs memory troveIDs) = _setupForRedemption(troveInterestRates); _redeemAndCreateZombieTrovesAAndB(troveIDs); assertLt(troveManager.getTroveEntireDebt(troveIDs.A), troveManager.MIN_NET_DEBT()); - assertLt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); + assertLt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); // 100 years passes vm.warp(block.timestamp + 36500 days); assertGt(troveManager.getTroveEntireDebt(troveIDs.A), troveManager.MIN_NET_DEBT()); - assertGt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); + assertGt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); } function testZombieTrovesCanReceiveRedistGainsThatBringThemAboveMIN_NET_DEBT() public { @@ -286,7 +286,7 @@ contract Redemptions is DevTestSetup { uint256 price = 2000e18; priceFeed.setPrice(price); - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -302,9 +302,9 @@ contract Redemptions is DevTestSetup { assertLt(troveManager.getCurrentICR(troveID_E, price), troveManager.MCR()); assertLt(troveManager.getTroveEntireDebt(troveIDs.A), troveManager.MIN_NET_DEBT()); - assertLt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); + assertLt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); - // A liquidates E + // A liquidates E liquidate(A, troveID_E); assertEq(troveManager.getTroveStatus(troveID_E), 3); // Status 3 - closed by liquidation @@ -312,13 +312,13 @@ contract Redemptions is DevTestSetup { assertTrue(troveManager.hasRedistributionGains(troveIDs.B)); assertGt(troveManager.getTroveEntireDebt(troveIDs.A), troveManager.MIN_NET_DEBT()); - assertGt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); + assertGt(troveManager.getTroveEntireDebt(troveIDs.B), troveManager.MIN_NET_DEBT()); } // --- Borrower ops on zombie troves --- function testZombieBorrowerCanCloseZombieTrove() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -337,7 +337,7 @@ contract Redemptions is DevTestSetup { } function testZombieBorrowerCanDrawFreshDebtToAboveMIN_NET_DEBT() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -355,27 +355,13 @@ contract Redemptions is DevTestSetup { // A and B withdraw Bold from their zombie Trove vm.startPrank(A); borrowerOperations.adjustUnredeemableTrove( - troveIDs.A, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.A, - troveIDs.A + troveIDs.A, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.A, troveIDs.A ); vm.stopPrank(); vm.startPrank(B); borrowerOperations.adjustUnredeemableTrove( - troveIDs.B, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.B, - troveIDs.B + troveIDs.B, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.B, troveIDs.B ); vm.stopPrank(); @@ -385,7 +371,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveDrawingFreshDebtToAboveMIN_NET_DEBTChangesStatusToActive() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -403,27 +389,13 @@ contract Redemptions is DevTestSetup { // A and B withdraw Bold from their zombie Trove vm.startPrank(A); borrowerOperations.adjustUnredeemableTrove( - troveIDs.A, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.A, - troveIDs.A + troveIDs.A, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.A, troveIDs.A ); vm.stopPrank(); vm.startPrank(B); borrowerOperations.adjustUnredeemableTrove( - troveIDs.B, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.B, - troveIDs.B + troveIDs.B, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.B, troveIDs.B ); vm.stopPrank(); @@ -437,7 +409,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveDrawingFreshDebtToAboveMIN_NET_DEBTInsertsItToSortedList() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -459,27 +431,13 @@ contract Redemptions is DevTestSetup { // A and B withdraw Bold from their zombie Trove vm.startPrank(A); borrowerOperations.adjustUnredeemableTrove( - troveIDs.A, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.A, - troveIDs.A + troveIDs.A, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.A, troveIDs.A ); vm.stopPrank(); vm.startPrank(B); borrowerOperations.adjustUnredeemableTrove( - troveIDs.B, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.B, - troveIDs.B + troveIDs.B, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.B, troveIDs.B ); vm.stopPrank(); @@ -493,7 +451,7 @@ contract Redemptions is DevTestSetup { } function testZombieBorrowerDrawsFreshDebtToAboveMIN_NET_DEBTReducesPendingInterestTo0() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -514,27 +472,13 @@ contract Redemptions is DevTestSetup { // A and B withdraw Bold from their zombie Trove vm.startPrank(A); borrowerOperations.adjustUnredeemableTrove( - troveIDs.A, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.A, - troveIDs.A + troveIDs.A, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.A, troveIDs.A ); vm.stopPrank(); vm.startPrank(B); borrowerOperations.adjustUnredeemableTrove( - troveIDs.B, - 1e18, - 0, - false, - debtDelta_A + surplusDebt, - true, - troveIDs.B, - troveIDs.B + troveIDs.B, 1e18, 0, false, debtDelta_A + surplusDebt, true, troveIDs.B, troveIDs.B ); vm.stopPrank(); @@ -548,7 +492,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveBorrowerCanNotDrawFreshDebtToBelowMIN_NET_DEBT() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -567,34 +511,20 @@ contract Redemptions is DevTestSetup { vm.startPrank(A); vm.expectRevert("BorrowerOps: Trove's net debt must be greater than minimum"); borrowerOperations.adjustUnredeemableTrove( - troveIDs.A, - 1e18, - 0, - false, - debtDelta_A - debtDeficiency, - true, - troveIDs.A, - troveIDs.A + troveIDs.A, 1e18, 0, false, debtDelta_A - debtDeficiency, true, troveIDs.A, troveIDs.A ); vm.stopPrank(); vm.startPrank(B); vm.expectRevert("BorrowerOps: Trove's net debt must be greater than minimum"); borrowerOperations.adjustUnredeemableTrove( - troveIDs.B, - 1e18, - 0, - false, - debtDelta_B - debtDeficiency, - true, - troveIDs.B, - troveIDs.B + troveIDs.B, 1e18, 0, false, debtDelta_B - debtDeficiency, true, troveIDs.B, troveIDs.B ); vm.stopPrank(); } function testZombieTroveBorrowerCanNotRepayDebt() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -616,7 +546,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveBorrowerCanNotUseNormalWithdrawBoldFunction() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -634,7 +564,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveBorrowerCanNotUseNormalAdjustTroveFunction() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -642,31 +572,17 @@ contract Redemptions is DevTestSetup { vm.startPrank(A); vm.expectRevert("BorrowerOps: Trove does not have active status"); - borrowerOperations.adjustTrove( - troveIDs.A, - 1e18, - 0, - false, - debtWithdrawal, - true - ); + borrowerOperations.adjustTrove(troveIDs.A, 1e18, 0, false, debtWithdrawal, true); vm.stopPrank(); vm.startPrank(B); vm.expectRevert("BorrowerOps: Trove does not have active status"); - borrowerOperations.adjustTrove( - troveIDs.B, - 1e18, - 0, - false, - debtWithdrawal, - true - ); + borrowerOperations.adjustTrove(troveIDs.B, 1e18, 0, false, debtWithdrawal, true); vm.stopPrank(); } function testZombieTroveBorrowerCanNotAddColl() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -681,12 +597,12 @@ contract Redemptions is DevTestSetup { // B attempts to repay and can't (since would leave Trove at debt < MIN_NET_DEBT) vm.startPrank(B); vm.expectRevert("BorrowerOps: Trove does not have active status"); - borrowerOperations.addColl(troveIDs.B, collTopUp); + borrowerOperations.addColl(troveIDs.B, collTopUp); vm.stopPrank(); } function testZombieTroveBorrowerCanNotChangeInterestRate() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -705,7 +621,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveAccruedInterestCanBePermissionlesslyApplied() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs); @@ -726,7 +642,7 @@ contract Redemptions is DevTestSetup { } function testZombieTroveCanBeLiquidated() public { - ( , , TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); + (,, TroveIDs memory troveIDs) = _setupForRedemptionAscendingInterest(); _redeemAndCreateZombieTrovesAAndB(troveIDs);