ore_boost_api/state/
mod.rs

1mod boost;
2mod config;
3mod checkpoint;
4mod directory;
5mod reservation;
6mod stake;
7
8pub use boost::*;
9pub use config::*;
10pub use checkpoint::*;
11pub use directory::*;
12pub use reservation::*;
13pub use stake::*;
14
15use steel::*;
16
17use crate::consts::{BOOST, CHECKPOINT, CONFIG, DIRECTORY, RESERVATION, STAKE};
18
19#[repr(u8)]
20#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
21pub enum BoostAccount {
22    Boost = 100,
23    Checkpoint = 101,
24    Config = 102,
25    Directory = 103,
26    Reservation = 104,
27    Stake = 105,
28}
29
30/// Fetch the PDA of the boost account.
31pub fn boost_pda(mint: Pubkey) -> (Pubkey, u8) {
32    Pubkey::find_program_address(&[BOOST, mint.as_ref()], &crate::id())
33}
34
35/// Fetch the PDA of the checkpoint account.
36pub fn checkpoint_pda(boost: Pubkey) -> (Pubkey, u8) {
37    Pubkey::find_program_address(&[CHECKPOINT, boost.as_ref()], &crate::id())
38}
39
40/// Fetch the PDA of the config account.
41pub fn config_pda() -> (Pubkey, u8) {
42    Pubkey::find_program_address(&[CONFIG], &crate::id())
43}
44
45/// Fetch the PDA of the directory account.
46pub fn directory_pda() -> (Pubkey, u8) {
47    Pubkey::find_program_address(&[DIRECTORY], &crate::id())
48}
49
50/// Fetch the PDA of the reservation account.
51pub fn reservation_pda(authority: Pubkey) -> (Pubkey, u8) {
52    Pubkey::find_program_address(&[RESERVATION, authority.as_ref()], &crate::id())
53}
54
55/// Fetch the PDA of the stake account.
56pub fn stake_pda(authority: Pubkey, boost: Pubkey) -> (Pubkey, u8) {
57    Pubkey::find_program_address(&[STAKE, authority.as_ref(), boost.as_ref()], &crate::id())
58}