ore_legacy_api/state/
boost.rs

1use steel::*;
2
3use super::BoostAccount;
4
5/// Boost tracks the priority, deposits, and rewards of a staking incentive.
6#[repr(C)]
7#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
8pub struct Boost {
9    /// The unix timestamp this boost expires.
10    pub expires_at: i64,
11
12    /// The config rewards factor the last time rewards were collected by this boost.
13    pub last_rewards_factor: Numeric,
14
15    /// The mint address of the token associated with this boost.
16    pub mint: Pubkey,
17
18    /// The cumulative rewards collected by this boost, divided by the total deposits at the time of collection.
19    pub rewards_factor: Numeric,
20
21    /// The total amount of stake deposited in this boost.
22    pub total_deposits: u64,
23
24    /// The number of stakers in this boost.
25    pub total_stakers: u64,
26
27    /// The weight of this boost relative to other boosts.
28    pub weight: u64,
29
30    /// A protocol fee charged for withdrawing from this boost (in basis points).
31    pub withdraw_fee: u64,
32}
33
34// impl Boost {
35//     /// Collect weighted rewards from the global rewards pool.
36//     pub fn collect_rewards(&mut self, config: &mut Config, proof: &Proof) {
37//         // Increment the global rewards factor
38//         if config.total_weight > 0 {
39//             config.rewards_factor += Numeric::from_fraction(proof.balance, config.total_weight);
40//         }
41
42//         // Accumulate weighted rewards into the boost rewards factor
43//         if config.rewards_factor > self.last_rewards_factor && self.total_deposits > 0 {
44//             let accumulated_rewards = config.rewards_factor - self.last_rewards_factor;
45//             if accumulated_rewards < Numeric::ZERO {
46//                 panic!("Accumulated rewards is negative");
47//             }
48//             let boost_rewards = accumulated_rewards * Numeric::from_u64(self.weight);
49//             self.rewards_factor += boost_rewards / Numeric::from_u64(self.total_deposits);
50//         }
51
52//         // Update this boost's last seen rewards factor
53//         self.last_rewards_factor = config.rewards_factor;
54//     }
55// }
56
57account!(BoostAccount, Boost);