Created
April 3, 2019 21:54
-
-
Save p-s-dev/92ae9dc08e94bbfd5f113f8cfd8ab319 to your computer and use it in GitHub Desktop.
Return all CompFi token supply/borrow values in 1 call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract IMoneyMarket { | |
function getSupplyBalance(address account, address asset) view public returns (uint); | |
function getBorrowBalance(address account, address asset) view public returns (uint); | |
} | |
contract AllComFiTokens { | |
address public bat; | |
address public dai; | |
address public rep; | |
address public weth; | |
address public zrx; | |
IMoneyMarket public moneyMarket; | |
constructor() public { | |
bat = address(0x0D8775F648430679A709E98d2b0Cb6250d2887EF); | |
dai = address(0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359); | |
rep = address(0x1985365e9f78359a9B6AD760e32412f4a445E862); | |
weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); | |
zrx = address(0xE41d2489571d322189246DaFA5ebDe1F4699F498); | |
moneyMarket = IMoneyMarket(0x3fda67f7583380e67ef93072294a7fac882fd7e7); | |
} | |
function getSupplyValues(address userAddress) public view returns (uint, uint, uint, uint, uint) { | |
return ( | |
moneyMarket.getSupplyBalance(userAddress, bat), | |
moneyMarket.getSupplyBalance(userAddress, dai), | |
moneyMarket.getSupplyBalance(userAddress, rep), | |
moneyMarket.getSupplyBalance(userAddress, weth), | |
moneyMarket.getSupplyBalance(userAddress, zrx) | |
); | |
} | |
function getBorrowValues(address userAddress) public view returns (uint, uint, uint, uint, uint) { | |
return ( | |
moneyMarket.getBorrowBalance(userAddress, bat), | |
moneyMarket.getBorrowBalance(userAddress, dai), | |
moneyMarket.getBorrowBalance(userAddress, rep), | |
moneyMarket.getBorrowBalance(userAddress, weth), | |
moneyMarket.getBorrowBalance(userAddress, zrx) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment