From a9fce4dd4b25226df1c5f6d6c738f8ecc6a99e7e Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Thu, 29 Apr 2021 09:51:37 +0200 Subject: [PATCH] feat: Added setBorrowCap in lendingpoolconfigurator --- contracts/interfaces/ILendingPoolConfigurator.sol | 7 +++++++ .../lendingpool/LendingPoolConfigurator.sol | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/contracts/interfaces/ILendingPoolConfigurator.sol b/contracts/interfaces/ILendingPoolConfigurator.sol index 7554f2a8..2dcd8259 100644 --- a/contracts/interfaces/ILendingPoolConfigurator.sol +++ b/contracts/interfaces/ILendingPoolConfigurator.sol @@ -127,6 +127,13 @@ interface ILendingPoolConfigurator { **/ event ReserveFactorChanged(address indexed asset, uint256 factor); + /** + * @dev Emitted when the borrow cap of a reserve is updated + * @param asset The address of the underlying asset of the reserve + * @param borrowCap The new borrow cap + **/ + event BorrowCapChanged(address indexed asset, uint256 borrowCap); + /** * @dev Emitted when the reserve decimals are updated * @param asset The address of the underlying asset of the reserve diff --git a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol index 99c46976..66100e1e 100644 --- a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol @@ -431,6 +431,21 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur emit ReserveFactorChanged(asset, reserveFactor); } + /** + * @dev Updates the borrow cap of a reserve + * @param asset The address of the underlying asset of the reserve + * @param borrowCap The new borrow of the reserve + **/ + function setBorrowCap(address asset, uint256 borrowCap) external onlyPoolAdmin { + DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); + + currentConfig.setBorrowCap(borrowCap); + + pool.setConfiguration(asset, currentConfig.data); + + emit BorrowCapChanged(asset, borrowCap); + } + /** * @dev Sets the interest rate strategy of a reserve * @param asset The address of the underlying asset of the reserve