Skip to content

Commit

Permalink
c4-008 Variable Pool liquidity check should validate balance of aToke…
Browse files Browse the repository at this point in the history
…n, not Pool (#127)
  • Loading branch information
aviggiano authored Jul 15, 2024
1 parent eb9e684 commit 5f9b633
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libraries/CapsLibrary.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {IAToken} from "@aave/interfaces/IAToken.sol";
import {State} from "@src/SizeStorage.sol";
import {Errors} from "@src/libraries/Errors.sol";

Expand Down Expand Up @@ -65,7 +66,9 @@ library CapsLibrary {
/// @param state The state struct
/// @param amount The amount of cash to withdraw
function validateVariablePoolHasEnoughLiquidity(State storage state, uint256 amount) public view {
uint256 liquidity = state.data.underlyingBorrowToken.balanceOf(address(state.data.variablePool));
IAToken aToken =
IAToken(state.data.variablePool.getReserveData(address(state.data.underlyingBorrowToken)).aTokenAddress);
uint256 liquidity = state.data.underlyingBorrowToken.balanceOf(address(aToken));
if (liquidity < amount) {
revert Errors.NOT_ENOUGH_BORROW_ATOKEN_LIQUIDITY(liquidity, amount);
}
Expand Down

0 comments on commit 5f9b633

Please sign in to comment.