aave-protocol-v2/contracts/misc/AaveProtocolTestHelpers.sol

50 lines
1.7 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: agpl-3.0
2020-06-08 15:36:40 +00:00
pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
2020-07-13 08:54:08 +00:00
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol';
import {ILendingPool} from '../interfaces/ILendingPool.sol';
2020-06-08 15:36:40 +00:00
contract AaveProtocolTestHelpers {
2020-07-13 08:54:08 +00:00
struct TokenData {
string symbol;
address tokenAddress;
}
2020-06-08 15:36:40 +00:00
2020-07-13 08:54:08 +00:00
ILendingPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
2020-06-08 15:36:40 +00:00
2020-07-13 08:54:08 +00:00
constructor(ILendingPoolAddressesProvider addressesProvider) public {
ADDRESSES_PROVIDER = addressesProvider;
}
2020-06-08 15:36:40 +00:00
2020-07-13 08:54:08 +00:00
function getAllReservesTokens() external view returns (TokenData[] memory) {
ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool());
2020-10-06 13:51:48 +00:00
address[] memory reserves = pool.getReservesList();
2020-07-13 08:54:08 +00:00
TokenData[] memory reservesTokens = new TokenData[](reserves.length);
for (uint256 i = 0; i < reserves.length; i++) {
reservesTokens[i] = TokenData({
symbol: (reserves[i] == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
? 'ETH'
: IERC20Detailed(reserves[i]).symbol(),
tokenAddress: reserves[i]
});
}
2020-07-13 08:54:08 +00:00
return reservesTokens;
}
2020-07-13 08:54:08 +00:00
function getAllATokens() external view returns (TokenData[] memory) {
ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool());
2020-10-06 13:51:48 +00:00
address[] memory reserves = pool.getReservesList();
2020-07-13 08:54:08 +00:00
TokenData[] memory aTokens = new TokenData[](reserves.length);
for (uint256 i = 0; i < reserves.length; i++) {
(address aTokenAddress, , ) = pool.getReserveTokensAddresses(reserves[i]);
aTokens[i] = TokenData({
symbol: IERC20Detailed(aTokenAddress).symbol(),
tokenAddress: aTokenAddress
});
2020-06-08 15:36:40 +00:00
}
2020-07-13 08:54:08 +00:00
return aTokens;
}
}