Skip to content

Commit

Permalink
perf: dont use reserve data extended (aave-dao#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Sep 19, 2024
1 parent 105baaf commit 3aad8ca
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,19 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St

///@inheritdoc IERC4626
function maxRedeem(address owner) public view override returns (uint256) {
DataTypes.ReserveData memory reserveData = POOL.getReserveDataExtended(asset());
DataTypes.ReserveConfigurationMap memory reserveConfiguration = POOL.getConfiguration(asset());

// if paused or inactive users cannot withdraw underlying
if (
!ReserveConfiguration.getActive(reserveData.configuration) ||
ReserveConfiguration.getPaused(reserveData.configuration)
!ReserveConfiguration.getActive(reserveConfiguration) ||
ReserveConfiguration.getPaused(reserveConfiguration)
) {
return 0;
}

// otherwise users can withdraw up to the available amount
uint256 underlyingTokenBalanceInShares = convertToShares(reserveData.virtualUnderlyingBalance);
uint128 virtualUnderlyingBalance = POOL.getVirtualUnderlyingBalance(asset());
uint256 underlyingTokenBalanceInShares = convertToShares(virtualUnderlyingBalance);
uint256 cachedUserBalance = balanceOf(owner);
return
underlyingTokenBalanceInShares >= cachedUserBalance
Expand Down

0 comments on commit 3aad8ca

Please sign in to comment.