The calculateLinearInterestFromBips function is susceptible to precision loss when the accumulatedInterestRay is smaller than the constant SECONDS_IN_365_DAYS. The division operation can result in rounding down to zero, leading to incorrect interest rate calculations. This precision loss can have a significant impact on the accuracy of interest accrual, especially when dealing with small interest rates or short time intervals.
Users may experience unexpected financial losses or gains due to inaccurate interest rate calculations. This can affect their overall financial position and potentially result in monetary losses.
Floating-Point Arithmetic: Use floating-point arithmetic or fixed-point representations with higher precision to perform the division, ensuring that precision is not lost.
Lines of code
https://github.com/code-423n4/2023-10-wildcat/blob/main/src/libraries/MathUtils.sol#L37
Vulnerability details
Impact
The calculateLinearInterestFromBips function is susceptible to precision loss when the accumulatedInterestRay is smaller than the constant SECONDS_IN_365_DAYS. The division operation can result in rounding down to zero, leading to incorrect interest rate calculations. This precision loss can have a significant impact on the accuracy of interest accrual, especially when dealing with small interest rates or short time intervals. Users may experience unexpected financial losses or gains due to inaccurate interest rate calculations. This can affect their overall financial position and potentially result in monetary losses.
Proof of Concept
Tools Used
Manual review
Recommended Mitigation Steps
Floating-Point Arithmetic: Use floating-point arithmetic or fixed-point representations with higher precision to perform the division, ensuring that precision is not lost.
Assessed type
Math