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)

This produces deterministic results regardless of how often transactions occur. A market with 100 daily transactions and one with a single monthly transaction produce the same scale factor.

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
  • Results are independent of transaction frequency

Accrual Example

Market: 8% APR, daily compounding

DayScale Factor1,000 USDC Value
01.00001,000.00
11.00021,000.22
71.00151,001.54
301.00661,006.60
901.01991,019.92
1801.04021,040.24
3651.08331,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

Between operations, interest is "pending" but not yet recorded. The next operation calculates and applies all pending interest. Because compounding is daily (not per-transaction), the result is the same whether 1 or 100 transactions occur in a day.

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

  1. Fixed rate — Rate doesn't change after market creation
  2. Daily compounding — Interest compounds once per day, deterministic regardless of transaction frequency
  3. Lazy accrual — Updated on each transaction, not per-block
  4. Fair distribution — All lenders earn proportionally
  5. Efficient — One scale factor update covers everyone

Footnotes

  1. 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) using elapsed seconds from Solana's clock. Elapsed time is split into whole days (compounded via exponentiation) and remaining seconds (linear). This produces deterministic daily compounding — the result is the same regardless of how often transactions occur.