Using a token with low decimals will result in 0 interest and fees in some cases
Let's look into the _calculateInterest
function and specifically this line interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;
This equation will round down to zero if the the total decimals from the left side of the equation are smaller than the right side.
Examples of when this can occur:
l.interestRate
and timeElapsed
are small numbers. In the example case, the debt can be anywhere from 100 to 999 tokens.
Higher interestRate
and timeElapsed
, but using a token with even fewer decimals.
Both the tests should fail with some numbers between the ones in the vm.assume
.
Loss of funds for the protocol and the lender of the pool.
Manual review
Foundry (fuzz)
The simplest way to fix this is to add a whitelist for tokens, or add a way to add more precision in the equation like a scaling factor.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.