Accrued Interest Calculation
Describes how accrued interest is calculated and where and when this happens
Formulae
Interest = (r * x * t) / 1yr / 10000
r = APR in basis points (e.g. 5% = 500bp)
x = amount of tokens
t = time (in seconds)
1 year = 365.25 days (in seconds)
Full Accrued Interest formula
InterestAccrued =
(rate.dRate * drawnBalance * timespan) / INTEREST_DENOMINATOR
+
(rate.fRate * (facilityBalance - drawnBalance) * timespan) / INTEREST_DENOMINATOR
Parameters
Base denominator
10000 (adjustment factor since rates are expressed in basis points (bps) --> e.g. 5% rate is expressed as 500bp so we need to divide by 100 to get a % and then by another 100 to arrive at the decimal (500/100/100 = 0.05)
One year
One Julian astronomical year, has 365.25 days: 1 year = 365.25 days = (365.25 days) × (24 hours/day) × (3600 seconds/hour) = 31557600 seconds
dRate
The annual interest rate charged to a Borrower on borrowed / drawn down funds (in basis points to 4 decimals, e.g. 1000bp = 10% and 1234bp = 12.34% and 1234.56bp = 12.3456%)
fRate
The annual interest rate charged to a Borrower on the remaining funds available, but not yet drawn down aka rate charged on the available facility headroom(in basis points to 4 decimals).
facilityBalance
The remaining balance of funds that a Borrower can still drawn down on the Line of Credit (aka headroom)
timespan= block.timestamp - rate.lastAccrued
The number of seconds for which interest will be accrued
Contract workflow
Please see here for an overview of the contract and function workflow.
The definitions below are useful for that.
Last updated
Was this helpful?