Fix conflicts

This commit is contained in:
David Racero 2020-11-05 16:15:52 +01:00
commit b5f2f283a2
41 changed files with 397 additions and 389 deletions

View File

@ -131,8 +131,9 @@ 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.buidlerevm]: undefined, [eEthereumNetwork.buidlerevm]: undefined,
[eEthereumNetwork.coverage]: undefined, [eEthereumNetwork.coverage]: undefined,
[eEthereumNetwork.hardhat]: undefined, [eEthereumNetwork.hardhat]: undefined,
@ -140,7 +141,16 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.main]: undefined, [eEthereumNetwork.main]: undefined,
}, },
AaveAdminIndex: 0, PoolAdminIndex: 0,
EmergencyAdmin: {
[eEthereumNetwork.hardhat]: undefined,
[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

@ -21,7 +21,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';
@ -114,13 +115,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

@ -33,13 +33,6 @@ interface ILendingPool {
**/ **/
event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);
event BorrowAllowanceDelegated(
address indexed fromUser,
address indexed toUser,
address[] assets,
uint256[] interestRateModes,
uint256[] amounts
);
/** /**
* @dev emitted on borrow * @dev emitted on borrow
* @param reserve the address of the reserve * @param reserve the address of the reserve
@ -196,27 +189,6 @@ interface ILendingPool {
address to address to
) external; ) external;
/**
* @dev Sets allowance to borrow on a certain type of debt assets for a certain user address
* @param assets The underlying asset of each debt token
* @param user The user to give allowance to
* @param interestRateModes Types of debt: 1 for stable, 2 for variable
* @param amounts Allowance amounts to borrow
**/
function delegateBorrowAllowance(
address[] calldata assets,
address user,
uint256[] calldata interestRateModes,
uint256[] calldata amounts
) external;
function getBorrowAllowance(
address fromUser,
address toUser,
address asset,
uint256 interestRateMode
) external view returns (uint256);
/** /**
* @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower * @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower
* already deposited enough collateral. * already deposited enough collateral.

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

@ -166,53 +166,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
emit Withdraw(asset, msg.sender, to, amountToWithdraw); emit Withdraw(asset, msg.sender, to, amountToWithdraw);
} }
/**
* @dev returns the borrow allowance of the user
* @param asset The underlying asset of the debt token
* @param fromUser The user to giving allowance
* @param toUser The user to give allowance to
* @param interestRateMode Type of debt: 1 for stable, 2 for variable
* @return the current allowance of toUser
**/
function getBorrowAllowance(
address fromUser,
address toUser,
address asset,
uint256 interestRateMode
) external override view returns (uint256) {
return
_borrowAllowance[_reserves[asset].getDebtTokenAddress(interestRateMode)][fromUser][toUser];
}
/**
* @dev Sets allowance to borrow on a certain type of debt assets for a certain user address
* @param assets The underlying asset of each debt token
* @param user The user to give allowance to
* @param interestRateModes Types of debt: 1 for stable, 2 for variable
* @param amounts Allowance amounts to borrow
**/
function delegateBorrowAllowance(
address[] calldata assets,
address user,
uint256[] calldata interestRateModes,
uint256[] calldata amounts
) external override {
_whenNotPaused();
uint256 countAssets = assets.length;
require(
countAssets == interestRateModes.length && countAssets == amounts.length,
Errors.LP_INCONSISTENT_PARAMS_LENGTH
);
for (uint256 i = 0; i < countAssets; i++) {
address debtToken = _reserves[assets[i]].getDebtTokenAddress(interestRateModes[i]);
_borrowAllowance[debtToken][msg.sender][user] = amounts[i];
}
emit BorrowAllowanceDelegated(msg.sender, user, assets, interestRateModes, amounts);
}
/** /**
* @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower * @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower
* already deposited enough collateral. * already deposited enough collateral.
@ -338,6 +291,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
//burn stable rate tokens, mint variable rate tokens //burn stable rate tokens, mint variable rate tokens
IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt); IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt);
IVariableDebtToken(reserve.variableDebtTokenAddress).mint( IVariableDebtToken(reserve.variableDebtTokenAddress).mint(
msg.sender,
msg.sender, msg.sender,
stableDebt, stableDebt,
reserve.variableBorrowIndex reserve.variableBorrowIndex
@ -350,6 +304,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
reserve.variableBorrowIndex reserve.variableBorrowIndex
); );
IStableDebtToken(reserve.stableDebtTokenAddress).mint( IStableDebtToken(reserve.stableDebtTokenAddress).mint(
msg.sender,
msg.sender, msg.sender,
variableDebt, variableDebt,
reserve.currentStableBorrowRate reserve.currentStableBorrowRate
@ -411,6 +366,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
IStableDebtToken(address(stableDebtToken)).burn(user, stableBorrowBalance); IStableDebtToken(address(stableDebtToken)).burn(user, stableBorrowBalance);
IStableDebtToken(address(stableDebtToken)).mint( IStableDebtToken(address(stableDebtToken)).mint(
user,
user, user,
stableBorrowBalance, stableBorrowBalance,
reserve.currentStableBorrowRate reserve.currentStableBorrowRate
@ -898,14 +854,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
oracle oracle
); );
if (vars.onBehalfOf != msg.sender) {
address debtToken = reserve.getDebtTokenAddress(vars.interestRateMode);
_borrowAllowance[debtToken][vars.onBehalfOf][msg.sender] = _borrowAllowance[debtToken][vars
.onBehalfOf][msg.sender]
.sub(vars.amount, Errors.LP_BORROW_ALLOWANCE_NOT_ENOUGH);
}
reserve.updateState(); reserve.updateState();
//caching the current stable borrow rate //caching the current stable borrow rate
@ -918,12 +866,14 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
currentStableRate = reserve.currentStableBorrowRate; currentStableRate = reserve.currentStableBorrowRate;
isFirstBorrowing = IStableDebtToken(reserve.stableDebtTokenAddress).mint( isFirstBorrowing = IStableDebtToken(reserve.stableDebtTokenAddress).mint(
vars.user,
vars.onBehalfOf, vars.onBehalfOf,
vars.amount, vars.amount,
currentStableRate currentStableRate
); );
} else { } else {
isFirstBorrowing = IVariableDebtToken(reserve.variableDebtTokenAddress).mint( isFirstBorrowing = IVariableDebtToken(reserve.variableDebtTokenAddress).mint(
vars.user,
vars.onBehalfOf, vars.onBehalfOf,
vars.amount, vars.amount,
reserve.variableBorrowIndex reserve.variableBorrowIndex

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

@ -15,8 +15,6 @@ contract LendingPoolStorage {
mapping(address => ReserveLogic.ReserveData) internal _reserves; mapping(address => ReserveLogic.ReserveData) internal _reserves;
mapping(address => UserConfiguration.Map) internal _usersConfig; mapping(address => UserConfiguration.Map) internal _usersConfig;
// debt token address => user who gives allowance => user who receives allowance => amount
mapping(address => mapping(address => mapping(address => uint256))) internal _borrowAllowance;
// the list of the available reserves, structured as a mapping for gas savings reasons // the list of the available reserves, structured as a mapping for gas savings reasons
mapping(uint256 => address) internal _reservesList; mapping(uint256 => address) internal _reservesList;

View File

@ -18,7 +18,8 @@ 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'
string public constant BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
//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 +48,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 +62,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'
@ -79,7 +81,6 @@ library Errors {
string public constant AT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint string public constant AT_INVALID_MINT_AMOUNT = '56'; //invalid amount to mint
string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57'; string public constant LP_FAILED_REPAY_WITH_COLLATERAL = '57';
string public constant AT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn string public constant AT_INVALID_BURN_AMOUNT = '58'; //invalid amount to burn
string public constant LP_BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small
string public constant LP_FAILED_COLLATERAL_SWAP = '60'; string public constant LP_FAILED_COLLATERAL_SWAP = '60';
string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61';
string public constant LP_REENTRANCY_NOT_ALLOWED = '62'; string public constant LP_REENTRANCY_NOT_ALLOWED = '62';

View File

@ -119,28 +119,6 @@ library ReserveLogic {
return cumulated; return cumulated;
} }
/**
* @dev returns an address of the debt token used for particular interest rate mode on asset.
* @param reserve the reserve object
* @param interestRateMode - STABLE or VARIABLE from ReserveLogic.InterestRateMode enum
* @return an address of the corresponding debt token from reserve configuration
**/
function getDebtTokenAddress(ReserveLogic.ReserveData storage reserve, uint256 interestRateMode)
external
view
returns (address)
{
require(
ReserveLogic.InterestRateMode.STABLE == ReserveLogic.InterestRateMode(interestRateMode) ||
ReserveLogic.InterestRateMode.VARIABLE == ReserveLogic.InterestRateMode(interestRateMode),
Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
);
return
ReserveLogic.InterestRateMode.STABLE == ReserveLogic.InterestRateMode(interestRateMode)
? reserve.stableDebtTokenAddress
: reserve.variableDebtTokenAddress;
}
/** /**
* @dev Updates the liquidity cumulative index Ci and variable borrow cumulative index Bvc. Refer to the whitepaper for * @dev Updates the liquidity cumulative index Ci and variable borrow cumulative index Bvc. Refer to the whitepaper for
* a formal specification. * a formal specification.

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

@ -16,9 +16,10 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
uint256 public constant DEBT_TOKEN_REVISION = 0x1; uint256 public constant DEBT_TOKEN_REVISION = 0x1;
uint256 private _avgStableRate; uint256 internal _avgStableRate;
mapping(address => uint40) _timestamps; mapping(address => uint40) internal _timestamps;
uint40 _totalSupplyTimestamp; mapping(address => uint256) internal _usersData;
uint40 internal _totalSupplyTimestamp;
constructor( constructor(
address pool, address pool,
@ -95,17 +96,18 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
**/ **/
function mint( function mint(
address user, address user,
address onBehalfOf,
uint256 amount, uint256 amount,
uint256 rate uint256 rate
) external override onlyLendingPool returns (bool) { ) external override onlyLendingPool returns (bool) {
MintLocalVars memory vars; MintLocalVars memory vars;
if (user != onBehalfOf) {
_decreaseBorrowAllowance(onBehalfOf, user, amount);
}
//cumulates the user debt //cumulates the user debt
( (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(onBehalfOf);
uint256 previousBalance,
uint256 currentBalance,
uint256 balanceIncrease
) = _calculateBalanceIncrease(user);
//accrueing the interest accumulation to the stored total supply and caching it //accrueing the interest accumulation to the stored total supply and caching it
vars.previousSupply = totalSupply(); vars.previousSupply = totalSupply();
@ -115,17 +117,17 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
vars.amountInRay = amount.wadToRay(); vars.amountInRay = amount.wadToRay();
//calculates the new stable rate for the user //calculates the new stable rate for the user
vars.newStableRate = _usersData[user] vars.newStableRate = _usersData[onBehalfOf]
.rayMul(currentBalance.wadToRay()) .rayMul(currentBalance.wadToRay())
.add(vars.amountInRay.rayMul(rate)) .add(vars.amountInRay.rayMul(rate))
.rayDiv(currentBalance.add(amount).wadToRay()); .rayDiv(currentBalance.add(amount).wadToRay());
require(vars.newStableRate < (1 << 128), 'Debt token: stable rate overflow'); require(vars.newStableRate < (1 << 128), 'Debt token: stable rate overflow');
_usersData[user] = vars.newStableRate; _usersData[onBehalfOf] = vars.newStableRate;
//updating the user and supply timestamp //updating the user and supply timestamp
//solium-disable-next-line //solium-disable-next-line
_totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp); _totalSupplyTimestamp = _timestamps[onBehalfOf] = uint40(block.timestamp);
//calculates the updated average stable rate //calculates the updated average stable rate
vars.currentAvgStableRate = _avgStableRate = vars vars.currentAvgStableRate = _avgStableRate = vars
@ -134,13 +136,14 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
.add(rate.rayMul(vars.amountInRay)) .add(rate.rayMul(vars.amountInRay))
.rayDiv(vars.nextSupply.wadToRay()); .rayDiv(vars.nextSupply.wadToRay());
_mint(user, amount.add(balanceIncrease), vars.previousSupply); _mint(onBehalfOf, amount.add(balanceIncrease), vars.previousSupply);
// transfer event to track balances // transfer event to track balances
emit Transfer(address(0), user, amount); emit Transfer(address(0), onBehalfOf, amount);
emit Mint( emit Mint(
user, user,
onBehalfOf,
amount, amount,
currentBalance, currentBalance,
balanceIncrease, balanceIncrease,
@ -158,11 +161,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
* @param amount the amount of debt tokens to mint * @param amount the amount of debt tokens to mint
**/ **/
function burn(address user, uint256 amount) external override onlyLendingPool { function burn(address user, uint256 amount) external override onlyLendingPool {
( (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(user);
uint256 previousBalance,
uint256 currentBalance,
uint256 balanceIncrease
) = _calculateBalanceIncrease(user);
uint256 previousSupply = totalSupply(); uint256 previousSupply = totalSupply();
uint256 newStableRate = 0; uint256 newStableRate = 0;

View File

@ -55,17 +55,22 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
**/ **/
function mint( function mint(
address user, address user,
address onBehalfOf,
uint256 amount, uint256 amount,
uint256 index uint256 index
) external override onlyLendingPool returns (bool) { ) external override onlyLendingPool returns (bool) {
uint256 previousBalance = super.balanceOf(user); if (user != onBehalfOf) {
_decreaseBorrowAllowance(onBehalfOf, user, amount);
}
uint256 previousBalance = super.balanceOf(onBehalfOf);
uint256 amountScaled = amount.rayDiv(index); uint256 amountScaled = amount.rayDiv(index);
require(amountScaled != 0, Errors.AT_INVALID_MINT_AMOUNT); require(amountScaled != 0, Errors.AT_INVALID_MINT_AMOUNT);
_mint(user, amountScaled); _mint(onBehalfOf, amountScaled);
emit Transfer(address(0), user, amount); emit Transfer(address(0), onBehalfOf, amount);
emit Mint(user, amount, index); emit Mint(user, onBehalfOf, amount, index);
return previousBalance == 0; return previousBalance == 0;
} }

View File

@ -15,9 +15,17 @@ import {Errors} from '../../libraries/helpers/Errors.sol';
*/ */
abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable { abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
event BorrowAllowanceDelegated(
address indexed fromUser,
address indexed toUser,
address asset,
uint256 amount
);
address public immutable UNDERLYING_ASSET_ADDRESS; address public immutable UNDERLYING_ASSET_ADDRESS;
ILendingPool public immutable POOL; ILendingPool public immutable POOL;
mapping(address => uint256) internal _usersData;
mapping(address => mapping(address => uint256)) internal _borrowAllowances;
/** /**
* @dev Only lending pool can call functions marked by this modifier * @dev Only lending pool can call functions marked by this modifier
@ -58,6 +66,28 @@ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
_setDecimals(decimals); _setDecimals(decimals);
} }
/**
* @dev delegates borrowing power to a user on the specific debt token
* @param delegatee the address receiving the delegated borrowing power
* @param amount the maximum amount being delegated. Delegation will still
* respect the liquidation constraints (even if delegated, a delegatee cannot
* force a delegator HF to go below 1)
**/
function approveDelegation(address delegatee, uint256 amount) external {
_borrowAllowances[_msgSender()][delegatee] = amount;
emit BorrowAllowanceDelegated(_msgSender(), delegatee, UNDERLYING_ASSET_ADDRESS, amount);
}
/**
* @dev returns the borrow allowance of the user
* @param fromUser The user to giving allowance
* @param toUser The user to give allowance to
* @return the current allowance of toUser
**/
function borrowAllowance(address fromUser, address toUser) external view returns (uint256) {
return _borrowAllowances[fromUser][toUser];
}
/** /**
* @dev Being non transferrable, the debt token does not implement any of the * @dev Being non transferrable, the debt token does not implement any of the
* standard ERC20 functions for transfer and allowance. * standard ERC20 functions for transfer and allowance.
@ -118,4 +148,19 @@ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
subtractedValue; subtractedValue;
revert('ALLOWANCE_NOT_SUPPORTED'); revert('ALLOWANCE_NOT_SUPPORTED');
} }
function _decreaseBorrowAllowance(
address delegator,
address delegatee,
uint256 amount
) internal {
uint256 newAllowance = _borrowAllowances[delegator][delegatee].sub(
amount,
Errors.BORROW_ALLOWANCE_NOT_ENOUGH
);
_borrowAllowances[delegator][delegatee] = newAllowance;
emit BorrowAllowanceDelegated(delegator, delegatee, UNDERLYING_ASSET_ADDRESS, newAllowance);
}
} }

View File

@ -5,6 +5,27 @@ import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
interface IAToken is IERC20, IScaledBalanceToken { interface IAToken is IERC20, IScaledBalanceToken {
/**
* @dev emitted after the mint action
* @param from the address performing the mint
* @param value the amount to be minted
* @param index the last index of the reserve
**/
event Mint(address indexed from, uint256 value, uint256 index);
/**
* @dev mints aTokens to user
* only lending pools can call this function
* @param user the address receiving the minted tokens
* @param amount the amount of tokens to mint
* @param index the liquidity index
*/
function mint(
address user,
uint256 amount,
uint256 index
) external returns (bool);
/** /**
* @dev emitted after aTokens are burned * @dev emitted after aTokens are burned
* @param from the address performing the redeem * @param from the address performing the redeem

View File

@ -2,27 +2,6 @@
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
interface IScaledBalanceToken { interface IScaledBalanceToken {
/**
* @dev emitted after the mint action
* @param from the address performing the mint
* @param value the amount to be minted
* @param index the last index of the reserve
**/
event Mint(address indexed from, uint256 value, uint256 index);
/**
* @dev mints aTokens to user
* only lending pools can call this function
* @param user the address receiving the minted tokens
* @param amount the amount of tokens to mint
* @param index the liquidity index
*/
function mint(
address user,
uint256 amount,
uint256 index
) external returns (bool);
/** /**
* @dev returns the principal balance of the user. The principal balance is the last * @dev returns the principal balance of the user. The principal balance is the last
* updated stored balance, which does not consider the perpetually accruing interest. * updated stored balance, which does not consider the perpetually accruing interest.

View File

@ -15,7 +15,8 @@ pragma solidity ^0.6.8;
interface IStableDebtToken { interface IStableDebtToken {
/** /**
* @dev emitted when new stable debt is minted * @dev emitted when new stable debt is minted
* @param user the address of the user * @param user the address of the user who triggered the minting
* @param onBehalfOf the address of the user
* @param amount the amount minted * @param amount the amount minted
* @param currentBalance the current balance of the user * @param currentBalance the current balance of the user
* @param balanceIncrease the the increase in balance since the last action of the user * @param balanceIncrease the the increase in balance since the last action of the user
@ -25,6 +26,7 @@ interface IStableDebtToken {
**/ **/
event Mint( event Mint(
address indexed user, address indexed user,
address indexed onBehalfOf,
uint256 amount, uint256 amount,
uint256 currentBalance, uint256 currentBalance,
uint256 balanceIncrease, uint256 balanceIncrease,
@ -60,6 +62,7 @@ interface IStableDebtToken {
**/ **/
function mint( function mint(
address user, address user,
address onBehalfOf,
uint256 amount, uint256 amount,
uint256 rate uint256 rate
) external returns (bool); ) external returns (bool);

View File

@ -9,6 +9,29 @@ import {IScaledBalanceToken} from './IScaledBalanceToken.sol';
* @notice defines the basic interface for a variable debt token. * @notice defines the basic interface for a variable debt token.
**/ **/
interface IVariableDebtToken is IScaledBalanceToken { interface IVariableDebtToken is IScaledBalanceToken {
/**
* @dev emitted after the mint action
* @param from the address performing the mint
* @param onBehalfOf the address of the user on which behalf minting has been performed
* @param value the amount to be minted
* @param index the last index of the reserve
**/
event Mint(address indexed from, address indexed onBehalfOf, uint256 value, uint256 index);
/**
* @dev mints aTokens to user
* only lending pools can call this function
* @param user the address receiving the minted tokens
* @param amount the amount of tokens to mint
* @param index the liquidity index
*/
function mint(
address user,
address onBehalfOf,
uint256 amount,
uint256 index
) external returns (bool);
/** /**
* @dev emitted when variable debt is burnt * @dev emitted when variable debt is burnt
* @param user the user which debt has been burned * @param user the user which debt has been burned

View File

@ -107,7 +107,7 @@
"loc": {"start": {"line": 82, "column": 2}, "end": {"line": 85, "column": 2}} "loc": {"start": {"line": 82, "column": 2}, "end": {"line": 85, "column": 2}}
}, },
"7": { "7": {
"name": "getAaveAdmin", "name": "getPoolAdmin",
"line": 92, "line": 92,
"loc": {"start": {"line": 92, "column": 2}, "end": {"line": 94, "column": 2}} "loc": {"start": {"line": 92, "column": 2}, "end": {"line": 94, "column": 2}}
}, },

View File

@ -261,7 +261,7 @@
}, },
"LendingPoolAddressesProviderRegistry": { "LendingPoolAddressesProviderRegistry": {
"buidlerevm": { "buidlerevm": {
"address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e", "address": "0x18b9306737eaf6E8FC8e737F488a1AE077b18053",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -275,7 +275,7 @@
}, },
"ReserveLogic": { "ReserveLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0x33958cC3535Fc328369EAC2B2Bebd120D67C7fa1", "address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -283,13 +283,13 @@
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F" "deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
}, },
"hardhat": { "hardhat": {
"address": "0x33958cC3535Fc328369EAC2B2Bebd120D67C7fa1", "address": "0x5F6CaC05CDF893f029b29F44d368eAeD40e573B6",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"GenericLogic": { "GenericLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0x2cBbbBE1B75Ad7848F0844215816F551f429c64f", "address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -297,13 +297,13 @@
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F" "deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
}, },
"hardhat": { "hardhat": {
"address": "0x2cBbbBE1B75Ad7848F0844215816F551f429c64f", "address": "0x92cfBAB5A86631e9F1A6126b42E01A74eadA61Df",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"ValidationLogic": { "ValidationLogic": {
"buidlerevm": { "buidlerevm": {
"address": "0xbAc762e2000b6815268587b081Fd17aC25519aD5", "address": "0x35c1419Da7cf0Ff885B8Ef8EA9242FEF6800c99b",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -311,21 +311,20 @@
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F" "deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
}, },
"hardhat": { "hardhat": {
"address": "0xbAc762e2000b6815268587b081Fd17aC25519aD5", "address": "0x78Aeff0658Fa67735fBF99Ce7CDB01Fe5D520259",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"LendingPool": { "LendingPool": {
"buidlerevm": { "buidlerevm": {
"address": "0xa43Ba00FCA75B805D17f67F9433b971E9a398690", "address": "0xe2607EabC87fd0A4856840bF23da8458cDF0434F",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
"address": "0x59525b17808F0a7eFe62303ca46e596A5a602683" "address": "0x59525b17808F0a7eFe62303ca46e596A5a602683"
}, },
"hardhat": { "hardhat": {
"address": "0xa43Ba00FCA75B805D17f67F9433b971E9a398690", "address": "0x813F07B2100e59ba6555d0D6dBA2660c68514665"
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
"LendingPoolConfigurator": { "LendingPoolConfigurator": {
@ -341,7 +340,7 @@
}, },
"StableAndVariableTokensHelper": { "StableAndVariableTokensHelper": {
"buidlerevm": { "buidlerevm": {
"address": "0xE4C10Db67595aF2Cb4166c8C274e0140f7E43059", "address": "0x06bA8d8af0dF898D0712DffFb0f862cC51AF45c2",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -355,7 +354,7 @@
}, },
"ATokensAndRatesHelper": { "ATokensAndRatesHelper": {
"buidlerevm": { "buidlerevm": {
"address": "0x099d9fF8F818290C8b5B7Db5bFca84CEebd2714c", "address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -369,7 +368,7 @@
}, },
"PriceOracle": { "PriceOracle": {
"buidlerevm": { "buidlerevm": {
"address": "0x85bdE212E66e2BAE510E44Ed59116c1eC712795b", "address": "0x1750499D05Ed1674d822430FB960d5F6731fDf64",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
@ -379,7 +378,7 @@
}, },
"MockAggregator": { "MockAggregator": {
"buidlerevm": { "buidlerevm": {
"address": "0x8Dd7f10813aC8fCB83ad7ad94e941D53b002fBc7", "address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
@ -389,7 +388,7 @@
}, },
"ChainlinkProxyPriceProvider": { "ChainlinkProxyPriceProvider": {
"buidlerevm": { "buidlerevm": {
"address": "0xfA9dbd706c674801F50169f4B5862cCe045408E6", "address": "0x7B6C3e5486D9e6959441ab554A889099eed76290",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
@ -399,7 +398,7 @@
}, },
"LendingRateOracle": { "LendingRateOracle": {
"buidlerevm": { "buidlerevm": {
"address": "0xbFAD7C67855cc0272CC5ED00dAabeFDB31E7190a", "address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
@ -421,7 +420,7 @@
}, },
"LendingPoolCollateralManager": { "LendingPoolCollateralManager": {
"buidlerevm": { "buidlerevm": {
"address": "0x417fc1038b2AF553D65F4fF2839efE9f93Ec1eac", "address": "0x3c5408De7435Dfa3eB2aF2Edf5E39385f68F69b2",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -443,7 +442,7 @@
}, },
"WalletBalanceProvider": { "WalletBalanceProvider": {
"buidlerevm": { "buidlerevm": {
"address": "0x2530ce07D254eA185E8e0bCC37a39e2FbA3bE548", "address": "0x77B0b5636fEA30eA79BB65AeCCdb599997A849A8",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"kovan": { "kovan": {
@ -491,7 +490,7 @@
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
"address": "0x0Cf45557d25a4e4c0F1aC65EF6c48ae67c61a0E6", "address": "0x7fAeC7791277Ff512c41CA903c177B2Ed952dDAc",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },
@ -501,7 +500,7 @@
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}, },
"hardhat": { "hardhat": {
"address": "0xf784709d2317D872237C4bC22f867d1BAe2913AB", "address": "0x0Cf45557d25a4e4c0F1aC65EF6c48ae67c61a0E6",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
} }
}, },

View File

@ -58,23 +58,36 @@ export const getFeeDistributionParamsCommon = (
receiver: tEthereumAddress receiver: tEthereumAddress
): iBasicDistributionParams => { ): iBasicDistributionParams => {
const receivers = [receiver, ZERO_ADDRESS]; const receivers = [receiver, ZERO_ADDRESS];
const percentages = ['2000', '8000']; const percentages = ['200:0', '8000'];
return { return {
receivers, receivers,
percentages, percentages,
}; };
}; };
export const getGenesisAaveAdmin = async (config: ICommonConfiguration) => { export const getGenesisPoolAdmin = async (config: ICommonConfiguration) => {
const currentNetwork = DRE.network.name; const currentNetwork = DRE.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 DRE.ethers.getSigners()).map((signer) => signer.getAddress()) (await DRE.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 = DRE.network.name;
const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eEthereumNetwork>currentNetwork);
if (targetAddress) {
return targetAddress;
}
const addressList = await Promise.all(
(await DRE.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

@ -80,7 +80,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'
@ -109,7 +109,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'
@ -122,6 +122,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'
@ -388,8 +389,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

@ -8,6 +8,9 @@ import {UserConfiguration} from '../../contracts/libraries/configuration/UserCon
import {ReserveLogic} from '../../contracts/libraries/logic/ReserveLogic.sol'; import {ReserveLogic} from '../../contracts/libraries/logic/ReserveLogic.sol';
import {ILendingPool} from '../../contracts/interfaces/ILendingPool.sol'; import {ILendingPool} from '../../contracts/interfaces/ILendingPool.sol';
import {LendingPool} from '../../contracts/lendingpool/LendingPool.sol'; import {LendingPool} from '../../contracts/lendingpool/LendingPool.sol';
import {
ILendingPoolAddressesProvider
} from '../../contracts/interfaces/ILendingPoolAddressesProvider.sol';
/* /*
Certora: Harness that delegates calls to the original LendingPool. Certora: Harness that delegates calls to the original LendingPool.
@ -25,26 +28,12 @@ contract LendingPoolHarnessForVariableDebtToken is ILendingPool {
originalPool.deposit(asset, amount, onBehalfOf, referralCode); originalPool.deposit(asset, amount, onBehalfOf, referralCode);
} }
function withdraw(address asset, uint256 amount) external override { function withdraw(
originalPool.withdraw(asset, amount);
}
function getBorrowAllowance(
address fromUser,
address toUser,
address asset, address asset,
uint256 interestRateMode uint256 amount,
) external override view returns (uint256) { address to
return originalPool.getBorrowAllowance(fromUser, toUser, asset, interestRateMode);
}
function delegateBorrowAllowance(
address asset,
address user,
uint256 interestRateMode,
uint256 amount
) external override { ) external override {
originalPool.delegateBorrowAllowance(asset, user, interestRateMode, amount); originalPool.withdraw(asset, amount, to);
} }
function borrow( function borrow(
@ -193,12 +182,12 @@ contract LendingPoolHarnessForVariableDebtToken is ILendingPool {
address receiver, address receiver,
address[] calldata assets, address[] calldata assets,
uint256[] calldata amounts, uint256[] calldata amounts,
uint256 mode, uint256[] calldata modes,
address onBehalfOf, address onBehalfOf,
bytes calldata params, bytes calldata params,
uint16 referralCode uint16 referralCode
) external override { ) external override {
originalPool.flashLoan(receiver, assets, amounts, mode, onBehalfOf, params, referralCode); originalPool.flashLoan(receiver, assets, amounts, modes, onBehalfOf, params, referralCode);
} }
function finalizeTransfer( function finalizeTransfer(
@ -211,4 +200,8 @@ contract LendingPoolHarnessForVariableDebtToken is ILendingPool {
) external override { ) external override {
originalPool.finalizeTransfer(asset, from, to, amount, balanceFromAfter, balanceToBefore); originalPool.finalizeTransfer(asset, from, to, amount, balanceFromAfter, balanceToBefore);
} }
function getAddressesProvider() external override view returns (ILendingPoolAddressesProvider) {
return originalPool.getAddressesProvider();
}
} }

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

@ -42,7 +42,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev enviroment')
return prev; return prev;
}, defaultTokenList); }, defaultTokenList);
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();
const admin = await addressesProvider.getAaveAdmin(); const admin = await addressesProvider.getPoolAdmin();
const fallbackOracle = await deployPriceOracle(verify); const fallbackOracle = await deployPriceOracle(verify);
await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei)); await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei));

View File

@ -45,7 +45,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
const reservesParams = getReservesConfigByPool(AavePools.proto); const reservesParams = getReservesConfigByPool(AavePools.proto);
const admin = await addressesProvider.getAaveAdmin(); const admin = await addressesProvider.getPoolAdmin();
await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS); await initReservesByHelper(reservesParams, protoPoolReservesAddresses, admin, ZERO_ADDRESS);
await enableReservesToBorrowByHelper( await enableReservesToBorrowByHelper(

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

@ -33,7 +33,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
Object.keys(ReserveAssets[network]).includes(key) Object.keys(ReserveAssets[network]).includes(key)
); );
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();
const admin = await addressesProvider.getAaveAdmin(); const admin = await addressesProvider.getPoolAdmin();
const fallbackOracle = await getParamPerNetwork(FallbackOracle, network); const fallbackOracle = await getParamPerNetwork(FallbackOracle, network);
const reserveAssets = await getParamPerNetwork(ReserveAssets, network); const reserveAssets = await getParamPerNetwork(ReserveAssets, network);

View File

@ -34,7 +34,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify); const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify);
const admin = await addressesProvider.getAaveAdmin(); const admin = await addressesProvider.getPoolAdmin();
if (!reserveAssets) { if (!reserveAssets) {
throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory'; throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
} }

View File

@ -26,7 +26,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 {
@ -34,7 +34,7 @@ import {
deployAllMockAggregators, deployAllMockAggregators,
setInitialMarketRatesInRatesOracleByHelper, setInitialMarketRatesInRatesOracleByHelper,
} from '../helpers/oracles-helpers'; } from '../helpers/oracles-helpers';
import {waitForTx} from '../helpers/misc-utils'; import {DRE, waitForTx} from '../helpers/misc-utils';
import { import {
initReservesByHelper, initReservesByHelper,
enableReservesToBorrowByHelper, enableReservesToBorrowByHelper,
@ -101,7 +101,14 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
}, {}); }, {});
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 DRE addresses list
const addressList = await Promise.all(
(await DRE.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

@ -454,10 +454,12 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
const flashAmount = ethers.utils.parseEther('0.8'); const flashAmount = ethers.utils.parseEther('0.8');
const reserveData = await pool.getReserveData(weth.address);
const stableDebtToken = await getVariableDebtToken(reserveData.stableDebtTokenAddress);
// Deposited for onBehalfOf user already, delegate borrow allowance // Deposited for onBehalfOf user already, delegate borrow allowance
await pool await stableDebtToken.connect(onBehalfOf.signer).approveDelegation(caller.address, flashAmount);
.connect(onBehalfOf.signer)
.delegateBorrowAllowance([weth.address], caller.address, [1], [flashAmount]);
await _mockFlashLoanReceiver.setFailExecutionTransfer(true); await _mockFlashLoanReceiver.setFailExecutionTransfer(true);

View File

@ -18,7 +18,12 @@ import {
import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/helpers'; import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/helpers';
import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers'; import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers';
import {getAToken, getMintableErc20} from '../../helpers/contracts-getters'; import {
getAToken,
getMintableErc20,
getStableDebtToken,
getVariableDebtToken,
} from '../../helpers/contracts-getters';
import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants'; import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants';
import {SignerWithAddress, TestEnv} from './make-suite'; import {SignerWithAddress, TestEnv} from './make-suite';
import {DRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils'; import {DRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils';
@ -277,9 +282,9 @@ export const withdraw = async (
}; };
export const delegateBorrowAllowance = async ( export const delegateBorrowAllowance = async (
reserveSymbols: string[], reserve: string,
amounts: string[], amount: string,
interestRateModes: string[], interestRateMode: string,
user: SignerWithAddress, user: SignerWithAddress,
receiver: tEthereumAddress, receiver: tEthereumAddress,
expectedResult: string, expectedResult: string,
@ -288,32 +293,33 @@ export const delegateBorrowAllowance = async (
) => { ) => {
const {pool} = testEnv; const {pool} = testEnv;
const reserves: tEthereumAddress[] = []; const reserveAddress: tEthereumAddress = await getReserveAddressFromSymbol(reserve);
const amountsToDelegate: tEthereumAddress[] = [];
for (const reserveSymbol of reserveSymbols) {
const newLength = reserves.push(await getReserveAddressFromSymbol(reserveSymbol));
amountsToDelegate.push(
await (
await convertToCurrencyDecimals(reserves[newLength - 1], amounts[newLength - 1])
).toString()
);
}
const delegateAllowancePromise = pool const amountToDelegate: string = await (
await convertToCurrencyDecimals(reserveAddress, amount)
).toString();
const reserveData = await pool.getReserveData(reserveAddress);
const debtToken =
interestRateMode === '1'
? await getStableDebtToken(reserveData.stableDebtTokenAddress)
: await getVariableDebtToken(reserveData.variableDebtTokenAddress);
const delegateAllowancePromise = debtToken
.connect(user.signer) .connect(user.signer)
.delegateBorrowAllowance(reserves, receiver, interestRateModes, amountsToDelegate); .approveDelegation(receiver, amountToDelegate);
if (expectedResult === 'revert') {
await expect(delegateAllowancePromise, revertMessage).to.be.reverted; if (expectedResult === 'revert' && revertMessage) {
await expect(delegateAllowancePromise, revertMessage).to.be.revertedWith(revertMessage);
return; return;
} else { } else {
await delegateAllowancePromise; await delegateAllowancePromise;
for (const [i, reserve] of reserves.entries()) { const allowance = await debtToken.borrowAllowance(user.address, receiver);
expect( expect(allowance.toString()).to.be.equal(
( amountToDelegate,
await pool.getBorrowAllowance(user.address, receiver, reserve, interestRateModes[i]) 'borrowAllowance is set incorrectly'
).toString() );
).to.be.equal(amountsToDelegate[i], 'borrowAllowance are set incorrectly');
}
} }
}; };

View File

@ -121,9 +121,9 @@ const executeAction = async (action: Action, users: SignerWithAddress[], testEnv
} }
await delegateBorrowAllowance( await delegateBorrowAllowance(
[reserve], reserve,
[amount], amount,
[rateMode], rateMode,
user, user,
toUser, toUser,
expected, expected,

View File

@ -68,7 +68,7 @@
"borrowRateMode": "stable" "borrowRateMode": "stable"
}, },
"expected": "revert", "expected": "revert",
"revertMessage": "54" "revertMessage": "59"
} }
] ]
}, },
@ -96,7 +96,7 @@
"borrowRateMode": "variable" "borrowRateMode": "variable"
}, },
"expected": "revert", "expected": "revert",
"revertMessage": "54" "revertMessage": "59"
} }
] ]
}, },
@ -126,23 +126,6 @@
"expected": "success" "expected": "success"
} }
] ]
},
{
"description": "User 0 delegates borrowing of 1 WETH to user 2 with wrong borrowRateMode, revert expected",
"actions": [
{
"name": "delegateBorrowAllowance",
"args": {
"reserve": "WETH",
"amount": "1",
"user": "0",
"borrowRateMode": "random",
"toUser": "2"
},
"expected": "revert",
"revertMessage": "8"
}
]
} }
] ]
} }

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,24 +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 () => {
const {pool, dai, users, configurator} = testEnv;
const user = users[1];
const toUser = users[2];
// Pause the pool
await configurator.setPoolPause(true);
// Try to execute liquidation
await expect(
pool.connect(user.signer).delegateBorrowAllowance([dai.address], toUser.address, ['1'], ['1'])
).revertedWith(LP_IS_PAUSED);
// Unpause the pool
await configurator.setPoolPause(false);
}); });
it('Borrow', async () => { it('Borrow', async () => {
@ -144,7 +127,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 +135,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 +143,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 +151,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 +164,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 +181,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 +254,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
await expect( await expect(
@ -279,7 +262,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 +283,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 +291,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 +318,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

@ -16,9 +16,9 @@ makeSuite('Stable debt token tests', (testEnv: TestEnv) => {
const stableDebtContract = await getStableDebtToken(daiStableDebtTokenAddress); const stableDebtContract = await getStableDebtToken(daiStableDebtTokenAddress);
await expect(stableDebtContract.mint(deployer.address, '1', '1')).to.be.revertedWith( await expect(
AT_CALLER_MUST_BE_LENDING_POOL stableDebtContract.mint(deployer.address, deployer.address, '1', '1')
); ).to.be.revertedWith(AT_CALLER_MUST_BE_LENDING_POOL);
}); });
it('Tries to invoke burn not being the LendingPool', async () => { it('Tries to invoke burn not being the LendingPool', async () => {

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 () => {

View File

@ -15,9 +15,9 @@ makeSuite('Variable debt token tests', (testEnv: TestEnv) => {
const variableDebtContract = await getVariableDebtToken(daiVariableDebtTokenAddress); const variableDebtContract = await getVariableDebtToken(daiVariableDebtTokenAddress);
await expect(variableDebtContract.mint(deployer.address, '1', '1')).to.be.revertedWith( await expect(
AT_CALLER_MUST_BE_LENDING_POOL variableDebtContract.mint(deployer.address, deployer.address, '1', '1')
); ).to.be.revertedWith(AT_CALLER_MUST_BE_LENDING_POOL);
}); });
it('Tries to invoke burn not being the LendingPool', async () => { it('Tries to invoke burn not being the LendingPool', async () => {