Skip to content

Pool Accounting

Lucas Manuel edited this page Feb 24, 2021 · 7 revisions

In the Maple protocol, financial accounting of Pools must be done using a combination of ERC-20 balances and state variable accounting. The reason for this is that for a given Pool, a significant portion of the capital that is managed in the Pool is not actually held within the LiquidityLocker, where it can be actively withdrawn by Liquidity Providers.

In order to maintain consistency between the total value of a Pool and the total claimable funds by Liquidity Providers, the following invariant must be satisfied:

liquidityLockerBal + principalOut = fdtTotalSupply + interestSum - bptShortfall

The left side of the equation represents actual ERC-20 balances (using USDC as an example):

  • liquidityLockerBal is the current balance of USDC in the LiquidityLocker
  • principalOut is the total amount of USDC that has been moved out of the LiquidityLocker to fund active Loans

The right side of the equation represents the accounting used to account for LP claimable funds

  • fdtTotalSupply is equal to the net amount of deposits/withdrawals of USDC that have made by LPs
  • interestSum is the sum of all interest that has been claimed by the Pool since instantiation
  • bptShortfall is the sum of all losses incurred by the Pool since instantiation. This value is only incremented when a Loan defaults, the maximum of BPTs have been burned, and there is still a shortfall. This concept is covered in more depth on this page

Below is an example of how this accounting works for interest payments:

Starting State
liquidityLockerB