Interest Accrual#
How interest accumulates in Coalesce Finance markets.
Overview#
Interest in Coalesce Finance:
- Accrues based on elapsed wall-clock time1
- Is tracked via the scale factor
- Applies to all deposited funds equally
- Is fixed at the market's creation rate
The Mechanics#
Accrual Formula#
Interest compounds daily. Each time a transaction touches the market, the protocol splits the elapsed time into whole days and remaining seconds:
daily_rate = annual_rate / 365
// Compound for whole days
new_scale_factor = old_scale_factor × (1 + daily_rate) ^ days_elapsed
// Linear for remaining sub-day seconds
new_scale_factor = new_scale_factor × (1 + annual_rate × remaining_seconds / seconds_per_year)
Within a single day, the sub-day linear term makes results insensitive to transaction frequency. Across multiple days, compounding depends on when accrual occurs, so more frequent cross-day accrual leads to more compounding steps.
Scale Factor#
Instead of updating every lender's balance, we update one number — the scale factor. Because each daily compound multiplies the already-grown factor, interest compounds predictably:
- One update covers all lenders
- No rounding differences between lenders
- Gas-efficient on-chain
- Within-day accrual is independent of transaction frequency
Accrual Example#
Market: 8% APR, daily compounding
| Day | Scale Factor | 1,000 USDC Value |
|---|---|---|
| 0 | 1.0000 | 1,000.00 |
| 1 | 1.0002 | 1,000.22 |
| 7 | 1.0015 | 1,001.54 |
| 30 | 1.0066 | 1,006.60 |
| 90 | 1.0199 | 1,019.92 |
| 180 | 1.0402 | 1,040.24 |
| 365 | 1.0833 | 1,083.28 |
When Does Accrual Happen?#
The scale factor is updated on every state-changing operation:
- Deposit
- Borrow
- Repay
- Repay Interest
- Withdraw
- Collect Fees
- ReSettle
- Force Close Position
Between operations, interest is "pending" but not yet recorded. The next operation calculates and applies all pending interest. Multiple accruals within the same day produce the same result, but compounding across days depends on when accrual happens.
See Protocol Calculations for the full calculation breakdown and on-chain precision details.
Impact on Deposits#
Early Depositors#
Deposit when scale_factor is lower → Get more shares:
Day 1 deposit of 1,000 USDC:
scale_factor = 1.00021918
shares = 1000 / 1.00021918 = 999.78
Day 30 deposit of 1,000 USDC:
scale_factor = 1.00659628
shares = 1000 / 1.00659628 = 993.45
Early depositors get more shares, which is fair because they have a longer duration risk.
Late Depositors#
Deposit when scale_factor is higher → Get fewer shares:
The shares are worth the same in USDC at deposit time, but late depositors have a shorter duration risk.
Impact on Withdrawals#
At withdrawal, shares convert back to USDC:
value = shares × scale_factor
Day 1 depositor at Day 90:
shares = 999.78
scale_factor = 1.01991967
value = 999.78 × 1.01991967 = 1,019.70 USDC
profit = 19.70 USDC (89 days of interest)
Day 30 depositor at Day 90:
shares = 993.45
scale_factor = 1.01991967
value = 993.45 × 1.01991967 = 1,013.24 USDC
profit = 13.24 USDC (60 days of interest)
Key Points#
- Fixed rate — Rate doesn't change after market creation
- Daily compounding — Whole days compound; sub-day remainder accrues linearly
- Lazy accrual — Updated on each transaction, not per-block
- Fair distribution — All lenders earn proportionally
- Efficient — One scale factor update covers everyone
Related#
- Protocol Calculations — All calculations
Footnotes
-
Interest is not updated every block. The scale factor is recalculated on each state-changing transaction (deposit, borrow, repay, repay_interest, withdraw, collect_fees, re_settle, force_close_position) using elapsed seconds from Solana's clock. Elapsed time is split into whole days (compounded via exponentiation) and remaining seconds (linear). This makes accrual deterministic within a given elapsed interval, but cross-day compounding still depends on when accrual events occur. ↩