oil_api/state/
automation.rs1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::miner_pda;
5
6use super::OilAccount;
7
8#[repr(C)]
9#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
10pub struct Automation {
11 pub amount: u64,
13
14 pub authority: Pubkey,
16
17 pub balance: u64,
19
20 pub executor: Pubkey,
22
23 pub fee: u64,
25
26 pub strategy: u64,
28
29 pub mask: u64,
32
33 pub reload: u64,
35
36 pub pooled: u64,
38}
39
40#[repr(u8)]
41#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive, TryFromPrimitive)]
42pub enum AutomationStrategy {
43 Random = 0,
44 Preferred = 1,
45}
46
47impl AutomationStrategy {
48 pub fn from_u64(value: u64) -> Self {
49 Self::try_from(value as u8).unwrap()
50 }
51}
52
53impl Automation {
54 pub fn pda(&self) -> (Pubkey, u8) {
55 miner_pda(self.authority)
56 }
57}
58
59account!(OilAccount, Automation);