fix: drop reserve logic updated

This commit is contained in:
Hadrien Charlanes 2021-06-06 09:35:32 +02:00
parent 52b903cd20
commit d0841097e6
3 changed files with 18 additions and 18 deletions

View File

@ -828,8 +828,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];
}
/**

View File

@ -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;

View File

@ -477,4 +477,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
);
}
}