From ff2af5cde65afe2c80532eeb6e3a33acd9453cd6 Mon Sep 17 00:00:00 2001 From: Mikael <26343374+0xmikko@users.noreply.github.com> Date: Fri, 28 Apr 2023 15:15:12 +0200 Subject: [PATCH] fix: more consistent naming + removing Slot1 --- contracts/credit/CreditConfigurator.sol | 12 +- contracts/credit/CreditManagerV3.sol | 136 +++++++++--------- contracts/factories/CreditManagerFactory.sol | 2 +- contracts/interfaces/ICreditConfigurator.sol | 4 +- contracts/interfaces/ICreditManagerV3.sol | 2 +- .../test/suites/CreditFacadeTestSuite.sol | 6 +- .../test/suites/CreditManagerTestSuite.sol | 4 +- .../test/unit/credit/CreditConfigurator.t.sol | 36 ++--- .../test/unit/credit/CreditManager.t.sol | 36 ++--- 9 files changed, 115 insertions(+), 123 deletions(-) diff --git a/contracts/credit/CreditConfigurator.sol b/contracts/credit/CreditConfigurator.sol index d62ee0e9..ee4b6b22 100644 --- a/contracts/credit/CreditConfigurator.sol +++ b/contracts/credit/CreditConfigurator.sol @@ -126,7 +126,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { } // Connects creditFacade and priceOracle - creditManager.upgradeCreditFacade(address(_creditFacade)); // F:[CC-1] + creditManager.setCreditFacade(address(_creditFacade)); // F:[CC-1] emit SetCreditFacade(address(_creditFacade)); // F: [CC-1A] emit SetPriceOracle(address(creditManager.priceOracle())); // F: [CC-1A] @@ -566,7 +566,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { /// @dev Upgrades the price oracle in the Credit Manager, taking the address /// from the address provider - function upgradePriceOracle() + function setPriceOracle() external configuratorOnly // F:[CC-2] { @@ -575,7 +575,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { // Checks that the price oracle is actually new to avoid emitting redundant events if (priceOracle != currentPriceOracle) { - creditManager.upgradePriceOracle(priceOracle); // F: [CC-28] + creditManager.setPriceOracle(priceOracle); // F: [CC-28] emit SetPriceOracle(priceOracle); // F:[CC-28] } } @@ -583,7 +583,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { /// @dev Upgrades the Credit Facade corresponding to the Credit Manager /// @param _creditFacade address of the new CreditFacadeV3 /// @param migrateParams Whether the previous CreditFacadeV3's parameter need to be copied - function upgradeCreditFacade(address _creditFacade, bool migrateParams) + function setCreditFacade(address _creditFacade, bool migrateParams) external configuratorOnly // F:[CC-2] { @@ -607,7 +607,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { address botList = creditFacade().botList(); // Sets Credit Facade to the new address - creditManager.upgradeCreditFacade(_creditFacade); // F:[CC-30] + creditManager.setCreditFacade(_creditFacade); // F:[CC-30] if (migrateParams) { // Copies all limits and restrictions on borrowing @@ -638,7 +638,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLNonReentrantTrait { _revertIfContractIncompatible(_creditConfigurator); // F:[CC-29] - creditManager.setConfigurator(_creditConfigurator); // F:[CC-31] + creditManager.setCreditConfigurator(_creditConfigurator); // F:[CC-31] emit CreditConfiguratorUpgraded(_creditConfigurator); // F:[CC-31] } diff --git a/contracts/credit/CreditManagerV3.sol b/contracts/credit/CreditManagerV3.sol index 1b2ed55b..511b6321 100644 --- a/contracts/credit/CreditManagerV3.sol +++ b/contracts/credit/CreditManagerV3.sol @@ -55,26 +55,6 @@ import "forge-std/console.sol"; uint256 constant ADDR_BIT_SIZE = 160; uint256 constant INDEX_PRECISION = 10 ** 9; -struct Slot1 { - /// @dev Interest fee charged by the protocol: fee = interest accrued * feeInterest - uint16 feeInterest; - /// @dev Liquidation fee charged by the protocol: fee = totalValue * feeLiquidation - uint16 feeLiquidation; - /// @dev Multiplier used to compute the total value of funds during liquidation. - /// At liquidation, the borrower's funds are discounted, and the pool is paid out of discounted value - /// The liquidator takes the difference between the discounted and actual values as premium. - uint16 liquidationDiscount; - /// @dev Liquidation fee charged by the protocol during liquidation by expiry. Typically lower than feeLiquidation. - uint16 feeLiquidationExpired; - /// @dev Multiplier used to compute the total value of funds during liquidation by expiry. Typically higher than - /// liquidationDiscount (meaning lower premium). - uint16 liquidationDiscountExpired; - /// @dev Price oracle used to evaluate assets on Credit Accounts. - IPriceOracleV2 priceOracle; - /// @dev Liquidation threshold for the underlying token. - uint16 ltUnderlying; -} - /// @title Credit Manager /// @notice Encapsulates the business logic for managing Credit Accounts /// @@ -95,8 +75,29 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, /// externalCallCA is used for adapters interation when adapter calls approve / execute methods address public externalCallCA; - /// @dev Stores fees & parameters commonly used together for gas savings - Slot1 internal slot1; + /// @dev Interest fee charged by the protocol: fee = interest accrued * feeInterest + uint16 public feeInterest; + + /// @dev Liquidation fee charged by the protocol: fee = totalValue * feeLiquidation + uint16 public feeLiquidation; + + /// @dev Multiplier used to compute the total value of funds during liquidation. + /// At liquidation, the borrower's funds are discounted, and the pool is paid out of discounted value + /// The liquidator takes the difference between the discounted and actual values as premium. + uint16 public liquidationDiscount; + + /// @dev Liquidation fee charged by the protocol during liquidation by expiry. Typically lower than feeLiquidation. + uint16 public feeLiquidationExpired; + + /// @dev Multiplier used to compute the total value of funds during liquidation by expiry. Typically higher than + /// liquidationDiscount (meaning lower premium). + uint16 public liquidationDiscountExpired; + + /// @dev Price oracle used to evaluate assets on Credit Accounts. + IPriceOracleV2 public override priceOracle; + + /// @dev Liquidation threshold for the underlying token. + uint16 public ltUnderlying; /// @dev A map from borrower addresses to Credit Account addresses mapping(address => address) public override creditAccounts; @@ -212,7 +213,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, wethGateway = addressProvider.getWETHGateway(); // F:[CM-1] // Price oracle is stored in Slot1, as it is accessed frequently with fees - slot1.priceOracle = IPriceOracleV2(addressProvider.getPriceOracle()); // F:[CM-1] + priceOracle = IPriceOracleV2(addressProvider.getPriceOracle()); // F:[CM-1] _accountFactory = IAccountFactory(addressProvider.getAccountFactory()); // F:[CM-1] creditConfigurator = msg.sender; // F:[CM-1] @@ -435,7 +436,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, (borrowedAmount * cumulativeIndexNow_RAY) / cumulativeIndexAtOpen_RAY - borrowedAmount; // F:[CM-21] // Computes profit, taken as a percentage of the interest rate - uint256 profit = (interestAccrued * slot1.feeInterest) / PERCENTAGE_FACTOR; // F:[CM-21] + uint256 profit = (interestAccrued * feeInterest) / PERCENTAGE_FACTOR; // F:[CM-21] if (amountRepaid >= interestAccrued + profit) { // If the amount covers all of the interest and fees, they are @@ -456,7 +457,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, // of interest, this ensures that the new fee is consistent with the // new pending interest - uint256 amountToPool = (amountRepaid * PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR + slot1.feeInterest); + uint256 amountToPool = (amountRepaid * PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR + feeInterest); amountProfit += amountRepaid - amountToPool; amountRepaid = 0; @@ -503,7 +504,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, amountRepaid = _amountRepaid; amountProfit = _amountProfit; - uint16 feeInterest = slot1.feeInterest; + uint16 _feeInterest = feeInterest; uint256 quotaInterestAccrued = cumulativeQuotaInterest[creditAccount] - 1; TokenLT[] memory tokens = _getQuotedTokens(enabledTokenMask); @@ -512,14 +513,14 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, } if (quotaInterestAccrued > 1) { - uint256 quotaProfit = (quotaInterestAccrued * feeInterest) / PERCENTAGE_FACTOR; + uint256 quotaProfit = (quotaInterestAccrued * _feeInterest) / PERCENTAGE_FACTOR; if (amountRepaid >= quotaInterestAccrued + quotaProfit) { amountRepaid -= quotaInterestAccrued + quotaProfit; // F: [CMQ-5] amountProfit += quotaProfit; // F: [CMQ-5] cumulativeQuotaInterest[creditAccount] = 1; // F: [CMQ-5] } else { - uint256 amountToPool = (amountRepaid * PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR + feeInterest); + uint256 amountToPool = (amountRepaid * PERCENTAGE_FACTOR) / (PERCENTAGE_FACTOR + _feeInterest); amountProfit += amountRepaid - amountToPool; // F: [CMQ-4] amountRepaid = 0; // F: [CMQ-4] @@ -699,7 +700,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, revert CustomHealthFactorTooLowException(); } - IPriceOracleV2 _priceOracle = slot1.priceOracle; + IPriceOracleV2 _priceOracle = priceOracle; uint256 twvUSD; uint256 borrowAmountPlusInterestRateAndFeesUSD; @@ -732,7 +733,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, bool canBeLiquidated ) { - IPriceOracleV2 _priceOracle = slot1.priceOracle; + IPriceOracleV2 _priceOracle = priceOracle; uint256[] memory collateralHints; enabledTokenMask = enabledTokensMap(creditAccount); uint256 totalUSD; @@ -1086,7 +1087,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, // The pool will compute the amount of Diesel tokens to treasury // based on profit amountToPool = borrowedAmountWithInterest - + ((borrowedAmountWithInterest - borrowedAmount) * slot1.feeInterest) / PERCENTAGE_FACTOR; // F:[CM-43] + + ((borrowedAmountWithInterest - borrowedAmount) * feeInterest) / PERCENTAGE_FACTOR; // F:[CM-43] if ( closureActionType == ClosureAction.LIQUIDATE_ACCOUNT @@ -1108,18 +1109,14 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, totalValue * ( closureActionType == ClosureAction.LIQUIDATE_ACCOUNT - ? slot1.liquidationDiscount - : slot1.liquidationDiscountExpired + ? liquidationDiscount + : liquidationDiscountExpired ) ) / PERCENTAGE_FACTOR; // F:[CM-43] amountToPool += ( totalValue - * ( - closureActionType == ClosureAction.LIQUIDATE_ACCOUNT - ? slot1.feeLiquidation - : slot1.feeLiquidationExpired - ) + * (closureActionType == ClosureAction.LIQUIDATE_ACCOUNT ? feeLiquidation : feeLiquidationExpired) ) / PERCENTAGE_FACTOR; // F:[CM-43] /// Adding fee here @@ -1187,7 +1184,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, // The underlying is a special case and its mask is always 1 if (tokenMask == 1) { token = underlying; // F:[CM-47] - liquidationThreshold = slot1.ltUnderlying; + liquidationThreshold = ltUnderlying; } else { CollateralTokenData memory tokenData = collateralTokensData[tokenMask]; // F:[CM-47] @@ -1292,7 +1289,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, // Fees are computed as a percentage of interest borrowedAmountWithInterestAndFees = borrowedAmountWithInterest - + ((borrowedAmountWithInterest - borrowedAmount) * slot1.feeInterest) / PERCENTAGE_FACTOR; // F: [CM-49] + + ((borrowedAmountWithInterest - borrowedAmount) * feeInterest) / PERCENTAGE_FACTOR; // F: [CM-49] } /// @dev Returns the parameters of the Credit Account required to calculate debt @@ -1316,7 +1313,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, /// @param token Token to retrieve the LT for function liquidationThresholds(address token) public view override returns (uint16 lt) { // Underlying is a special case and its LT is stored separately - if (token == underlying) return slot1.ltUnderlying; // F:[CM-47] + if (token == underlying) return ltUnderlying; // F:[CM-47] uint256 tokenMask = getTokenMaskOrRevert(token); (, lt) = collateralTokensByMask(tokenMask); // F:[CM-47] @@ -1330,37 +1327,32 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, } /// @dev Returns the fee parameters of the Credit Manager - /// @return feeInterest Percentage of interest taken by the protocol as profit - /// @return feeLiquidation Percentage of account value taken by the protocol as profit + /// @return _feeInterest Percentage of interest taken by the protocol as profit + /// @return _feeLiquidation Percentage of account value taken by the protocol as profit /// during unhealthy account liquidations - /// @return liquidationDiscount Multiplier that reduces the effective totalValue during unhealthy account liquidations, + /// @return _liquidationDiscount Multiplier that reduces the effective totalValue during unhealthy account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremium) - /// @return feeLiquidationExpired Percentage of account value taken by the protocol as profit + /// @return _feeLiquidationExpired Percentage of account value taken by the protocol as profit /// during expired account liquidations - /// @return liquidationDiscountExpired Multiplier that reduces the effective totalValue during expired account liquidations, + /// @return _liquidationDiscountExpired Multiplier that reduces the effective totalValue during expired account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremiumExpired) function fees() external view override returns ( - uint16 feeInterest, - uint16 feeLiquidation, - uint16 liquidationDiscount, - uint16 feeLiquidationExpired, - uint16 liquidationDiscountExpired + uint16 _feeInterest, + uint16 _feeLiquidation, + uint16 _liquidationDiscount, + uint16 _feeLiquidationExpired, + uint16 _liquidationDiscountExpired ) { - feeInterest = slot1.feeInterest; // F:[CM-51] - feeLiquidation = slot1.feeLiquidation; // F:[CM-51] - liquidationDiscount = slot1.liquidationDiscount; // F:[CM-51] - feeLiquidationExpired = slot1.feeLiquidationExpired; // F:[CM-51] - liquidationDiscountExpired = slot1.liquidationDiscountExpired; // F:[CM-51] - } - - /// @dev Returns the price oracle used to evaluate collateral tokens - function priceOracle() external view override returns (IPriceOracleV2) { - return slot1.priceOracle; + _feeInterest = feeInterest; // F:[CM-51] + _feeLiquidation = feeLiquidation; // F:[CM-51] + _liquidationDiscount = liquidationDiscount; // F:[CM-51] + _feeLiquidationExpired = feeLiquidationExpired; // F:[CM-51] + _liquidationDiscountExpired = liquidationDiscountExpired; // F:[CM-51] } /// @dev Address of the connected pool @@ -1438,11 +1430,11 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, external creditConfiguratorOnly // F:[CM-4] { - slot1.feeInterest = _feeInterest; // F:[CM-51] - slot1.feeLiquidation = _feeLiquidation; // F:[CM-51] - slot1.liquidationDiscount = _liquidationDiscount; // F:[CM-51] - slot1.feeLiquidationExpired = _feeLiquidationExpired; // F:[CM-51] - slot1.liquidationDiscountExpired = _liquidationDiscountExpired; // F:[CM-51] + feeInterest = _feeInterest; // F:[CM-51] + feeLiquidation = _feeLiquidation; // F:[CM-51] + liquidationDiscount = _liquidationDiscount; // F:[CM-51] + feeLiquidationExpired = _feeLiquidationExpired; // F:[CM-51] + liquidationDiscountExpired = _liquidationDiscountExpired; // F:[CM-51] } // @@ -1463,7 +1455,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, // to be accessed frequently if (token == underlying) { // F:[CM-47] - slot1.ltUnderlying = liquidationThreshold; // F:[CM-47] + ltUnderlying = liquidationThreshold; // F:[CM-47] } else { uint256 tokenMask = getTokenMaskOrRevert(token); // F:[CM-47, 54] @@ -1548,7 +1540,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, /// @dev Sets the Credit Facade /// @param _creditFacade Address of the new Credit Facade - function upgradeCreditFacade(address _creditFacade) + function setCreditFacade(address _creditFacade) external creditConfiguratorOnly // F:[CM-4] { @@ -1557,21 +1549,21 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard, /// @dev Sets the Price Oracle /// @param _priceOracle Address of the new Price Oracle - function upgradePriceOracle(address _priceOracle) + function setPriceOracle(address _priceOracle) external creditConfiguratorOnly // F:[CM-4] { - slot1.priceOracle = IPriceOracleV2(_priceOracle); + priceOracle = IPriceOracleV2(_priceOracle); } /// @dev Sets a new Credit Configurator /// @param _creditConfigurator Address of the new Credit Configurator - function setConfigurator(address _creditConfigurator) + function setCreditConfigurator(address _creditConfigurator) external creditConfiguratorOnly // F:[CM-4] { creditConfigurator = _creditConfigurator; // F:[CM-58] - emit SetConfigurator(_creditConfigurator); // F:[CM-58] + emit SetCreditConfigurator(_creditConfigurator); // F:[CM-58] } function _checkEnabledTokenLength(uint256 enabledTokenMask) internal view { diff --git a/contracts/factories/CreditManagerFactory.sol b/contracts/factories/CreditManagerFactory.sol index 3db5de4c..dbf51b70 100644 --- a/contracts/factories/CreditManagerFactory.sol +++ b/contracts/factories/CreditManagerFactory.sol @@ -30,7 +30,7 @@ contract CreditManagerFactory { creditConfigurator = CreditConfigurator(Create2.computeAddress(salt, keccak256(configuratorByteCode))); - creditManager.setConfigurator(address(creditConfigurator)); + creditManager.setCreditConfigurator(address(creditConfigurator)); Create2.deploy(0, salt, configuratorByteCode); diff --git a/contracts/interfaces/ICreditConfigurator.sol b/contracts/interfaces/ICreditConfigurator.sol index 02492c88..66353405 100644 --- a/contracts/interfaces/ICreditConfigurator.sol +++ b/contracts/interfaces/ICreditConfigurator.sol @@ -181,12 +181,12 @@ interface ICreditConfigurator is ICreditConfiguratorEvents, IVersion { /// @dev Upgrades the price oracle in the Credit Manager, taking the address /// from the address provider - function upgradePriceOracle() external; + function setPriceOracle() external; /// @dev Upgrades the Credit Facade corresponding to the Credit Manager /// @param _creditFacade address of the new CreditFacadeV3 /// @param migrateParams Whether the previous CreditFacadeV3's parameter need to be copied - function upgradeCreditFacade(address _creditFacade, bool migrateParams) external; + function setCreditFacade(address _creditFacade, bool migrateParams) external; /// @dev Upgrades the Credit Configurator for a connected Credit Manager /// @param _creditConfigurator New Credit Configurator's address diff --git a/contracts/interfaces/ICreditManagerV3.sol b/contracts/interfaces/ICreditManagerV3.sol index f1a1020e..3071b0fd 100644 --- a/contracts/interfaces/ICreditManagerV3.sol +++ b/contracts/interfaces/ICreditManagerV3.sol @@ -47,7 +47,7 @@ interface ICreditManagerV3Events { event ExecuteOrder(address indexed targetContract); /// @dev Emits when a configurator is upgraded - event SetConfigurator(address indexed newConfigurator); + event SetCreditConfigurator(address indexed newConfigurator); } /// @notice All Credit Manager functions are access-restricted and can only be called diff --git a/contracts/test/suites/CreditFacadeTestSuite.sol b/contracts/test/suites/CreditFacadeTestSuite.sol index 9aedddaa..ae67401e 100644 --- a/contracts/test/suites/CreditFacadeTestSuite.sol +++ b/contracts/test/suites/CreditFacadeTestSuite.sol @@ -113,7 +113,7 @@ contract CreditFacadeTestSuite is PoolDeployer { false ); - creditConfigurator.upgradeCreditFacade(address(creditFacade), true); + creditConfigurator.setCreditFacade(address(creditFacade), true); degenNFT.addCreditFacade(address(creditFacade)); @@ -130,7 +130,7 @@ contract CreditFacadeTestSuite is PoolDeployer { true ); - creditConfigurator.upgradeCreditFacade(address(creditFacade), true); + creditConfigurator.setCreditFacade(address(creditFacade), true); creditConfigurator.setExpirationDate(uint40(block.timestamp + 1)); evm.stopPrank(); @@ -146,7 +146,7 @@ contract CreditFacadeTestSuite is PoolDeployer { false ); - creditConfigurator.upgradeCreditFacade(address(creditFacade), true); + creditConfigurator.setCreditFacade(address(creditFacade), true); // blacklistHelper.addCreditFacade(address(creditFacade)); diff --git a/contracts/test/suites/CreditManagerTestSuite.sol b/contracts/test/suites/CreditManagerTestSuite.sol index 3bf6888e..fd4dfaa6 100644 --- a/contracts/test/suites/CreditManagerTestSuite.sol +++ b/contracts/test/suites/CreditManagerTestSuite.sol @@ -60,11 +60,11 @@ contract CreditManagerTestSuite is PoolDeployer { creditFacade = msg.sender; - creditManager.setConfigurator(CONFIGURATOR); + creditManager.setCreditConfigurator(CONFIGURATOR); evm.startPrank(CONFIGURATOR); - creditManager.upgradeCreditFacade(creditFacade); + creditManager.setCreditFacade(creditFacade); creditManager.setParams( DEFAULT_FEE_INTEREST, diff --git a/contracts/test/unit/credit/CreditConfigurator.t.sol b/contracts/test/unit/credit/CreditConfigurator.t.sol index e8b20c09..b94d8f95 100644 --- a/contracts/test/unit/credit/CreditConfigurator.t.sol +++ b/contracts/test/unit/credit/CreditConfigurator.t.sol @@ -271,7 +271,7 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig address creditConfiguratorAddr = _getAddress(configuratorByteCode, 0); - creditManager.setConfigurator(creditConfiguratorAddr); + creditManager.setCreditConfigurator(creditConfiguratorAddr); evm.expectEmit(true, false, false, true); emit SetTokenLiquidationThreshold(underlying, DEFAULT_UNDERLYING_LT); @@ -330,10 +330,10 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig // Upgrades evm.expectRevert(CallerNotConfiguratorException.selector); - creditConfigurator.upgradePriceOracle(); + creditConfigurator.setPriceOracle(); evm.expectRevert(CallerNotConfiguratorException.selector); - creditConfigurator.upgradeCreditFacade(DUMB_ADDRESS, false); + creditConfigurator.setCreditFacade(DUMB_ADDRESS, false); evm.expectRevert(CallerNotConfiguratorException.selector); creditConfigurator.upgradeCreditConfigurator(DUMB_ADDRESS); @@ -871,51 +871,51 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig // CONTRACT UPGRADES // - /// @dev [CC-28]: upgradePriceOracle upgrades priceOracleCorrectly and doesnt change facade - function test_CC_28_upgradePriceOracle_upgrades_priceOracleCorrectly_and_doesnt_change_facade() public { + /// @dev [CC-28]: setPriceOracle upgrades priceOracleCorrectly and doesnt change facade + function test_CC_28_setPriceOracle_upgrades_priceOracleCorrectly_and_doesnt_change_facade() public { evm.startPrank(CONFIGURATOR); cct.addressProvider().setPriceOracle(DUMB_ADDRESS); evm.expectEmit(true, false, false, false); emit SetPriceOracle(DUMB_ADDRESS); - creditConfigurator.upgradePriceOracle(); + creditConfigurator.setPriceOracle(); assertEq(address(creditManager.priceOracle()), DUMB_ADDRESS); evm.stopPrank(); } - /// @dev [CC-29]: upgradePriceOracle upgrades priceOracleCorrectly and doesnt change facade - function test_CC_29_upgradeCreditFacade_upgradeCreditConfigurator_reverts_for_incompatible_contracts() public { + /// @dev [CC-29]: setPriceOracle upgrades priceOracleCorrectly and doesnt change facade + function test_CC_29_setCreditFacade_upgradeCreditConfigurator_reverts_for_incompatible_contracts() public { evm.startPrank(CONFIGURATOR); evm.expectRevert(ZeroAddressException.selector); - creditConfigurator.upgradeCreditFacade(address(0), false); + creditConfigurator.setCreditFacade(address(0), false); evm.expectRevert(ZeroAddressException.selector); creditConfigurator.upgradeCreditConfigurator(address(0)); evm.expectRevert(abi.encodeWithSelector(AddressIsNotContractException.selector, DUMB_ADDRESS)); - creditConfigurator.upgradeCreditFacade(DUMB_ADDRESS, false); + creditConfigurator.setCreditFacade(DUMB_ADDRESS, false); evm.expectRevert(abi.encodeWithSelector(AddressIsNotContractException.selector, DUMB_ADDRESS)); creditConfigurator.upgradeCreditConfigurator(DUMB_ADDRESS); evm.expectRevert(IncompatibleContractException.selector); - creditConfigurator.upgradeCreditFacade(underlying, false); + creditConfigurator.setCreditFacade(underlying, false); evm.expectRevert(IncompatibleContractException.selector); creditConfigurator.upgradeCreditConfigurator(underlying); evm.expectRevert(IncompatibleContractException.selector); - creditConfigurator.upgradeCreditFacade(address(adapterDifferentCM), false); + creditConfigurator.setCreditFacade(address(adapterDifferentCM), false); evm.expectRevert(IncompatibleContractException.selector); creditConfigurator.upgradeCreditConfigurator(address(adapterDifferentCM)); } - /// @dev [CC-30]: upgradeCreditFacade upgrades creditFacade and doesnt change priceOracle - function test_CC_30_upgradeCreditFacade_upgrades_creditFacade_and_doesnt_change_priceOracle() public { + /// @dev [CC-30]: setCreditFacade upgrades creditFacade and doesnt change priceOracle + function test_CC_30_setCreditFacade_upgrades_creditFacade_and_doesnt_change_priceOracle() public { for (uint256 id = 0; id < 2; id++) { bool isIDF = id != 0; for (uint256 ex = 0; ex < 2; ex++) { @@ -934,7 +934,7 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig ); evm.prank(CONFIGURATOR); - creditConfigurator.upgradeCreditFacade(address(initialCf), migrateSettings); + creditConfigurator.setCreditFacade(address(initialCf), migrateSettings); evm.prank(CONFIGURATOR); creditConfigurator.setExpirationDate(uint40(block.timestamp + 1)); @@ -958,7 +958,7 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig emit SetCreditFacade(address(cf)); evm.prank(CONFIGURATOR); - creditConfigurator.upgradeCreditFacade(address(cf), migrateSettings); + creditConfigurator.setCreditFacade(address(cf), migrateSettings); assertEq(address(creditManager.priceOracle()), cct.addressProvider().getPriceOracle()); @@ -987,7 +987,7 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig } } - /// @dev [CC-30A]: uupgradeCreditFacade transfers bot list + /// @dev [CC-30A]: usetCreditFacade transfers bot list function test_CC_30A_botList_is_transferred_on_CreditFacade_upgrade() public { for (uint256 ms = 0; ms < 2; ms++) { bool migrateSettings = ms != 0; @@ -1006,7 +1006,7 @@ contract CreditConfiguratorTest is DSTest, ICreditManagerV3Events, ICreditConfig ); evm.prank(CONFIGURATOR); - creditConfigurator.upgradeCreditFacade(address(cf), migrateSettings); + creditConfigurator.setCreditFacade(address(cf), migrateSettings); address botList2 = cf.botList(); diff --git a/contracts/test/unit/credit/CreditManager.t.sol b/contracts/test/unit/credit/CreditManager.t.sol index 4503ec02..9d6bd52a 100644 --- a/contracts/test/unit/credit/CreditManager.t.sol +++ b/contracts/test/unit/credit/CreditManager.t.sol @@ -347,7 +347,7 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { /// - setForbidMask /// - changeContractAllowance /// - upgradeContracts - /// - setConfigurator + /// - setCreditConfigurator /// - addEmergencyLiquidator /// - removeEmergenceLiquidator function test_CM_04_credit_account_configurator_functions_revert_if_not_called_by_creditConfigurator() public { @@ -368,13 +368,13 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { creditManager.changeContractAllowance(DUMB_ADDRESS, DUMB_ADDRESS); evm.expectRevert(CallerNotConfiguratorException.selector); - creditManager.upgradeCreditFacade(DUMB_ADDRESS); + creditManager.setCreditFacade(DUMB_ADDRESS); evm.expectRevert(CallerNotConfiguratorException.selector); - creditManager.upgradePriceOracle(DUMB_ADDRESS); + creditManager.setPriceOracle(DUMB_ADDRESS); evm.expectRevert(CallerNotConfiguratorException.selector); - creditManager.setConfigurator(DUMB_ADDRESS); + creditManager.setCreditConfigurator(DUMB_ADDRESS); evm.expectRevert(CallerNotConfiguratorException.selector); creditManager.setMaxEnabledTokens(255); @@ -1358,8 +1358,8 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { CreditManagerV3 cm = new CreditManagerV3(address(poolMock), address(withdrawManager)); cms.cr().addCreditManager(address(cm)); - cm.upgradeCreditFacade(address(this)); - cm.upgradePriceOracle(address(priceOracle)); + cm.setCreditFacade(address(this)); + cm.setPriceOracle(address(priceOracle)); evm.stopPrank(); @@ -1406,8 +1406,8 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { creditManager = new CreditManagerV3(address(poolMock), address(withdrawManager)); cms.cr().addCreditManager(address(creditManager)); - creditManager.upgradeCreditFacade(address(this)); - creditManager.upgradePriceOracle(address(priceOracle)); + creditManager.setCreditFacade(address(this)); + creditManager.setPriceOracle(address(priceOracle)); creditManager.setLiquidationThreshold(poolMock.underlyingToken(), 9300); evm.stopPrank(); @@ -2088,22 +2088,22 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { // UPGRADE CONTRACTS // - /// @dev [CM-57A]: upgradeCreditFacade updates Credit Facade correctly - function test_CM_57A_upgradeCreditFacade_updates_contract_correctly() public { + /// @dev [CM-57A]: setCreditFacade updates Credit Facade correctly + function test_CM_57A_setCreditFacade_updates_contract_correctly() public { assertTrue(creditManager.creditFacade() != DUMB_ADDRESS, "creditFacade( is already the same"); evm.prank(CONFIGURATOR); - creditManager.upgradeCreditFacade(DUMB_ADDRESS); + creditManager.setCreditFacade(DUMB_ADDRESS); assertEq(creditManager.creditFacade(), DUMB_ADDRESS, "creditFacade is not set correctly"); } - /// @dev [CM-57B]: upgradePriceOracle updates contract correctly - function test_CM_57_upgradePriceOracle_updates_contract_correctly() public { + /// @dev [CM-57B]: setPriceOracle updates contract correctly + function test_CM_57_setPriceOracle_updates_contract_correctly() public { assertTrue(address(creditManager.priceOracle()) != DUMB_ADDRESS2, "priceOracle is already the same"); evm.prank(CONFIGURATOR); - creditManager.upgradePriceOracle(DUMB_ADDRESS2); + creditManager.setPriceOracle(DUMB_ADDRESS2); assertEq(address(creditManager.priceOracle()), DUMB_ADDRESS2, "priceOracle is not set correctly"); } @@ -2112,16 +2112,16 @@ contract CreditManagerTest is DSTest, ICreditManagerV3Events, BalanceHelper { // SET CONFIGURATOR // - /// @dev [CM-58]: setConfigurator sets creditConfigurator correctly and emits event - function test_CM_58_setConfigurator_sets_creditConfigurator_correctly_and_emits_event() public { + /// @dev [CM-58]: setCreditConfigurator sets creditConfigurator correctly and emits event + function test_CM_58_setCreditConfigurator_sets_creditConfigurator_correctly_and_emits_event() public { assertTrue(creditManager.creditConfigurator() != DUMB_ADDRESS, "creditConfigurator is already the same"); evm.prank(CONFIGURATOR); evm.expectEmit(true, false, false, false); - emit SetConfigurator(DUMB_ADDRESS); + emit SetCreditConfigurator(DUMB_ADDRESS); - creditManager.setConfigurator(DUMB_ADDRESS); + creditManager.setCreditConfigurator(DUMB_ADDRESS); assertEq(creditManager.creditConfigurator(), DUMB_ADDRESS, "creditConfigurator is not set correctly"); }