From 24a082ff1ae8fc9f177334cf36e89910e2936523 Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Mon, 24 May 2021 17:31:12 +0200 Subject: [PATCH] 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); }