use serde::{Deserialize, Serialize};
use steel::*;
use crate::state::miner_pda;
use super::OreAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct Automation {
pub amount: u64,
pub authority: Pubkey,
pub balance: u64,
pub executor: Pubkey,
pub fee: u64,
pub strategy: u64,
pub mask: u64,
pub reload: u64,
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum AutomationStrategy {
Random = 0,
Preferred = 1,
Discretionary = 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!(OreAccount, Automation);