Struct safe_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
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<TransferFee> for TransferFee
impl PartialEq<TransferFee> 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 RefUnwindSafe for TransferFee
impl Send for TransferFee
impl Sync for TransferFee
impl Unpin for TransferFee
impl UnwindSafe for TransferFee
Blanket Implementations§
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
.