fn compound_interest(
        &mut self,
        current_borrow_rate: Rate,
        slots_elapsed: u64,
        reserve_owner_fee_wad: u64,
    ) -> ProgramResult {
        let slot_interest_rate = current_borrow_rate.try_div(SLOTS_PER_YEAR)?;
        let compounded_interest_rate = Rate::one()
            .try_add(slot_interest_rate)?
            .try_pow(slots_elapsed)?;
        self.cumulative_borrow_rate_wads = self
            .cumulative_borrow_rate_wads
            .try_mul(compounded_interest_rate)?;
        let new_unclaimed = self.borrowed_amount_wads
            .try_mul(compounded_interest_rate.try_sub(Rate::one())?)?
            .try_mul(Rate::from_scaled_val(reserve_owner_fee_wad))?;
        self.owner_unclaimed = self
            .owner_unclaimed
            .try_add(new_unclaimed)?;

        self.borrowed_amount_wads = self
            .borrowed_amount_wads
            .try_mul(compounded_interest_rate)?;

        Ok(())
    }
/// Compound current borrow rate over elapsed slots

Compound current borrow rate over elapsed slots
Compound current borrow rate over elapsed slots
fn compound_interest(
        &mut self,
        current_borrow_rate: Rate,
        slots_elapsed: u64,
        reserve_owner_fee_wad: u64,
    ) -> ProgramResult {
        let slot_interest_rate = current_borrow_rate.try_div(SLOTS_PER_YEAR)?;
        let compounded_interest_rate = Rate::one()
            .try_add(slot_interest_rate)?
            .try_pow(slots_elapsed)?;
        self.cumulative_borrow_rate_wads = self
            .cumulative_borrow_rate_wads
            .try_mul(compounded_interest_rate)?;
        let new_unclaimed = self.borrowed_amount_wads
            .try_mul(compounded_interest_rate.try_sub(Rate::one())?)?
            .try_mul(Rate::from_scaled_val(reserve_owner_fee_wad))?;
        self.owner_unclaimed = self
            .owner_unclaimed
            .try_add(new_unclaimed)?;
        self.borrowed_amount_wads = self
            .borrowed_amount_wads
            .try_mul(compounded_interest_rate)?;
        Ok(())
    }
fn compound_interest ( & mut self , current_borrow_rate : Rate , slots_elapsed : u64 , reserve_owner_fee_wad : u64 , ) -> ProgramResult { let slot_interest_rate = current_borrow_rate . try_div ( SLOTS_PER_YEAR ) ? ; let compounded_interest_rate = Rate :: one ( ) . try_add ( slot_interest_rate ) ? . try_pow ( slots_elapsed ) ? ; self . cumulative_borrow_rate_wads = self . cumulative_borrow_rate_wads . try_mul ( compounded_interest_rate ) ? ; let new_unclaimed = self . borrowed_amount_wads . try_mul ( compounded_interest_rate . try_sub ( Rate :: one ( ) ) ? ) ? . try_mul ( Rate :: from_scaled_val ( reserve_owner_fee_wad ) ) ? ; self . owner_unclaimed = self . owner_unclaimed . try_add ( new_unclaimed ) ? ; self . borrowed_amount_wads = self . borrowed_amount_wads . try_mul ( compounded_interest_rate ) ? ; Ok ( ( ) ) }
Compound current borrow rate over elapsed slots
Compound current borrow rate over elapsed slots
&mut self
current_borrow_rate
Rate
slots_elapsed
u64
reserve_owner_fee_wad
u64
&mut self
current_borrow_rate
Rate
slots_elapsed
u64
reserve_owner_fee_wad
u64