#[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
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,
Source§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: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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