adding stack too deep

This commit is contained in:
Hadrien Charlanes 2021-04-27 18:26:08 +02:00
parent a869be648b
commit 03103fb63d
2 changed files with 17 additions and 0 deletions

View File

@ -103,6 +103,7 @@ library Errors {
string public constant LP_NOT_CONTRACT = '78';
string public constant SDT_STABLE_DEBT_OVERFLOW = '79';
string public constant SDT_BURN_EXCEEDS_BALANCE = '80';
string public constant VL_BORROW_CAP_EXCEEDED = '81';
string public constant RC_INVALID_BORROW_CAP = '82';
enum CollateralManagerErrors {

View File

@ -14,6 +14,8 @@ import {UserConfiguration} from '../configuration/UserConfiguration.sol';
import {Errors} from '../helpers/Errors.sol';
import {Helpers} from '../helpers/Helpers.sol';
import {IReserveInterestRateStrategy} from '../../../interfaces/IReserveInterestRateStrategy.sol';
import {IVariableDebtToken} from '../../../interfaces/IVariableDebtToken.sol';
import {IStableDebtToken} from '../../../interfaces/IStableDebtToken.sol';
import {DataTypes} from '../types/DataTypes.sol';
/**
@ -149,6 +151,20 @@ library ValidationLogic {
uint256(DataTypes.InterestRateMode.STABLE) == interestRateMode,
Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
);
// not using this because stack too deep
// uint256 totalStableDebt;
// (totalStableDebt, ) = IStableDebtToken(reserve.stableDebtTokenAddress)
// .getTotalSupplyAndAvgRate();
require(
IERC20(reserve.stableDebtTokenAddress).totalSupply()
.add(IVariableDebtToken(reserve.variableDebtTokenAddress)
.scaledTotalSupply()
.rayMul(reserve.variableBorrowIndex)
).add(amount)
< reserve.configuration.getBorrowCap(),
Errors.VL_BORROW_CAP_EXCEEDED);
(
vars.userCollateralBalanceETH,