From 3f714b9dc848d28d1753fd8a673038fda4f024ed Mon Sep 17 00:00:00 2001 From: eboado Date: Wed, 28 Oct 2020 11:48:55 +0100 Subject: [PATCH] - Fixed non-initialized availableLiquidity on validateBorrow() --- contracts/lendingpool/LendingPool.sol | 1 + contracts/libraries/logic/ValidationLogic.sol | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index c63ff348..b387f59f 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -844,6 +844,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage ); ValidationLogic.validateBorrow( + vars.asset, reserve, vars.onBehalfOf, vars.amount, diff --git a/contracts/libraries/logic/ValidationLogic.sol b/contracts/libraries/logic/ValidationLogic.sol index 947d84ea..08f0ba35 100644 --- a/contracts/libraries/logic/ValidationLogic.sol +++ b/contracts/libraries/logic/ValidationLogic.sol @@ -99,6 +99,7 @@ library ValidationLogic { /** * @dev validates a borrow. + * @param asset the address of the asset to borrow * @param reserve the reserve state from which the user is borrowing * @param userAddress the address of the user * @param amount the amount to be borrowed @@ -112,6 +113,7 @@ library ValidationLogic { */ function validateBorrow( + address asset, ReserveLogic.ReserveData storage reserve, address userAddress, uint256 amount, @@ -198,6 +200,8 @@ library ValidationLogic { Errors.CALLATERAL_SAME_AS_BORROWING_CURRENCY ); + vars.availableLiquidity = IERC20(asset).balanceOf(reserve.aTokenAddress); + //calculate the max available loan size in stable rate mode as a percentage of the //available liquidity uint256 maxLoanSizeStable = vars.availableLiquidity.percentMul(maxStableLoanPercent);