#[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 function checks if those are met, returning an error if not.
Trait Implementations§
Source§impl BorshDeserialize for Fee
impl BorshDeserialize for Fee
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSchema for Fee
impl BorshSchema for Fee
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
Source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition>, )
Recursively, using DFS, add type definitions required for this type.
Type definition partially explains how to serialize/deserialize a type.
Source§impl BorshSerialize for Fee
impl BorshSerialize for Fee
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