change wallet balance provider to support eth

This commit is contained in:
andyk 2020-11-06 17:06:52 +03:00
parent d599dee431
commit 7cb042517f
3 changed files with 12 additions and 8 deletions

View File

@ -3,7 +3,7 @@ pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {IUiPoolDataProvider} from './IUiPoolDataProvider.sol';
import {IUiPoolDataProvider} from './interfaces/IUiPoolDataProvider.sol';
import {ILendingPool} from '../interfaces/ILendingPool.sol';
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';

View File

@ -25,7 +25,7 @@ contract WalletBalanceProvider {
using ReserveConfiguration for ReserveConfiguration.Map;
LendingPoolAddressesProvider internal immutable _provider;
address constant MOCK_ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
address constant MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
constructor(LendingPoolAddressesProvider provider) public {
_provider = provider;
@ -69,11 +69,15 @@ contract WalletBalanceProvider {
for (uint256 i = 0; i < users.length; i++) {
for (uint256 j = 0; j < tokens.length; j++) {
uint256 _offset = i * tokens.length;
if (!tokens[j].isContract()) {
revert('INVALID_TOKEN');
uint256 offset = i * tokens.length;
if (tokens[j] == MOCK_ETH_ADDRESS) {
balances[offset + j] = users[i].balance; // ETH balance
} else {
balances[_offset + j] = balanceOf(users[i], tokens[j]);
if (!tokens[j].isContract()) {
revert('INVALID_TOKEN');
} else {
balances[offset + j] = balanceOf(users[i], tokens[j]);
}
}
}
}

View File

@ -2,8 +2,8 @@
pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol';
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
import {ReserveLogic} from '../../libraries/logic/ReserveLogic.sol';
interface IUiPoolDataProvider {
struct AggregatedReserveData {