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
64#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
65pub enum Treasury {
66 V1(TreasuryV1),
67 V4(TreasuryV4),
68}
69
70#[allow(deprecated)]
71impl Treasury {
72 pub fn balance(&self) -> u64 {
73 match self {
74 Treasury::V1(t) => t.balance,
75 Treasury::V4(_) => 0,
76 }
77 }
78
79 pub fn buffer_a(&self) -> u64 {
80 match self {
81 Treasury::V1(t) => t.buffer_a,
82 Treasury::V4(_) => 0,
83 }
84 }
85
86 pub fn motherlode(&self) -> u64 {
87 match self {
88 Treasury::V1(t) => t.motherlode,
89 Treasury::V4(t) => t.motherlode,
90 }
91 }
92
93 pub fn miner_rewards_factor(&self) -> Numeric {
94 match self {
95 Treasury::V1(t) => t.miner_rewards_factor,
96 Treasury::V4(t) => t.rewards_factor,
97 }
98 }
99
100 pub fn stake_rewards_factor(&self) -> Numeric {
101 match self {
102 Treasury::V1(t) => t.stake_rewards_factor,
103 Treasury::V4(_) => Numeric::ZERO,
104 }
105 }
106
107 pub fn buffer_b(&self) -> u64 {
108 match self {
109 Treasury::V1(t) => t.buffer_b,
110 Treasury::V4(_) => 0,
111 }
112 }
113
114 pub fn total_refined(&self) -> u64 {
115 match self {
116 Treasury::V1(t) => t.total_refined,
117 Treasury::V4(t) => t.total_refined,
118 }
119 }
120
121 pub fn total_staked(&self) -> u64 {
122 match self {
123 Treasury::V1(t) => t.total_staked,
124 Treasury::V4(_) => 0,
125 }
126 }
127
128 pub fn total_unclaimed(&self) -> u64 {
129 match self {
130 Treasury::V1(t) => t.total_unclaimed,
131 Treasury::V4(t) => t.total_unrefined,
132 }
133 }
134}