ore_api/state/config.rs
1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use crate::state::{config_pda, OreAccountV4};
5
6#[repr(C)]
7#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
8pub struct Config {
9 /// The admin config.
10 pub admin: AdminConfig,
11
12 /// The protocol config.
13 pub protocol: ProtocolConfig,
14}
15
16#[repr(C)]
17#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
18pub struct AdminConfig {
19 /// The authority of this admin config.
20 pub authority: Pubkey,
21
22 /// The address of the admin fee collector.
23 pub fee_collector: Pubkey,
24
25 /// The admin fee rate.
26 pub fee_rate: u64,
27}
28
29#[repr(C)]
30#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
31pub struct ProtocolConfig {
32 /// The authority of this protocol config.
33 pub authority: Pubkey,
34
35 /// The address of the protocol fee collector.
36 pub fee_collector: Pubkey,
37
38 /// The protocol fee rate.
39 pub fee_rate: u64,
40
41 /// The number of slots in the intermission period.
42 pub intermission_slots: u64,
43
44 /// The number of slots in a round.
45 pub round_slots: u64,
46
47 /// The address of the var account.
48 pub entropy_var_address: Pubkey,
49
50 /// The entropy program id.
51 pub entropy_program_id: Pubkey,
52}
53
54impl Config {
55 pub fn pda() -> (Pubkey, u8) {
56 config_pda()
57 }
58}
59
60account!(OreAccountV4, Config);
61
62// impl Config {
63// pub fn admin(&self) -> Pubkey {
64// match self {
65// Config::V1(c) => c.admin,
66// Config::V4(c) => c.admin.authority,
67// }
68// }
69
70// pub fn buffer_a(&self) -> [u8; 32] {
71// match self {
72// Config::V1(c) => c.buffer_a,
73// Config::V4(_) => [0; 32],
74// }
75// }
76
77// pub fn buffer_b(&self) -> [u8; 32] {
78// match self {
79// Config::V1(c) => c.buffer_b,
80// Config::V4(_) => [0; 32],
81// }
82// }
83
84// pub fn buffer_c(&self) -> [u8; 32] {
85// match self {
86// Config::V1(c) => c.buffer_c,
87// Config::V4(_) => [0; 32],
88// }
89// }
90
91// pub fn buffer_d(&self) -> [u8; 32] {
92// match self {
93// Config::V1(c) => c.buffer_d,
94// Config::V4(_) => [0; 32],
95// }
96// }
97
98// pub fn buffer_e(&self) -> [u8; 8] {
99// match self {
100// Config::V1(c) => c.buffer_e,
101// Config::V4(_) => [0; 8],
102// }
103// }
104// }