pub struct TransferFeeConfig {
pub older: TransferFeeRate,
pub newer: TransferFeeRate,
}Expand description
Two-rate fee schedule.
Fields§
§older: TransferFeeRate§newer: TransferFeeRateImplementations§
Source§impl TransferFeeConfig
impl TransferFeeConfig
Sourcepub fn rate_for_epoch(&self, current_epoch: u64) -> &TransferFeeRate
pub fn rate_for_epoch(&self, current_epoch: u64) -> &TransferFeeRate
Pick the rate that will be applied at current_epoch.
Token-2022 activates newer once current_epoch >= newer.epoch,
otherwise it keeps using older.
Sourcepub fn calculate_fee(
&self,
amount: u64,
current_epoch: u64,
) -> Result<u64, CoreError>
pub fn calculate_fee( &self, amount: u64, current_epoch: u64, ) -> Result<u64, CoreError>
Fee that the Token-2022 program will withhold when transferring
amount raw units of this mint at current_epoch.
Sourcepub fn calculate_pre_fee_amount(
&self,
post_fee_amount: u64,
current_epoch: u64,
) -> Result<Option<u64>, CoreError>
pub fn calculate_pre_fee_amount( &self, post_fee_amount: u64, current_epoch: u64, ) -> Result<Option<u64>, CoreError>
Inverse of [calculate_fee]: given the net amount the recipient
should observe, return the smallest gross amount that, after fee
deduction, yields at least post_fee_amount.
Returns None only when no finite gross amount can deliver the
requested net without overflowing u64.
Trait Implementations§
Source§impl Clone for TransferFeeConfig
impl Clone for TransferFeeConfig
Source§fn clone(&self) -> TransferFeeConfig
fn clone(&self) -> TransferFeeConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TransferFeeConfig
impl Debug for TransferFeeConfig
Source§impl PartialEq for TransferFeeConfig
impl PartialEq for TransferFeeConfig
Source§fn eq(&self, other: &TransferFeeConfig) -> bool
fn eq(&self, other: &TransferFeeConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for TransferFeeConfig
impl Eq for TransferFeeConfig
impl StructuralPartialEq for TransferFeeConfig
Auto Trait Implementations§
impl Freeze for TransferFeeConfig
impl RefUnwindSafe for TransferFeeConfig
impl Send for TransferFeeConfig
impl Sync for TransferFeeConfig
impl Unpin for TransferFeeConfig
impl UnsafeUnpin for TransferFeeConfig
impl UnwindSafe for TransferFeeConfig
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
Mutably borrows from an owned value. Read more