1mod automation;
2mod auction;
3mod board;
4mod config;
5mod micro;
6mod miner;
7mod pool;
8mod referral;
9mod rig;
10mod round;
11mod share;
12mod well;
13mod stake;
14mod treasury;
15mod whitelist;
16
17pub use automation::*;
18pub use auction::*;
19pub use board::*;
20pub use config::*;
21pub use micro::*;
22pub use miner::*;
23pub use pool::*;
24pub use referral::*;
25pub use rig::*;
26pub use round::*;
27pub use share::*;
28pub use well::*;
29pub use stake::*;
30pub use treasury::*;
31#[allow(unused_imports)] pub use whitelist::*;
33use crate::consts::*;
34
35use steel::*;
36
37#[repr(u8)]
38#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
39pub enum OilAccount {
40 Automation = 100,
41 Config = 101,
42 Miner = 103,
43 Treasury = 104,
44 Board = 105,
45 Stake = 108,
46 Round = 109,
47 Referral = 110,
48 Pool = 111,
49 Auction = 114,
50 Well = 115,
51 Rig = 116,
52 Whitelist = 117,
53 Micro = 118,
54 Share = 119,
55}
56
57pub fn automation_pda(authority: Pubkey) -> (Pubkey, u8) {
58 Pubkey::find_program_address(&[AUTOMATION, &authority.to_bytes()], &crate::ID)
59}
60
61pub fn board_pda() -> (Pubkey, u8) {
62 Pubkey::find_program_address(&[BOARD], &crate::ID)
63}
64
65pub fn config_pda() -> (Pubkey, u8) {
66 Pubkey::find_program_address(&[CONFIG], &crate::ID)
67}
68
69pub fn miner_pda(authority: Pubkey) -> (Pubkey, u8) {
70 Pubkey::find_program_address(&[MINER, &authority.to_bytes()], &crate::ID)
71}
72
73pub fn round_pda(id: u64) -> (Pubkey, u8) {
74 Pubkey::find_program_address(&[ROUND, &id.to_le_bytes()], &crate::ID)
75}
76
77pub fn stake_pda(authority: Pubkey) -> (Pubkey, u8) {
78 Pubkey::find_program_address(&[STAKE, &authority.to_bytes()], &crate::ID)
79}
80
81pub fn stake_pda_with_id(authority: Pubkey, stake_id: u64) -> (Pubkey, u8) {
82 Pubkey::find_program_address(&[STAKE, &authority.to_bytes(), &stake_id.to_le_bytes()], &crate::ID)
83}
84
85pub fn referral_pda(authority: Pubkey) -> (Pubkey, u8) {
86 Pubkey::find_program_address(&[REFERRAL, &authority.to_bytes()], &crate::ID)
87}
88
89pub fn treasury_pda() -> (Pubkey, u8) {
90 Pubkey::find_program_address(&[TREASURY], &crate::ID)
91}
92
93pub fn treasury_tokens_address() -> Pubkey {
94 spl_associated_token_account::get_associated_token_address(&TREASURY_ADDRESS, &MINT_ADDRESS)
95}
96
97pub fn pool_pda() -> (Pubkey, u8) {
98 Pubkey::find_program_address(&[POOL], &crate::ID)
99}
100
101pub fn pool_tokens_address() -> Pubkey {
102 let pool_address = pool_pda().0;
103 spl_associated_token_account::get_associated_token_address(&pool_address, &MINT_ADDRESS)
104}
105
106pub fn auction_pda() -> (Pubkey, u8) {
107 Pubkey::find_program_address(&[AUCTION], &crate::ID)
108}
109
110pub fn well_pda(well_id: u64) -> (Pubkey, u8) {
111 Pubkey::find_program_address(&[WELL, &well_id.to_le_bytes()], &crate::ID)
112}
113
114pub fn whitelist_pda(code_hash: [u8; 32]) -> (Pubkey, u8) {
115 Pubkey::find_program_address(&[WHITELIST, &code_hash], &crate::ID)
116}
117
118pub fn rig_pda(authority: Pubkey) -> (Pubkey, u8) {
119 Pubkey::find_program_address(&[RIG, &authority.to_bytes()], &crate::ID)
120}
121
122pub fn micro_pda(well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
123 Pubkey::find_program_address(&[MICRO, &well_id.to_le_bytes(), &epoch_id.to_le_bytes()], &crate::ID)
124}
125
126pub fn share_pda(authority: Pubkey, well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
127 Pubkey::find_program_address(&[SHARE, &authority.to_bytes(), &well_id.to_le_bytes(), &epoch_id.to_le_bytes()], &crate::ID)
128}