Struct spl_token_2022::extension::transfer_fee::TransferFee
source · #[repr(C)]pub struct TransferFee {
pub epoch: PodU64,
pub maximum_fee: PodU64,
pub transfer_fee_basis_points: PodU16,
}
Expand description
Transfer fee information
Fields§
§epoch: PodU64
First epoch where the transfer fee takes effect
maximum_fee: PodU64
Maximum fee assessed on transfers, expressed as an amount of tokens
transfer_fee_basis_points: PodU16
Amount of transfer collected as fees, expressed as basis points of the transfer amount, ie. increments of 0.01%
Implementations§
source§impl TransferFee
impl TransferFee
sourcepub fn calculate_fee(&self, pre_fee_amount: u64) -> Option<u64>
pub fn calculate_fee(&self, pre_fee_amount: u64) -> Option<u64>
Calculate the transfer fee
sourcepub fn calculate_post_fee_amount(&self, pre_fee_amount: u64) -> Option<u64>
pub fn calculate_post_fee_amount(&self, pre_fee_amount: u64) -> Option<u64>
Calculate the gross transfer amount after deducting fees
sourcepub fn calculate_pre_fee_amount(&self, post_fee_amount: u64) -> Option<u64>
pub fn calculate_pre_fee_amount(&self, post_fee_amount: u64) -> Option<u64>
Calculate the transfer amount that will result in a specified net transfer amount.
The original transfer amount may not always be unique due to rounding. In this case, the smaller amount will be chosen. e.g. Both transfer amount 10, 11 with 10% fee rate results in net transfer amount of 9. In this case, 10 will be chosen. e.g. Fee rate is 100%. In this case, 0 will be chosen.
The original transfer amount may not always exist on large net transfer
amounts due to overflow. In this case, None
is returned.
e.g. The net fee amount is u64::MAX
with a positive fee rate.
sourcepub fn calculate_inverse_fee(&self, post_fee_amount: u64) -> Option<u64>
pub fn calculate_inverse_fee(&self, post_fee_amount: u64) -> Option<u64>
Calculate the fee that would produce the given output
Note: this function is not an exact inverse operation of
calculate_fee
. Meaning, it is not the case that:
calculate_fee(x) == calculate_inverse_fee(x - calculate_fee(x))
Only the following relationship holds:
calculate_fee(x) >= calculate_inverse_fee(x - calculate_fee(x))
Trait Implementations§
source§impl Clone for TransferFee
impl Clone for TransferFee
source§fn clone(&self) -> TransferFee
fn clone(&self) -> TransferFee
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransferFee
impl Debug for TransferFee
source§impl Default for TransferFee
impl Default for TransferFee
source§fn default() -> TransferFee
fn default() -> TransferFee
source§impl PartialEq for TransferFee
impl PartialEq for TransferFee
source§fn eq(&self, other: &TransferFee) -> bool
fn eq(&self, other: &TransferFee) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for TransferFee
impl Pod for TransferFee
impl StructuralPartialEq for TransferFee
Auto Trait Implementations§
impl Freeze for TransferFee
impl RefUnwindSafe for TransferFee
impl Send for TransferFee
impl Sync for TransferFee
impl Unpin for TransferFee
impl UnwindSafe for TransferFee
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
.source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more