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