CreditLine.sol assumes 365 day year #86
Labels
0 (Non-critical)
Code style, clarity, syntax, versioning, off-chain monitoring (events etc), exclude gas optimisation
bug
Something isn't working
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
sirhashalot
Vulnerability details
Impact
CreditLine.sol assumes a year is 365 days with the
YEAR_IN_SECONDS
constant, but this is not always true. This assumption impacts thecalculateInterest
function and will more interest than it should during leap years (roughly 1 / 365 = 0.274% more). Solidity documentation warns against assuming a year is 365 days, and theyears
suffix was removed for this reason from Solidity 0.5.0.Proof of Concept
CreditLine.sol
https://github.com/code-423n4/2021-12-sublime/blob/9df1b7c4247f8631647c7627a8da9bdc16db8b11/contracts/CreditLine/CreditLine.sol
Recommended Mitigation Steps
Handle leap year edge case in
calculateInterest
function to improve interest calculation accuracyThe text was updated successfully, but these errors were encountered: