The LoanManager interacts with Loans on behalf of the PoolManager and represents all the outstanding these Loans' outstanding value with the
assetsUnderManagementfunction. This function returns the outstanding principal of all loans plus the outstanding interest.
The outstanding principal component of AUM in the LoanManager is represented by the
principalOutstate 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 LoanManager has to represent the current aggregate value of the outstanding interest in all loans in the most accurate and efficient way possible. Interest in MapleLoans 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 MapleLoan 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
fundsAssetper 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.timestampafter each update.
domainEnd: The timestamp marking the end of the issuance domain.
The equation for outstanding interest is shown below: