Struct spl_stake_pool::state::Fee
source · #[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: u64
denominator of the fee ratio
numerator: u64
numerator 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,
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 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 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