Skip to content

FLO-18: rename perSecondInterestRate to use nominal label#260

Open
holyfuchs wants to merge 17 commits intomainfrom
holyfuchs/FLO-18-nominal-interets
Open

FLO-18: rename perSecondInterestRate to use nominal label#260
holyfuchs wants to merge 17 commits intomainfrom
holyfuchs/FLO-18-nominal-interets

Conversation

@holyfuchs
Copy link
Member

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

@holyfuchs holyfuchs requested a review from a team as a code owner March 10, 2026 20:22
liobrasil and others added 11 commits March 10, 2026 16:51
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>
docs: clarify nominal interest rate semantics
@liobrasil liobrasil force-pushed the holyfuchs/FLO-18-nominal-interets branch from ad94e24 to 4699e83 Compare March 11, 2026 05:31
@liobrasil
Copy link
Contributor

liobrasil commented Mar 11, 2026

For clarity, the current final state of this PR is broader than the original description.

What this branch now does:

  • Clarifies that the rates configured by the interest curves are nominal yearly rates, not exact one-year effective yields.
  • Keeps the protocol behavior unchanged: the configured yearly rate is still decomposed into a per-second rate and accrues through the existing index-based compounding logic.
  • Makes the docs/comments consistent with the @holyfuchs and @Gornutz discussion: a stated yearly rate is nominal, so the realized one-year effective return can be slightly higher under compounding, and under variable utilization it should not be interpreted as a fixed promised APY.
  • Cleans up fixed-curve commentary so it matches the actual protocol-fee spread logic. In practice, the deposit-side rate is derived from the borrow-side rate after applying the combined insurance/stability fee fractions; this PR does not change that logic, it only fixes wording that previously described it too loosely.
  • Adds effectiveYearlyRate(nominalYearlyRate:) in FlowALPMath as an explicit helper for the constant-rate case, using the same discrete per-second compounding convention as the protocol: (1 + r / secondsPerYear)^secondsPerYear - 1.
  • Adds coverage for that helper in cadence/tests/effective_interest_rate_test.cdc.
  • Includes a follow-up merge fix to restore API consistency around perSecondInterestRate(yearlyRate: ...) after the branch history briefly mixed yearlyRate and nominalYearlyRate labels. The final code keeps yearlyRate at that call site; the nominal/effective distinction is documented in comments/docs rather than enforced through that parameter name.

Files touched in the final branch state:

  • cadence/contracts/FlowALPEvents.cdc
  • cadence/contracts/FlowALPInterestRates.cdc
  • cadence/lib/FlowALPMath.cdc
  • cadence/tests/TEST_COVERAGE.md
  • cadence/tests/effective_interest_rate_test.cdc
  • cadence/tests/interest_accrual_integration_test.cdc
  • cadence/tests/interest_curve_advanced_test.cdc
  • cadence/tests/interest_curve_test.cdc
  • cadence/tests/kink_curve_utilization_regression_test.cdc
  • cadence/tests/update_interest_rate_test.cdc
  • cadence/transactions/flow-alp/pool-governance/add_supported_token_fixed_rate_curve.cdc
  • cadence/transactions/flow-alp/pool-governance/add_supported_token_zero_rate_curve.cdc
  • cadence/transactions/flow-alp/pool-governance/set_interest_curve_fixed.cdc
  • docs/interest_rate_and_protocol_fees.md

Validation run on this branch:

  • flow test cadence/tests/interest_curve_test.cdc
  • flow test cadence/tests/update_interest_rate_test.cdc
  • flow test cadence/tests/effective_interest_rate_test.cdc
  • flow test cadence/tests/interest_curve_advanced_test.cdc
  • flow test cadence/tests/interest_accrual_integration_test.cdc
  • flow test cadence/tests/kink_curve_utilization_regression_test.cdc

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FLO-18: perSecondInterestRate() Uses Linear Instead of Logarithmic Decomposition

3 participants