#[repr(C)]pub struct Fee {
pub denominator: u64,
pub numerator: u64,
}Expand description
Fee rate as a ratio, minted on UpdateStakePoolBalance as a proportion of
the rewards
If either the numerator or the denominator is 0, the fee is considered to be 0
Fields§
§denominator: u64denominator of the fee ratio
numerator: u64numerator of the fee ratio
Implementations§
Source§impl Fee
impl Fee
Sourcepub fn apply(&self, amt: u64) -> Option<u128>
pub fn apply(&self, amt: u64) -> Option<u128>
Applies the Fee’s rates to a given amount, amt
returning the amount to be subtracted from it as fees
(0 if denominator is 0 or amt is 0),
or None if overflow occurs
Sourcepub fn check_withdrawal(
&self,
old_withdrawal_fee: &Fee,
) -> Result<(), StakePoolError>
pub fn check_withdrawal( &self, old_withdrawal_fee: &Fee, ) -> Result<(), StakePoolError>
Withdrawal fees have some additional restrictions, this fn checks if those are met, returning an error if not. Does nothing and returns Ok if fee type is not withdrawal
Trait Implementations§
Source§impl BorshDeserialize for Feewhere
u64: BorshDeserialize,
impl BorshDeserialize for Feewhere
u64: BorshDeserialize,
Source§impl BorshSchema for Feewhere
u64: BorshSchema,
impl BorshSchema for Feewhere
u64: BorshSchema,
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
Source§fn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut HashMap<Declaration, Definition>, )
Recursively, using DFS, add type definitions required for this type. For primitive types
this is an empty map. Type definition explains how to serialize/deserialize a type.
Source§fn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition>,
)
fn add_definition( declaration: String, definition: Definition, definitions: &mut HashMap<String, Definition>, )
Helper method to add a single type definition to the map.
fn schema_container() -> BorshSchemaContainer
Source§impl BorshSerialize for Feewhere
u64: BorshSerialize,
impl BorshSerialize for Feewhere
u64: BorshSerialize,
impl Copy for Fee
impl StructuralPartialEq for Fee
Auto Trait Implementations§
impl Freeze for Fee
impl RefUnwindSafe for Fee
impl Send for Fee
impl Sync for Fee
impl Unpin for Fee
impl UnwindSafe for Fee
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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