1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use serde::{Deserialize, Serialize};
use steel::*;
use crate::state::miner_pda;
use super::OilAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct Automation {
/// The amount of SOL to deploy on each territory per round.
pub amount: u64,
/// The authority of this automation account.
pub authority: Pubkey,
/// The amount of SOL this automation has left.
pub balance: u64,
/// The executor of this automation account.
pub executor: Pubkey,
/// The amount of SOL the executor should receive in fees.
pub fee: u64,
/// The strategy this automation uses.
pub strategy: u64,
/// The mask of squares this automation should deploy to.
/// - Preferred: bit flags for which squares to deploy to
/// - Random: first byte is number of squares to randomly select
/// - Repeat: bit flags for which squares to deploy to (auto-updated after each deployment)
pub mask: u64,
/// Whether or not to auto-reload SOL winnings into the automation balance.
pub reload: u64,
/// Whether automated deployments should be pooled (1 = pooled, 0 = not pooled).
pub pooled: u64,
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum AutomationStrategy {
Random = 0,
Preferred = 1,
Repeat = 2,
}
impl AutomationStrategy {
pub fn from_u64(value: u64) -> Self {
Self::try_from(value as u8).unwrap()
}
}
impl Automation {
pub fn pda(&self) -> (Pubkey, u8) {
miner_pda(self.authority)
}
}
account!(OilAccount, Automation);