Closed sherlock-admin4 closed 6 months ago
1 comment(s) were left on this issue during the judging contest.
panprog commented:
invalid, the loss of precision is inevitable in fixed point calculations. This one doesn't cause any impact other than tiny difference in calculations
jasonxiale
high
APR in
OCC_Modular.applyCombine
is not correctSummary
The APR calculation in
OCC_Modular.applyCombine
is not correctly, which might causes the system loses interest, or the borrower pays more interest than repay the loan one-by-oneVulnerability Detail
In OCC_Modular.applyCombine, the APR depends on the sum APR of every loans,
principalOwed
of every loan.But this calcuation is not correctly. Supposed Alice(the borrower) has two loans, both of the two loans are
Bullet
type: the 1st loan is 1000$, APR=0.15, and the term is 2 years; the 2nd loan is 2000$, APR=0.12, and the term is 1 years;applyCombine
, the APR will be APR = (1000 0.15 + 2000 0.12) / (1000 + 2000) = 0.13, and theprincipalOwed
of the new combined loan will be 1000 + 2000 = 3000$. 1) So if theloan.term
is 1 year, Alice will pay 3000 0.13 = 390$ as interest, the system will loss profit. 2) And if theloan.term
is 1.5 years, the interest will be 3000 0.13 * 1.5 = 585$, in such case, Alice will pay more interest than repay the loans one by oneImpact
The APR calculation in
OCC_Modular.applyCombine
is not correctly, which might causes the system loses interest, or the borrower pays more interest than repay the loan one-by-oneCode Snippet
https://github.com/sherlock-audit/2024-03-zivoe/blob/d4111645b19a1ad3ccc899bea073b6f19be04ccd/zivoe-core-foundry/src/lockers/OCC/OCC_Modular.sol#L773-L774 https://github.com/sherlock-audit/2024-03-zivoe/blob/d4111645b19a1ad3ccc899bea073b6f19be04ccd/zivoe-core-foundry/src/lockers/OCC/OCC_Modular.sol#L781
Tool used
Manual Review
Recommendation