pragma solidity ^0.5.8; pragma experimental ABIEncoderV2; interface TokenInterface { function balanceOf(address) external view returns (uint); } contract DSMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, "math-not-safe"); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "math-not-safe"); } uint constant WAD = 10 ** 18; function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } } contract Helpers is DSMath { /** * @dev get ethereum address */ function getAddressETH() public pure returns (address eth) { eth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; } } contract InstaBalRead is Helpers { function getTokensBalData(address owner, address[] memory tknAddress) public view returns (uint[] memory) { uint[] memory tokensBal = new uint[](tknAddress.length); for (uint i = 0; i < tknAddress.length; i++) { if (tknAddress[i] == getAddressETH()) { tokensBal[i] = owner.balance; } else { TokenInterface token = TokenInterface(tknAddress[i]); tokensBal[i] = token.balanceOf(owner); } } return tokensBal; } }