pub trait InterestAccrual<Rate, Balance, Adjustment> {
    type MaxRateCount: Get<u32>;
    type NormalizedDebt: Member + Parameter + MaxEncodedLen + TypeInfo + Copy + Zero;
    type Rates: RateCollection<Rate, Balance, Self::NormalizedDebt>;

    // Required methods
    fn calculate_debt(
        interest_rate: &InterestRate<Rate>,
        normalized_debt: Self::NormalizedDebt,
        when: Seconds
    ) -> Result<Balance, DispatchError>;
    fn adjust_normalized_debt(
        interest_rate: &InterestRate<Rate>,
        normalized_debt: Self::NormalizedDebt,
        adjustment: Adjustment
    ) -> Result<Self::NormalizedDebt, DispatchError>;
    fn renormalize_debt(
        old_interest_rate: &InterestRate<Rate>,
        new_interest_rate: &InterestRate<Rate>,
        normalized_debt: Self::NormalizedDebt
    ) -> Result<Self::NormalizedDebt, DispatchError>;
    fn reference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult;
    fn unreference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult;
    fn validate_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult;
    fn rates() -> Self::Rates;
}
Expand description

A trait that can be used to calculate interest accrual for debt

Required Associated Types§

source

type MaxRateCount: Get<u32>

The maximum number of rates this InterestAccrual can contain. It is necessary for rate calculations in consumers of this pallet, but is otherwise unused in this interface.

source

type NormalizedDebt: Member + Parameter + MaxEncodedLen + TypeInfo + Copy + Zero

source

type Rates: RateCollection<Rate, Balance, Self::NormalizedDebt>

Required Methods§

source

fn calculate_debt( interest_rate: &InterestRate<Rate>, normalized_debt: Self::NormalizedDebt, when: Seconds ) -> Result<Balance, DispatchError>

Calculate the debt at an specific moment

source

fn adjust_normalized_debt( interest_rate: &InterestRate<Rate>, normalized_debt: Self::NormalizedDebt, adjustment: Adjustment ) -> Result<Self::NormalizedDebt, DispatchError>

Increase or decrease the normalized debt

source

fn renormalize_debt( old_interest_rate: &InterestRate<Rate>, new_interest_rate: &InterestRate<Rate>, normalized_debt: Self::NormalizedDebt ) -> Result<Self::NormalizedDebt, DispatchError>

Re-normalize a debt for a new interest rate

source

fn reference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult

Validate and indicate that a yearly rate is in use

source

fn unreference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult

Indicate that a rate is no longer in use

source

fn validate_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult

Ask if the rate is valid to use by the implementation

source

fn rates() -> Self::Rates

Returns a collection of pre-computed rates to perform multiple operations with

Object Safety§

This trait is not object safe.

Implementors§