Skip to content

Commit

Permalink
fix: Fix stack too deep for unoptimized compile of PoolConfigurator
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Oct 6, 2021
1 parent 10300d4 commit ef14f03
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions contracts/interfaces/IPoolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ interface IPoolDataProvider {
uint256 variableBorrowIndex,
uint40 lastUpdateTimestamp
);

/**
* @notice Returns the total supply of aTokens for a given asset
* @param asset The address of the underlying asset of the reserve
* @return The total supply of the aToken
**/
function getATokenTotalSupply(address asset) external view returns (uint256);
}
12 changes: 12 additions & 0 deletions contracts/misc/AaveProtocolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ contract AaveProtocolDataProvider is IPoolDataProvider {
);
}

/**
* @notice Returns the total supply of aTokens for a given asset
* @param asset The address of the underlying asset of the reserve
* @return The total supply of the aToken
**/
function getATokenTotalSupply(address asset) external view override returns (uint256) {
DataTypes.ReserveData memory reserve = IPool(ADDRESSES_PROVIDER.getPool()).getReserveData(
asset
);
return IERC20Detailed(reserve.aTokenAddress).totalSupply();
}

/**
* @notice Returns the user data in a reserve
* @param asset The address of the underlying asset of the reserve
Expand Down
6 changes: 4 additions & 2 deletions contracts/protocol/pool/PoolConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,11 @@ contract PoolConfigurator is VersionedInitializable, IPoolConfigurator {
}

function _checkNoLiquidity(address asset) internal view {
(, , uint256 totalATokens, , , , , , , , , ) = IPoolDataProvider(
uint256 totalATokens = IPoolDataProvider(_addressesProvider.getPoolDataProvider())
.getATokenTotalSupply(asset);
/*(, , uint256 totalATokens, , , , , , , , , ) = IPoolDataProvider(
_addressesProvider.getPoolDataProvider()
).getReserveData(asset);
).getReserveData(asset);*/

require(totalATokens == 0, Errors.PC_RESERVE_LIQUIDITY_NOT_0);
}
Expand Down

0 comments on commit ef14f03

Please sign in to comment.