mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Refactored code
This commit is contained in:
parent
7b51fde8e7
commit
dd008ae226
|
@ -141,7 +141,6 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
event ReserveInterestRateStrategyChanged(address _reserve, address _strategy);
|
event ReserveInterestRateStrategyChanged(address _reserve, address _strategy);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev emitted when an aToken implementation is upgraded
|
* @dev emitted when an aToken implementation is upgraded
|
||||||
* @param _reserve the address of the reserve
|
* @param _reserve the address of the reserve
|
||||||
|
@ -150,7 +149,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
event ATokenUpgraded(address _reserve, address _proxy, address _implementation);
|
event ATokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev emitted when the implementation of a stable debt token is upgraded
|
* @dev emitted when the implementation of a stable debt token is upgraded
|
||||||
* @param _reserve the address of the reserve
|
* @param _reserve the address of the reserve
|
||||||
* @param _proxy the stable debt token proxy address
|
* @param _proxy the stable debt token proxy address
|
||||||
|
@ -158,7 +157,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
event StableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
event StableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev emitted when the implementation of a variable debt token is upgraded
|
* @dev emitted when the implementation of a variable debt token is upgraded
|
||||||
* @param _reserve the address of the reserve
|
* @param _reserve the address of the reserve
|
||||||
* @param _proxy the variable debt token proxy address
|
* @param _proxy the variable debt token proxy address
|
||||||
|
@ -166,7 +165,6 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
**/
|
**/
|
||||||
event VariableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
event VariableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||||
|
|
||||||
|
|
||||||
LendingPoolAddressesProvider public poolAddressesProvider;
|
LendingPoolAddressesProvider public poolAddressesProvider;
|
||||||
LendingPool public pool;
|
LendingPool public pool;
|
||||||
|
|
||||||
|
@ -209,21 +207,21 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
uint8 _underlyingAssetDecimals,
|
uint8 _underlyingAssetDecimals,
|
||||||
address _interestRateStrategyAddress
|
address _interestRateStrategyAddress
|
||||||
) public onlyLendingPoolManager {
|
) public onlyLendingPoolManager {
|
||||||
address aTokenProxyAddress = _initWithProxy(
|
address aTokenProxyAddress = _initTokenWithProxy(
|
||||||
_aTokenImpl,
|
_aTokenImpl,
|
||||||
_underlyingAssetDecimals,
|
_underlyingAssetDecimals,
|
||||||
IERC20Detailed(_aTokenImpl).name(),
|
IERC20Detailed(_aTokenImpl).name(),
|
||||||
IERC20Detailed(_aTokenImpl).symbol()
|
IERC20Detailed(_aTokenImpl).symbol()
|
||||||
);
|
);
|
||||||
|
|
||||||
address stableDebtTokenProxyAddress = _initWithProxy(
|
address stableDebtTokenProxyAddress = _initTokenWithProxy(
|
||||||
_stableDebtTokenImpl,
|
_stableDebtTokenImpl,
|
||||||
_underlyingAssetDecimals,
|
_underlyingAssetDecimals,
|
||||||
IERC20Detailed(_stableDebtTokenImpl).name(),
|
IERC20Detailed(_stableDebtTokenImpl).name(),
|
||||||
IERC20Detailed(_stableDebtTokenImpl).symbol()
|
IERC20Detailed(_stableDebtTokenImpl).symbol()
|
||||||
);
|
);
|
||||||
|
|
||||||
address variableDebtTokenProxyAddress = _initWithProxy(
|
address variableDebtTokenProxyAddress = _initTokenWithProxy(
|
||||||
_variableDebtTokenImpl,
|
_variableDebtTokenImpl,
|
||||||
_underlyingAssetDecimals,
|
_underlyingAssetDecimals,
|
||||||
IERC20Detailed(_variableDebtTokenImpl).name(),
|
IERC20Detailed(_variableDebtTokenImpl).name(),
|
||||||
|
@ -264,15 +262,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
function updateAToken(address _reserve, address _implementation) external onlyLendingPoolManager {
|
function updateAToken(address _reserve, address _implementation) external onlyLendingPoolManager {
|
||||||
(address aTokenAddress, , ) = pool.getReserveTokensAddresses(_reserve);
|
(address aTokenAddress, , ) = pool.getReserveTokensAddresses(_reserve);
|
||||||
|
|
||||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
_upgradeTokenImplementation(_reserve, aTokenAddress, _implementation);
|
||||||
|
|
||||||
_upgradeImplementation(
|
|
||||||
aTokenAddress,
|
|
||||||
_implementation,
|
|
||||||
uint8(decimals),
|
|
||||||
IERC20Detailed(_implementation).name(),
|
|
||||||
IERC20Detailed(_implementation).symbol()
|
|
||||||
);
|
|
||||||
|
|
||||||
emit ATokenUpgraded(_reserve, aTokenAddress, _implementation);
|
emit ATokenUpgraded(_reserve, aTokenAddress, _implementation);
|
||||||
}
|
}
|
||||||
|
@ -288,18 +278,9 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
{
|
{
|
||||||
(, address stableDebtToken, ) = pool.getReserveTokensAddresses(_reserve);
|
(, address stableDebtToken, ) = pool.getReserveTokensAddresses(_reserve);
|
||||||
|
|
||||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
_upgradeTokenImplementation(_reserve, stableDebtToken, _implementation);
|
||||||
|
|
||||||
_upgradeImplementation(
|
|
||||||
stableDebtToken,
|
|
||||||
_implementation,
|
|
||||||
uint8(decimals),
|
|
||||||
IERC20Detailed(_implementation).name(),
|
|
||||||
IERC20Detailed(_implementation).symbol()
|
|
||||||
);
|
|
||||||
|
|
||||||
emit StableDebtTokenUpgraded(_reserve, stableDebtToken, _implementation);
|
emit StableDebtTokenUpgraded(_reserve, stableDebtToken, _implementation);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,15 +294,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
{
|
{
|
||||||
(, , address variableDebtToken) = pool.getReserveTokensAddresses(_reserve);
|
(, , address variableDebtToken) = pool.getReserveTokensAddresses(_reserve);
|
||||||
|
|
||||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
_upgradeTokenImplementation(_reserve, variableDebtToken, _implementation);
|
||||||
|
|
||||||
_upgradeImplementation(
|
|
||||||
variableDebtToken,
|
|
||||||
_implementation,
|
|
||||||
uint8(decimals),
|
|
||||||
IERC20Detailed(_implementation).name(),
|
|
||||||
IERC20Detailed(_implementation).symbol()
|
|
||||||
);
|
|
||||||
|
|
||||||
emit VariableDebtTokenUpgraded(_reserve, variableDebtToken, _implementation);
|
emit VariableDebtTokenUpgraded(_reserve, variableDebtToken, _implementation);
|
||||||
}
|
}
|
||||||
|
@ -579,10 +552,13 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @dev initializes a token with a proxy and a specific implementation
|
||||||
*
|
* @param _implementation the address of the implementation
|
||||||
|
* @param _decimals the decimals of the token
|
||||||
|
* @param _name the name of the token
|
||||||
|
* @param _symbol the symbol of the token
|
||||||
**/
|
**/
|
||||||
function _initWithProxy(
|
function _initTokenWithProxy(
|
||||||
address _implementation,
|
address _implementation,
|
||||||
uint8 _decimals,
|
uint8 _decimals,
|
||||||
string memory _name,
|
string memory _name,
|
||||||
|
@ -602,22 +578,22 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
||||||
return address(proxy);
|
return address(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _upgradeImplementation(
|
function _upgradeTokenImplementation(
|
||||||
|
address _reserve,
|
||||||
address _proxy,
|
address _proxy,
|
||||||
address _implementation,
|
address _implementation
|
||||||
uint8 _decimals,
|
|
||||||
string memory _name,
|
|
||||||
string memory _symbol
|
|
||||||
) internal returns (address) {
|
) internal returns (address) {
|
||||||
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(
|
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(
|
||||||
payable(_proxy)
|
payable(_proxy)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
||||||
|
|
||||||
bytes memory params = abi.encodeWithSignature(
|
bytes memory params = abi.encodeWithSignature(
|
||||||
'initialize(uint8,string,string)',
|
'initialize(uint8,string,string)',
|
||||||
_decimals,
|
uint8(decimals),
|
||||||
_name,
|
IERC20Detailed(_implementation).name(),
|
||||||
_symbol
|
IERC20Detailed(_implementation).symbol()
|
||||||
);
|
);
|
||||||
|
|
||||||
proxy.upgradeToAndCall(_implementation, params);
|
proxy.upgradeToAndCall(_implementation, params);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user