Skip to main content

oil_api/state/
mod.rs

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