Skip to main content

oil_api/state/
rig.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::rig_pda;
5
6use super::OilAccount;
7
8/// Rig account tracks a user's auction participation and checkpoint status across all wells
9#[repr(C)]
10#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
11pub struct Rig {
12    /// Authority (user's wallet)
13    pub authority: Pubkey,
14    
15    /// Last epoch participated in per well (index = well_id, 0-3)
16    pub current_epoch_id: [u64; 4],
17    
18    /// Last epoch checkpointed per well (index = well_id, 0-3)
19    pub checkpointed_epoch_id: [u64; 4],
20    
21    /// Buffer field for future extensions
22    pub buffer_a: u64,
23    
24    /// Buffer field for future extensions
25    pub buffer_b: u64,
26    
27    /// Buffer field for future extensions
28    pub buffer_c: u64,
29}
30
31impl Rig {
32    pub fn pda(authority: Pubkey) -> (Pubkey, u8) {
33        rig_pda(authority)
34    }
35
36    pub fn initialize(&mut self, authority: Pubkey) {
37        self.authority = authority;
38        self.current_epoch_id = [0; 4];
39        self.checkpointed_epoch_id = [0; 4];
40        self.buffer_a = 0;
41        self.buffer_b = 0;
42        self.buffer_c = 0;
43    }
44}
45
46account!(OilAccount, Rig);