From e281e51b6791164480f431cc16b25f1a08134f78 Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Sat, 11 Apr 2020 03:40:02 +1000 Subject: [PATCH] balances resolver --- protocols/balances.sol | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 protocols/balances.sol diff --git a/protocols/balances.sol b/protocols/balances.sol new file mode 100644 index 0000000..a6c47c4 --- /dev/null +++ b/protocols/balances.sol @@ -0,0 +1,21 @@ +pragma solidity ^0.6.0; + +interface TokenInterface { + function balanceOf(address) external view returns (uint); +} + + +contract InstaBalanceResolver { + function getBalances(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] == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { + tokensBal[i] = owner.balance; + } else { + TokenInterface token = TokenInterface(tknAddress[i]); + tokensBal[i] = token.balanceOf(owner); + } + } + return tokensBal; + } +} \ No newline at end of file