Skip to main content

solana_stake_program/
lib.rs

1use solana_native_token::LAMPORTS_PER_SOL;
2
3pub mod helpers;
4pub mod processor;
5
6pub mod entrypoint;
7
8solana_pubkey::declare_id!("Stake11111111111111111111111111111111111111");
9
10// feature_set::reduce_stake_warmup_cooldown changed the warmup/cooldown from
11// 25% to 9%. a function is provided by the sdk,
12// new_warmup_cooldown_rate_epoch(), which returns the epoch this change
13// happened. this function is not available to bpf programs. however, we dont
14// need it. the number is necessary to calculate historical effective stake from
15// stake history, but we only care that stake we are dealing with in the present
16// epoch has been fully (de)activated. this means, as long as one epoch has
17// passed since activation where all prior stake had escaped warmup/cooldown,
18// we can pretend the rate has always beein 9% without issue. so we do that
19const PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH: Option<u64> = Some(0);
20
21// Historically, `Meta.rent_exempt_reserve` contained the canonical rent
22// reservation for a stake account. This implicitly depended on
23// lamports-per-byte remaining fixed over time. This value will be allowed
24// to fluctuate, which means the stake program must calculate rent from the
25// `Rent` sysvar directly. However, downstream programs may still rely on the
26// `Meta` value being set. For maximum predictability, we set `rent_exempt_reserve`
27// to its historical value unconditionally, but ignore it in the stake program.
28const PSEUDO_RENT_EXEMPT_RESERVE: u64 = 2_282_880;
29
30/// The minimum stake amount that can be delegated, in lamports.
31/// NOTE: This is also used to calculate the minimum balance of a delegated
32/// stake account, which is the rent exempt reserve _plus_ the minimum stake
33/// delegation.
34#[inline(always)]
35pub fn get_minimum_delegation() -> u64 {
36    const MINIMUM_DELEGATION_SOL: u64 = 1;
37    MINIMUM_DELEGATION_SOL * LAMPORTS_PER_SOL
38}