Skip to content

Interest Rate Boundary Conditions Testing #180

@UlyanaAndrukhiv

Description

@UlyanaAndrukhiv

Context

Tests cover normal utilization ranges, need extreme scenarios.

Missing Test Coverage:

  • Extreme Utilization

    • Utilization = 99.9% (nearly all liquidity borrowed)
    • Interest rate at maximum cap (400%)
    • KinkCurve steep slope behavior
    • Borrowing cost discourages further borrowing
  • Zero Balance Edge Cases

    • totalCreditBalance = 0 (no liquidity)
    • Attempting to borrow should fail
    • Interest rate calculation with zero denominator
    • New deposit enables borrowing
  • Empty Pool

    • totalDebitBalance = 0 (no borrows)
    • Credit interest rate = 0
    • First borrow triggers rate update
    • Utilization jumps from 0% to X%
  • Kink Point Transitions

    • Utilization exactly at kink (e.g., 80.0%)
    • Rate calculation uses slope1 or slope2?
    • Smooth transition validation
    • No discontinuities or jumps
  • Maximum Rate Enforcement

    • Interest curve returns 450% (exceeds cap)
    • Protocol enforces 400% maximum
    • Validation in postcondition
    • No overflow or panic
  • Long Time Period Accrual

    • Interest accrues for 1 year (31,557,600 seconds)
    • Interest accrues for 10 years
    • Compound interest doesn't overflow
    • UFix128 precision maintained
  • Time Jump Scenarios

    • Blockchain halts for 1 day
    • First transaction after restart
    • Interest accrual for large time delta
    • No overflow in dt calculation

Recommended Tests:

Test: Utilization 99.9%, validate interest rate
Test: totalCreditBalance = 0, borrow attempt fails
Test: totalDebitBalance = 0, credit rate = 0
Test: Utilization exactly 80.0% (kink point)
Test: Interest curve returns 450%, enforced to 400%
Test: Accrue interest for 10 years, no overflow
Test: Time jump 1 day, interest accrual correct

Metadata

Metadata

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