PaymenLib
A library for managing loan payments
Library for managing loan payments. Each payment has a principal amount that is due at the end of the maturity period and defaults after the grace period. An interest rate is applied linearly to the principal amount over time until the payment is due. A premium rate is added to the rate thereafter.
State Variables
INTEREST_SCALE
YEAR_IN_SECONDS
Functions
matured
Whether the principal is due at a given time.
maturedAt
The time when the principal is due.
defaulted
Whether the payment is defaulted.
defaulted
Whether the payment is defaulted at a given time.
defaultedAt
The time when the payment is defaulted.
accruedInterest
The total amount of interest accrued. This includes both regular and premium interest.
regularAccruedInterest
The total amount of regular interest accrued.
premiumAccruedInterest
The total amount of premium interest accrued.
_accruedInterest
Linear interpolation of the interest linearly accrued between two timepoints. Precision is maintained by scaling the rate by 1e4.