Computing Supply & Borrows
Monitoring Instructions:
RefreshReserve - handles all the tracking work and updates ratio
RefreshObligation - computes obligation balances based on reserve ratios
For Supply:
cToken Ratio acts as a % ownership of the LP
For a pool with 99 USDC, if you deposit 1 USDC, you will own 1% of the pool
When the RefreshReserve occurs, the pool now has 110 USDC. Your 1% is now worth 1.1 USDC.
Total Reserves / cTokens Minted
For Borrows:
APY is used to update CumulativeBorrowRate as an index
When borrowing, calculate the initial CumulativeBorrowRate (let's say 1)
RefreshReserve → Updates the CumulativeBorrowRate (let's say its 1.02)
Obligation borrows would be increased by *1.02/1 or 2%
Why: For efficiency, the RefreshReserve just has to update the cToken Rate or the CumulativeBorrowRate instead of updating every obligation’s supply or borrow numbers. Tracking is only done at the ratio/index level, and never at an individual level unless changes to the user's positions are being made.
Last updated