ore_api/
consts.rs

1use array_const_fn_init::array_const_fn_init;
2use const_crypto::ed25519;
3use solana_program::{pubkey, pubkey::Pubkey};
4
5/// The authority allowed to initialize the program.
6pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk");
7
8/// The base reward rate to intialize the program with.
9pub const INITIAL_BASE_REWARD_RATE: u64 = BASE_REWARD_RATE_MIN_THRESHOLD;
10
11/// The minimum allowed base reward rate, at which point the min difficulty should be increased
12pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2u64.pow(5);
13
14/// The maximum allowed base reward rate, at which point the min difficulty should be decreased.
15pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(8);
16
17/// The spam/liveness tolerance in seconds.
18pub const TOLERANCE: i64 = 5;
19
20/// The minimum difficulty to initialize the program with.
21pub const INITIAL_MIN_DIFFICULTY: u32 = 1;
22
23/// The decimal precision of the ORE token.
24/// There are 100 billion indivisible units per ORE (called "grains").
25pub const TOKEN_DECIMALS: u8 = 11;
26
27/// The decimal precision of the ORE v1 token.
28pub const TOKEN_DECIMALS_V1: u8 = 9;
29
30/// One ORE token, denominated in indivisible units.
31pub const ONE_ORE: u64 = 10u64.pow(TOKEN_DECIMALS as u32);
32
33/// The duration of one minute, in seconds.
34pub const ONE_MINUTE: i64 = 60;
35
36/// The number of minutes in a program epoch.
37pub const EPOCH_MINUTES: i64 = 10;
38
39/// The duration of a program epoch, in seconds.
40pub const EPOCH_DURATION: i64 = ONE_MINUTE * EPOCH_MINUTES;
41
42/// The maximum token supply (5 million).
43pub const MAX_SUPPLY: u64 = ONE_ORE * 5_000_000;
44
45/// The target quantity of ORE to be mined per epoch.
46pub const TARGET_EPOCH_REWARDS: u64 = ONE_ORE * EPOCH_MINUTES as u64;
47
48/// The maximum quantity of ORE that can be mined per epoch.
49/// Inflation target ≈ 1 ORE / min
50pub const MAX_EPOCH_REWARDS: u64 = TARGET_EPOCH_REWARDS * BUS_COUNT as u64;
51
52/// The quantity of ORE each bus is allowed to issue per epoch.
53pub const BUS_EPOCH_REWARDS: u64 = MAX_EPOCH_REWARDS / BUS_COUNT as u64;
54
55/// The number of bus accounts, for parallelizing mine operations.
56pub const BUS_COUNT: usize = 8;
57
58/// The smoothing factor for reward rate changes. The reward rate cannot change by more or less
59/// than a factor of this constant from one epoch to the next.
60pub const SMOOTHING_FACTOR: u64 = 2;
61
62// Assert MAX_EPOCH_REWARDS is evenly divisible by BUS_COUNT.
63static_assertions::const_assert!(
64    (MAX_EPOCH_REWARDS / BUS_COUNT as u64) * BUS_COUNT as u64 == MAX_EPOCH_REWARDS
65);
66
67/// The seed of the bus account PDA.
68pub const BUS: &[u8] = b"bus";
69
70/// The seed of the config account PDA.
71pub const CONFIG: &[u8] = b"config";
72
73/// The seed of the metadata account PDA.
74pub const METADATA: &[u8] = b"metadata";
75
76/// The seed of the mint account PDA.
77pub const MINT: &[u8] = b"mint";
78
79/// The seed of proof account PDAs.
80pub const PROOF: &[u8] = b"proof";
81
82/// The seed of the treasury account PDA.
83pub const TREASURY: &[u8] = b"treasury";
84
85/// Noise for deriving the mint pda
86pub const MINT_NOISE: [u8; 16] = [
87    89, 157, 88, 232, 243, 249, 197, 132, 199, 49, 19, 234, 91, 94, 150, 41,
88];
89
90/// The name for token metadata.
91pub const METADATA_NAME: &str = "ORE";
92
93/// The ticker symbol for token metadata.
94pub const METADATA_SYMBOL: &str = "ORE";
95
96/// The uri for token metdata.
97pub const METADATA_URI: &str = "https://ore.supply/metadata-v2.json";
98
99/// Program id for const pda derivations
100const PROGRAM_ID: [u8; 32] = unsafe { *(&crate::id() as *const Pubkey as *const [u8; 32]) };
101
102/// The addresses of the bus accounts.
103pub const BUS_ADDRESSES: [Pubkey; BUS_COUNT] = array_const_fn_init![const_bus_address; 8];
104
105/// Function to derive const bus addresses.
106const fn const_bus_address(i: usize) -> Pubkey {
107    Pubkey::new_from_array(ed25519::derive_program_address(&[BUS, &[i as u8]], &PROGRAM_ID).0)
108}
109
110/// The address of the config account.
111pub const CONFIG_ADDRESS: Pubkey =
112    Pubkey::new_from_array(ed25519::derive_program_address(&[CONFIG], &PROGRAM_ID).0);
113
114/// The address of the mint metadata account.
115pub const METADATA_ADDRESS: Pubkey = Pubkey::new_from_array(
116    ed25519::derive_program_address(
117        &[
118            METADATA,
119            unsafe { &*(&mpl_token_metadata::ID as *const Pubkey as *const [u8; 32]) },
120            unsafe { &*(&MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
121        ],
122        unsafe { &*(&mpl_token_metadata::ID as *const Pubkey as *const [u8; 32]) },
123    )
124    .0,
125);
126
127/// The address of the mint account.
128pub const MINT_ADDRESS: Pubkey =
129    Pubkey::new_from_array(ed25519::derive_program_address(&[MINT, &MINT_NOISE], &PROGRAM_ID).0);
130
131/// The bump of the mint account.
132pub const MINT_BUMP: u8 = ed25519::derive_program_address(&[MINT, &MINT_NOISE], &PROGRAM_ID).1;
133
134/// The address of the v1 mint account.
135#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")]
136pub const MINT_V1_ADDRESS: Pubkey = pubkey!("oreoN2tQbHXVaZsr3pf66A48miqcBXCDJozganhEJgz");
137
138/// The address of the treasury account.
139pub const TREASURY_ADDRESS: Pubkey =
140    Pubkey::new_from_array(ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).0);
141
142/// The bump of the treasury account, for cpis.
143pub const TREASURY_BUMP: u8 = ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).1;
144
145/// The address of the treasury token account.
146pub const TREASURY_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
147    ed25519::derive_program_address(
148        &[
149            unsafe { &*(&TREASURY_ADDRESS as *const Pubkey as *const [u8; 32]) },
150            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
151            unsafe { &*(&MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
152        ],
153        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
154    )
155    .0,
156);
157
158/// The address of the CU-optimized Solana noop program.
159pub const NOOP_PROGRAM_ID: Pubkey = pubkey!("noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW");