Skip to content

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

Closed

Description

@liobrasil

Severity: Low

Files Affected

  • cadence/contracts/FlowALPv1.cdc

Description

The protocol calculates the interest rate applied per second by linearly dividing the annual rate by the number of seconds in a year. However, the interest is actually applied to the global indices using an exponential compounding formula. When a linear rate is plugged into an exponential compounding function, the effective annual percentage yield (APY) can diverge significantly from the intended annual rate. This results in borrowers being overcharged and the protocol's economic model becoming increasingly inaccurate as the nominal interest rate increases.

Recommendation

To ensure that the compounded per-second rate exactly matches the intended annual rate, the protocol must use the natural logarithm to decompose the annual rate. The per-second rate should be calculated as: r_sec = ln(1 + r_annual) / 31536000 Since ln is not natively available in Cadence, the protocol should either pre-calculate the per-second rates off-chain before passing them to setInterestCurve(), or utilize a fixed-point math library capable of approximating Taylor series for logarithmic functions.


Parent Issue: #209

Activity

  1. holyfuchs commented on Mar 9, 2026

    @holyfuchs
    Contributor

    I don't think Taylor makes sense. Will clarify in the Q&A if we use nominal interest.

    Target % Linear Log Taylor
    1% 1.0050% 1.0000% 1.0000%
    2% 2.0201% 2.0000% 2.0000%
    5% 5.1271% 5.0000% 5.0000%
    10% 10.5171% 10.0000% 9.9998%
    50% 64.8721% 50.0000% 49.3379%
    100% 171.8282% 100.0000% 79.2002%
    400% 5459.8136% 400.0000% -100.0000%
  2. self-assigned this
    on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions