ore_api/state/
automation.rs

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