1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#![deny(missing_docs)]
pub mod borsh;
pub mod error;
pub mod instruction;
pub mod processor;
pub mod stake_program;
pub mod state;
#[cfg(not(feature = "no-entrypoint"))]
pub mod entrypoint;
pub use solana_program;
use {
crate::stake_program::Meta,
solana_program::{native_token::LAMPORTS_PER_SOL, pubkey::Pubkey},
};
const AUTHORITY_DEPOSIT: &[u8] = b"deposit";
const AUTHORITY_WITHDRAW: &[u8] = b"withdraw";
const TRANSIENT_STAKE_SEED: &[u8] = b"transient";
pub const MINIMUM_ACTIVE_STAKE: u64 = LAMPORTS_PER_SOL;
pub const MAX_VALIDATORS_TO_UPDATE: usize = 10;
pub fn minimum_stake_lamports(meta: &Meta) -> u64 {
meta.rent_exempt_reserve
.saturating_add(MINIMUM_ACTIVE_STAKE)
}
pub fn minimum_reserve_lamports(meta: &Meta) -> u64 {
meta.rent_exempt_reserve.saturating_add(1)
}
pub fn find_deposit_authority_program_address(
program_id: &Pubkey,
stake_pool_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[&stake_pool_address.to_bytes()[..32], AUTHORITY_DEPOSIT],
program_id,
)
}
pub fn find_withdraw_authority_program_address(
program_id: &Pubkey,
stake_pool_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[&stake_pool_address.to_bytes()[..32], AUTHORITY_WITHDRAW],
program_id,
)
}
pub fn find_stake_program_address(
program_id: &Pubkey,
vote_account_address: &Pubkey,
stake_pool_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
&vote_account_address.to_bytes()[..32],
&stake_pool_address.to_bytes()[..32],
],
program_id,
)
}
pub fn find_transient_stake_program_address(
program_id: &Pubkey,
vote_account_address: &Pubkey,
stake_pool_address: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
TRANSIENT_STAKE_SEED,
&vote_account_address.to_bytes()[..32],
&stake_pool_address.to_bytes()[..32],
],
program_id,
)
}
solana_program::declare_id!("poo1B9L9nR3CrcaziKVYVpRX6A9Y1LAXYasjjfCbApj");