Interest Accumulation

Interest accumulation on a reserve updates the indexes that tracks the accumulated interest. This operation mutates the Reserve Indexes based on the rates inside Reserve Data and the time that have passed since the last Reserve Indexes mutation.

**'Internal' Inputs:**
- `reserve_indexes`: mutable reference to `ReserveIndexes
- `reserve_data`: reference to `ReserveData` struct
**'External' Inputs:**
- `timestamp`: actual block timestamp

**Pseudocode:**

1. Calculate `delta_timestamp`- time that passed since last accumulation
    as the difference between `timestamp` and `self.update_timestamp`.
    
2. If `delta_timestamp` is 0 then accumulation was already performed in this block,
    return.
    
3. If `reserve_data.current_deposit_rate_e18` is not 0 
    and `reserve_data.total_deposit` is not 0 then:
        update the reserve_indexes.deposit_index_e18 by multiplying it by
        ( 1 + reserve_data.current_deposit_rate_e18 * delta_timestamp / 10^18)
        round in such way that the result is not greater than the "precise result".
        
4. If `reserve_data.current_debt_rate_e18` is not 0
    and `reserve_data.total_debt` is not 0 then:
        update the reserve_indexes.debt_index_e18 by multiplying it by
        ( 1 + reserve_data.current_debt_rate_e18 * delta_timestamp / 10^18)
        round in such way that the result is not smaller than the "precise result".
        
5. Update `reserve_indexes.update_timestamp` to the value of `timestamp`.

Last updated