interest
Interest & Time-Based Calculations (f64)
Financial mathematics for DeFi applications using 32.32 fixed-point. Gas-optimized versions of the f128 interest functions.
Interpolation
linear_interpolate- Linear interpolation between two values
Growth & Decay
exponential_growth- Calculate growth with compoundingdecay- Calculate exponential decay
Interest Calculations
simple_interest- Simple interest: P × (1 + rt)compound- Compound interest: P × (1 + r/n)^(nt)continuous_compound- Continuous compounding: P × e^(rt)
Financial Utilities
present_value- Discount future value to presenteffective_annual_rate- Convert nominal to effective rate
Fully qualified path: cairo_fp::f64::math::interest
Free functions
| linear_interpolate | Linear interpolation between start and end. Returns start + (end - start) × t for 0 ≤ t ≤ 1. |
| exponential_growth | Calculates exponential growth: initial × (1 + rate)^periods. |
| decay | Calculates exponential decay: initial × (1 - rate)^periods. Requires rate < 1 for meaningful results. |
| compound | Calculates compound interest. Formula: principal × (1 + rate/n)^(n×t)… |
| simple_interest | Calculates simple interest: principal × (1 + rate × time). |
| continuous_compound | Calculates continuously compounded interest: principal × e^(rate × time). |
| present_value | Calculates present value from future value. Formula: FV / (1 + rate)^periods |
| effective_annual_rate | Calculates effective annual rate from nominal rate. Formula: (1 + r/n)^n - 1 |