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// placeholders for features
11// we have ONE feature in the current stake program we care about:
12// * stake_raise_minimum_delegation_to_1_sol /
13//   9onWzzvCzNC2jfhxxeqRgs5q7nFAAKpCUvkj6T6GJK9i this may or may not be
14//   activated by time we are done, but it should be confined to the program so
15//   we use a placeholder for now to call it out. but we can just change the
16//   program. it is unclear if or when it will ever be activated, because it
17//   requires a validator vote
18const FEATURE_STAKE_RAISE_MINIMUM_DELEGATION_TO_1_SOL: bool = false;
19
20// feature_set::reduce_stake_warmup_cooldown changed the warmup/cooldown from
21// 25% to 9%. a function is provided by the sdk,
22// new_warmup_cooldown_rate_epoch(), which returns the epoch this change
23// happened. this function is not available to bpf programs. however, we dont
24// need it. the number is necessary to calculate historical effective stake from
25// stake history, but we only care that stake we are dealing with in the present
26// epoch has been fully (de)activated. this means, as long as one epoch has
27// passed since activation where all prior stake had escaped warmup/cooldown,
28// we can pretend the rate has always beein 9% without issue. so we do that
29const PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH: Option<u64> = Some(0);
30
31/// The minimum stake amount that can be delegated, in lamports.
32/// NOTE: This is also used to calculate the minimum balance of a delegated
33/// stake account, which is the rent exempt reserve _plus_ the minimum stake
34/// delegation.
35#[inline(always)]
36pub fn get_minimum_delegation() -> u64 {
37    if FEATURE_STAKE_RAISE_MINIMUM_DELEGATION_TO_1_SOL {
38        const MINIMUM_DELEGATION_SOL: u64 = 1;
39        MINIMUM_DELEGATION_SOL * LAMPORTS_PER_SOL
40    } else {
41        1
42    }
43}