pub(crate) fn update_borrow_index(
        borrow_rate: Rate,
        asset_id: AssetIdOf<T>,
        market: &Market<BalanceOf<T>>,
        delta_time: u64,
    ) -> DispatchResult {
        let borrows_prior = Self::total_borrows(asset_id);
        let reserve_prior = Self::total_reserves(asset_id);
        let interest_accumulated = Self::accrued_interest(borrow_rate, borrows_prior, delta_time)
            .ok_or(ArithmeticError::Overflow)?;
        let total_borrows_new = interest_accumulated
            .checked_add(borrows_prior)
            .ok_or(ArithmeticError::Overflow)?;
        let total_reserves_new = market
            .reserve_factor
            .mul_floor(interest_accumulated)
            .checked_add(reserve_prior)
            .ok_or(ArithmeticError::Overflow)?;
        let borrow_index = Self::borrow_index(asset_id);
        let borrow_index_new = Self::increment_index(borrow_rate, borrow_index, delta_time)
            .and_then(|r| r.checked_add(&borrow_index))
            .ok_or(ArithmeticError::Overflow)?;

        TotalBorrows::<T>::insert(asset_id, total_borrows_new);
        TotalReserves::<T>::insert(asset_id, total_reserves_new);
        BorrowIndex::<T>::insert(asset_id, borrow_index_new);

        Ok(())
    }
/// Update the borrow index by borrow rate, the total borrows and
/// total reserves will be updated simultaneously.
///
/// interestAccumulated = totalBorrows * borrowRate
/// totalBorrows = interestAccumulated + totalBorrows
/// totalReserves = interestAccumulated * reserveFactor + totalReserves
/// borrowIndex = borrowIndex * (1 + borrowRate)
Update the borrow index by borrow rate, the total borrows and
total reserves will be updated simultaneously.

interestAccumulated = totalBorrows * borrowRate
totalBorrows = interestAccumulated + totalBorrows
totalReserves = interestAccumulated * reserveFactor + totalReserves
borrowIndex = borrowIndex * (1 + borrowRate)
Update the borrow index by borrow rate the total borrows and total reserves will be updated simultaneously . interestAccumulated = totalBorrows * borrowRate totalBorrows = interestAccumulated + totalBorrows totalReserves = interestAccumulated * reserveFactor + totalReserves borrowIndex = borrowIndex * ( 1 + borrowRate )
pub(crate) fn update_borrow_index(
        borrow_rate: Rate,
        asset_id: AssetIdOf<T>,
        market: &Market<BalanceOf<T>>,
        delta_time: u64,
    ) -> DispatchResult {
        let borrows_prior = Self::total_borrows(asset_id);
        let reserve_prior = Self::total_reserves(asset_id);
        let interest_accumulated = Self::accrued_interest(borrow_rate, borrows_prior, delta_time)
            .ok_or(ArithmeticError::Overflow)?;
        let total_borrows_new = interest_accumulated
            .checked_add(borrows_prior)
            .ok_or(ArithmeticError::Overflow)?;
        let total_reserves_new = market
            .reserve_factor
            .mul_floor(interest_accumulated)
            .checked_add(reserve_prior)
            .ok_or(ArithmeticError::Overflow)?;
        let borrow_index = Self::borrow_index(asset_id);
        let borrow_index_new = Self::increment_index(borrow_rate, borrow_index, delta_time)
            .and_then(|r| r.checked_add(&borrow_index))
            .ok_or(ArithmeticError::Overflow)?;
        TotalBorrows::<T>::insert(asset_id, total_borrows_new);
        TotalReserves::<T>::insert(asset_id, total_reserves_new);
        BorrowIndex::<T>::insert(asset_id, borrow_index_new);
        Ok(())
    }
pub ( crate ) fn update_borrow_index ( borrow_rate : Rate , asset_id : AssetIdOf < T > , market : & Market < BalanceOf < T > > , delta_time : u64 , ) -> DispatchResult { let borrows_prior = Self :: total_borrows ( asset_id ) ; let reserve_prior = Self :: total_reserves ( asset_id ) ; let interest_accumulated = Self :: accrued_interest ( borrow_rate , borrows_prior , delta_time ) . ok_or ( ArithmeticError :: Overflow ) ? ; let total_borrows_new = interest_accumulated . checked_add ( borrows_prior ) . ok_or ( ArithmeticError :: Overflow ) ? ; let total_reserves_new = market . reserve_factor . mul_floor ( interest_accumulated ) . checked_add ( reserve_prior ) . ok_or ( ArithmeticError :: Overflow ) ? ; let borrow_index = Self :: borrow_index ( asset_id ) ; let borrow_index_new = Self :: increment_index ( borrow_rate , borrow_index , delta_time ) . and_then ( | r | r . checked_add ( & borrow_index ) ) . ok_or ( ArithmeticError :: Overflow ) ? ; TotalBorrows :: < T > :: insert ( asset_id , total_borrows_new ) ; TotalReserves :: < T > :: insert ( asset_id , total_reserves_new ) ; BorrowIndex :: < T > :: insert ( asset_id , borrow_index_new ) ; Ok ( ( ) ) }
Update the borrow index by borrow rate, the total borrows and
total reserves will be updated simultaneously.
Update the borrow index by borrow rate the total borrows and total reserves will be updated simultaneously .
borrow_rate
Rate
asset_id
AssetIdOf<T>
market
&Market<BalanceOf<T>>
delta_time
u64
borrow_rate
Rate
asset_id
AssetIdOf<T>
market
&Market<BalanceOf<T>>
delta_time
u64