Trait cfg_traits::interest::InterestAccrual
source · 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§
sourcetype MaxRateCount: Get<u32>
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.
type NormalizedDebt: Member + Parameter + MaxEncodedLen + TypeInfo + Copy + Zero
type Rates: RateCollection<Rate, Balance, Self::NormalizedDebt>
Required Methods§
sourcefn calculate_debt(
interest_rate: &InterestRate<Rate>,
normalized_debt: Self::NormalizedDebt,
when: Seconds
) -> Result<Balance, DispatchError>
fn calculate_debt( interest_rate: &InterestRate<Rate>, normalized_debt: Self::NormalizedDebt, when: Seconds ) -> Result<Balance, DispatchError>
Calculate the debt at an specific moment
sourcefn adjust_normalized_debt(
interest_rate: &InterestRate<Rate>,
normalized_debt: Self::NormalizedDebt,
adjustment: Adjustment
) -> Result<Self::NormalizedDebt, DispatchError>
fn adjust_normalized_debt( interest_rate: &InterestRate<Rate>, normalized_debt: Self::NormalizedDebt, adjustment: Adjustment ) -> Result<Self::NormalizedDebt, DispatchError>
Increase or decrease the normalized debt
sourcefn renormalize_debt(
old_interest_rate: &InterestRate<Rate>,
new_interest_rate: &InterestRate<Rate>,
normalized_debt: Self::NormalizedDebt
) -> 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>
Re-normalize a debt for a new interest rate
sourcefn reference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
fn reference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
Validate and indicate that a yearly rate is in use
sourcefn unreference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
fn unreference_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
Indicate that a rate is no longer in use
sourcefn validate_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
fn validate_rate(interest_rate: &InterestRate<Rate>) -> DispatchResult
Ask if the rate is valid to use by the implementation
Object Safety§
This trait is not object safe.