2020-06-08 15:36:40 +00:00
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
pragma experimental ABIEncoderV2;
|
2020-06-08 19:06:26 +00:00
|
|
|
|
2020-06-08 15:36:40 +00:00
|
|
|
import {ILendingPoolAddressesProvider} from "../interfaces/ILendingPoolAddressesProvider.sol";
|
2020-06-09 09:11:19 +00:00
|
|
|
import {IERC20Detailed} from "../interfaces/IERC20Detailed.sol";
|
2020-06-20 23:40:03 +00:00
|
|
|
import {LendingPool} from "../lendingpool/LendingPool.sol";
|
2020-06-08 15:36:40 +00:00
|
|
|
import {AToken} from "../tokenization/AToken.sol";
|
|
|
|
|
|
|
|
contract AaveProtocolTestHelpers {
|
2020-06-09 09:11:19 +00:00
|
|
|
struct TokenData {
|
2020-06-08 15:36:40 +00:00
|
|
|
string symbol;
|
2020-06-09 09:11:19 +00:00
|
|
|
address tokenAddress;
|
2020-06-08 15:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ILendingPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
|
|
|
|
|
|
|
|
constructor(ILendingPoolAddressesProvider addressesProvider) public {
|
|
|
|
ADDRESSES_PROVIDER = addressesProvider;
|
|
|
|
}
|
|
|
|
|
2020-06-09 09:11:19 +00:00
|
|
|
function getAllReservesTokens() external view returns(TokenData[] memory) {
|
2020-06-20 23:40:03 +00:00
|
|
|
LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool()));
|
|
|
|
address[] memory reserves = pool.getReserves();
|
2020-06-09 09:11:19 +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]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return reservesTokens;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAllATokens() external view returns(TokenData[] memory) {
|
2020-06-20 23:40:03 +00:00
|
|
|
LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool()));
|
|
|
|
address[] memory reserves = pool.getReserves();
|
2020-06-09 09:11:19 +00:00
|
|
|
TokenData[] memory aTokens = new TokenData[](reserves.length);
|
2020-06-08 15:36:40 +00:00
|
|
|
for (uint256 i = 0; i < reserves.length; i++) {
|
2020-06-27 02:13:32 +00:00
|
|
|
(,,,,address aTokenAddress,,,,,) = pool.getReserveConfigurationData(reserves[i]);
|
2020-06-09 09:11:19 +00:00
|
|
|
aTokens[i] = TokenData({
|
2020-06-08 15:36:40 +00:00
|
|
|
symbol: AToken(aTokenAddress).symbol(),
|
2020-06-09 09:11:19 +00:00
|
|
|
tokenAddress: aTokenAddress
|
2020-06-08 15:36:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return aTokens;
|
|
|
|
}
|
|
|
|
}
|