Overview
Last updated
Was this helpful?
Last updated
Was this helpful?
The FixedTermLoanManager interacts with FixedTermLoans on behalf of the PoolManager and represents these Loans' outstanding value with the assetsUnderManagement
function. This function returns the outstanding principal of all loans plus the outstanding interest.
The outstanding principal component of AUM in the FixedTermLoanManager is represented by the principalOut
state variable. This variable is incremented and decremented based on the actions of individual Loans and is equal to the sum of principal balance on all outstanding Loans.
Outstanding interest in the FixedTermLoanManager has to represent the current aggregate value of the outstanding interest in all loans in the most accurate and efficient way possible. in FixedTermLoans is represented as fixed amounts owed at a given date. For example, a $1m loan with 12% interest and a 30 day payment interval would be shown as:
This amount of $9863.01$ would be due exactly 30 days from when the loan gets funded.
Using this information, the current value of interest in the FixedTermLoan at any given time can be represented with the following equation:
So in an easier example, with a loan that expects $1000 on day 20, the value on day 9 would be:
Expanding on this concept, the naive calculation of the outstanding interest of all loans would be:
In a system managing many loans at once, calculating the outstanding interest by summing the values naively is prohibitively expensive. In order to represent this value more efficiently, an alternative approach was taken. By saving the values from Loans during interactions and using them in an aggregate expression, a piecewise linear function can be constructed to represent the value of outstanding interest at any given time. This function consists of four parameters:
issuanceRate
: Units of fundsAsset
per second being earned as interest for all outstanding loans.
accountedInterest
: "Snapshotted" value of outstanding interest saved at each point the function parameters are updated.
domainStart
: The timestamp marking beginning of the domain in which the interest accrual expression is valid (called the "issuance domain"). Set to block.timestamp
after each update.
domainEnd
: The timestamp marking the end of the issuance domain.
The equation for outstanding interest is shown below:
where: