mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Added flusher balance resolver
This commit is contained in:
parent
7238ad512c
commit
d5e2f0c7e0
49
contracts/flusher/balances.sol
Normal file
49
contracts/flusher/balances.sol
Normal file
|
@ -0,0 +1,49 @@
|
|||
pragma solidity ^0.6.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface TokenInterface {
|
||||
function balanceOf(address) external view returns (uint);
|
||||
}
|
||||
|
||||
|
||||
contract Resolver {
|
||||
struct Balances {
|
||||
address flusher;
|
||||
uint[] balance;
|
||||
bool isDeployed;
|
||||
}
|
||||
|
||||
function getBalances(address[] memory flushers, address[] memory tknAddress) public view returns (Balances[] memory) {
|
||||
Balances[] memory tokensBal = new Balances[](flushers.length);
|
||||
for (uint i = 0; i < flushers.length; i++) {
|
||||
uint[] memory bals = new uint[](tknAddress.length);
|
||||
for (uint j = 0; j < tknAddress.length; j++) {
|
||||
if (tknAddress[j] == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
|
||||
bals[j] = flushers[i].balance;
|
||||
} else {
|
||||
TokenInterface token = TokenInterface(tknAddress[j]);
|
||||
bals[j] = token.balanceOf(flushers[i]);
|
||||
}
|
||||
}
|
||||
tokensBal[i] = Balances({
|
||||
flusher: flushers[i],
|
||||
balance: bals,
|
||||
isDeployed: isContractDeployed(flushers[i]);
|
||||
});
|
||||
}
|
||||
return tokensBal;
|
||||
}
|
||||
|
||||
function isContractDeployed(address flusher) public view returns (bool) {
|
||||
uint32 size;
|
||||
assembly {
|
||||
size := extcodesize(flusher)
|
||||
}
|
||||
return (size > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contract InstaFlusherERC20Resolver is Resolver {
|
||||
string public constant name = "ERC20-Flusher-Resolver-v1";
|
||||
}
|
Loading…
Reference in New Issue
Block a user