From 53c1617b32f221b5bf0b2b66392546e5481d8970 Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Mon, 24 May 2021 17:28:32 +0200 Subject: [PATCH 1/3] fix: Rename internal variables of LP Configurator adding _ as prefix --- .../lendingpool/LendingPoolConfigurator.sol | 88 +++++++++---------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol index 49451d92..8a3dbeb3 100644 --- a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol @@ -30,17 +30,17 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur using PercentageMath for uint256; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - ILendingPoolAddressesProvider internal addressesProvider; - ILendingPool internal pool; + ILendingPoolAddressesProvider internal _addressesProvider; + ILendingPool internal _pool; modifier onlyPoolAdmin { - require(addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN); + require(_addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN); _; } modifier onlyEmergencyAdmin { require( - addressesProvider.getEmergencyAdmin() == msg.sender, + _addressesProvider.getEmergencyAdmin() == msg.sender, Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN ); _; @@ -53,15 +53,15 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur } function initialize(ILendingPoolAddressesProvider provider) public initializer { - addressesProvider = provider; - pool = ILendingPool(addressesProvider.getLendingPool()); + _addressesProvider = provider; + _pool = ILendingPool(_addressesProvider.getLendingPool()); } /** * @dev Initializes reserves in batch **/ function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin { - ILendingPool cachedPool = pool; + ILendingPool cachedPool = _pool; for (uint256 i = 0; i < input.length; i++) { _initReserve(cachedPool, input[i]); } @@ -145,13 +145,14 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Updates the aToken implementation for the reserve **/ function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin { - ILendingPool cachedPool = pool; + ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); - bytes memory encodedCall = abi.encodeWithSelector( + bytes memory encodedCall = + abi.encodeWithSelector( IInitializableAToken.initialize.selector, cachedPool, input.treasury, @@ -163,11 +164,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur input.params ); - _upgradeTokenImplementation( - reserveData.aTokenAddress, - input.implementation, - encodedCall - ); + _upgradeTokenImplementation(reserveData.aTokenAddress, input.implementation, encodedCall); emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); } @@ -176,13 +173,14 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Updates the stable debt token implementation for the reserve **/ function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { - ILendingPool cachedPool = pool; + ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); - + (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); - bytes memory encodedCall = abi.encodeWithSelector( + bytes memory encodedCall = + abi.encodeWithSelector( IInitializableDebtToken.initialize.selector, cachedPool, input.asset, @@ -209,17 +207,15 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur /** * @dev Updates the variable debt token implementation for the asset **/ - function updateVariableDebtToken(UpdateDebtTokenInput calldata input) - external - onlyPoolAdmin - { - ILendingPool cachedPool = pool; + function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { + ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory(); - bytes memory encodedCall = abi.encodeWithSelector( + bytes memory encodedCall = + abi.encodeWithSelector( IInitializableDebtToken.initialize.selector, cachedPool, input.asset, @@ -252,12 +248,12 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setBorrowingEnabled(true); currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled); } @@ -267,11 +263,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setBorrowingEnabled(false); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit BorrowingDisabledOnReserve(asset); } @@ -290,7 +286,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur uint256 liquidationThreshold, uint256 liquidationBonus ) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); //validation of the parameters: the LTV can //only be lower or equal than the liquidation threshold @@ -323,7 +319,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur currentConfig.setLiquidationThreshold(liquidationThreshold); currentConfig.setLiquidationBonus(liquidationBonus); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus); } @@ -333,11 +329,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function enableReserveStableRate(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setStableRateBorrowingEnabled(true); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit StableRateEnabledOnReserve(asset); } @@ -347,11 +343,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function disableReserveStableRate(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setStableRateBorrowingEnabled(false); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit StableRateDisabledOnReserve(asset); } @@ -361,11 +357,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function activateReserve(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setActive(true); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit ReserveActivated(asset); } @@ -377,11 +373,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur function deactivateReserve(address asset) external onlyPoolAdmin { _checkNoLiquidity(asset); - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setActive(false); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit ReserveDeactivated(asset); } @@ -392,11 +388,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function freezeReserve(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setFrozen(true); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit ReserveFrozen(asset); } @@ -406,11 +402,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve **/ function unfreezeReserve(address asset) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setFrozen(false); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit ReserveUnfrozen(asset); } @@ -421,11 +417,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param reserveFactor The new reserve factor of the reserve **/ function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setReserveFactor(reserveFactor); - pool.setConfiguration(asset, currentConfig.data); + _pool.setConfiguration(asset, currentConfig.data); emit ReserveFactorChanged(asset, reserveFactor); } @@ -439,7 +435,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur external onlyPoolAdmin { - pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress); + _pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress); emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress); } @@ -448,7 +444,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param val true if protocol needs to be paused, false otherwise **/ function setPoolPause(bool val) external onlyEmergencyAdmin { - pool.setPause(val); + _pool.setPause(val); } function _initTokenWithProxy(address implementation, bytes memory initParams) @@ -475,7 +471,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur } function _checkNoLiquidity(address asset) internal view { - DataTypes.ReserveData memory reserveData = pool.getReserveData(asset); + DataTypes.ReserveData memory reserveData = _pool.getReserveData(asset); uint256 availableLiquidity = IERC20Detailed(asset).balanceOf(reserveData.aTokenAddress); From 24a082ff1ae8fc9f177334cf36e89910e2936523 Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Mon, 24 May 2021 17:31:12 +0200 Subject: [PATCH 2/3] fix: Expose functions of LP Configurator in its interface --- .../interfaces/ILendingPoolConfigurator.sol | 95 +++++++++++++++++++ .../lendingpool/LendingPoolConfigurator.sol | 38 +++++--- 2 files changed, 119 insertions(+), 14 deletions(-) diff --git a/contracts/interfaces/ILendingPoolConfigurator.sol b/contracts/interfaces/ILendingPoolConfigurator.sol index 7554f2a8..5f85ebe7 100644 --- a/contracts/interfaces/ILendingPoolConfigurator.sol +++ b/contracts/interfaces/ILendingPoolConfigurator.sol @@ -176,4 +176,99 @@ interface ILendingPoolConfigurator { address indexed proxy, address indexed implementation ); + + function batchInitReserve(InitReserveInput[] calldata input) external; + + function updateAToken(UpdateATokenInput calldata input) external; + + function updateStableDebtToken(UpdateDebtTokenInput calldata input) external; + + function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external; + + /** + * @dev Enables borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve + **/ + function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled) external; + + /** + * @dev Disables borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function disableBorrowingOnReserve(address asset) external; + + /** + * @dev Configures the reserve collateralization parameters + * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00% + * @param asset The address of the underlying asset of the reserve + * @param ltv The loan to value of the asset when used as collateral + * @param liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized + * @param liquidationBonus The bonus liquidators receive to liquidate this asset. The values is always above 100%. A value of 105% + * means the liquidator will receive a 5% bonus + **/ + function configureReserveAsCollateral( + address asset, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus + ) external; + + /** + * @dev Enable stable rate borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function enableReserveStableRate(address asset) external; + + /** + * @dev Disable stable rate borrowing on a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function disableReserveStableRate(address asset) external; + + /** + * @dev Activates a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function activateReserve(address asset) external; + + /** + * @dev Deactivates a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function deactivateReserve(address asset) external; + + /** + * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap + * but allows repayments, liquidations, rate rebalances and withdrawals + * @param asset The address of the underlying asset of the reserve + **/ + function freezeReserve(address asset) external; + + /** + * @dev Unfreezes a reserve + * @param asset The address of the underlying asset of the reserve + **/ + function unfreezeReserve(address asset) external; + + /** + * @dev Updates the reserve factor of a reserve + * @param asset The address of the underlying asset of the reserve + * @param reserveFactor The new reserve factor of the reserve + **/ + function setReserveFactor(address asset, uint256 reserveFactor) external; + + /** + * @dev Sets the interest rate strategy of a reserve + * @param asset The address of the underlying asset of the reserve + * @param rateStrategyAddress The new address of the interest strategy contract + **/ + function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) + external; + + /** + * @dev pauses or unpauses all the actions of the protocol, including aToken transfers + * @param val true if protocol needs to be paused, false otherwise + **/ + function setPoolPause(bool val) external; } diff --git a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol index 8a3dbeb3..7b3287e9 100644 --- a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol @@ -60,7 +60,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur /** * @dev Initializes reserves in batch **/ - function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin { + function batchInitReserve(InitReserveInput[] calldata input) external override onlyPoolAdmin { ILendingPool cachedPool = _pool; for (uint256 i = 0; i < input.length; i++) { _initReserve(cachedPool, input[i]); @@ -144,7 +144,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur /** * @dev Updates the aToken implementation for the reserve **/ - function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin { + function updateAToken(UpdateATokenInput calldata input) external override onlyPoolAdmin { ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); @@ -172,7 +172,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur /** * @dev Updates the stable debt token implementation for the reserve **/ - function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { + function updateStableDebtToken(UpdateDebtTokenInput calldata input) + external + override + onlyPoolAdmin + { ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); @@ -207,7 +211,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur /** * @dev Updates the variable debt token implementation for the asset **/ - function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin { + function updateVariableDebtToken(UpdateDebtTokenInput calldata input) + external + override + onlyPoolAdmin + { ILendingPool cachedPool = _pool; DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset); @@ -246,6 +254,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur **/ function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled) external + override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -262,7 +271,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Disables borrowing on a reserve * @param asset The address of the underlying asset of the reserve **/ - function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { + function disableBorrowingOnReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setBorrowingEnabled(false); @@ -285,7 +294,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus - ) external onlyPoolAdmin { + ) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); //validation of the parameters: the LTV can @@ -328,7 +337,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Enable stable rate borrowing on a reserve * @param asset The address of the underlying asset of the reserve **/ - function enableReserveStableRate(address asset) external onlyPoolAdmin { + function enableReserveStableRate(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setStableRateBorrowingEnabled(true); @@ -342,7 +351,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Disable stable rate borrowing on a reserve * @param asset The address of the underlying asset of the reserve **/ - function disableReserveStableRate(address asset) external onlyPoolAdmin { + function disableReserveStableRate(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setStableRateBorrowingEnabled(false); @@ -356,7 +365,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Activates a reserve * @param asset The address of the underlying asset of the reserve **/ - function activateReserve(address asset) external onlyPoolAdmin { + function activateReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setActive(true); @@ -370,7 +379,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Deactivates a reserve * @param asset The address of the underlying asset of the reserve **/ - function deactivateReserve(address asset) external onlyPoolAdmin { + function deactivateReserve(address asset) external override onlyPoolAdmin { _checkNoLiquidity(asset); DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -387,7 +396,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * but allows repayments, liquidations, rate rebalances and withdrawals * @param asset The address of the underlying asset of the reserve **/ - function freezeReserve(address asset) external onlyPoolAdmin { + function freezeReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setFrozen(true); @@ -401,7 +410,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev Unfreezes a reserve * @param asset The address of the underlying asset of the reserve **/ - function unfreezeReserve(address asset) external onlyPoolAdmin { + function unfreezeReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setFrozen(false); @@ -416,7 +425,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @param asset The address of the underlying asset of the reserve * @param reserveFactor The new reserve factor of the reserve **/ - function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin { + function setReserveFactor(address asset, uint256 reserveFactor) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); currentConfig.setReserveFactor(reserveFactor); @@ -433,6 +442,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur **/ function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) external + override onlyPoolAdmin { _pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress); @@ -443,7 +453,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur * @dev pauses or unpauses all the actions of the protocol, including aToken transfers * @param val true if protocol needs to be paused, false otherwise **/ - function setPoolPause(bool val) external onlyEmergencyAdmin { + function setPoolPause(bool val) external override onlyEmergencyAdmin { _pool.setPause(val); } From 98c5bfb9a045a29e8b623915b71c710e099aefda Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Tue, 25 May 2021 07:40:53 +0200 Subject: [PATCH 3/3] fix: Add interface @inheritdoc to LendingPoolConfigurator --- .../interfaces/ILendingPoolConfigurator.sol | 16 ++++ .../lendingpool/LendingPoolConfigurator.sol | 85 ++++--------------- 2 files changed, 32 insertions(+), 69 deletions(-) diff --git a/contracts/interfaces/ILendingPoolConfigurator.sol b/contracts/interfaces/ILendingPoolConfigurator.sol index 5f85ebe7..1f2ec03c 100644 --- a/contracts/interfaces/ILendingPoolConfigurator.sol +++ b/contracts/interfaces/ILendingPoolConfigurator.sol @@ -177,12 +177,28 @@ interface ILendingPoolConfigurator { address indexed implementation ); + /** + * @dev Initializes reserves in batch + * @param input The array of reserves initialization parameters + **/ function batchInitReserve(InitReserveInput[] calldata input) external; + /** + * @dev Updates the aToken implementation for the reserve + * @param input The aToken update paramenters + **/ function updateAToken(UpdateATokenInput calldata input) external; + /** + * @dev Updates the stable debt token implementation for the reserve + * @param input The stableDebtToken update parameters + **/ function updateStableDebtToken(UpdateDebtTokenInput calldata input) external; + /** + * @dev Updates the variable debt token implementation for the asset + * @param input The variableDebtToken update parameters + **/ function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external; /** diff --git a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol index 7b3287e9..025aa867 100644 --- a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol @@ -57,9 +57,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur _pool = ILendingPool(_addressesProvider.getLendingPool()); } - /** - * @dev Initializes reserves in batch - **/ + /// @inheritdoc ILendingPoolConfigurator function batchInitReserve(InitReserveInput[] calldata input) external override onlyPoolAdmin { ILendingPool cachedPool = _pool; for (uint256 i = 0; i < input.length; i++) { @@ -141,9 +139,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur ); } - /** - * @dev Updates the aToken implementation for the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function updateAToken(UpdateATokenInput calldata input) external override onlyPoolAdmin { ILendingPool cachedPool = _pool; @@ -169,9 +165,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation); } - /** - * @dev Updates the stable debt token implementation for the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function updateStableDebtToken(UpdateDebtTokenInput calldata input) external override @@ -208,9 +202,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur ); } - /** - * @dev Updates the variable debt token implementation for the asset - **/ + /// @inheritdoc ILendingPoolConfigurator function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external override @@ -247,11 +239,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur ); } - /** - * @dev Enables borrowing on a reserve - * @param asset The address of the underlying asset of the reserve - * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled) external override @@ -267,10 +255,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled); } - /** - * @dev Disables borrowing on a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function disableBorrowingOnReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -280,15 +265,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit BorrowingDisabledOnReserve(asset); } - /** - * @dev Configures the reserve collateralization parameters - * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00% - * @param asset The address of the underlying asset of the reserve - * @param ltv The loan to value of the asset when used as collateral - * @param liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized - * @param liquidationBonus The bonus liquidators receive to liquidate this asset. The values is always above 100%. A value of 105% - * means the liquidator will receive a 5% bonus - **/ + /// @inheritdoc ILendingPoolConfigurator function configureReserveAsCollateral( address asset, uint256 ltv, @@ -333,10 +310,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus); } - /** - * @dev Enable stable rate borrowing on a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function enableReserveStableRate(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -347,10 +321,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit StableRateEnabledOnReserve(asset); } - /** - * @dev Disable stable rate borrowing on a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function disableReserveStableRate(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -361,10 +332,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit StableRateDisabledOnReserve(asset); } - /** - * @dev Activates a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function activateReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -375,10 +343,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveActivated(asset); } - /** - * @dev Deactivates a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function deactivateReserve(address asset) external override onlyPoolAdmin { _checkNoLiquidity(asset); @@ -391,11 +356,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveDeactivated(asset); } - /** - * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap - * but allows repayments, liquidations, rate rebalances and withdrawals - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function freezeReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -406,10 +367,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveFrozen(asset); } - /** - * @dev Unfreezes a reserve - * @param asset The address of the underlying asset of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function unfreezeReserve(address asset) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -420,11 +378,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveUnfrozen(asset); } - /** - * @dev Updates the reserve factor of a reserve - * @param asset The address of the underlying asset of the reserve - * @param reserveFactor The new reserve factor of the reserve - **/ + /// @inheritdoc ILendingPoolConfigurator function setReserveFactor(address asset, uint256 reserveFactor) external override onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); @@ -435,11 +389,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveFactorChanged(asset, reserveFactor); } - /** - * @dev Sets the interest rate strategy of a reserve - * @param asset The address of the underlying asset of the reserve - * @param rateStrategyAddress The new address of the interest strategy contract - **/ + /// @inheritdoc ILendingPoolConfigurator function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) external override @@ -449,10 +399,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress); } - /** - * @dev pauses or unpauses all the actions of the protocol, including aToken transfers - * @param val true if protocol needs to be paused, false otherwise - **/ + /// @inheritdoc ILendingPoolConfigurator function setPoolPause(bool val) external override onlyEmergencyAdmin { _pool.setPause(val); }