Fixed compounded interest approximation

This commit is contained in:
emilio 2020-08-11 10:11:35 +02:00
parent 413b648b41
commit 9b0b190019
2 changed files with 7 additions and 2 deletions

View File

@ -57,7 +57,8 @@ library MathUtils {
}
uint256 expMinusOne = exp.sub(1);
uint256 expMinusTwo = exp.sub(2);
uint256 expMinusTwo = exp > 2 ? exp.sub(2) : 0;
uint256 ratePerSecond = _rate.div(31536000);

View File

@ -1265,8 +1265,12 @@ const calcCompoundedInterest = (
const timeDifference = currentTimestamp.minus(lastUpdateTimestamp);
if(timeDifference.eq(0)){
return new BigNumber(RAY);
}
const expMinusOne = timeDifference.minus(1);
const expMinusTwo = timeDifference.minus(2);
const expMinusTwo = timeDifference.gt(2) ? timeDifference.minus(2) : 0;
const ratePerSecond = rate.div(ONE_YEAR);