Protocol Accounting
Deep dive into Lotus protocol accounting covering junior supply, free supply, interest cascade mechanics, bad debt allocation, and lazy accrual patterns.
Lotus uses tranche ordering to route liquidity, interest, and losses through a market:
Unused liquidity from junior tranches can be used by senior borrowers.
Interest and bad debt cascade to the current tranche and all more junior tranches, proportional to each tranche's share of available supply.
Junior Supply and Borrow
Assume a market has N tranches indexed [0 β¦ N-1] from most senior to most junior.
The junior supply at tranche i is the total lender liquidity from tranche i through tranche N-1, including interest that has been accrued but not yet distributed. Intuitively, it is the liquidity accessible to a tranche ignoring borrowing activity.
The junior borrow at tranche i is total borrower debt outstanding from tranche i through tranche N-1.
The junior net supply is unused liquidity from tranche i through tranche N-1 . Junior net supply must always be β₯ 0.
Free Supply and Utilization
The free supply at tranche i is the amount of loanToken that can be:
borrowed from tranche
i, and/orwithdrawn by lenders from tranche
i
It is the tightest constraint across the cascade from tranche 0 through tranche i, because any senior borrow demand can limit what is actually free at more junior tranches.
The available supply at tranche i is the liquidity tranche i had access to before any borrowing in tranche i.
Tranche supply utilization is the fraction of available supply attributable to suppliers who supplied specifically to tranche i.
Interest or bad debt generated from a borrow tranche cascades to more junior supply tranches based on trancheSupplyUtilization.
Interest & Fee Accrual
When Lotus accrues interest, it does two things:
Accrues borrower interest for each tranche (increasing
trancheBorrowAssets).Routes that interest to suppliers in the current tranche and more junior tranches using the tranche utilization weights.
Each tranche contributes to a running balance called cascadingInterest:
newly accrued
trancheBorrowInterestany previously stored
pendingInterest
Each tranche i receives a share of the current cascadingInterest proportional to trancheSupplyUtilization[i]. Any remainder continues cascading to more junior tranches.
Bad Debt Allocation
If a liquidation generates bad debt, the loss is deducted from suppliers in the current tranche and more junior tranches using the same utilization weighting.
At tranche i:
Lazy Interest Accrual
Interest accrues lazily during operations that touch tranche state. Borrower-side interest can be accrued independently from supplier-side interest distribution. Two important accounting facts:
trancheBorrowAssetsincludes interest accrued up tolastUpdate.trancheSupplyAssetsmay not include all interest accrued up tolastUpdate, because supplier interest depends on cascading interest from tranches0 ... i.
To fully update trancheSupplyAssets[i], Lotus processes borrow interest and pending interest for all tranches more senior than (and including) i and distributes the resulting cascade using utilization weights.
Borrowing
In borrow(), repay(), and withdrawCollateral(), Lotus accrues borrower interest only for the specified tranche.
Newly accrued interest is stored in pendingInterest until a supply-side operation needs accurate supplier balances.
Lending
supply() and withdraw() require up-to-date supplier accounting. Lotus iterates from tranche 0 through the target tranche index and:
accruing borrow interest,
pulling
pendingInterestintocascadingInterest,allocating supplier interest to
trancheSupplyAssets,distributing fees,
carrying any remainder forward as
pendingInterestin the next tranche
Withdraw gas/accuracy option
Lenders can opt out of interest accrual on withdraw() (shouldAccrueInterest = false). This avoids the gas cost of sweeping senior tranches but uses stale supplier accounting, so the withdrawing lender receives fewer loanToken units than with full accrual.
Liquidation
If a liquidation produces no bad debt, Lotus accrues interest like other borrow-side operations (tranche-local only).
If a liquidation produces bad debt, Lotus accrues interest for the entire market so loss allocation uses up-to-date balances.
Fee Accrual
A Tranche.fee fraction of trancheSupplyInterest is distributed to the protocolβs feeRecipient by inflating supply shares.
Fees are capped by the global MAX_FEE. If the fee is updated via setFee(), Lotus accrues interest first so the change applies to up-to-date state.
Last updated

