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