fix: exposure cap is on supply of collaterals, not on debts..

This commit is contained in:
Hadrien Charlanes 2021-06-03 16:31:09 +02:00
parent 68ff74a3a6
commit 129a96a3cf
2 changed files with 3 additions and 9 deletions
contracts/protocol/libraries/logic

View File

@ -116,10 +116,7 @@ library GenericLogic {
vars.totalCollateralInETH = vars.totalCollateralInETH.add(vars.userBalanceETH);
vars.exposureCap = currentReserve.configuration.getExposureCap();
vars.exposureCapped =
IERC20(currentReserve.stableDebtTokenAddress)
.totalSupply()
.add(IERC20(currentReserve.variableDebtTokenAddress).totalSupply())
.div(10**vars.decimals) >
IERC20(currentReserve.aTokenAddress).totalSupply().div(10**vars.decimals) >
vars.exposureCap;
vars.avgLtv = vars.avgLtv.add(vars.exposureCapped ? 0 : vars.userBalanceETH.mul(vars.ltv));
vars.avgLiquidationThreshold = vars.avgLiquidationThreshold.add(

View File

@ -467,8 +467,7 @@ library ValidationLogic {
);
uint256 exposureCap = reserve.configuration.getExposureCapMemory();
uint256 totalSupplyStableDebt = IERC20(reserve.stableDebtTokenAddress).totalSupply();
uint256 totalSupplyVariableDebt = IERC20(reserve.variableDebtTokenAddress).totalSupply();
uint256 totalSupplyAtoken = IERC20(reserve.aTokenAddress).totalSupply();
(, , , uint256 reserveDecimals, ) = reserve.configuration.getParamsMemory();
require(
@ -477,9 +476,7 @@ library ValidationLogic {
);
require(
exposureCap == 0 ||
ltv == 0 ||
totalSupplyStableDebt.add(totalSupplyVariableDebt).div(10**reserveDecimals) < exposureCap,
exposureCap == 0 || ltv == 0 || totalSupplyAtoken.div(10**reserveDecimals) < exposureCap,
Errors.VL_COLLATERAL_EXPOSURE_CAP_EXCEEDED
);
}