safemath in calculation of interest owed

This commit is contained in:
Barry Gitarts 2019-04-14 09:28:07 -04:00
parent 8f3fa1c2af
commit fc185fdc61
1 changed files with 3 additions and 1 deletions

View File

@ -106,7 +106,9 @@ contract Subscription {
function getInterestOwed(uint256 amountOwed) view public returns (uint256) {
uint256 totalAmount = compound.getSupplyBalance(address(this), daiAddress);
uint256 totalInterest = totalAmount - totalBalances;
uint256 interestOwed = totalInterest * amountOwed / totalBalances;
if (amountOwed == totalBalances) return totalInterest;
uint256 totalOwned = totalInterest * amountOwed;
uint256 interestOwed = totalOwned.div(totalBalances);
return interestOwed;
}