fixes in lendingpool folder to follow our styleguide

This commit is contained in:
andyk 2020-08-25 11:53:58 +03:00
parent dfe865fc76
commit 4b00cde616
3 changed files with 100 additions and 110 deletions

View File

@ -44,18 +44,18 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
uint256 public constant MAX_STABLE_RATE_BORROW_SIZE_PERCENT = 25; uint256 public constant MAX_STABLE_RATE_BORROW_SIZE_PERCENT = 25;
uint256 public constant FLASHLOAN_FEE_TOTAL = 9; uint256 public constant FLASHLOAN_FEE_TOTAL = 9;
ILendingPoolAddressesProvider internal addressesProvider; ILendingPoolAddressesProvider internal _addressesProvider;
mapping(address => ReserveLogic.ReserveData) internal _reserves; mapping(address => ReserveLogic.ReserveData) internal _reserves;
mapping(address => UserConfiguration.Map) internal _usersConfig; mapping(address => UserConfiguration.Map) internal _usersConfig;
address[] internal reservesList; address[] internal _reservesList;
/** /**
* @dev only lending pools configurator can use functions affected by this modifier * @dev only lending pools configurator can use functions affected by this modifier
**/ **/
modifier onlyLendingPoolConfigurator { modifier onlyLendingPoolConfigurator {
require(addressesProvider.getLendingPoolConfigurator() == msg.sender, '30'); require(_addressesProvider.getLendingPoolConfigurator() == msg.sender, '30');
_; _;
} }
@ -73,7 +73,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
* @param provider the address of the LendingPoolAddressesProvider registry * @param provider the address of the LendingPoolAddressesProvider registry
**/ **/
function initialize(ILendingPoolAddressesProvider provider) public initializer { function initialize(ILendingPoolAddressesProvider provider) public initializer {
addressesProvider = provider; _addressesProvider = provider;
} }
/** /**
@ -114,7 +114,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
} }
/** /**
* @dev withdraws the _reserves of _user. * @dev withdraws the _reserves of user.
* @param asset the address of the reserve * @param asset the address of the reserve
* @param amount the underlying amount to be redeemed * @param amount the underlying amount to be redeemed
**/ **/
@ -139,8 +139,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
userBalance, userBalance,
_reserves, _reserves,
_usersConfig[msg.sender], _usersConfig[msg.sender],
reservesList, _reservesList,
addressesProvider.getPriceOracle() _addressesProvider.getPriceOracle()
); );
reserve.updateCumulativeIndexesAndTimestamp(); reserve.updateCumulativeIndexesAndTimestamp();
@ -173,7 +173,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
ReserveLogic.ReserveData storage reserve = _reserves[asset]; ReserveLogic.ReserveData storage reserve = _reserves[asset];
UserConfiguration.Map storage userConfig = _usersConfig[msg.sender]; UserConfiguration.Map storage userConfig = _usersConfig[msg.sender];
uint256 amountInETH = IPriceOracleGetter(addressesProvider.getPriceOracle()) uint256 amountInETH = IPriceOracleGetter(_addressesProvider.getPriceOracle())
.getAssetPrice(asset) .getAssetPrice(asset)
.mul(amount) .mul(amount)
.div(10**reserve.configuration.getDecimals()); //price is in ether .div(10**reserve.configuration.getDecimals()); //price is in ether
@ -187,8 +187,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
MAX_STABLE_RATE_BORROW_SIZE_PERCENT, MAX_STABLE_RATE_BORROW_SIZE_PERCENT,
_reserves, _reserves,
_usersConfig[msg.sender], _usersConfig[msg.sender],
reservesList, _reservesList,
addressesProvider.getPriceOracle() _addressesProvider.getPriceOracle()
); );
//caching the current stable borrow rate //caching the current stable borrow rate
@ -225,26 +225,26 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
/** /**
* @notice repays a borrow on the specific reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). * @notice repays a borrow on the specific reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified).
* @dev the target user is defined by _onBehalfOf. If there is no repayment on behalf of another account, * @dev the target user is defined by onBehalfOf. If there is no repayment on behalf of another account,
* _onBehalfOf must be equal to msg.sender. * onBehalfOf must be equal to msg.sender.
* @param asset the address of the reserve on which the user borrowed * @param asset the address of the reserve on which the user borrowed
* @param amount the amount to repay, or uint256(-1) if the user wants to repay everything * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything
* @param _onBehalfOf the address for which msg.sender is repaying. * @param onBehalfOf the address for which msg.sender is repaying.
**/ **/
function repay( function repay(
address asset, address asset,
uint256 amount, uint256 amount,
uint256 _rateMode, uint256 rateMode,
address _onBehalfOf address onBehalfOf
) external override nonReentrant { ) external override nonReentrant {
ReserveLogic.ReserveData storage reserve = _reserves[asset]; ReserveLogic.ReserveData storage reserve = _reserves[asset];
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(_onBehalfOf, reserve); (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve);
ReserveLogic.InterestRateMode interestRateMode = ReserveLogic.InterestRateMode(rateMode);
ReserveLogic.InterestRateMode rateMode = ReserveLogic.InterestRateMode(_rateMode);
//default to max amount //default to max amount
uint256 paybackAmount = rateMode == ReserveLogic.InterestRateMode.STABLE uint256 paybackAmount = interestRateMode == ReserveLogic.InterestRateMode.STABLE
? stableDebt ? stableDebt
: variableDebt; : variableDebt;
@ -255,8 +255,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
ValidationLogic.validateRepay( ValidationLogic.validateRepay(
reserve, reserve,
amount, amount,
rateMode, interestRateMode,
_onBehalfOf, onBehalfOf,
stableDebt, stableDebt,
variableDebt variableDebt
); );
@ -264,46 +264,46 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
reserve.updateCumulativeIndexesAndTimestamp(); reserve.updateCumulativeIndexesAndTimestamp();
//burns an equivalent amount of debt tokens //burns an equivalent amount of debt tokens
if (rateMode == ReserveLogic.InterestRateMode.STABLE) { if (interestRateMode == ReserveLogic.InterestRateMode.STABLE) {
IStableDebtToken(reserve.stableDebtTokenAddress).burn(_onBehalfOf, paybackAmount); IStableDebtToken(reserve.stableDebtTokenAddress).burn(onBehalfOf, paybackAmount);
} else { } else {
IVariableDebtToken(reserve.variableDebtTokenAddress).burn(_onBehalfOf, paybackAmount); IVariableDebtToken(reserve.variableDebtTokenAddress).burn(onBehalfOf, paybackAmount);
} }
reserve.updateInterestRates(asset, paybackAmount, 0); reserve.updateInterestRates(asset, paybackAmount, 0);
if (stableDebt.add(variableDebt).sub(paybackAmount) == 0) { if (stableDebt.add(variableDebt).sub(paybackAmount) == 0) {
_usersConfig[_onBehalfOf].setBorrowing(reserve.index, false); _usersConfig[onBehalfOf].setBorrowing(reserve.index, false);
} }
IERC20(asset).safeTransferFrom(msg.sender, reserve.aTokenAddress, paybackAmount); IERC20(asset).safeTransferFrom(msg.sender, reserve.aTokenAddress, paybackAmount);
emit Repay(asset, _onBehalfOf, msg.sender, paybackAmount); emit Repay(asset, onBehalfOf, msg.sender, paybackAmount);
} }
/** /**
* @dev borrowers can user this function to swap between stable and variable borrow rate modes. * @dev borrowers can user this function to swap between stable and variable borrow rate modes.
* @param asset the address of the reserve on which the user borrowed * @param asset the address of the reserve on which the user borrowed
* @param _rateMode the rate mode that the user wants to swap * @param rateMode the rate mode that the user wants to swap
**/ **/
function swapBorrowRateMode(address asset, uint256 _rateMode) external override nonReentrant { function swapBorrowRateMode(address asset, uint256 rateMode) external override nonReentrant {
ReserveLogic.ReserveData storage reserve = _reserves[asset]; ReserveLogic.ReserveData storage reserve = _reserves[asset];
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve); (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve);
ReserveLogic.InterestRateMode rateMode = ReserveLogic.InterestRateMode(_rateMode); ReserveLogic.InterestRateMode interestRateMode = ReserveLogic.InterestRateMode(rateMode);
ValidationLogic.validateSwapRateMode( ValidationLogic.validateSwapRateMode(
reserve, reserve,
_usersConfig[msg.sender], _usersConfig[msg.sender],
stableDebt, stableDebt,
variableDebt, variableDebt,
rateMode interestRateMode
); );
reserve.updateCumulativeIndexesAndTimestamp(); reserve.updateCumulativeIndexesAndTimestamp();
if (rateMode == ReserveLogic.InterestRateMode.STABLE) { if (interestRateMode == ReserveLogic.InterestRateMode.STABLE) {
//burn stable rate tokens, mint variable rate tokens //burn stable rate tokens, mint variable rate tokens
IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt); IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt);
IVariableDebtToken(reserve.variableDebtTokenAddress).mint(msg.sender, stableDebt); IVariableDebtToken(reserve.variableDebtTokenAddress).mint(msg.sender, stableDebt);
@ -332,14 +332,14 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
* this is regulated by Aave to ensure that the protocol is not abused, and the user is paying a fair * this is regulated by Aave to ensure that the protocol is not abused, and the user is paying a fair
* rate. Anyone can call this function. * rate. Anyone can call this function.
* @param asset the address of the reserve * @param asset the address of the reserve
* @param _user the address of the user to be rebalanced * @param user the address of the user to be rebalanced
**/ **/
function rebalanceStableBorrowRate(address asset, address _user) external override nonReentrant { function rebalanceStableBorrowRate(address asset, address user) external override nonReentrant {
ReserveLogic.ReserveData storage reserve = _reserves[asset]; ReserveLogic.ReserveData storage reserve = _reserves[asset];
IStableDebtToken stableDebtToken = IStableDebtToken(reserve.stableDebtTokenAddress); IStableDebtToken stableDebtToken = IStableDebtToken(reserve.stableDebtTokenAddress);
uint256 stableBorrowBalance = IERC20(address(stableDebtToken)).balanceOf(_user); uint256 stableBorrowBalance = IERC20(address(stableDebtToken)).balanceOf(user);
// user must be borrowing on asset at a stable rate // user must be borrowing on asset at a stable rate
require(stableBorrowBalance > 0, 'User does not have any stable rate loan for this reserve'); require(stableBorrowBalance > 0, 'User does not have any stable rate loan for this reserve');
@ -353,7 +353,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
//2. user stable rate is above the market avg borrow rate of a certain delta, and utilization rate is low. //2. user stable rate is above the market avg borrow rate of a certain delta, and utilization rate is low.
//In this case, the user is paying an interest that is too high, and needs to be rescaled down. //In this case, the user is paying an interest that is too high, and needs to be rescaled down.
uint256 userStableRate = stableDebtToken.getUserStableRate(_user); uint256 userStableRate = stableDebtToken.getUserStableRate(user);
require( require(
userStableRate < reserve.currentLiquidityRate || userStableRate > rebalanceDownRateThreshold, userStableRate < reserve.currentLiquidityRate || userStableRate > rebalanceDownRateThreshold,
@ -364,12 +364,12 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
reserve.updateCumulativeIndexesAndTimestamp(); reserve.updateCumulativeIndexesAndTimestamp();
stableDebtToken.burn(_user, stableBorrowBalance); stableDebtToken.burn(user, stableBorrowBalance);
stableDebtToken.mint(_user, stableBorrowBalance, reserve.currentStableBorrowRate); stableDebtToken.mint(user, stableBorrowBalance, reserve.currentStableBorrowRate);
reserve.updateInterestRates(asset, 0, 0); reserve.updateInterestRates(asset, 0, 0);
emit RebalanceStableBorrowRate(asset, _user); emit RebalanceStableBorrowRate(asset, user);
return; return;
} }
@ -377,9 +377,9 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
/** /**
* @dev allows depositors to enable or disable a specific deposit as collateral. * @dev allows depositors to enable or disable a specific deposit as collateral.
* @param asset the address of the reserve * @param asset the address of the reserve
* @param _useAsCollateral true if the user wants to user the deposit as collateral, false otherwise. * @param useAsCollateral true if the user wants to user the deposit as collateral, false otherwise.
**/ **/
function setUserUseReserveAsCollateral(address asset, bool _useAsCollateral) function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
external external
override override
nonReentrant nonReentrant
@ -391,13 +391,13 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
asset, asset,
_reserves, _reserves,
_usersConfig[msg.sender], _usersConfig[msg.sender],
reservesList, _reservesList,
addressesProvider.getPriceOracle() _addressesProvider.getPriceOracle()
); );
_usersConfig[msg.sender].setUsingAsCollateral(reserve.index, _useAsCollateral); _usersConfig[msg.sender].setUsingAsCollateral(reserve.index, useAsCollateral);
if (_useAsCollateral) { if (useAsCollateral) {
emit ReserveUsedAsCollateralEnabled(asset, msg.sender); emit ReserveUsedAsCollateralEnabled(asset, msg.sender);
} else { } else {
emit ReserveUsedAsCollateralDisabled(asset, msg.sender); emit ReserveUsedAsCollateralDisabled(asset, msg.sender);
@ -408,29 +408,29 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
* @dev users can invoke this function to liquidate an undercollateralized position. * @dev users can invoke this function to liquidate an undercollateralized position.
* @param asset the address of the collateral to liquidated * @param asset the address of the collateral to liquidated
* @param asset the address of the principal reserve * @param asset the address of the principal reserve
* @param _user the address of the borrower * @param user the address of the borrower
* @param _purchaseAmount the amount of principal that the liquidator wants to repay * @param purchaseAmount the amount of principal that the liquidator wants to repay
* @param _receiveAToken true if the liquidators wants to receive the aTokens, false if * @param receiveAToken true if the liquidators wants to receive the aTokens, false if
* he wants to receive the underlying asset directly * he wants to receive the underlying asset directly
**/ **/
function liquidationCall( function liquidationCall(
address _collateral, address collateral,
address asset, address asset,
address _user, address user,
uint256 _purchaseAmount, uint256 purchaseAmount,
bool _receiveAToken bool receiveAToken
) external override nonReentrant { ) external override nonReentrant {
address liquidationManager = addressesProvider.getLendingPoolLiquidationManager(); address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager();
//solium-disable-next-line //solium-disable-next-line
(bool success, bytes memory result) = liquidationManager.delegatecall( (bool success, bytes memory result) = liquidationManager.delegatecall(
abi.encodeWithSignature( abi.encodeWithSignature(
'liquidationCall(address,address,address,uint256,bool)', 'liquidationCall(address,address,address,uint256,bool)',
_collateral, collateral,
asset, asset,
_user, user,
_purchaseAmount, purchaseAmount,
_receiveAToken receiveAToken
) )
); );
require(success, 'Liquidation call failed'); require(success, 'Liquidation call failed');
@ -490,7 +490,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
'The actual balance of the protocol is inconsistent' 'The actual balance of the protocol is inconsistent'
); );
//compounding the cumulated interest //compounding the cumulated interest
reserve.updateCumulativeIndexesAndTimestamp(); reserve.updateCumulativeIndexesAndTimestamp();
uint256 totalLiquidityBefore = availableLiquidityBefore uint256 totalLiquidityBefore = availableLiquidityBefore
@ -595,7 +595,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
); );
} }
function getUserAccountData(address _user) function getUserAccountData(address user)
external external
override override
view view
@ -615,11 +615,11 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
currentLiquidationThreshold, currentLiquidationThreshold,
healthFactor healthFactor
) = GenericLogic.calculateUserAccountData( ) = GenericLogic.calculateUserAccountData(
_user, user,
_reserves, _reserves,
_usersConfig[_user], _usersConfig[user],
reservesList, _reservesList,
addressesProvider.getPriceOracle() _addressesProvider.getPriceOracle()
); );
availableBorrowsETH = GenericLogic.calculateAvailableBorrowsETH( availableBorrowsETH = GenericLogic.calculateAvailableBorrowsETH(
@ -629,7 +629,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
); );
} }
function getUserReserveData(address asset, address _user) function getUserReserveData(address asset, address user)
external external
override override
view view
@ -648,20 +648,20 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
{ {
ReserveLogic.ReserveData storage reserve = _reserves[asset]; ReserveLogic.ReserveData storage reserve = _reserves[asset];
currentATokenBalance = IERC20(reserve.aTokenAddress).balanceOf(_user); currentATokenBalance = IERC20(reserve.aTokenAddress).balanceOf(user);
(currentStableDebt, currentVariableDebt) = Helpers.getUserCurrentDebt(_user, reserve); (currentStableDebt, currentVariableDebt) = Helpers.getUserCurrentDebt(user, reserve);
(principalStableDebt, principalVariableDebt) = Helpers.getUserPrincipalDebt(_user, reserve); (principalStableDebt, principalVariableDebt) = Helpers.getUserPrincipalDebt(user, reserve);
liquidityRate = reserve.currentLiquidityRate; liquidityRate = reserve.currentLiquidityRate;
stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(_user); stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(user);
stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated( stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated(
_user user
); );
usageAsCollateralEnabled = _usersConfig[_user].isUsingAsCollateral(reserve.index); usageAsCollateralEnabled = _usersConfig[user].isUsingAsCollateral(reserve.index);
variableBorrowIndex = IVariableDebtToken(reserve.variableDebtTokenAddress).getUserIndex(_user); variableBorrowIndex = IVariableDebtToken(reserve.variableDebtTokenAddress).getUserIndex(user);
} }
function getReserves() external override view returns (address[] memory) { function getReserves() external override view returns (address[] memory) {
return reservesList; return _reservesList;
} }
receive() external payable { receive() external payable {
@ -671,21 +671,21 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
/** /**
* @dev initializes a reserve * @dev initializes a reserve
* @param asset the address of the reserve * @param asset the address of the reserve
* @param _aTokenAddress the address of the overlying aToken contract * @param aTokenAddress the address of the overlying aToken contract
* @param _interestRateStrategyAddress the address of the interest rate strategy contract * @param interestRateStrategyAddress the address of the interest rate strategy contract
**/ **/
function initReserve( function initReserve(
address asset, address asset,
address _aTokenAddress, address aTokenAddress,
address _stableDebtAddress, address stableDebtAddress,
address _variableDebtAddress, address variableDebtAddress,
address _interestRateStrategyAddress address interestRateStrategyAddress
) external override onlyLendingPoolConfigurator { ) external override onlyLendingPoolConfigurator {
_reserves[asset].init( _reserves[asset].init(
_aTokenAddress, aTokenAddress,
_stableDebtAddress, stableDebtAddress,
_variableDebtAddress, variableDebtAddress,
_interestRateStrategyAddress interestRateStrategyAddress
); );
_addReserveToList(asset); _addReserveToList(asset);
} }
@ -730,13 +730,13 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
**/ **/
function _addReserveToList(address asset) internal { function _addReserveToList(address asset) internal {
bool reserveAlreadyAdded = false; bool reserveAlreadyAdded = false;
for (uint256 i = 0; i < reservesList.length; i++) for (uint256 i = 0; i < _reservesList.length; i++)
if (reservesList[i] == asset) { if (_reservesList[i] == asset) {
reserveAlreadyAdded = true; reserveAlreadyAdded = true;
} }
if (!reserveAlreadyAdded) { if (!reserveAlreadyAdded) {
_reserves[asset].index = uint8(reservesList.length); _reserves[asset].index = uint8(_reservesList.length);
reservesList.push(asset); _reservesList.push(asset);
} }
} }
@ -782,8 +782,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
amount, amount,
_reserves, _reserves,
_usersConfig[user], _usersConfig[user],
reservesList, _reservesList,
addressesProvider.getPriceOracle() _addressesProvider.getPriceOracle()
); );
} }
@ -791,13 +791,13 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
* @dev returns the list of the initialized reserves * @dev returns the list of the initialized reserves
**/ **/
function getReservesList() external view returns (address[] memory) { function getReservesList() external view returns (address[] memory) {
return reservesList; return _reservesList;
} }
/** /**
* @dev returns the addresses provider * @dev returns the addresses provider
**/ **/
function getAddressesProvider() external view returns (ILendingPoolAddressesProvider) { function getAddressesProvider() external view returns (ILendingPoolAddressesProvider) {
return addressesProvider; return _addressesProvider;
} }
} }

View File

@ -164,10 +164,10 @@ contract LendingPoolConfigurator is VersionedInitializable {
/** /**
* @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 asset the address of the reserve * @param asset the address of the reserve
* @param _proxy the variable debt token proxy address * @param proxy the variable debt token proxy address
* @param _implementation the new aToken implementation * @param implementation the new aToken implementation
**/ **/
event VariableDebtTokenUpgraded(address asset, address _proxy, address _implementation); event VariableDebtTokenUpgraded(address asset, address proxy, address implementation);
ILendingPoolAddressesProvider internal addressesProvider; ILendingPoolAddressesProvider internal addressesProvider;
ILendingPool internal pool; ILendingPool internal pool;
@ -211,10 +211,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
uint8 underlyingAssetDecimals, uint8 underlyingAssetDecimals,
address interestRateStrategyAddress address interestRateStrategyAddress
) public onlyLendingPoolManager { ) public onlyLendingPoolManager {
address aTokenProxyAddress = _initTokenWithProxy( address aTokenProxyAddress = _initTokenWithProxy(aTokenImpl, underlyingAssetDecimals);
aTokenImpl,
underlyingAssetDecimals
);
address stableDebtTokenProxyAddress = _initTokenWithProxy( address stableDebtTokenProxyAddress = _initTokenWithProxy(
stableDebtTokenImpl, stableDebtTokenImpl,
@ -280,6 +277,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
emit StableDebtTokenUpgraded(asset, stableDebtToken, implementation); emit StableDebtTokenUpgraded(asset, stableDebtToken, implementation);
} }
/** /**
* @dev updates the variable debt token implementation for the asset * @dev updates the variable debt token implementation for the asset
* @param asset the address of the reserve to be updated * @param asset the address of the reserve to be updated
@ -349,12 +347,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
pool.setConfiguration(asset, currentConfig.data); pool.setConfiguration(asset, currentConfig.data);
emit ReserveEnabledAsCollateral( emit ReserveEnabledAsCollateral(asset, ltv, liquidationThreshold, liquidationBonus);
asset,
ltv,
liquidationThreshold,
liquidationBonus
);
} }
/** /**
@ -553,10 +546,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param implementation the address of the implementation * @param implementation the address of the implementation
* @param decimals the decimals of the token * @param decimals the decimals of the token
**/ **/
function _initTokenWithProxy( function _initTokenWithProxy(address implementation, uint8 decimals) internal returns (address) {
address implementation,
uint8 decimals
) internal returns (address) {
InitializableAdminUpgradeabilityProxy proxy = new InitializableAdminUpgradeabilityProxy(); InitializableAdminUpgradeabilityProxy proxy = new InitializableAdminUpgradeabilityProxy();
bytes memory params = abi.encodeWithSignature( bytes memory params = abi.encodeWithSignature(

View File

@ -283,8 +283,8 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl
* @return principalAmountNeeded the purchase amount * @return principalAmountNeeded the purchase amount
**/ **/
function calculateAvailableCollateralToLiquidate( function calculateAvailableCollateralToLiquidate(
ReserveLogic.ReserveData storage _collateralReserve, ReserveLogic.ReserveData storage collateralReserve,
ReserveLogic.ReserveData storage _principalReserve, ReserveLogic.ReserveData storage principalReserve,
address collateralAddress, address collateralAddress,
address principalAddress, address principalAddress,
uint256 purchaseAmount, uint256 purchaseAmount,
@ -300,10 +300,10 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl
vars.collateralPrice = oracle.getAssetPrice(collateralAddress); vars.collateralPrice = oracle.getAssetPrice(collateralAddress);
vars.principalCurrencyPrice = oracle.getAssetPrice(principalAddress); vars.principalCurrencyPrice = oracle.getAssetPrice(principalAddress);
(, , vars.liquidationBonus, vars.collateralDecimals) = _collateralReserve (, , vars.liquidationBonus, vars.collateralDecimals) = collateralReserve
.configuration .configuration
.getParams(); .getParams();
vars.principalDecimals = _principalReserve.configuration.getDecimals(); vars.principalDecimals = principalReserve.configuration.getDecimals();
//this is the maximum possible amount of the selected collateral that can be liquidated, given the //this is the maximum possible amount of the selected collateral that can be liquidated, given the
//max amount of principal currency that is available for liquidation. //max amount of principal currency that is available for liquidation.