Maple
Search
⌃K

Pool Accounting Examples

Overview

This section is intended to demonstrate multiple scenarios with loans to show how value is represented with totalAssets. During each payment, accounting state in the Pool contracts is changed in the following way:
  1. 1.
    accountedInterest is decreased. This is because the
    outstandingInterestoutstandingInterest
    portion of assetsUnderManagement must discretely decrease when a payment is made.
  2. 2.
    domainStart is updated to the current timestamp.
  3. 3.
    issuanceRate is updated based on the resulting state.
  4. 4.
    domainEnd is set to the next earliest payment due date.
  5. 5.
    Cash in the pool increases.
Note 1: For all of the below examples, only interest is being paid so outstanding principal (principalOut) remains constant.
Note 2: For the purpose of simplicity, issuanceRate is represented as
units/dayunits/day
in the equations below. In reality, it is represented as
units×1e30/secondunits \times 1e30 / second
.
Note 3: None of the below diagrams are to scale.

Example 1: Single Loan - On Time Payment

In this example, there is a single Loan that makes a payment at the exact timestamp at which the payment is due. The payment is for 5000 units of fundsAsset.
It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:
Since the payment was made at the exact time that it was due, the outstanding interest exactly equaled the actual interest paid, so no discrete change in totalAssets is observed.

Example 2: Single Loan - Early Payment

In this example, there is a single Loan that makes an early payment, two days before the payment is due. The interest due is 5000 units, but since the payment is made on day 8, only 4000 units have accrued in the LoanManager accounting.
It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:
When a payment is made early, there is a discrete increase in totalAssets since the cash balance in the pool increases more than the outstanding interest that was represented when the payment was made.

Example 3: Single Loan - Late Payment

In this example, there is a single Loan that makes a late payment, four days after the payment is due. The interest due is 5000 units, but since the payment is made late, there is an extra 3000 units of late interest that must be paid. In addition, since the payment is made on day 14, four days of interest (2000 units) has accrued in the second payment interval. Note that for a late payment, the issuance rate does not change.
Whenever the current timestamp is past the domainEnd in the LoanManager, assetsUnderManagement no longer accrues interest until the interest accrual formula is updated.
It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:
When a payment is made late, there is a discrete increase in totalAssets since the interest accruing in the second interval is not represented in the accounting until a payment is made, plus late fees are added.

Example 4: Double Loan - Single On-Time Payment

In this example, there are two outstanding Loans. Loan 2 gets funded on day 5. Loan 1 makes a payment exactly on time at day 10.
When there is more than one outstanding loan, the issuanceRate becomes an aggregate value, representing the units of fundsAsset accruing against both loans simultaneously. This value gets updated from
IR1IR_1
to
IR1,2IR_{1,2}
when Loan 2 gets funded and gets updated to
IR2IR_2
when Loan 1 is paid.

Loan 2 Funding

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Loan 1 Payment

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Example 5: Double Loan - Multiple On Time Payments

In this example, there are two outstanding Loans. Loan 2 gets funded on day 5. Loan 1 makes a payment exactly on time at day 10. Loan 1 makes another payment exactly on time on day 20.

Loan 2 Funding

Accounting gets updated in the same way as Example 4.

Loan 1 Payment 1

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Loan 1 Payment 2

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Example 6: Double Loan - Early Payment then On Time Payment

In this example, there are two outstanding loans. Loan 2 gets funded on day 5. Loan 1 makes a payment early on day 8. Loan 1 makes another payment exactly on time on day 20.
Note that it is an edge case to make payments exactly on time. The second payment is more for illustrative purposes of how aggregate issuance rates are rendered with multiple loans and payments.
In this example, there are two different aggregate issuance rates since the issuance rate for Loan 1 changes when an early payment is made.

Loan 2 Funding

Accounting gets updated in the same way as Example 4.

Loan 1 Payment 1

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Loan 1 Payment 2

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Example 7: Double Loan - Late Payment then On Time Payment

In this example, there are two outstanding Loans. Loan 2 gets funded on day 5. Loan 1 makes a payment late on day 12. Loan 1 makes another payment exactly on time on day 20.
Note that when the second payment is made, it is made after domainEnd. This means that the interest from Loan 1 is fully accounted for, the payment is removed from the sorted list, the issuance rate is reduced, and the interest is accrued to the current timestamp before updating the state. More details on how this works here, specifically in this example.

Loan 2 Funding

Accounting gets updated in the same way as Example 4.

Loan 1 Payment 1

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows:

Loan 1 Payment 2

It can be seen that during this transaction, outstanding interest accounting gets updated as follows:
totalAssets accounting gets updated as follows: