ore_api/state/
treasury.rs1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::OreAccountV4;
5
6use super::OreAccountV1;
7
8#[repr(C)]
11#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
12pub struct TreasuryV1 {
13 pub balance: u64,
15
16 pub buffer_a: u64,
18
19 pub motherlode: u64,
21
22 pub miner_rewards_factor: Numeric,
24
25 #[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
27 pub stake_rewards_factor: Numeric,
28
29 pub buffer_b: u64,
31
32 pub total_refined: u64,
34
35 #[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
37 pub total_staked: u64,
38
39 pub total_unclaimed: u64,
41}
42
43#[repr(C)]
46#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
47pub struct TreasuryV4 {
48 pub motherlode: u64,
50
51 pub rewards_factor: Numeric,
53
54 pub total_refined: u64,
56
57 pub total_unrefined: u64,
59}
60
61account!(OreAccountV1, TreasuryV1);
62account!(OreAccountV4, TreasuryV4);
63
64pub enum Treasury {
65 TreasuryV1(TreasuryV1),
66 TreasuryV4(TreasuryV4),
67}
68
69#[allow(deprecated)]
70impl Treasury {
71 pub fn balance(&self) -> u64 {
72 match self {
73 Treasury::TreasuryV1(t) => t.balance,
74 Treasury::TreasuryV4(_) => 0,
75 }
76 }
77
78 pub fn buffer_a(&self) -> u64 {
79 match self {
80 Treasury::TreasuryV1(t) => t.buffer_a,
81 Treasury::TreasuryV4(_) => 0,
82 }
83 }
84
85 pub fn motherlode(&self) -> u64 {
86 match self {
87 Treasury::TreasuryV1(t) => t.motherlode,
88 Treasury::TreasuryV4(t) => t.motherlode,
89 }
90 }
91
92 pub fn miner_rewards_factor(&self) -> Numeric {
93 match self {
94 Treasury::TreasuryV1(t) => t.miner_rewards_factor,
95 Treasury::TreasuryV4(t) => t.rewards_factor,
96 }
97 }
98
99 pub fn stake_rewards_factor(&self) -> Numeric {
100 match self {
101 Treasury::TreasuryV1(t) => t.stake_rewards_factor,
102 Treasury::TreasuryV4(_) => Numeric::ZERO,
103 }
104 }
105
106 pub fn buffer_b(&self) -> u64 {
107 match self {
108 Treasury::TreasuryV1(t) => t.buffer_b,
109 Treasury::TreasuryV4(_) => 0,
110 }
111 }
112
113 pub fn total_refined(&self) -> u64 {
114 match self {
115 Treasury::TreasuryV1(t) => t.total_refined,
116 Treasury::TreasuryV4(t) => t.total_refined,
117 }
118 }
119
120 pub fn total_staked(&self) -> u64 {
121 match self {
122 Treasury::TreasuryV1(t) => t.total_staked,
123 Treasury::TreasuryV4(_) => 0,
124 }
125 }
126
127 pub fn total_unclaimed(&self) -> u64 {
128 match self {
129 Treasury::TreasuryV1(t) => t.total_unclaimed,
130 Treasury::TreasuryV4(t) => t.total_unrefined,
131 }
132 }
133}