mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: added risk admins
This commit is contained in:
parent
992e026075
commit
0b0996b49c
|
@ -203,6 +203,18 @@ interface ILendingPoolConfigurator {
|
|||
address indexed implementation
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev Emitted when a new risk admin is registered
|
||||
* @param admin the newly registered admin
|
||||
**/
|
||||
event RiskAdminRegistered(address indexed admin);
|
||||
|
||||
/**
|
||||
* @dev Emitted when a risk admin is unregistered
|
||||
* @param admin the unregistered admin
|
||||
**/
|
||||
event RiskAdminUnregistered(address indexed admin);
|
||||
|
||||
/**
|
||||
* @dev Initializes reserves in batch
|
||||
* @param input The array of reserves initialization parameters
|
||||
|
@ -210,7 +222,7 @@ interface ILendingPoolConfigurator {
|
|||
function batchInitReserve(InitReserveInput[] calldata input) external;
|
||||
|
||||
/**
|
||||
* @dev Updates the aToken implementation for the reserve
|
||||
* @dev pauseReservev Updates the aToken implementation for the reserve
|
||||
* @param input The aToken update paramenters
|
||||
**/
|
||||
function updateAToken(UpdateATokenInput calldata input) external;
|
||||
|
@ -344,4 +356,23 @@ interface ILendingPoolConfigurator {
|
|||
* @param supplyCap The new supply of the reserve
|
||||
**/
|
||||
function setSupplyCap(address asset, uint256 supplyCap) external;
|
||||
|
||||
/**
|
||||
* @dev Registers a new admin with rights on risk related configurations
|
||||
* @param admin The address of the admin to register
|
||||
**/
|
||||
function registerRiskAdmin(address admin) external;
|
||||
|
||||
/**
|
||||
* @dev Unegisters a risk admin
|
||||
* @param admin The address of the admin to unregister
|
||||
**/
|
||||
function unregisterRiskAdmin(address admin) external;
|
||||
|
||||
/**
|
||||
* @dev Returns wether an address in a risk admin or not
|
||||
* @param admin The address of the potential admin
|
||||
**/
|
||||
function isRiskAdmin(address admin) external view returns (bool);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
ILendingPoolAddressesProvider internal _addressesProvider;
|
||||
ILendingPool internal _pool;
|
||||
|
||||
mapping(address => bool) private _riskAdmins;
|
||||
|
||||
modifier onlyPoolAdmin {
|
||||
require(_addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
|
||||
_;
|
||||
|
@ -55,6 +57,14 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
_;
|
||||
}
|
||||
|
||||
modifier onlyRiskOrPoolAdmins {
|
||||
require(
|
||||
_riskAdmins[msg.sender] || addressesProvider.getPoolAdmin() == msg.sender,
|
||||
Errors.LPC_CALLER_NOT_RISK_OR_POOL_ADMIN
|
||||
);
|
||||
_;
|
||||
}
|
||||
|
||||
uint256 internal constant CONFIGURATOR_REVISION = 0x1;
|
||||
|
||||
function getRevision() internal pure override returns (uint256) {
|
||||
|
@ -254,7 +264,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
address asset,
|
||||
uint256 borrowCap,
|
||||
bool stableBorrowRateEnabled
|
||||
) external override onlyPoolAdmin {
|
||||
) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setBorrowingEnabled(true);
|
||||
|
@ -268,7 +278,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
/// @inheritdoc ILendingPoolConfigurator
|
||||
function disableBorrowingOnReserve(address asset) external override onlyPoolAdmin {
|
||||
function disableBorrowingOnReserve(address asset) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setBorrowingEnabled(false);
|
||||
|
@ -283,7 +293,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
uint256 ltv,
|
||||
uint256 liquidationThreshold,
|
||||
uint256 liquidationBonus
|
||||
) external override onlyPoolAdmin {
|
||||
) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
//validation of the parameters: the LTV can
|
||||
|
@ -323,7 +333,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
/// @inheritdoc ILendingPoolConfigurator
|
||||
function enableReserveStableRate(address asset) external override onlyPoolAdmin {
|
||||
function enableReserveStableRate(address asset) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setStableRateBorrowingEnabled(true);
|
||||
|
@ -334,7 +344,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
/// @inheritdoc ILendingPoolConfigurator
|
||||
function disableReserveStableRate(address asset) external override onlyPoolAdmin {
|
||||
function disableReserveStableRate(address asset) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setStableRateBorrowingEnabled(false);
|
||||
|
@ -413,7 +423,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
/// @inheritdoc ILendingPoolConfigurator
|
||||
function setReserveFactor(address asset, uint256 reserveFactor) external override onlyPoolAdmin {
|
||||
function setReserveFactor(address asset, uint256 reserveFactor) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setReserveFactor(reserveFactor);
|
||||
|
@ -424,7 +434,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
///@inheritdoc ILendingPoolConfigurator
|
||||
function setBorrowCap(address asset, uint256 borrowCap) external override onlyPoolAdmin {
|
||||
function setBorrowCap(address asset, uint256 borrowCap) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setBorrowCap(borrowCap);
|
||||
|
@ -435,7 +445,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
}
|
||||
|
||||
///@inheritdoc ILendingPoolConfigurator
|
||||
function setSupplyCap(address asset, uint256 supplyCap) external override onlyPoolAdmin {
|
||||
function setSupplyCap(address asset, uint256 supplyCap) external override onlyRiskOrPoolAdmins {
|
||||
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||
|
||||
currentConfig.setSupplyCap(supplyCap);
|
||||
|
@ -445,15 +455,11 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
emit SupplyCapChanged(asset, supplyCap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
onlyPoolAdmin
|
||||
onlyRiskOrPoolAdmins
|
||||
{
|
||||
_pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
|
||||
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
|
||||
|
@ -464,6 +470,20 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
|||
_pool.setPause(val);
|
||||
}
|
||||
|
||||
function registerRiskAdmin(address admin) external override onlyPoolAdmin {
|
||||
_riskAdmins[admin] = true;
|
||||
emit RiskAdminRegistered(admin);
|
||||
}
|
||||
|
||||
function unregisterRiskAdmin(address admin) external override onlyPoolAdmin {
|
||||
_riskAdmins[admin] = false;
|
||||
emit RiskAdminUnregistered(admin);
|
||||
}
|
||||
|
||||
function isRiskAdmin(address admin) external view override onlyPoolAdmin returns (bool) {
|
||||
return _riskAdmins[admin];
|
||||
}
|
||||
|
||||
function _initTokenWithProxy(address implementation, bytes memory initParams)
|
||||
internal
|
||||
returns (address)
|
||||
|
|
|
@ -108,6 +108,7 @@ library Errors {
|
|||
string public constant RC_INVALID_SUPPLY_CAP = '84';
|
||||
string public constant LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN = '85';
|
||||
string public constant VL_RESERVE_PAUSED = '86';
|
||||
string public constant LPC_CALLER_NOT_RISK_OR_POOL_ADMIN = '87';
|
||||
|
||||
enum CollateralManagerErrors {
|
||||
NO_ERROR,
|
||||
|
|
Loading…
Reference in New Issue
Block a user