From 44ba72540c1e8cc598ce86731e2c73e56770a02c Mon Sep 17 00:00:00 2001 From: The3D Date: Fri, 9 Oct 2020 17:59:10 +0200 Subject: [PATCH] Updated configurator, LendingPool interface --- contracts/interfaces/ILendingPool.sol | 4 ++ .../lendingpool/LendingPoolConfigurator.sol | 42 ++++++++----------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 82f5f773..3a774e1f 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -3,6 +3,8 @@ pragma solidity ^0.6.8; import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; + pragma experimental ABIEncoderV2; interface ILendingPool { @@ -361,6 +363,8 @@ interface ILendingPool { function getReserveNormalizedVariableDebt(address reserve) external view returns (uint256); + function getReserveData(address asset) external view returns (ReserveLogic.ReserveData memory); + function balanceDecreaseAllowed( address reserve, address user, diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index 6bedff76..c9e34f3e 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -14,6 +14,7 @@ import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddresses import {ILendingPool} from '../interfaces/ILendingPool.sol'; import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; +import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; /** * @title LendingPoolConfigurator contract @@ -260,11 +261,11 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param implementation the address of the new aToken implementation **/ function updateAToken(address asset, address implementation) external onlyAaveAdmin { - (address aTokenAddress, , ) = pool.getReserveTokensAddresses(asset); + ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); - _upgradeTokenImplementation(asset, aTokenAddress, implementation); + _upgradeTokenImplementation(asset, reserveData.aTokenAddress, implementation); - emit ATokenUpgraded(asset, aTokenAddress, implementation); + emit ATokenUpgraded(asset, reserveData.aTokenAddress, implementation); } /** @@ -273,11 +274,11 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param implementation the address of the new aToken implementation **/ function updateStableDebtToken(address asset, address implementation) external onlyAaveAdmin { - (, address stableDebtToken, ) = pool.getReserveTokensAddresses(asset); + ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); - _upgradeTokenImplementation(asset, stableDebtToken, implementation); + _upgradeTokenImplementation(asset, reserveData.stableDebtTokenAddress, implementation); - emit StableDebtTokenUpgraded(asset, stableDebtToken, implementation); + emit StableDebtTokenUpgraded(asset, reserveData.stableDebtTokenAddress, implementation); } /** @@ -286,11 +287,11 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param implementation the address of the new aToken implementation **/ function updateVariableDebtToken(address asset, address implementation) external onlyAaveAdmin { - (, , address variableDebtToken) = pool.getReserveTokensAddresses(asset); + ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); - _upgradeTokenImplementation(asset, variableDebtToken, implementation); + _upgradeTokenImplementation(asset, reserveData.variableDebtTokenAddress, implementation); - emit VariableDebtTokenUpgraded(asset, variableDebtToken, implementation); + emit VariableDebtTokenUpgraded(asset, reserveData.variableDebtTokenAddress, implementation); } /** @@ -410,18 +411,12 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param asset the address of the reserve **/ function deactivateReserve(address asset) external onlyAaveAdmin { - ( - uint256 availableLiquidity, - uint256 totalStableDebt, - uint256 totalVariableDebt, - , - , - , - , - , - , + ReserveLogic.ReserveData memory reserveData = pool.getReserveData(asset); + + uint256 availableLiquidity = IERC20Detailed(reserveData.aTokenAddress).totalSupply(); + uint256 totalStableDebt = IERC20Detailed(reserveData.stableDebtTokenAddress).totalSupply(); + uint256 totalVariableDebt = IERC20Detailed(reserveData.variableDebtTokenAddress).totalSupply(); - ) = pool.getReserveData(asset); require( availableLiquidity == 0 && totalStableDebt == 0 && totalVariableDebt == 0, Errors.RESERVE_LIQUIDITY_NOT_0 @@ -479,7 +474,7 @@ contract LendingPoolConfigurator is VersionedInitializable { emit ReserveBaseLtvChanged(asset, ltv); } - /** + /** * @dev updates the reserve factor of a reserve * @param asset the address of the reserve * @param reserveFactor the new reserve factor of the reserve @@ -494,7 +489,6 @@ contract LendingPoolConfigurator is VersionedInitializable { emit ReserveFactorChanged(asset, reserveFactor); } - /** * @dev updates the liquidation threshold of a reserve. * @param asset the address of the reserve @@ -582,11 +576,11 @@ contract LendingPoolConfigurator is VersionedInitializable { payable(proxyAddress) ); - (uint256 decimals, , , , , , , , , , ) = pool.getReserveConfigurationData(asset); + ReserveConfiguration.Map memory configuration = pool.getConfiguration(asset); bytes memory params = abi.encodeWithSignature( 'initialize(uint8,string,string)', - uint8(decimals), + uint8(configuration.getDecimals()), IERC20Detailed(implementation).name(), IERC20Detailed(implementation).symbol() );