1#![deny(missing_docs)]
2
3pub mod error;
6pub mod inline_mpl_token_metadata;
7pub mod instruction;
8pub mod processor;
9pub mod state;
10
11#[cfg(not(feature = "no-entrypoint"))]
12pub mod entrypoint;
13
14use {solana_native_token::LAMPORTS_PER_SOL, solana_pubkey::Pubkey};
15
16solana_pubkey::declare_id!("SVSPxpvHdN29nkVg9rPapPNDddN5DipNLRUFhyjFThE");
17
18const POOL_PREFIX: &[u8] = b"pool";
19const POOL_STAKE_PREFIX: &[u8] = b"stake";
20const POOL_ONRAMP_PREFIX: &[u8] = b"onramp";
21const POOL_MINT_PREFIX: &[u8] = b"mint";
22const POOL_MINT_AUTHORITY_PREFIX: &[u8] = b"mint_authority";
23const POOL_STAKE_AUTHORITY_PREFIX: &[u8] = b"stake_authority";
24const POOL_MPL_AUTHORITY_PREFIX: &[u8] = b"mpl_authority";
25
26const PHANTOM_TOKEN_AMOUNT: u64 = LAMPORTS_PER_SOL;
27const MINT_DECIMALS: u8 = 9;
28const PERPETUAL_NEW_WARMUP_COOLDOWN_RATE_EPOCH: Option<u64> = Some(0);
29
30const VOTE_STATE_DISCRIMINATOR_END: usize = 4;
31const VOTE_STATE_AUTHORIZED_WITHDRAWER_START: usize = 36;
32const VOTE_STATE_AUTHORIZED_WITHDRAWER_END: usize = 68;
33
34fn find_pool_address_and_bump(program_id: &Pubkey, vote_account_address: &Pubkey) -> (Pubkey, u8) {
35 Pubkey::find_program_address(&[POOL_PREFIX, vote_account_address.as_ref()], program_id)
36}
37
38fn find_pool_stake_address_and_bump(program_id: &Pubkey, pool_address: &Pubkey) -> (Pubkey, u8) {
39 Pubkey::find_program_address(&[POOL_STAKE_PREFIX, pool_address.as_ref()], program_id)
40}
41
42fn find_pool_onramp_address_and_bump(program_id: &Pubkey, pool_address: &Pubkey) -> (Pubkey, u8) {
43 Pubkey::find_program_address(&[POOL_ONRAMP_PREFIX, pool_address.as_ref()], program_id)
44}
45
46fn find_pool_mint_address_and_bump(program_id: &Pubkey, pool_address: &Pubkey) -> (Pubkey, u8) {
47 Pubkey::find_program_address(&[POOL_MINT_PREFIX, pool_address.as_ref()], program_id)
48}
49
50fn find_pool_stake_authority_address_and_bump(
51 program_id: &Pubkey,
52 pool_address: &Pubkey,
53) -> (Pubkey, u8) {
54 Pubkey::find_program_address(
55 &[POOL_STAKE_AUTHORITY_PREFIX, pool_address.as_ref()],
56 program_id,
57 )
58}
59
60fn find_pool_mint_authority_address_and_bump(
61 program_id: &Pubkey,
62 pool_address: &Pubkey,
63) -> (Pubkey, u8) {
64 Pubkey::find_program_address(
65 &[POOL_MINT_AUTHORITY_PREFIX, pool_address.as_ref()],
66 program_id,
67 )
68}
69
70fn find_pool_mpl_authority_address_and_bump(
71 program_id: &Pubkey,
72 pool_address: &Pubkey,
73) -> (Pubkey, u8) {
74 Pubkey::find_program_address(
75 &[POOL_MPL_AUTHORITY_PREFIX, pool_address.as_ref()],
76 program_id,
77 )
78}
79
80pub fn find_pool_address(program_id: &Pubkey, vote_account_address: &Pubkey) -> Pubkey {
82 find_pool_address_and_bump(program_id, vote_account_address).0
83}
84
85pub fn find_pool_stake_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
87 find_pool_stake_address_and_bump(program_id, pool_address).0
88}
89
90pub fn find_pool_onramp_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
92 find_pool_onramp_address_and_bump(program_id, pool_address).0
93}
94
95pub fn find_pool_mint_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
97 find_pool_mint_address_and_bump(program_id, pool_address).0
98}
99
100pub fn find_pool_stake_authority_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
102 find_pool_stake_authority_address_and_bump(program_id, pool_address).0
103}
104
105pub fn find_pool_mint_authority_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
107 find_pool_mint_authority_address_and_bump(program_id, pool_address).0
108}
109
110pub fn find_pool_mpl_authority_address(program_id: &Pubkey, pool_address: &Pubkey) -> Pubkey {
112 find_pool_mpl_authority_address_and_bump(program_id, pool_address).0
113}