2020-05-29 16:45:37 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
|
2020-08-21 13:38:47 +00:00
|
|
|
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
|
|
|
|
import {
|
|
|
|
InitializableAdminUpgradeabilityProxy
|
|
|
|
} from '../libraries/openzeppelin-upgradeability/InitializableAdminUpgradeabilityProxy.sol';
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-08-21 13:38:47 +00:00
|
|
|
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
2020-05-29 16:45:37 +00:00
|
|
|
|
|
|
|
/**
|
2020-07-13 08:54:08 +00:00
|
|
|
* @title LendingPoolAddressesProvider contract
|
|
|
|
* @notice Is the main registry of the protocol. All the different components of the protocol are accessible
|
|
|
|
* through the addresses provider.
|
|
|
|
* @author Aave
|
|
|
|
**/
|
2020-05-29 16:45:37 +00:00
|
|
|
|
2020-08-19 12:53:00 +00:00
|
|
|
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider {
|
|
|
|
mapping(bytes32 => address) private _addresses;
|
|
|
|
|
2020-07-13 08:54:08 +00:00
|
|
|
bytes32 private constant LENDING_POOL = 'LENDING_POOL';
|
|
|
|
bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE';
|
|
|
|
bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR';
|
2020-09-16 12:09:42 +00:00
|
|
|
bytes32 private constant AAVE_ADMIN = 'AAVE_ADMIN';
|
|
|
|
bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER';
|
2020-07-13 08:54:08 +00:00
|
|
|
bytes32 private constant LENDING_POOL_FLASHLOAN_PROVIDER = 'FLASHLOAN_PROVIDER';
|
|
|
|
bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER';
|
|
|
|
bytes32 private constant ETHEREUM_ADDRESS = 'ETHEREUM_ADDRESS';
|
|
|
|
bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE';
|
|
|
|
bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE';
|
|
|
|
bytes32 private constant WALLET_BALANCE_PROVIDER = 'WALLET_BALANCE_PROVIDER';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the address of the LendingPool proxy
|
|
|
|
* @return the lending pool proxy address
|
|
|
|
**/
|
2020-08-19 12:53:00 +00:00
|
|
|
function getLendingPool() external override view returns (address) {
|
|
|
|
return _addresses[LENDING_POOL];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev updates the implementation of the lending pool
|
2020-08-19 12:53:00 +00:00
|
|
|
* @param pool the new lending pool implementation
|
2020-07-13 08:54:08 +00:00
|
|
|
**/
|
2020-08-19 12:53:00 +00:00
|
|
|
function setLendingPoolImpl(address pool) external override onlyOwner {
|
2020-08-21 16:18:12 +00:00
|
|
|
_updateImpl(LENDING_POOL, pool);
|
2020-08-19 12:53:00 +00:00
|
|
|
emit LendingPoolUpdated(pool);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev returns the address of the LendingPoolConfigurator proxy
|
|
|
|
* @return the lending pool configurator proxy address
|
|
|
|
**/
|
2020-08-19 12:53:00 +00:00
|
|
|
function getLendingPoolConfigurator() external override view returns (address) {
|
|
|
|
return _addresses[LENDING_POOL_CONFIGURATOR];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev updates the implementation of the lending pool configurator
|
2020-08-19 12:53:00 +00:00
|
|
|
* @param configurator the new lending pool configurator implementation
|
2020-07-13 08:54:08 +00:00
|
|
|
**/
|
2020-08-19 12:53:00 +00:00
|
|
|
function setLendingPoolConfiguratorImpl(address configurator) external override onlyOwner {
|
2020-08-21 16:18:12 +00:00
|
|
|
_updateImpl(LENDING_POOL_CONFIGURATOR, configurator);
|
2020-08-19 12:53:00 +00:00
|
|
|
emit LendingPoolConfiguratorUpdated(configurator);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-16 10:41:12 +00:00
|
|
|
* @dev returns the address of the LendingPoolCollateralManager. Since the manager is used
|
2020-07-13 08:54:08 +00:00
|
|
|
* through delegateCall within the LendingPool contract, the proxy contract pattern does not work properly hence
|
|
|
|
* the addresses are changed directly.
|
2020-09-16 12:09:42 +00:00
|
|
|
* @return the address of the Lending pool collateral manager
|
2020-07-13 08:54:08 +00:00
|
|
|
**/
|
|
|
|
|
2020-09-16 10:41:12 +00:00
|
|
|
function getLendingPoolCollateralManager() external override view returns (address) {
|
2020-09-16 12:09:42 +00:00
|
|
|
return _addresses[LENDING_POOL_COLLATERAL_MANAGER];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-16 12:09:42 +00:00
|
|
|
* @dev updates the address of the Lending pool collateral manager
|
|
|
|
* @param manager the new lending pool collateral manager address
|
2020-07-13 08:54:08 +00:00
|
|
|
**/
|
2020-09-16 10:41:12 +00:00
|
|
|
function setLendingPoolCollateralManager(address manager) external override onlyOwner {
|
2020-09-16 12:09:42 +00:00
|
|
|
_addresses[LENDING_POOL_COLLATERAL_MANAGER] = manager;
|
2020-09-16 10:41:12 +00:00
|
|
|
emit LendingPoolCollateralManagerUpdated(manager);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev the functions below are storing specific addresses that are outside the context of the protocol
|
|
|
|
* hence the upgradable proxy pattern is not used
|
|
|
|
**/
|
|
|
|
|
2020-09-16 12:09:42 +00:00
|
|
|
function getAaveAdmin() external override view returns (address) {
|
|
|
|
return _addresses[AAVE_ADMIN];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-16 12:09:42 +00:00
|
|
|
function setAaveAdmin(address aaveAdmin) external override onlyOwner {
|
|
|
|
_addresses[AAVE_ADMIN] = aaveAdmin;
|
|
|
|
emit AaveAdminUpdated(aaveAdmin);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 12:53:00 +00:00
|
|
|
function getPriceOracle() external override view returns (address) {
|
|
|
|
return _addresses[PRICE_ORACLE];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 12:53:00 +00:00
|
|
|
function setPriceOracle(address priceOracle) external override onlyOwner {
|
|
|
|
_addresses[PRICE_ORACLE] = priceOracle;
|
|
|
|
emit PriceOracleUpdated(priceOracle);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 12:53:00 +00:00
|
|
|
function getLendingRateOracle() external override view returns (address) {
|
|
|
|
return _addresses[LENDING_RATE_ORACLE];
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 12:53:00 +00:00
|
|
|
function setLendingRateOracle(address lendingRateOracle) external override onlyOwner {
|
|
|
|
_addresses[LENDING_RATE_ORACLE] = lendingRateOracle;
|
|
|
|
emit LendingRateOracleUpdated(lendingRateOracle);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev internal function to update the implementation of a specific component of the protocol
|
2020-08-19 12:53:00 +00:00
|
|
|
* @param id the id of the contract to be updated
|
|
|
|
* @param newAddress the address of the new implementation
|
2020-07-13 08:54:08 +00:00
|
|
|
**/
|
2020-08-21 16:18:12 +00:00
|
|
|
function _updateImpl(bytes32 id, address newAddress) internal {
|
2020-08-19 12:53:00 +00:00
|
|
|
address payable proxyAddress = payable(_addresses[id]);
|
2020-07-13 08:54:08 +00:00
|
|
|
|
|
|
|
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(
|
|
|
|
proxyAddress
|
|
|
|
);
|
|
|
|
bytes memory params = abi.encodeWithSignature('initialize(address)', address(this));
|
|
|
|
|
|
|
|
if (proxyAddress == address(0)) {
|
|
|
|
proxy = new InitializableAdminUpgradeabilityProxy();
|
2020-08-19 12:53:00 +00:00
|
|
|
proxy.initialize(newAddress, address(this), params);
|
|
|
|
_addresses[id] = address(proxy);
|
|
|
|
emit ProxyCreated(id, address(proxy));
|
2020-07-13 08:54:08 +00:00
|
|
|
} else {
|
2020-08-19 12:53:00 +00:00
|
|
|
proxy.upgradeToAndCall(newAddress, params);
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-29 16:45:37 +00:00
|
|
|
}
|