Wrong Calculation Of Apr
Submitted by (2) Lambda, also found by rbserver
Summary:
When publishing a project, if the
lentAmountfor the community is non-zero, calculate the interest before updating the APR.Project A is unpublished, the
lentAmountis still 1,000,000 USD.During one year, no calls to
repayLender,reduceDebt, orescrowhappens, i.e. the interest is never added and thelastTimestampnot updated.After one year, the project is published again in the same community. Because the FED raised interest rates, it is specified that the APR should be 5% from now on.
Another $1,000,000 is lent to the project by calling
lendToProject. Now,claimInterestis called which calculates the interest of the last year for the first million. However, the function already uses the new APR of 5%, meaning the added interest is 50,000 USD instead of the correct 30,000 USD.
Mitigation:
When publishing a project, if the lentAmount for the community is non-zero, calculate the interest before updating the APR.
TAGS: #math
Last updated