1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::share_pda;
5
6use super::OilAccount;
7
8#[repr(C)]
10#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
11pub struct Share {
12 pub authority: Pubkey,
14
15 pub well_id: u64,
17
18 pub epoch_id: u64,
20
21 pub contribution: u64,
23
24 pub created_at: u64,
26
27 pub claimed_oil: u64,
29
30 pub claimed_sol: u64,
32
33 pub buffer_a: u64,
35
36 pub buffer_b: u64,
38
39 pub buffer_c: u64,
41}
42
43impl Share {
44 pub fn pda(authority: Pubkey, well_id: u64, epoch_id: u64) -> (Pubkey, u8) {
45 share_pda(authority, well_id, epoch_id)
46 }
47
48 pub fn initialize(&mut self, authority: Pubkey, well_id: u64, epoch_id: u64, clock: &Clock) {
49 self.authority = authority;
50 self.well_id = well_id;
51 self.epoch_id = epoch_id;
52 self.contribution = 0;
53 self.created_at = clock.unix_timestamp as u64;
54 self.claimed_oil = 0;
55 self.claimed_sol = 0;
56 self.buffer_a = 0;
57 self.buffer_b = 0;
58 self.buffer_c = 0;
59 }
60}
61
62account!(OilAccount, Share);