2025-02-12 03:41:50 -05:00
|
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
2024-09-01 01:55:42 +03:00
|
|
|
|
2025-09-20 04:45:04 -04:00
|
|
|
use serai_primitives::{
|
|
|
|
|
network_id::ExternalNetworkId,
|
|
|
|
|
balance::{Amount, ExternalBalance},
|
|
|
|
|
};
|
2025-02-12 03:41:50 -05:00
|
|
|
|
|
|
|
|
/// An event from economic security.
|
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
2024-09-01 01:55:42 +03:00
|
|
|
pub enum Event {
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Economic security was achieved for a network's validator set.
|
|
|
|
|
EconomicSecurityAchieved {
|
|
|
|
|
/// The network whose validator set achieved economic security.
|
|
|
|
|
network: ExternalNetworkId,
|
|
|
|
|
},
|
2024-09-01 01:55:42 +03:00
|
|
|
}
|
2025-09-20 01:41:54 -04:00
|
|
|
|
|
|
|
|
/// A trait representing access to the information on economic security.
|
|
|
|
|
pub trait EconomicSecurity {
|
2025-09-20 04:45:04 -04:00
|
|
|
/// If an external network has _ever_ achieved economic security.
|
2025-09-20 01:41:54 -04:00
|
|
|
#[must_use]
|
|
|
|
|
fn achieved_economic_security(network: ExternalNetworkId) -> bool;
|
2025-09-20 04:45:04 -04:00
|
|
|
|
|
|
|
|
/// The security oracle's valuation of this balance in SRI.
|
|
|
|
|
fn sri_value(balance: ExternalBalance) -> Amount;
|
2025-09-20 01:41:54 -04:00
|
|
|
}
|