#[repr(C)]pub struct Stake {Show 14 fields
pub authority: Pubkey,
pub balance: u64,
pub lock_duration_days: u64,
pub lock_ends_at: u64,
pub buffer_c: u64,
pub buffer_d: u64,
pub buffer_e: u64,
pub last_claim_at: i64,
pub last_deposit_at: i64,
pub last_withdraw_at: i64,
pub rewards_factor: Numeric,
pub rewards: u64,
pub lifetime_rewards: u64,
pub buffer_f: u64,
}Fields§
The authority of this miner account.
balance: u64The balance of this stake account.
lock_duration_days: u64Lock duration in days (0 = no lock, 1-730 days)
lock_ends_at: u64Unix timestamp when lock expires (0 = no lock)
buffer_c: u64Buffer c (placeholder)
buffer_d: u64Buffer d (placeholder)
buffer_e: u64Buffer e (placeholder)
last_claim_at: i64The timestamp of last claim.
last_deposit_at: i64The timestamp the last time this staker deposited.
last_withdraw_at: i64The timestamp the last time this staker withdrew.
rewards_factor: NumericThe rewards factor last time rewards were updated on this stake account.
rewards: u64The amount of SOL this staker can claim.
lifetime_rewards: u64The total amount of SOL this staker has earned over its lifetime.
buffer_f: u64Buffer f (placeholder)
Implementations§
Source§impl Stake
impl Stake
pub fn pda(&self) -> (Pubkey, u8)
Sourcepub fn calculate_multiplier(lock_duration_days: u64) -> f64
pub fn calculate_multiplier(lock_duration_days: u64) -> f64
Calculate lock multiplier based on duration (Magic Eden formula)
Sourcepub fn remaining_lock_seconds(&self, clock: &Clock) -> u64
pub fn remaining_lock_seconds(&self, clock: &Clock) -> u64
Get remaining lock time in seconds (0 if unlocked)
Sourcepub fn calculate_penalty_percent(lock_duration_days: u64) -> u64
pub fn calculate_penalty_percent(lock_duration_days: u64) -> u64
Calculate early withdrawal penalty percentage based on lock duration Uses next higher tier (no interpolation) Penalty tiers: 0% (0 days), 5% (1-7), 10% (8-30), 25% (31-180), 40% (181-365), 60% (366-730)
pub fn claim(&mut self, amount: u64, clock: &Clock, pool: &Pool) -> u64
pub fn deposit( &mut self, amount: u64, clock: &Clock, pool: &mut Pool, sender: &TokenAccount, ) -> u64
pub fn withdraw(&mut self, amount: u64, clock: &Clock, pool: &mut Pool) -> u64
pub fn update_rewards(&mut self, pool: &Pool)
Trait Implementations§
Source§impl AccountValidation for Stake
impl AccountValidation for Stake
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl<'de> Deserialize<'de> for Stake
impl<'de> Deserialize<'de> for Stake
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Discriminator for Stake
impl Discriminator for Stake
fn discriminator() -> u8
impl Copy for Stake
impl Pod for Stake
impl StructuralPartialEq for Stake
Auto Trait Implementations§
impl Freeze for Stake
impl RefUnwindSafe for Stake
impl Send for Stake
impl Sync for Stake
impl Unpin for Stake
impl UnwindSafe for Stake
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
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<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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>
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