mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Optimized calculateLinearInterest() on MathUtils.
This commit is contained in:
parent
bb6b322925
commit
e88d9dc81b
|
@ -25,9 +25,7 @@ library MathUtils {
|
|||
//solium-disable-next-line
|
||||
uint256 timeDifference = block.timestamp.sub(uint256(lastUpdateTimestamp));
|
||||
|
||||
uint256 timeDelta = timeDifference.wadToRay().rayDiv(SECONDS_PER_YEAR.wadToRay());
|
||||
|
||||
return rate.rayMul(timeDelta).add(WadRayMath.ray());
|
||||
return (rate.mul(timeDifference) / SECONDS_PER_YEAR).add(WadRayMath.ray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1153,11 +1153,12 @@ const calcLinearInterest = (
|
|||
currentTimestamp: BigNumber,
|
||||
lastUpdateTimestamp: BigNumber
|
||||
) => {
|
||||
const timeDifference = currentTimestamp.minus(lastUpdateTimestamp).wadToRay();
|
||||
const timeDifference = currentTimestamp.minus(lastUpdateTimestamp);
|
||||
|
||||
const timeDelta = timeDifference.rayDiv(new BigNumber(ONE_YEAR).wadToRay());
|
||||
|
||||
const cumulatedInterest = rate.rayMul(timeDelta).plus(RAY);
|
||||
const cumulatedInterest = rate
|
||||
.multipliedBy(timeDifference)
|
||||
.dividedBy(new BigNumber(ONE_YEAR))
|
||||
.plus(RAY);
|
||||
|
||||
return cumulatedInterest;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user