use serde::{Deserialize, Serialize};
use steel::*;
use crate::state::OreAccountV4;
use super::OreAccountV1;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct TreasuryV1 {
pub balance: u64,
pub buffer_a: u64,
pub motherlode: u64,
pub miner_rewards_factor: Numeric,
#[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
pub stake_rewards_factor: Numeric,
pub buffer_b: u64,
pub total_refined: u64,
#[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
pub total_staked: u64,
pub total_unclaimed: u64,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct TreasuryV4 {
pub motherlode: u64,
pub rewards_factor: Numeric,
pub total_refined: u64,
pub total_unrefined: u64,
}
account!(OreAccountV1, TreasuryV1);
account!(OreAccountV4, TreasuryV4);
pub enum Treasury {
V1(TreasuryV1),
V4(TreasuryV4),
}
#[allow(deprecated)]
impl Treasury {
pub fn balance(&self) -> u64 {
match self {
Treasury::V1(t) => t.balance,
Treasury::V4(_) => 0,
}
}
pub fn buffer_a(&self) -> u64 {
match self {
Treasury::V1(t) => t.buffer_a,
Treasury::V4(_) => 0,
}
}
pub fn motherlode(&self) -> u64 {
match self {
Treasury::V1(t) => t.motherlode,
Treasury::V4(t) => t.motherlode,
}
}
pub fn miner_rewards_factor(&self) -> Numeric {
match self {
Treasury::V1(t) => t.miner_rewards_factor,
Treasury::V4(t) => t.rewards_factor,
}
}
pub fn stake_rewards_factor(&self) -> Numeric {
match self {
Treasury::V1(t) => t.stake_rewards_factor,
Treasury::V4(_) => Numeric::ZERO,
}
}
pub fn buffer_b(&self) -> u64 {
match self {
Treasury::V1(t) => t.buffer_b,
Treasury::V4(_) => 0,
}
}
pub fn total_refined(&self) -> u64 {
match self {
Treasury::V1(t) => t.total_refined,
Treasury::V4(t) => t.total_refined,
}
}
pub fn total_staked(&self) -> u64 {
match self {
Treasury::V1(t) => t.total_staked,
Treasury::V4(_) => 0,
}
}
pub fn total_unclaimed(&self) -> u64 {
match self {
Treasury::V1(t) => t.total_unclaimed,
Treasury::V4(t) => t.total_unrefined,
}
}
}