refactor: fixed stack too deep

This commit is contained in:
Hadrien Charlanes 2021-04-27 18:37:13 +02:00
parent 03103fb63d
commit 7e02877966

View File

@ -98,6 +98,8 @@ library ValidationLogic {
uint256 userBorrowBalanceETH; uint256 userBorrowBalanceETH;
uint256 availableLiquidity; uint256 availableLiquidity;
uint256 healthFactor; uint256 healthFactor;
uint256 totalSupplyStableDebt;
uint256 totalSupplyVariableDebt;
bool isActive; bool isActive;
bool isFrozen; bool isFrozen;
bool borrowingEnabled; bool borrowingEnabled;
@ -152,17 +154,18 @@ library ValidationLogic {
Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
); );
// not using this because stack too deep (vars.totalSupplyStableDebt, ) = IStableDebtToken(reserve.stableDebtTokenAddress)
// uint256 totalStableDebt; .getTotalSupplyAndAvgRate();
// (totalStableDebt, ) = IStableDebtToken(reserve.stableDebtTokenAddress)
// .getTotalSupplyAndAvgRate(); vars.totalSupplyVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress)
.scaledTotalSupply()
.rayMul(reserve.variableBorrowIndex);
require( require(
IERC20(reserve.stableDebtTokenAddress).totalSupply() vars.totalSupplyStableDebt
.add(IVariableDebtToken(reserve.variableDebtTokenAddress) .add(vars.totalSupplyVariableDebt)
.scaledTotalSupply() .add(amount)
.rayMul(reserve.variableBorrowIndex)
).add(amount)
< reserve.configuration.getBorrowCap(), < reserve.configuration.getBorrowCap(),
Errors.VL_BORROW_CAP_EXCEEDED); Errors.VL_BORROW_CAP_EXCEEDED);