ore_api/state/
automation.rs

1use steel::*;
2
3use crate::state::miner_pda;
4
5use super::OreAccount;
6
7#[repr(C)]
8#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
9pub struct Automation {
10    /// The amount of SOL to deploy on each territory per round.
11    pub amount: u64,
12
13    /// The authority of this automation account.
14    pub authority: Pubkey,
15
16    /// The amount of SOL this automation has left.
17    pub balance: u64,
18
19    /// The executor of this automation account.
20    pub executor: Pubkey,
21
22    /// The amount of SOL the executor should receive in fees.
23    pub fee: u64,
24
25    /// The strategy this automation uses.
26    pub strategy: u64,
27
28    /// The mask of squares this automation should deploy to if preferred strategy.
29    /// If strategy is Random, first bit is used to determine how many squares to deploy to.
30    pub mask: u64,
31}
32
33#[repr(u8)]
34#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive, TryFromPrimitive)]
35pub enum AutomationStrategy {
36    Random = 0,
37    Preferred = 1,
38}
39
40impl AutomationStrategy {
41    pub fn from_u64(value: u64) -> Self {
42        Self::try_from(value as u8).unwrap()
43    }
44}
45
46impl Automation {
47    pub fn pda(&self) -> (Pubkey, u8) {
48        miner_pda(self.authority)
49    }
50}
51
52account!(OreAccount, Automation);