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 #[deprecated(since = "3.9.0", note = "No more balance")]
15 pub balance: u64,
16
17 pub buffer_a: u64,
19
20 pub motherlode: u64,
22
23 pub miner_rewards_factor: Numeric,
25
26 #[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
28 pub stake_rewards_factor: Numeric,
29
30 pub buffer_b: u64,
32
33 pub total_refined: u64,
35
36 #[deprecated(since = "3.8.0", note = "Staking has moved to ore-stake program")]
38 pub total_staked: u64,
39
40 pub total_unclaimed: u64,
42}
43
44#[repr(C)]
47#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
48pub struct TreasuryV4 {
49 pub motherlode: u64,
51
52 pub rewards_factor: Numeric,
54
55 pub total_refined: u64,
57
58 pub total_unrefined: u64,
60}
61
62account!(OreAccountV1, TreasuryV1);
63account!(OreAccountV4, TreasuryV4);
64
65#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
66pub enum Treasury {
67 V1(TreasuryV1),
68 V4(TreasuryV4),
69}
70
71#[allow(deprecated)]
72impl Treasury {
73 pub fn balance(&self) -> u64 {
74 match self {
75 Treasury::V1(t) => t.balance,
76 Treasury::V4(_) => 0,
77 }
78 }
79
80 pub fn buffer_a(&self) -> u64 {
81 match self {
82 Treasury::V1(t) => t.buffer_a,
83 Treasury::V4(_) => 0,
84 }
85 }
86
87 pub fn motherlode(&self) -> u64 {
88 match self {
89 Treasury::V1(t) => t.motherlode,
90 Treasury::V4(t) => t.motherlode,
91 }
92 }
93
94 pub fn miner_rewards_factor(&self) -> Numeric {
95 match self {
96 Treasury::V1(t) => t.miner_rewards_factor,
97 Treasury::V4(t) => t.rewards_factor,
98 }
99 }
100
101 pub fn stake_rewards_factor(&self) -> Numeric {
102 match self {
103 Treasury::V1(t) => t.stake_rewards_factor,
104 Treasury::V4(_) => Numeric::ZERO,
105 }
106 }
107
108 pub fn buffer_b(&self) -> u64 {
109 match self {
110 Treasury::V1(t) => t.buffer_b,
111 Treasury::V4(_) => 0,
112 }
113 }
114
115 pub fn total_refined(&self) -> u64 {
116 match self {
117 Treasury::V1(t) => t.total_refined,
118 Treasury::V4(t) => t.total_refined,
119 }
120 }
121
122 pub fn total_staked(&self) -> u64 {
123 match self {
124 Treasury::V1(t) => t.total_staked,
125 Treasury::V4(_) => 0,
126 }
127 }
128
129 pub fn total_unclaimed(&self) -> u64 {
130 match self {
131 Treasury::V1(t) => t.total_unclaimed,
132 Treasury::V4(t) => t.total_unrefined,
133 }
134 }
135}