marsh_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 unix timestamp after which mining can begin.
6/// TODO decide a new date
7// Tentative time
8// Thursday, August 15, 2024 3:00:00 AM GMT
9// pub const START_AT: i64 = 1723690800;
10
11// Test Start Time
12// Date and time (GMT): Sunday, July 14, 2024 10:00:00 AM
13pub const START_AT: i64 = 1720951200;
14
15/// The unix timestamp after which mining will stop.
16/// TODO decide a new date
17// Tentative time
18// Wednesday, August 15, 2074 3:00:00 AM GMT
19// pub const END_AT: i64 = 3301527600;
20
21// Test End Time
22// Date and time (GMT): Monday, July 15, 2024 10:00:00 AM
23// pub const END_AT: i64 = 1721037600;
24// Date and time (GMT): Wednesday, July 31, 2024 10:00:00 AM
25pub const END_AT: i64 = 1722420000;
26
27// Test initializer (mac::id.json)
28// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("Ac2ev4ofDx61tuSJCgq9ToSBfVwHD2a1FVJf6p7TAqiB");
29// Test initializer (mac&hp::test-id.json)
30pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("4ALL9EAVHpv7ioJF95ktDLtrHUEJezPuFxTFFMy3fpSy");
31
32/// The authority allowed to initialize the program.
33// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("staryJacbXodPh4WfwVtgA5jkJhvsMHERtkdttnLEHc");
34
35/// The base reward rate to intialize the program with.
36// pub const INITIAL_BASE_REWARD_RATE: u64 = BASE_REWARD_RATE_MIN_THRESHOLD;
37// pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(7);
38pub const INITIAL_BASE_REWARD_RATE: u64 = 2u64.pow(8);
39
40/// The minimum allowed base reward rate, at which point the min difficulty should be increased
41pub const BASE_REWARD_RATE_MIN_THRESHOLD: u64 = 2u64.pow(5);
42
43/// The maximum allowed base reward rate, at which point the min difficulty should be decreased.
44// pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(8);
45// pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(10);
46pub const BASE_REWARD_RATE_MAX_THRESHOLD: u64 = 2u64.pow(16);
47
48/// The spam/liveness tolerance in seconds.
49pub const TOLERANCE: i64 = 5;
50
51/// The minimum difficulty to initialize the program with.
52// pub const INITIAL_MIN_DIFFICULTY: u32 = 1;
53// pub const INITIAL_MIN_DIFFICULTY: u32 = 5;
54// pub const INITIAL_MIN_DIFFICULTY: u32 = 7;
55pub const INITIAL_MIN_DIFFICULTY: u32 = 8;
56
57/// The decimal precision of the Marsh token.
58/// There are 1 billion indivisible units per Marsh (called "raindrops").
59pub const TOKEN_DECIMALS: u8 = 9;
60
61/// The decimal precision of the legacy Mars(h) token.
62pub const TOKEN_DECIMALS_V1: u8 = 8;
63
64/// One Marsh token, denominated in indivisible units.
65pub const ONE_MARSH: u64 = 10u64.pow(TOKEN_DECIMALS as u32);
66
67/// Ten MARSH token
68// pub const TEN_MARSH: u64 = ONE_MARSH.saturating_mul(10);
69pub const TEN_MARSH: u64 = ONE_MARSH * 10;
70
71/// The duration of one minute, in seconds.
72pub const ONE_MINUTE: i64 = 60;
73
74/// The number of minutes in a program epoch.
75pub const EPOCH_MINUTES: i64 = 1;
76
77/// The duration of a program epoch, in seconds.
78// pub const EPOCH_DURATION: i64 = ONE_MINUTE.saturating_mul(EPOCH_MINUTES);
79pub const EPOCH_DURATION: i64 = ONE_MINUTE * EPOCH_MINUTES;
80
81/// The maximum token supply (50 million).
82// pub const MAX_SUPPLY: u64 = ONE_MARSH.saturating_mul(50_000_000);
83pub const MAX_SUPPLY: u64 = ONE_MARSH * 50_000_000;
84
85/// The target quantity of MARSH to be mined per epoch.
86// pub const TARGET_EPOCH_REWARDS: u64 = ONE_MARSH.saturating_mul(EPOCH_MINUTES as u64);
87// pub const TARGET_EPOCH_REWARDS: u64 = TEN_MARSH.saturating_mul(EPOCH_MINUTES as u64);
88pub const TARGET_EPOCH_REWARDS: u64 = TEN_MARSH * EPOCH_MINUTES as u64;
89
90/// The maximum quantity of MARSH that can be mined per epoch.
91/// Inflation rate ≈ 10 MARSH / min (min 0, max 8)
92// pub const MAX_EPOCH_REWARDS: u64 = TARGET_EPOCH_REWARDS.saturating_mul(BUS_COUNT as u64);
93pub const MAX_EPOCH_REWARDS: u64 = TARGET_EPOCH_REWARDS * BUS_COUNT as u64;
94
95/// The quantity of MARSH each bus is allowed to issue per epoch.
96// pub const BUS_EPOCH_REWARDS: u64 = MAX_EPOCH_REWARDS.saturating_div(BUS_COUNT as u64);
97pub const BUS_EPOCH_REWARDS: u64 = MAX_EPOCH_REWARDS / BUS_COUNT as u64;
98
99/// The number of bus accounts, for parallelizing mine operations.
100pub const BUS_COUNT: usize = 8;
101
102/// The smoothing factor for reward rate changes. The reward rate cannot change by more or less
103/// than a factor of this constant from one epoch to the next.
104pub const SMOOTHING_FACTOR: u64 = 2;
105
106// Assert MAX_EPOCH_REWARDS is evenly divisible by BUS_COUNT.
107static_assertions::const_assert!(
108    (MAX_EPOCH_REWARDS / BUS_COUNT as u64) * BUS_COUNT as u64 == MAX_EPOCH_REWARDS
109);
110
111/// The seed of the bus account PDA.
112pub const BUS: &[u8] = b"bus";
113
114/// The seed of the config account PDA.
115pub const CONFIG: &[u8] = b"config";
116
117/// The seed of the metadata account PDA.
118pub const METADATA: &[u8] = b"metadata";
119
120/// The seed of the mint account PDA.
121pub const MINT: &[u8] = b"mint";
122
123/// The seed of proof account PDAs.
124pub const PROOF: &[u8] = b"proof";
125
126/// The seed of the treasury account PDA.
127pub const TREASURY: &[u8] = b"treasury";
128
129/// Noise for deriving the mint pda.
130// mint noise: Mirascapians, big-endian: [77, 105, 114, 97, 115, 99, 97, 112, 105, 97, 110, 115]
131// nonce: 92596813, big-endian: [5, 132, 234, 77]
132// Mirascapians concat(+) nonce
133/// Noise for deriving the mint pda.
134pub const MINT_NOISE: [u8; 16] = [
135    77, 105, 114, 97, 115, 99, 97, 112, 105, 97, 110, 115, 5, 132, 234, 77,
136];
137
138/// The name for token metadata.
139pub const METADATA_NAME: &str = "Marsh";
140
141/// The ticker symbol for token metadata.
142pub const METADATA_SYMBOL: &str = "MARSH";
143
144/// The uri for token metdata.
145pub const METADATA_URI: &str = "https://github.com/miraland-labs/resources/blob/main/metadata/marsh.json";
146
147/// Program id for const pda derivations
148const PROGRAM_ID: [u8; 32] = unsafe { *(&crate::id() as *const Pubkey as *const [u8; 32]) };
149
150/// The addresses of the bus accounts.
151pub const BUS_ADDRESSES: [Pubkey; BUS_COUNT] = array_const_fn_init![const_bus_address; 8];
152
153/// Function to derive const bus addresses.
154const fn const_bus_address(i: usize) -> Pubkey {
155    Pubkey::new_from_array(ed25519::derive_program_address(&[BUS, &[i as u8]], &PROGRAM_ID).0)
156}
157
158/// The address of the config account.
159pub const CONFIG_ADDRESS: Pubkey =
160    Pubkey::new_from_array(ed25519::derive_program_address(&[CONFIG], &PROGRAM_ID).0);
161
162/// The address of the mint metadata account.
163pub const METADATA_ADDRESS: Pubkey = Pubkey::new_from_array(
164    ed25519::derive_program_address(
165        &[
166            METADATA,
167            unsafe { &*(&mpl_token_metadata::ID as *const Pubkey as *const [u8; 32]) },
168            unsafe { &*(&MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
169        ],
170        unsafe { &*(&mpl_token_metadata::ID as *const Pubkey as *const [u8; 32]) },
171    )
172    .0,
173);
174
175// MI
176// Marsh mint address: MARSs8nkDeZrr3D9V7wzap5kiWtmQJ131f8xf61ZZrW
177/// The address of the mint account.
178pub const MINT_ADDRESS: Pubkey =
179    Pubkey::new_from_array(ed25519::derive_program_address(&[MINT, &MINT_NOISE], &PROGRAM_ID).0);
180
181/// The address of the legacy Mars(h) mint account.
182pub const MINT_V1_ADDRESS: Pubkey = pubkey!("7RAV5UPRTzxn46kLeA8MiJsdNy9VKc5fip8FWEgTpTHh");
183
184/// The address of the treasury account.
185pub const TREASURY_ADDRESS: Pubkey =
186    Pubkey::new_from_array(ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).0);
187
188/// The bump of the treasury account, for cpis.
189pub const TREASURY_BUMP: u8 = ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).1;
190
191/// The address of the treasury token account.
192pub const TREASURY_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
193    ed25519::derive_program_address(
194        &[
195            unsafe { &*(&TREASURY_ADDRESS as *const Pubkey as *const [u8; 32]) },
196            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
197            unsafe { &*(&MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
198        ],
199        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
200    )
201    .0,
202);
203
204/// The address of the CU-optimized Solana noop program.
205pub const NOOP_PROGRAM_ID: Pubkey = pubkey!("noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW");