FLO-18: rename perSecondInterestRate to use nominal label#260
FLO-18: rename perSecondInterestRate to use nominal label#260
Conversation
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
Co-authored-by: Gornutz <90406700+Gornutz@users.noreply.github.com>
…-rate-terminology
docs: clarify nominal interest rate semantics
ad94e24 to
4699e83
Compare
|
For clarity, the current final state of this PR is broader than the original description. What this branch now does:
Files touched in the final branch state:
Validation run on this branch:
So the net effect is: terminology/documentation cleanup, one explicit helper for effective annual yield in the constant-rate case, and no intended change to protocol economics. |
| /// Converts a nominal yearly interest rate to a per-second multiplication factor (stored in a UFix128 as a fixed | ||
| /// point number with 18 decimal places). The input to this function is the relative nominal annual rate | ||
| /// (e.g. 0.05 for a 5% nominal yearly rate), and the result is the per-second multiplier | ||
| /// (e.g. 1.000000000001). For positive rates, the effective one-year growth will be slightly higher than the | ||
| /// nominal rate because interest compounds over time. |
There was a problem hiding this comment.
The rate is always positive (it’s a UFix128), so that’s already guaranteed.
What does “relative rate” mean here, relative to what?
“Slightly higher” doesn’t seem accurate. If the nominal rate reaches 100%, the effective rate exceeds 170%, which is significantly higher, not just a slight difference.
| /// Converts a nominal yearly interest rate to a per-second multiplication factor (stored in a UFix128 as a fixed | |
| /// point number with 18 decimal places). The input to this function is the relative nominal annual rate | |
| /// (e.g. 0.05 for a 5% nominal yearly rate), and the result is the per-second multiplier | |
| /// (e.g. 1.000000000001). For positive rates, the effective one-year growth will be slightly higher than the | |
| /// nominal rate because interest compounds over time. | |
| /// Converts a nominal yearly interest rate to a per-second multiplication factor (stored in a UFix128 as a fixed | |
| /// point number with 18 decimal places). The input to this function is the nominal annual rate | |
| /// (e.g. 0.05 for a 5% nominal yearly rate), and the result is the per-second multiplier | |
| /// (e.g. 1.000000000001). | |
| /// The effective annual rate will be higher than the nominal rate | |
| /// because interest compounds over time. |
|
@liobrasil I can’t approve this PR since I created it, but it now reflects both of our changes, so I think it’s good to merge if you’re happy with it. I left a small suggestion on the comment for the perSecondInterestRate function. |
Closes: #227
Addresses FLO-18. The per-second rate uses linear (nominal) decomposition (r / secondsPerYear), which means exponential compounding produces an effective APY that exceeds the stated rate. Rather than changing the behavior, this PR clarifies the semantics:
Renames perSecondInterestRate(yearlyRate:) → perSecondInterestRate(nominalYearlyRate:) to make the nominal nature explicit
Adds effectiveYearlyRate(nominalYearlyRate:) view function computing (1 + r/n)^n - 1