Skip to content

Commit

Permalink
- Fixed non-initialized availableLiquidity on validateBorrow()
Browse files Browse the repository at this point in the history
  • Loading branch information
eboadom committed Oct 28, 2020
1 parent 1cd7f2d commit 3f714b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/lendingpool/LendingPool.sol
Expand Up @@ -844,6 +844,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
);

ValidationLogic.validateBorrow(
vars.asset,
reserve,
vars.onBehalfOf,
vars.amount,
Expand Down
4 changes: 4 additions & 0 deletions contracts/libraries/logic/ValidationLogic.sol
Expand Up @@ -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
Expand All @@ -112,6 +113,7 @@ library ValidationLogic {
*/

function validateBorrow(
address asset,
ReserveLogic.ReserveData storage reserve,
address userAddress,
uint256 amount,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3f714b9

Please sign in to comment.