From dc1e3948ba0b3495bad7ca539fac5759d7e16433 Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Sun, 6 Jun 2021 09:35:32 +0200 Subject: [PATCH] fix: drop reserve logic updated --- contracts/protocol/lendingpool/LendingPool.sol | 3 ++- .../protocol/libraries/logic/ReserveLogic.sol | 17 ----------------- .../libraries/logic/ValidationLogic.sol | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/contracts/protocol/lendingpool/LendingPool.sol b/contracts/protocol/lendingpool/LendingPool.sol index 5479e5a2..213fca52 100644 --- a/contracts/protocol/lendingpool/LendingPool.sol +++ b/contracts/protocol/lendingpool/LendingPool.sol @@ -803,8 +803,9 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage * @param asset The address of the underlying asset of the reserve **/ function dropReserve(address asset) external override onlyLendingPoolConfigurator { - _reserves[asset].dropReserve(); + ValidationLogic.validateDropReserve(_reserves[asset]); _removeReserveFromList(asset); + delete _reserves[asset]; } /** diff --git a/contracts/protocol/libraries/logic/ReserveLogic.sol b/contracts/protocol/libraries/logic/ReserveLogic.sol index 183aa3a6..2b5b2cf4 100644 --- a/contracts/protocol/libraries/logic/ReserveLogic.sol +++ b/contracts/protocol/libraries/logic/ReserveLogic.sol @@ -178,23 +178,6 @@ library ReserveLogic { reserve.interestRateStrategyAddress = interestRateStrategyAddress; } - /** - * @dev drop a reserve - * @param reserve The reserve object - **/ - function dropReserve(DataTypes.ReserveData storage reserve) external { - require(IERC20(reserve.aTokenAddress).totalSupply() == 0, Errors.RL_ATOKEN_SUPPLY_NOT_NULL); - require( - IERC20(reserve.stableDebtTokenAddress).totalSupply() == 0, - Errors.RL_STABLE_DEBT_NOT_NULL - ); - require( - IERC20(reserve.variableDebtTokenAddress).totalSupply() == 0, - Errors.RL_VARIABLE_DEBT_SUPPLY_NOT_NULL - ); - reserve.id = type(uint8).max; - } - struct UpdateInterestRatesLocalVars { address stableDebtTokenAddress; uint256 availableLiquidity; diff --git a/contracts/protocol/libraries/logic/ValidationLogic.sol b/contracts/protocol/libraries/logic/ValidationLogic.sol index d170f94b..4bea7a8d 100644 --- a/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -470,4 +470,20 @@ library ValidationLogic { function validateTransfer(DataTypes.ReserveData storage reserve) internal view { require(!reserve.configuration.getPaused(), Errors.VL_RESERVE_PAUSED); } + + /** + * @dev Validates a drop reserve action + * @param reserve The reserve object + **/ + function validateDropReserve(DataTypes.ReserveData storage reserve) external view { + require(IERC20(reserve.aTokenAddress).totalSupply() == 0, Errors.RL_ATOKEN_SUPPLY_NOT_NULL); + require( + IERC20(reserve.stableDebtTokenAddress).totalSupply() == 0, + Errors.RL_STABLE_DEBT_NOT_NULL + ); + require( + IERC20(reserve.variableDebtTokenAddress).totalSupply() == 0, + Errors.RL_VARIABLE_DEBT_SUPPLY_NOT_NULL + ); + } }