solana_program/stake/
config.rs

1//! config for staking
2//!  carries variables that the stake program cares about
3use serde_derive::{Deserialize, Serialize};
4
5// stake config ID
6crate::declare_id!("StakeConfig11111111111111111111111111111111");
7
8// means that no more than RATE of current effective stake may be added or subtracted per
9//  epoch
10pub const DEFAULT_WARMUP_COOLDOWN_RATE: f64 = 0.25;
11pub const DEFAULT_SLASH_PENALTY: u8 = ((5 * std::u8::MAX as usize) / 100) as u8;
12
13#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Copy)]
14pub struct Config {
15    /// how much stake we can activate/deactivate per-epoch as a fraction of currently effective stake
16    pub warmup_cooldown_rate: f64,
17    /// percentage of stake lost when slash, expressed as a portion of std::u8::MAX
18    pub slash_penalty: u8,
19}
20
21impl Default for Config {
22    fn default() -> Self {
23        Self {
24            warmup_cooldown_rate: DEFAULT_WARMUP_COOLDOWN_RATE,
25            slash_penalty: DEFAULT_SLASH_PENALTY,
26        }
27    }
28}