#[repr(C)]
pub struct InterestBearingConfig { pub rate_authority: OptionalNonZeroPubkey, pub initialization_timestamp: UnixTimestamp, pub pre_update_average_rate: BasisPoints, pub last_update_timestamp: UnixTimestamp, pub current_rate: BasisPoints, }
Expand description

Interest-bearing extension data for mints

Tokens accrue interest at an annual rate expressed by current_rate, compounded continuously, so APY will be higher than the published interest rate.

To support changing the rate, the config also maintains state for the previous rate.

Fields

rate_authority: OptionalNonZeroPubkey

Authority that can set the interest rate and authority

initialization_timestamp: UnixTimestamp

Timestamp of initialization, from which to base interest calculations

pre_update_average_rate: BasisPoints

Average rate from initialization until the last time it was updated

last_update_timestamp: UnixTimestamp

Timestamp of the last update, used to calculate the total amount accrued

current_rate: BasisPoints

Current rate, since the last update

Implementations

Convert a raw amount to its UI representation using the given decimals field Excess zeroes or unneeded decimal point are trimmed.

Try to convert a UI represenation of a token amount to its raw amount using the given decimals field

The new average rate is the time-weighted average of the current rate and average rate, solving for r such that:

exp(r_1 * t_1) * exp(r_2 * t_2) = exp(r * (t_1 + t_2))

r_1 * t_1 + r_2 * t_2 = r * (t_1 + t_2)

r = (r_1 * t_1 + r_2 * t_2) / (t_1 + t_2)

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Associated extension type enum, checked at the start of TLV entries
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more
If this function returns true, then it must be valid to reinterpret bits as &Self. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.