You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The compound interest formula uses saturating_pow, which can iterate 32 times in the worst case. Lending interest is accrued by external pallets such as the vault-registry or oracle, so it's very important that the implementation is efficient.
Describe the solution you'd like
Aave uses a Taylor series to approximate the exponential and only computes the first three terms. We could use a similar approach, to reduce the function weight. See #758.
Context
Since the exponent is the seconds elapsed since the last accrual, one re-accrual per day takes 16 steps (log2(24*60*60)). One interaction every 10 days is 20 steps. So changing this is not very high priority. Re-accruing every 50 years will still not exceed the 32 exponent bits.
The text was updated successfully, but these errors were encountered:
Because the simple interest formula relies on interest being re-accrued very often, whereas the compound interest one will correctly compute interest no matter how often it is called. We switched to the latter based on the OpenZeppelin audit report of Compound v2: #901
Is your feature request related to a problem? Please describe.
The compound interest formula uses
saturating_pow
, which can iterate 32 times in the worst case. Lending interest is accrued by external pallets such as the vault-registry or oracle, so it's very important that the implementation is efficient.Describe the solution you'd like
Aave uses a Taylor series to approximate the exponential and only computes the first three terms. We could use a similar approach, to reduce the function weight. See #758.
Context
Since the exponent is the seconds elapsed since the last accrual, one re-accrual per day takes 16 steps (
log2(24*60*60)
). One interaction every 10 days is 20 steps. So changing this is not very high priority. Re-accruing every 50 years will still not exceed the 32 exponent bits.The text was updated successfully, but these errors were encountered: