mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added function to update stable/variable debt tokens
This commit is contained in:
parent
674b885b31
commit
4a4073f1a9
|
@ -141,6 +141,32 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
|||
**/
|
||||
event ReserveInterestRateStrategyChanged(address _reserve, address _strategy);
|
||||
|
||||
|
||||
/**
|
||||
* @dev emitted when an aToken implementation is upgraded
|
||||
* @param _reserve the address of the reserve
|
||||
* @param _proxy the aToken proxy address
|
||||
* @param _implementation the new aToken implementation
|
||||
**/
|
||||
event ATokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||
|
||||
/**
|
||||
* @dev emitted when the implementation of a stable debt token is upgraded
|
||||
* @param _reserve the address of the reserve
|
||||
* @param _proxy the stable debt token proxy address
|
||||
* @param _implementation the new aToken implementation
|
||||
**/
|
||||
event StableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||
|
||||
/**
|
||||
* @dev emitted when the implementation of a variable debt token is upgraded
|
||||
* @param _reserve the address of the reserve
|
||||
* @param _proxy the variable debt token proxy address
|
||||
* @param _implementation the new aToken implementation
|
||||
**/
|
||||
event VariableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation);
|
||||
|
||||
|
||||
LendingPoolAddressesProvider public poolAddressesProvider;
|
||||
LendingPool public pool;
|
||||
|
||||
|
@ -240,18 +266,64 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
|||
|
||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
||||
|
||||
InitializableAdminUpgradeabilityProxy aTokenProxy = InitializableAdminUpgradeabilityProxy(
|
||||
payable(aTokenAddress)
|
||||
);
|
||||
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
'initialize(uint8,string,string)',
|
||||
_upgradeImplementation(
|
||||
aTokenAddress,
|
||||
_implementation,
|
||||
uint8(decimals),
|
||||
IERC20Detailed(_implementation).name(),
|
||||
IERC20Detailed(_implementation).symbol()
|
||||
);
|
||||
|
||||
aTokenProxy.upgradeToAndCall(_implementation, params);
|
||||
emit ATokenUpgraded(_reserve, aTokenAddress, _implementation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev updates the stable debt token implementation for the _reserve
|
||||
* @param _reserve the address of the reserve to be updated
|
||||
* @param _implementation the address of the new aToken implementation
|
||||
**/
|
||||
function updateStableDebtToken(address _reserve, address _implementation)
|
||||
external
|
||||
onlyLendingPoolManager
|
||||
{
|
||||
(, address stableDebtToken, ) = pool.getReserveTokensAddresses(_reserve);
|
||||
|
||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
||||
|
||||
_upgradeImplementation(
|
||||
stableDebtToken,
|
||||
_implementation,
|
||||
uint8(decimals),
|
||||
IERC20Detailed(_implementation).name(),
|
||||
IERC20Detailed(_implementation).symbol()
|
||||
);
|
||||
|
||||
emit StableDebtTokenUpgraded(_reserve, stableDebtToken, _implementation);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev updates the variable debt token implementation for the _reserve
|
||||
* @param _reserve the address of the reserve to be updated
|
||||
* @param _implementation the address of the new aToken implementation
|
||||
**/
|
||||
function updateVariableDebtToken(address _reserve, address _implementation)
|
||||
external
|
||||
onlyLendingPoolManager
|
||||
{
|
||||
(, , address variableDebtToken) = pool.getReserveTokensAddresses(_reserve);
|
||||
|
||||
(uint256 decimals, , , , , , , , , ) = pool.getReserveConfigurationData(_reserve);
|
||||
|
||||
_upgradeImplementation(
|
||||
variableDebtToken,
|
||||
_implementation,
|
||||
uint8(decimals),
|
||||
IERC20Detailed(_implementation).name(),
|
||||
IERC20Detailed(_implementation).symbol()
|
||||
);
|
||||
|
||||
emit VariableDebtTokenUpgraded(_reserve, variableDebtToken, _implementation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,4 +601,25 @@ contract LendingPoolConfigurator is VersionedInitializable {
|
|||
|
||||
return address(proxy);
|
||||
}
|
||||
|
||||
function _upgradeImplementation(
|
||||
address _proxy,
|
||||
address _implementation,
|
||||
uint8 _decimals,
|
||||
string memory _name,
|
||||
string memory _symbol
|
||||
) internal returns (address) {
|
||||
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(
|
||||
payable(_proxy)
|
||||
);
|
||||
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
'initialize(uint8,string,string)',
|
||||
_decimals,
|
||||
_name,
|
||||
_symbol
|
||||
);
|
||||
|
||||
proxy.upgradeToAndCall(_implementation, params);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user