mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix: exposure cap is on supply of collaterals, not on debts..
This commit is contained in:
parent
68ff74a3a6
commit
129a96a3cf
contracts/protocol/libraries/logic
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user