Adds Emergency admin

This commit is contained in:
emilio 2020-11-05 12:35:50 +01:00
parent 688c7da6e6
commit 69c3d5b9b7
18 changed files with 203 additions and 136 deletions

View File

@ -118,15 +118,23 @@ export const CommonsConfig: ICommonConfiguration = {
// COMMON PROTOCOL ADDRESSES ACROSS POOLS // COMMON PROTOCOL ADDRESSES ACROSS POOLS
// ---------------- // ----------------
// If lendingPoolManagerAddress is set, will take priority over lendingPoolManagerAddressIndex // If PoolAdmin/emergencyAdmin is set, will take priority over PoolAdminIndex/emergencyAdminIndex
AaveAdmin: { PoolAdmin: {
[eEthereumNetwork.coverage]: undefined, [eEthereumNetwork.coverage]: undefined,
[eEthereumNetwork.buidlerevm]: undefined, [eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.kovan]: undefined, [eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.main]: undefined, [eEthereumNetwork.main]: undefined,
}, },
AaveAdminIndex: 0, PoolAdminIndex: 0,
EmergencyAdmin: {
[eEthereumNetwork.coverage]: undefined,
[eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.main]: undefined,
},
EmergencyAdminIndex: 1,
ProviderRegistry: { ProviderRegistry: {
[eEthereumNetwork.kovan]: '', [eEthereumNetwork.kovan]: '',
[eEthereumNetwork.ropsten]: '', [eEthereumNetwork.ropsten]: '',

View File

@ -20,7 +20,8 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
bytes32 private constant LENDING_POOL = 'LENDING_POOL'; bytes32 private constant LENDING_POOL = 'LENDING_POOL';
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR'; bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
bytes32 private constant AAVE_ADMIN = 'AAVE_ADMIN'; bytes32 private constant POOL_ADMIN = 'POOL_ADMIN';
bytes32 private constant EMERGENCY_ADMIN = 'EMERGENCY_ADMIN';
bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER'; bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER';
bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE'; bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE';
bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE'; bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE';
@ -113,13 +114,22 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider
* hence the upgradable proxy pattern is not used * hence the upgradable proxy pattern is not used
**/ **/
function getAaveAdmin() external override view returns (address) { function getPoolAdmin() external override view returns (address) {
return getAddress(AAVE_ADMIN); return getAddress(POOL_ADMIN);
} }
function setAaveAdmin(address aaveAdmin) external override onlyOwner { function setPoolAdmin(address admin) external override onlyOwner {
_addresses[AAVE_ADMIN] = aaveAdmin; _addresses[POOL_ADMIN] = admin;
emit AaveAdminUpdated(aaveAdmin); emit ConfigurationAdminUpdated(admin);
}
function getEmergencyAdmin() external override view returns (address) {
return getAddress(EMERGENCY_ADMIN);
}
function setEmergencyAdmin(address emergencyAdmin) external override onlyOwner {
_addresses[EMERGENCY_ADMIN] = emergencyAdmin;
emit EmergencyAdminUpdated(emergencyAdmin);
} }
function getPriceOracle() external override view returns (address) { function getPriceOracle() external override view returns (address) {

View File

@ -8,7 +8,8 @@ pragma solidity ^0.6.8;
interface ILendingPoolAddressesProvider { interface ILendingPoolAddressesProvider {
event LendingPoolUpdated(address indexed newAddress); event LendingPoolUpdated(address indexed newAddress);
event AaveAdminUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress);
event EmergencyAdminUpdated(address indexed newAddress);
event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress);
event LendingPoolCollateralManagerUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress);
event EthereumAddressUpdated(address indexed newAddress); event EthereumAddressUpdated(address indexed newAddress);
@ -37,9 +38,13 @@ interface ILendingPoolAddressesProvider {
function setLendingPoolCollateralManager(address manager) external; function setLendingPoolCollateralManager(address manager) external;
function getAaveAdmin() external view returns (address); function getPoolAdmin() external view returns (address);
function setAaveAdmin(address aaveAdmin) external; function setPoolAdmin(address admin) external;
function getEmergencyAdmin() external view returns (address);
function setEmergencyAdmin(address admin) external;
function getPriceOracle() external view returns (address); function getPriceOracle() external view returns (address);

View File

@ -188,10 +188,21 @@ contract LendingPoolConfigurator is VersionedInitializable {
ILendingPool internal pool; ILendingPool internal pool;
/** /**
* @dev only the aave admin can call functions affected by this modifier * @dev only the pool admin can call functions affected by this modifier
**/ **/
modifier onlyAaveAdmin { modifier onlyPoolAdmin {
require(addressesProvider.getAaveAdmin() == msg.sender, Errors.CALLER_NOT_AAVE_ADMIN); require(addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
_;
}
/**
* @dev only the emergency admin can call functions affected by this modifier
**/
modifier onlyEmergencyAdmin {
require(
addressesProvider.getEmergencyAdmin() == msg.sender,
Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN
);
_; _;
} }
@ -220,7 +231,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
address variableDebtTokenImpl, address variableDebtTokenImpl,
uint8 underlyingAssetDecimals, uint8 underlyingAssetDecimals,
address interestRateStrategyAddress address interestRateStrategyAddress
) public onlyAaveAdmin { ) public onlyPoolAdmin {
address asset = ITokenConfiguration(aTokenImpl).UNDERLYING_ASSET_ADDRESS(); address asset = ITokenConfiguration(aTokenImpl).UNDERLYING_ASSET_ADDRESS();
require( require(
@ -287,7 +298,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve to be updated * @param asset the address of the reserve to be updated
* @param implementation the address of the new aToken implementation * @param implementation the address of the new aToken implementation
**/ **/
function updateAToken(address asset, address implementation) external onlyAaveAdmin { function updateAToken(address asset, address implementation) external onlyPoolAdmin {
ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset);
_upgradeTokenImplementation(asset, reserveData.aTokenAddress, implementation); _upgradeTokenImplementation(asset, reserveData.aTokenAddress, implementation);
@ -300,7 +311,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve to be updated * @param asset the address of the reserve to be updated
* @param implementation the address of the new aToken implementation * @param implementation the address of the new aToken implementation
**/ **/
function updateStableDebtToken(address asset, address implementation) external onlyAaveAdmin { function updateStableDebtToken(address asset, address implementation) external onlyPoolAdmin {
ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset);
_upgradeTokenImplementation(asset, reserveData.stableDebtTokenAddress, implementation); _upgradeTokenImplementation(asset, reserveData.stableDebtTokenAddress, implementation);
@ -313,7 +324,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve to be updated * @param asset the address of the reserve to be updated
* @param implementation the address of the new aToken implementation * @param implementation the address of the new aToken implementation
**/ **/
function updateVariableDebtToken(address asset, address implementation) external onlyAaveAdmin { function updateVariableDebtToken(address asset, address implementation) external onlyPoolAdmin {
ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset);
_upgradeTokenImplementation(asset, reserveData.variableDebtTokenAddress, implementation); _upgradeTokenImplementation(asset, reserveData.variableDebtTokenAddress, implementation);
@ -328,7 +339,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
**/ **/
function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled) function enableBorrowingOnReserve(address asset, bool stableBorrowRateEnabled)
external external
onlyAaveAdmin onlyPoolAdmin
{ {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
@ -344,7 +355,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev disables borrowing on a reserve * @dev disables borrowing on a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function disableBorrowingOnReserve(address asset) external onlyAaveAdmin { function disableBorrowingOnReserve(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setBorrowingEnabled(false); currentConfig.setBorrowingEnabled(false);
@ -365,7 +376,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
uint256 ltv, uint256 ltv,
uint256 liquidationThreshold, uint256 liquidationThreshold,
uint256 liquidationBonus uint256 liquidationBonus
) external onlyAaveAdmin { ) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
//validation of the parameters: the LTV can //validation of the parameters: the LTV can
@ -401,7 +412,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev enable stable rate borrowing on a reserve * @dev enable stable rate borrowing on a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function enableReserveStableRate(address asset) external onlyAaveAdmin { function enableReserveStableRate(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(true); currentConfig.setStableRateBorrowingEnabled(true);
@ -415,7 +426,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev disable stable rate borrowing on a reserve * @dev disable stable rate borrowing on a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function disableReserveStableRate(address asset) external onlyAaveAdmin { function disableReserveStableRate(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(false); currentConfig.setStableRateBorrowingEnabled(false);
@ -429,7 +440,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev activates a reserve * @dev activates a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function activateReserve(address asset) external onlyAaveAdmin { function activateReserve(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setActive(true); currentConfig.setActive(true);
@ -443,7 +454,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev deactivates a reserve * @dev deactivates a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function deactivateReserve(address asset) external onlyAaveAdmin { function deactivateReserve(address asset) external onlyPoolAdmin {
_checkNoLiquidity(asset); _checkNoLiquidity(asset);
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
@ -459,7 +470,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev freezes a reserve. A frozen reserve doesn't accept any new deposit, borrow or rate swap, but can accept repayments, liquidations, rate rebalances and redeems * @dev freezes a reserve. A frozen reserve doesn't accept any new deposit, borrow or rate swap, but can accept repayments, liquidations, rate rebalances and redeems
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function freezeReserve(address asset) external onlyAaveAdmin { function freezeReserve(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(true); currentConfig.setFrozen(true);
@ -473,7 +484,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev unfreezes a reserve * @dev unfreezes a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function unfreezeReserve(address asset) external onlyAaveAdmin { function unfreezeReserve(address asset) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(false); currentConfig.setFrozen(false);
@ -488,7 +499,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
* @param ltv the new value for the loan to value * @param ltv the new value for the loan to value
**/ **/
function setLtv(address asset, uint256 ltv) external onlyAaveAdmin { function setLtv(address asset, uint256 ltv) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLtv(ltv); currentConfig.setLtv(ltv);
@ -503,7 +514,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
* @param reserveFactor the new reserve factor of the reserve * @param reserveFactor the new reserve factor of the reserve
**/ **/
function setReserveFactor(address asset, uint256 reserveFactor) external onlyAaveAdmin { function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setReserveFactor(reserveFactor); currentConfig.setReserveFactor(reserveFactor);
@ -518,7 +529,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
* @param threshold the new value for the liquidation threshold * @param threshold the new value for the liquidation threshold
**/ **/
function setLiquidationThreshold(address asset, uint256 threshold) external onlyAaveAdmin { function setLiquidationThreshold(address asset, uint256 threshold) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLiquidationThreshold(threshold); currentConfig.setLiquidationThreshold(threshold);
@ -533,7 +544,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
* @param bonus the new value for the liquidation bonus * @param bonus the new value for the liquidation bonus
**/ **/
function setLiquidationBonus(address asset, uint256 bonus) external onlyAaveAdmin { function setLiquidationBonus(address asset, uint256 bonus) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLiquidationBonus(bonus); currentConfig.setLiquidationBonus(bonus);
@ -548,7 +559,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
* @param decimals the new number of decimals * @param decimals the new number of decimals
**/ **/
function setReserveDecimals(address asset, uint256 decimals) external onlyAaveAdmin { function setReserveDecimals(address asset, uint256 decimals) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset); ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setDecimals(decimals); currentConfig.setDecimals(decimals);
@ -565,7 +576,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
**/ **/
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
external external
onlyAaveAdmin onlyPoolAdmin
{ {
pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress); pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress); emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
@ -620,7 +631,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @dev pauses or unpauses LendingPool actions * @dev pauses or unpauses LendingPool actions
* @param val the boolean value to set the current pause state of LendingPool * @param val the boolean value to set the current pause state of LendingPool
**/ **/
function setPoolPause(bool val) external onlyAaveAdmin { function setPoolPause(bool val) external onlyEmergencyAdmin {
pool.setPause(val); pool.setPause(val);
} }

View File

@ -18,7 +18,7 @@ pragma solidity ^0.6.8;
*/ */
library Errors { library Errors {
//common errors //common errors
string public constant CALLER_NOT_AAVE_ADMIN = '33'; // 'The caller must be the aave admin' string public constant CALLER_NOT_POOL_ADMIN = '33'; // 'The caller must be the pool admin'
//contract specific errors //contract specific errors
string public constant VL_AMOUNT_NOT_GREATER_THAN_0 = '1'; // 'Amount must be greater than 0' string public constant VL_AMOUNT_NOT_GREATER_THAN_0 = '1'; // 'Amount must be greater than 0'
@ -47,7 +47,7 @@ library Errors {
string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow' string public constant LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24'; // 'There is not enough liquidity available to borrow'
string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.' string public constant LP_REQUESTED_AMOUNT_TOO_SMALL = '25'; // 'The requested amount is too small for a FlashLoan.'
string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent' string public constant LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26'; // 'The actual balance of the protocol is inconsistent'
string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The actual balance of the protocol is inconsistent' string public constant LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27'; // 'The caller of the function is not the lending pool configurator'
string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28'; string public constant LP_INCONSISTENT_FLASHLOAN_PARAMS = '28';
string public constant AT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool' string public constant AT_CALLER_MUST_BE_LENDING_POOL = '29'; // 'The caller of this function must be a lending pool'
string public constant AT_CANNOT_GIVE_ALLVWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant AT_CANNOT_GIVE_ALLVWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself'
@ -61,6 +61,7 @@ library Errors {
string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39'; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_ADDRESSES_PROVIDER_ID = '40'; // 'The liquidity of the reserve needs to be 0'
string public constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve' string public constant LPC_INVALID_CONFIGURATION = '75'; // 'Invalid risk parameters for the reserve'
string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = '76'; // 'The caller must be the emergency admin'
string public constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered' string public constant LPAPR_PROVIDER_NOT_REGISTERED = '41'; // 'Provider is not registered'
string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold' string public constant LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42'; // 'Health factor is not below the threshold'
string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated' string public constant LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43'; // 'The collateral chosen cannot be liquidated'

View File

@ -25,10 +25,10 @@ contract DelegationAwareAToken is AToken {
/** /**
* @dev only the aave admin can call this function * @dev only the aave admin can call this function
**/ **/
modifier onlyAaveAdmin { modifier onlyPoolAdmin {
require( require(
_msgSender() == ILendingPool(POOL).getAddressesProvider().getAaveAdmin(), _msgSender() == ILendingPool(POOL).getAddressesProvider().getPoolAdmin(),
Errors.CALLER_NOT_AAVE_ADMIN Errors.CALLER_NOT_POOL_ADMIN
); );
_; _;
} }
@ -66,7 +66,7 @@ contract DelegationAwareAToken is AToken {
* @dev delegates voting power of the underlying asset to a specific address * @dev delegates voting power of the underlying asset to a specific address
* @param delegatee the address that will receive the delegation * @param delegatee the address that will receive the delegation
**/ **/
function delegateUnderlyingTo(address delegatee) external onlyAaveAdmin { function delegateUnderlyingTo(address delegatee) external onlyPoolAdmin {
IDelegationToken(UNDERLYING_ASSET_ADDRESS).delegate(delegatee); IDelegationToken(UNDERLYING_ASSET_ADDRESS).delegate(delegatee);
} }
} }

View File

@ -157,31 +157,31 @@
}, },
"LendingPoolAddressesProviderRegistry": { "LendingPoolAddressesProviderRegistry": {
"buidlerevm": { "buidlerevm": {
"address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F", "address": "0x18b9306737eaf6E8FC8e737F488a1AE077b18053",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"ReserveLogic": { "ReserveLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c", "address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"GenericLogic": { "GenericLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7", "address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"ValidationLogic": { "ValidationLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574", "address": "0x35c1419Da7cf0Ff885B8Ef8EA9242FEF6800c99b",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"LendingPool": { "LendingPool": {
"buidlerevm": { "buidlerevm": {
"address": "0x35c1419Da7cf0Ff885B8Ef8EA9242FEF6800c99b", "address": "0xe2607EabC87fd0A4856840bF23da8458cDF0434F",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
@ -192,59 +192,59 @@
}, },
"StableAndVariableTokensHelper": { "StableAndVariableTokensHelper": {
"buidlerevm": { "buidlerevm": {
"address": "0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E", "address": "0x06bA8d8af0dF898D0712DffFb0f862cC51AF45c2",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"ATokensAndRatesHelper": { "ATokensAndRatesHelper": {
"buidlerevm": { "buidlerevm": {
"address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7", "address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"PriceOracle": { "PriceOracle": {
"buidlerevm": { "buidlerevm": {
"address": "0xb682dEEf4f8e298d86bFc3e21f50c675151FB974", "address": "0x1750499D05Ed1674d822430FB960d5F6731fDf64",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"MockAggregator": { "MockAggregator": {
"buidlerevm": { "buidlerevm": {
"address": "0x3D8FFB457fedDFBc760F3F243283F52692b579B1", "address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"ChainlinkProxyPriceProvider": { "ChainlinkProxyPriceProvider": {
"buidlerevm": { "buidlerevm": {
"address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89", "address": "0x7B6C3e5486D9e6959441ab554A889099eed76290",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"LendingRateOracle": { "LendingRateOracle": {
"buidlerevm": { "buidlerevm": {
"address": "0xAF6BA11790D1942625C0c2dA07da19AB63845cfF", "address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"AaveProtocolTestHelpers": { "AaveProtocolTestHelpers": {
"buidlerevm": { "buidlerevm": {
"address": "0xf4830d6b1D70C8595d3BD8A63f9ed9F636DB9ef2" "address": "0xd5C35F41baD857A2D4F34D7554E78d0391BAcEDF"
} }
}, },
"LendingPoolCollateralManager": { "LendingPoolCollateralManager": {
"buidlerevm": { "buidlerevm": {
"address": "0x8D0206fEBEB380486729b64bB4cfEDC5b354a6D6", "address": "0x3c5408De7435Dfa3eB2aF2Edf5E39385f68F69b2",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"MockFlashLoanReceiver": { "MockFlashLoanReceiver": {
"buidlerevm": { "buidlerevm": {
"address": "0xfC88832bac6AbdF216BC5A67be68E9DE94aD5ba2" "address": "0x1256eBA4d0a7A38D10BaF4F61775ba491Ce7EE25"
} }
}, },
"WalletBalanceProvider": { "WalletBalanceProvider": {
"buidlerevm": { "buidlerevm": {
"address": "0x1256eBA4d0a7A38D10BaF4F61775ba491Ce7EE25", "address": "0x77B0b5636fEA30eA79BB65AeCCdb599997A849A8",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
@ -268,13 +268,13 @@
}, },
"MintableDelegationERC20": { "MintableDelegationERC20": {
"buidlerevm": { "buidlerevm": {
"address": "0x77B0b5636fEA30eA79BB65AeCCdb599997A849A8", "address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"AToken": { "AToken": {
"buidlerevm": { "buidlerevm": {
"address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c", "address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
} }

View File

@ -63,16 +63,29 @@ export const getFeeDistributionParamsCommon = (
}; };
}; };
export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => { export const getGenesisPoolAdmin = async (config: ICommonConfiguration) => {
const currentNetwork = BRE.network.name; const currentNetwork = BRE.network.name;
const targetAddress = getParamPerNetwork(config.AaveAdmin, <eEthereumNetwork>currentNetwork); const targetAddress = getParamPerNetwork(config.PoolAdmin, <eEthereumNetwork>currentNetwork);
if (targetAddress) { if (targetAddress) {
return targetAddress; return targetAddress;
} }
const addressList = await Promise.all( const addressList = await Promise.all(
(await BRE.ethers.getSigners()).map((signer) => signer.getAddress()) (await BRE.ethers.getSigners()).map((signer) => signer.getAddress())
); );
const addressIndex = config.AaveAdminIndex; const addressIndex = config.PoolAdminIndex;
return addressList[addressIndex];
};
export const getEmergencyAdmin = async (config: ICommonConfiguration) => {
const currentNetwork = BRE.network.name;
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork);
if (targetAddress) {
return targetAddress;
}
const addressList = await Promise.all(
(await BRE.ethers.getSigners()).map((signer) => signer.getAddress())
);
const addressIndex = config.EmergencyAdminIndex;
return addressList[addressIndex]; return addressList[addressIndex];
}; };

View File

@ -24,7 +24,7 @@ export const initReservesByHelper = async (
const addressProvider = await getLendingPoolAddressesProvider(); const addressProvider = await getLendingPoolAddressesProvider();
// Set aTokenAndRatesDeployer as temporal admin // Set aTokenAndRatesDeployer as temporal admin
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address)); await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
// CHUNK CONFIGURATION // CHUNK CONFIGURATION
const tokensChunks = 4; const tokensChunks = 4;
@ -140,7 +140,7 @@ export const initReservesByHelper = async (
} }
// Set deployer back as admin // Set deployer back as admin
await waitForTx(await addressProvider.setAaveAdmin(admin)); await waitForTx(await addressProvider.setPoolAdmin(admin));
}; };
export const getPairsTokenAggregator = ( export const getPairsTokenAggregator = (
@ -207,7 +207,7 @@ export const enableReservesToBorrowByHelper = async (
} }
if (tokens.length) { if (tokens.length) {
// Set aTokenAndRatesDeployer as temporal admin // Set aTokenAndRatesDeployer as temporal admin
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address)); await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
// Deploy init per chunks // Deploy init per chunks
const stableChunks = 20; const stableChunks = 20;
@ -233,7 +233,7 @@ export const enableReservesToBorrowByHelper = async (
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
} }
// Set deployer back as admin // Set deployer back as admin
await waitForTx(await addressProvider.setAaveAdmin(admin)); await waitForTx(await addressProvider.setPoolAdmin(admin));
} }
}; };
@ -280,7 +280,7 @@ export const enableReservesAsCollateralByHelper = async (
} }
if (tokens.length) { if (tokens.length) {
// Set aTokenAndRatesDeployer as temporal admin // Set aTokenAndRatesDeployer as temporal admin
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address)); await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
// Deploy init per chunks // Deploy init per chunks
const enableChunks = 20; const enableChunks = 20;
@ -304,6 +304,6 @@ export const enableReservesAsCollateralByHelper = async (
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`); console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
} }
// Set deployer back as admin // Set deployer back as admin
await waitForTx(await addressProvider.setAaveAdmin(admin)); await waitForTx(await addressProvider.setPoolAdmin(admin));
} }
}; };

View File

@ -75,7 +75,7 @@ export enum eContractid {
*/ */
export enum ProtocolErrors { export enum ProtocolErrors {
//common errors //common errors
CALLER_NOT_AAVE_ADMIN = '33', // 'The caller must be the aave admin' CALLER_NOT_POOL_ADMIN = '33', // 'The caller must be the pool admin'
//contract specific errors //contract specific errors
VL_AMOUNT_NOT_GREATER_THAN_0 = '1', // 'Amount must be greater than 0' VL_AMOUNT_NOT_GREATER_THAN_0 = '1', // 'Amount must be greater than 0'
@ -104,7 +104,7 @@ export enum ProtocolErrors {
LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24', // 'There is not enough liquidity available to borrow' LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24', // 'There is not enough liquidity available to borrow'
LP_REQUESTED_AMOUNT_TOO_SMALL = '25', // 'The requested amount is too small for a FlashLoan.' LP_REQUESTED_AMOUNT_TOO_SMALL = '25', // 'The requested amount is too small for a FlashLoan.'
LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26', // 'The actual balance of the protocol is inconsistent' LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26', // 'The actual balance of the protocol is inconsistent'
LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27', // 'The actual balance of the protocol is inconsistent' LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27', // 'The caller is not the lending pool configurator'
LP_INCONSISTENT_FLASHLOAN_PARAMS = '28', LP_INCONSISTENT_FLASHLOAN_PARAMS = '28',
AT_CALLER_MUST_BE_LENDING_POOL = '29', // 'The caller of this function must be a lending pool' AT_CALLER_MUST_BE_LENDING_POOL = '29', // 'The caller of this function must be a lending pool'
AT_CANNOT_GIVE_ALLVWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself' AT_CANNOT_GIVE_ALLVWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself'
@ -117,6 +117,7 @@ export enum ProtocolErrors {
LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38', // 'The liquidity of the reserve needs to be 0' LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39', // 'The liquidity of the reserve needs to be 0' LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_ADDRESSES_PROVIDER_ID = '40', // 'The liquidity of the reserve needs to be 0' LPC_INVALID_ADDRESSES_PROVIDER_ID = '40', // 'The liquidity of the reserve needs to be 0'
LPC_CALLER_NOT_EMERGENCY_ADMIN = '76', // 'The caller must be the emergencya admin'
LPAPR_PROVIDER_NOT_REGISTERED = '41', // 'Provider is not registered' LPAPR_PROVIDER_NOT_REGISTERED = '41', // 'Provider is not registered'
LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42', // 'Health factor is not below the threshold' LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42', // 'Health factor is not below the threshold'
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43', // 'The collateral chosen cannot be liquidated' LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43', // 'The collateral chosen cannot be liquidated'
@ -372,8 +373,10 @@ export interface ICommonConfiguration {
ChainlinkProxyPriceProvider: iParamsPerNetwork<tEthereumAddress>; ChainlinkProxyPriceProvider: iParamsPerNetwork<tEthereumAddress>;
FallbackOracle: iParamsPerNetwork<tEthereumAddress>; FallbackOracle: iParamsPerNetwork<tEthereumAddress>;
ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>; ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>;
AaveAdmin: iParamsPerNetwork<tEthereumAddress | undefined>; PoolAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
AaveAdminIndex: number; PoolAdminIndex: number;
EmergencyAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
EmergencyAdminIndex: number;
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>; ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
ReservesConfig: iMultiPoolsAssets<IReserveParams>; ReservesConfig: iMultiPoolsAssets<IReserveParams>;
ATokenDomainSeparator: iParamsPerNetwork<string>; ATokenDomainSeparator: iParamsPerNetwork<string>;

View File

@ -16,7 +16,7 @@ task(
const admin = await (await localBRE.ethers.getSigners())[0].getAddress(); const admin = await (await localBRE.ethers.getSigners())[0].getAddress();
const addressesProvider = await deployLendingPoolAddressesProvider(verify); const addressesProvider = await deployLendingPoolAddressesProvider(verify);
await waitForTx(await addressesProvider.setAaveAdmin(admin)); await waitForTx(await addressesProvider.setPoolAdmin(admin));
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify); const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
await waitForTx( await waitForTx(

View File

@ -5,7 +5,12 @@ import {
deployLendingPoolAddressesProviderRegistry, deployLendingPoolAddressesProviderRegistry,
} from '../../helpers/contracts-deployments'; } from '../../helpers/contracts-deployments';
import {waitForTx} from '../../helpers/misc-utils'; import {waitForTx} from '../../helpers/misc-utils';
import {ConfigNames, loadPoolConfig, getGenesisAaveAdmin} from '../../helpers/configuration'; import {
ConfigNames,
loadPoolConfig,
getGenesisPoolAdmin,
getEmergencyAdmin,
} from '../../helpers/configuration';
import {eEthereumNetwork} from '../../helpers/types'; import {eEthereumNetwork} from '../../helpers/types';
import {getLendingPoolAddressesProviderRegistry} from '../../helpers/contracts-getters'; import {getLendingPoolAddressesProviderRegistry} from '../../helpers/contracts-getters';
@ -24,7 +29,11 @@ task(
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network); const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
// Deploy address provider and set genesis manager // Deploy address provider and set genesis manager
const addressesProvider = await deployLendingPoolAddressesProvider(verify); const addressesProvider = await deployLendingPoolAddressesProvider(verify);
await waitForTx(await addressesProvider.setAaveAdmin(await getGenesisAaveAdmin(poolConfig))); await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
const admin = await getEmergencyAdmin(poolConfig);
console.log('Admin is ', admin);
await waitForTx(await addressesProvider.setEmergencyAdmin(admin));
// If no provider registry is set, deploy lending pool address provider registry and register the address provider // If no provider registry is set, deploy lending pool address provider registry and register the address provider
const addressesProviderRegistry = !providerRegistryAddress const addressesProviderRegistry = !providerRegistryAddress

View File

@ -24,7 +24,7 @@ import {
import {Signer} from 'ethers'; import {Signer} from 'ethers';
import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types'; import {TokenContractId, eContractid, tEthereumAddress, AavePools} from '../helpers/types';
import {MintableErc20 as MintableERC20} from '../types/MintableErc20'; import {MintableErc20 as MintableERC20} from '../types/MintableErc20';
import {getReservesConfigByPool} from '../helpers/configuration'; import {getEmergencyAdmin, getReservesConfigByPool} from '../helpers/configuration';
import {initializeMakeSuite} from './helpers/make-suite'; import {initializeMakeSuite} from './helpers/make-suite';
import { import {
@ -32,7 +32,7 @@ import {
deployAllMockAggregators, deployAllMockAggregators,
setInitialMarketRatesInRatesOracleByHelper, setInitialMarketRatesInRatesOracleByHelper,
} from '../helpers/oracles-helpers'; } from '../helpers/oracles-helpers';
import {waitForTx} from '../helpers/misc-utils'; import {BRE, waitForTx} from '../helpers/misc-utils';
import { import {
initReservesByHelper, initReservesByHelper,
enableReservesToBorrowByHelper, enableReservesToBorrowByHelper,
@ -89,7 +89,14 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
const mockTokens = await deployAllMockTokens(deployer); const mockTokens = await deployAllMockTokens(deployer);
const addressesProvider = await deployLendingPoolAddressesProvider(); const addressesProvider = await deployLendingPoolAddressesProvider();
await waitForTx(await addressesProvider.setAaveAdmin(aaveAdmin)); await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
//setting users[1] as emergency admin, which is in position 2 in the BRE addresses list
const addressList = await Promise.all(
(await BRE.ethers.getSigners()).map((signer) => signer.getAddress())
);
await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(); const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry();
await waitForTx( await waitForTx(

View File

@ -11,7 +11,7 @@ const {expect} = require('chai');
makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const { const {
CALLER_NOT_AAVE_ADMIN, CALLER_NOT_POOL_ADMIN,
LPC_RESERVE_LIQUIDITY_NOT_0, LPC_RESERVE_LIQUIDITY_NOT_0,
RC_INVALID_LTV, RC_INVALID_LTV,
RC_INVALID_LIQ_THRESHOLD, RC_INVALID_LIQ_THRESHOLD,
@ -87,16 +87,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).deactivateReserve(weth.address), configurator.connect(users[2].signer).deactivateReserve(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on activateReserve ', async () => { it('Check the onlyAaveAdmin on activateReserve ', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).activateReserve(weth.address), configurator.connect(users[2].signer).activateReserve(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Freezes the ETH reserve', async () => { it('Freezes the ETH reserve', async () => {
@ -156,16 +156,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).freezeReserve(weth.address), configurator.connect(users[2].signer).freezeReserve(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on unfreezeReserve ', async () => { it('Check the onlyAaveAdmin on unfreezeReserve ', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).unfreezeReserve(weth.address), configurator.connect(users[2].signer).unfreezeReserve(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Deactivates the ETH reserve for borrowing', async () => { it('Deactivates the ETH reserve for borrowing', async () => {
@ -228,16 +228,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address), configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => { it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true), configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, true),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Deactivates the ETH reserve as collateral', async () => { it('Deactivates the ETH reserve as collateral', async () => {
@ -300,8 +300,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
configurator configurator
.connect(users[2].signer) .connect(users[2].signer)
.configureReserveAsCollateral(weth.address, '7500', '8000', '10500'), .configureReserveAsCollateral(weth.address, '7500', '8000', '10500'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Disable stable borrow rate on the ETH reserve', async () => { it('Disable stable borrow rate on the ETH reserve', async () => {
@ -360,16 +360,16 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).disableReserveStableRate(weth.address), configurator.connect(users[2].signer).disableReserveStableRate(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on enableReserveStableRate', async () => { it('Check the onlyAaveAdmin on enableReserveStableRate', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).enableReserveStableRate(weth.address), configurator.connect(users[2].signer).enableReserveStableRate(weth.address),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Changes LTV of the reserve', async () => { it('Changes LTV of the reserve', async () => {
@ -402,8 +402,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setLtv(weth.address, '75'), configurator.connect(users[2].signer).setLtv(weth.address, '75'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Changes the reserve factor of the reserve', async () => { it('Changes the reserve factor of the reserve', async () => {
@ -436,8 +436,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setReserveFactor(weth.address, '2000'), configurator.connect(users[2].signer).setReserveFactor(weth.address, '2000'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Changes liquidation threshold of the reserve', async () => { it('Changes liquidation threshold of the reserve', async () => {
@ -470,8 +470,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'), configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Changes liquidation bonus of the reserve', async () => { it('Changes liquidation bonus of the reserve', async () => {
@ -504,24 +504,24 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'), configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on setReserveDecimals', async () => { it('Check the onlyAaveAdmin on setReserveDecimals', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setReserveDecimals(weth.address, '80'), configurator.connect(users[2].signer).setReserveDecimals(weth.address, '80'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => { it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
const {configurator, users, weth} = testEnv; const {configurator, users, weth} = testEnv;
await expect( await expect(
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'), configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
CALLER_NOT_AAVE_ADMIN CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => { it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {

View File

@ -43,7 +43,7 @@ makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => {
await expect( await expect(
delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address) delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address)
).to.be.revertedWith(ProtocolErrors.CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(ProtocolErrors.CALLER_NOT_POOL_ADMIN);
}); });
it('Tries to delegate to user 2', async () => { it('Tries to delegate to user 2', async () => {

View File

@ -21,7 +21,7 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
addressesProvider.setLendingPoolImpl, addressesProvider.setLendingPoolImpl,
addressesProvider.setLendingPoolConfiguratorImpl, addressesProvider.setLendingPoolConfiguratorImpl,
addressesProvider.setLendingPoolCollateralManager, addressesProvider.setLendingPoolCollateralManager,
addressesProvider.setAaveAdmin, addressesProvider.setPoolAdmin,
addressesProvider.setPriceOracle, addressesProvider.setPriceOracle,
addressesProvider.setLendingRateOracle, addressesProvider.setLendingRateOracle,
]) { ]) {

View File

@ -39,7 +39,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
const user1Balance = await aDai.balanceOf(users[1].address); const user1Balance = await aDai.balanceOf(users[1].address);
// Configurator pauses the pool // Configurator pauses the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// User 0 tries the transfer to User 1 // User 0 tries the transfer to User 1
await expect( await expect(
@ -59,7 +59,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
); );
// Configurator unpauses the pool // Configurator unpauses the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
// User 0 succeeds transfer to User 1 // User 0 succeeds transfer to User 1
await aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit); await aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit);
@ -88,13 +88,13 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL);
// Configurator pauses the pool // Configurator pauses the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
await expect( await expect(
pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0') pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0')
).to.revertedWith(LP_IS_PAUSED); ).to.revertedWith(LP_IS_PAUSED);
// Configurator unpauses the pool // Configurator unpauses the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('Withdraw', async () => { it('Withdraw', async () => {
@ -111,7 +111,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
.deposit(dai.address, amountDAItoDeposit, users[0].address, '0'); .deposit(dai.address, amountDAItoDeposit, users[0].address, '0');
// Configurator pauses the pool // Configurator pauses the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// user tries to burn // user tries to burn
await expect( await expect(
@ -119,7 +119,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).to.revertedWith(LP_IS_PAUSED); ).to.revertedWith(LP_IS_PAUSED);
// Configurator unpauses the pool // Configurator unpauses the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('DelegateBorrowAllowance', async () => { it('DelegateBorrowAllowance', async () => {
@ -128,7 +128,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
const user = users[1]; const user = users[1];
const toUser = users[2]; const toUser = users[2];
// Pause the pool // Pause the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// Try to execute liquidation // Try to execute liquidation
await expect( await expect(
@ -136,7 +136,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause the pool // Unpause the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('Borrow', async () => { it('Borrow', async () => {
@ -144,7 +144,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
const user = users[1]; const user = users[1];
// Pause the pool // Pause the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// Try to execute liquidation // Try to execute liquidation
await expect( await expect(
@ -152,7 +152,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause the pool // Unpause the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('Repay', async () => { it('Repay', async () => {
@ -160,7 +160,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
const user = users[1]; const user = users[1];
// Pause the pool // Pause the pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// Try to execute liquidation // Try to execute liquidation
await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith( await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith(
@ -168,7 +168,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
); );
// Unpause the pool // Unpause the pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('Flash loan', async () => { it('Flash loan', async () => {
@ -181,7 +181,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await _mockFlashLoanReceiver.setFailExecutionTransfer(true); await _mockFlashLoanReceiver.setFailExecutionTransfer(true);
// Pause pool // Pause pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
await expect( await expect(
pool pool
@ -198,7 +198,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause pool // Unpause pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('Liquidation call', async () => { it('Liquidation call', async () => {
@ -271,7 +271,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
.toFixed(0); .toFixed(0);
// Pause pool // Pause pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// Do liquidation // Do liquidation
expect( expect(
@ -279,7 +279,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause pool // Unpause pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('SwapBorrowRateMode', async () => { it('SwapBorrowRateMode', async () => {
@ -300,7 +300,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await pool.connect(user.signer).borrow(usdc.address, amountToBorrow, 2, 0, user.address); await pool.connect(user.signer).borrow(usdc.address, amountToBorrow, 2, 0, user.address);
// Pause pool // Pause pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
// Try to repay // Try to repay
await expect( await expect(
@ -308,21 +308,21 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause pool // Unpause pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('RebalanceStableBorrowRate', async () => { it('RebalanceStableBorrowRate', async () => {
const {pool, dai, users, configurator} = testEnv; const {pool, dai, users, configurator} = testEnv;
const user = users[1]; const user = users[1];
// Pause pool // Pause pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
await expect( await expect(
pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address) pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address)
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause pool // Unpause pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
it('setUserUseReserveAsCollateral', async () => { it('setUserUseReserveAsCollateral', async () => {
@ -335,13 +335,13 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await pool.connect(user.signer).deposit(weth.address, amountWETHToDeposit, user.address, '0'); await pool.connect(user.signer).deposit(weth.address, amountWETHToDeposit, user.address, '0');
// Pause pool // Pause pool
await configurator.setPoolPause(true); await configurator.connect(users[1].signer).setPoolPause(true);
await expect( await expect(
pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false) pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false)
).revertedWith(LP_IS_PAUSED); ).revertedWith(LP_IS_PAUSED);
// Unpause pool // Unpause pool
await configurator.setPoolPause(false); await configurator.connect(users[1].signer).setPoolPause(false);
}); });
}); });

View File

@ -19,7 +19,7 @@ import {
} from '../helpers/contracts-deployments'; } from '../helpers/contracts-deployments';
makeSuite('Upgradeability', (testEnv: TestEnv) => { makeSuite('Upgradeability', (testEnv: TestEnv) => {
const {CALLER_NOT_AAVE_ADMIN} = ProtocolErrors; const {CALLER_NOT_POOL_ADMIN} = ProtocolErrors;
let newATokenAddress: string; let newATokenAddress: string;
let newStableTokenAddress: string; let newStableTokenAddress: string;
let newVariableTokenAddress: string; let newVariableTokenAddress: string;
@ -61,7 +61,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
await expect( await expect(
configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress) configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress)
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Upgrades the DAI Atoken implementation ', async () => { it('Upgrades the DAI Atoken implementation ', async () => {
@ -83,7 +83,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
configurator configurator
.connect(users[1].signer) .connect(users[1].signer)
.updateStableDebtToken(dai.address, newStableTokenAddress) .updateStableDebtToken(dai.address, newStableTokenAddress)
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Upgrades the DAI stable debt token implementation ', async () => { it('Upgrades the DAI stable debt token implementation ', async () => {
@ -109,7 +109,7 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
configurator configurator
.connect(users[1].signer) .connect(users[1].signer)
.updateVariableDebtToken(dai.address, newVariableTokenAddress) .updateVariableDebtToken(dai.address, newVariableTokenAddress)
).to.be.revertedWith(CALLER_NOT_AAVE_ADMIN); ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
}); });
it('Upgrades the DAI variable debt token implementation ', async () => { it('Upgrades the DAI variable debt token implementation ', async () => {