#[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§
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§
source§impl InterestBearingConfig
impl InterestBearingConfig
sourcepub fn amount_to_ui_amount(
&self,
amount: u64,
decimals: u8,
unix_timestamp: i64
) -> Option<String>
pub fn amount_to_ui_amount( &self, amount: u64, decimals: u8, unix_timestamp: i64 ) -> Option<String>
Convert a raw amount to its UI representation using the given decimals field Excess zeroes or unneeded decimal point are trimmed.
sourcepub fn try_ui_amount_into_amount(
&self,
ui_amount: &str,
decimals: u8,
unix_timestamp: i64
) -> Result<u64, ProgramError>
pub fn try_ui_amount_into_amount( &self, ui_amount: &str, decimals: u8, unix_timestamp: i64 ) -> Result<u64, ProgramError>
Try to convert a UI representation of a token amount to its raw amount using the given decimals field
sourcepub fn time_weighted_average_rate(&self, current_timestamp: i64) -> Option<i16>
pub fn time_weighted_average_rate(&self, current_timestamp: i64) -> Option<i16>
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§
source§impl Clone for InterestBearingConfig
impl Clone for InterestBearingConfig
source§fn clone(&self) -> InterestBearingConfig
fn clone(&self) -> InterestBearingConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InterestBearingConfig
impl Debug for InterestBearingConfig
source§impl Default for InterestBearingConfig
impl Default for InterestBearingConfig
source§fn default() -> InterestBearingConfig
fn default() -> InterestBearingConfig
source§impl Extension for InterestBearingConfig
impl Extension for InterestBearingConfig
source§const TYPE: ExtensionType = ExtensionType::InterestBearingConfig
const TYPE: ExtensionType = ExtensionType::InterestBearingConfig
source§impl PartialEq for InterestBearingConfig
impl PartialEq for InterestBearingConfig
source§fn eq(&self, other: &InterestBearingConfig) -> bool
fn eq(&self, other: &InterestBearingConfig) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for InterestBearingConfig
impl Pod for InterestBearingConfig
impl StructuralPartialEq for InterestBearingConfig
Auto Trait Implementations§
impl RefUnwindSafe for InterestBearingConfig
impl Send for InterestBearingConfig
impl Sync for InterestBearingConfig
impl Unpin for InterestBearingConfig
impl UnwindSafe for InterestBearingConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.