Skip to main content

ic_query/nns/governance/model/
metrics.rs

1//! Module: nns::governance::model::metrics
2//!
3//! Responsibility: native NNS Governance cached-metrics report contracts.
4//! Does not own: economics, reward events, maturity modulation, transport, or rendering.
5//! Boundary: preserves metric buckets, aggregate values, and native neuron subsets.
6
7use super::NnsGovernanceReportContext;
8use serde::{Deserialize as SerdeDeserialize, Serialize};
9
10///
11/// NnsGovernanceMetricBucket
12///
13/// One native Governance metric bucket represented as a named key/value row.
14///
15
16#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
17pub struct NnsGovernanceMetricBucket<Value> {
18    /// Raw unlabeled Candid bucket key.
19    pub key: u64,
20    /// Raw unlabeled Candid bucket value.
21    pub value: Value,
22}
23
24///
25/// NnsGovernanceMetricsReport
26///
27/// Serializable live snapshot of cached NNS Governance metrics.
28///
29
30#[derive(Clone, Debug, PartialEq, SerdeDeserialize, Serialize)]
31pub struct NnsGovernanceMetricsReport {
32    /// Shared Governance query provenance.
33    #[serde(flatten)]
34    pub context: NnsGovernanceReportContext,
35    /// Native Governance metrics.
36    pub metrics: NnsGovernanceMetrics,
37}
38
39///
40/// NnsGovernanceMetrics
41///
42/// Native cached metrics returned by the NNS Governance canister.
43///
44
45#[derive(Clone, Debug, PartialEq, SerdeDeserialize, Serialize)]
46pub struct NnsGovernanceMetrics {
47    /// Total maturity in e8s-equivalent.
48    pub total_maturity_e8s_equivalent: u64,
49    /// Non-dissolving neuron stake buckets.
50    pub not_dissolving_neurons_e8s_buckets: Vec<NnsGovernanceMetricBucket<f64>>,
51    /// Staked maturity of dissolving neurons in e8s-equivalent.
52    pub dissolving_neurons_staked_maturity_e8s_equivalent_sum: u64,
53    /// Number of garbage-collectable neurons.
54    pub garbage_collectable_neurons_count: u64,
55    /// Staked-maturity buckets for dissolving neurons.
56    pub dissolving_neurons_staked_maturity_e8s_equivalent_buckets:
57        Vec<NnsGovernanceMetricBucket<f64>>,
58    /// Number of neurons with invalid stake.
59    pub neurons_with_invalid_stake_count: u64,
60    /// Count buckets for non-dissolving neurons.
61    pub not_dissolving_neurons_count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
62    /// Number of early-contributor-token neurons.
63    pub ect_neuron_count: u64,
64    /// Total ICP supply reported by Governance.
65    pub total_supply_icp: u64,
66    /// Number of neurons with less than six months dissolve delay.
67    pub neurons_with_less_than_6_months_dissolve_delay_count: u64,
68    /// Number of dissolved neurons.
69    pub dissolved_neurons_count: u64,
70    /// Community Fund maturity in e8s-equivalent.
71    pub community_fund_total_maturity_e8s_equivalent: u64,
72    /// Total seed-neuron stake in e8s.
73    pub total_staked_e8s_seed: u64,
74    /// Total staked maturity of early-contributor-token neurons.
75    pub total_staked_maturity_e8s_equivalent_ect: u64,
76    /// Total neuron stake in e8s.
77    pub total_staked_e8s: u64,
78    /// Number of non-dissolving neurons.
79    pub not_dissolving_neurons_count: u64,
80    /// Total locked stake in e8s.
81    pub total_locked_e8s: u64,
82    /// Number of active Neurons' Fund neurons.
83    pub neurons_fund_total_active_neurons: u64,
84    /// Voting power controlled by non-self-authenticating principals.
85    pub total_voting_power_non_self_authenticating_controller: Option<u64>,
86    /// Total staked maturity in e8s-equivalent.
87    pub total_staked_maturity_e8s_equivalent: u64,
88    /// Non-dissolving early-contributor-token neuron stake buckets.
89    pub not_dissolving_neurons_e8s_buckets_ect: Vec<NnsGovernanceMetricBucket<f64>>,
90    /// Total stake of early-contributor-token neurons in e8s.
91    pub total_staked_e8s_ect: u64,
92    /// Staked maturity of non-dissolving neurons in e8s-equivalent.
93    pub not_dissolving_neurons_staked_maturity_e8s_equivalent_sum: u64,
94    /// Total dissolved-neuron stake in e8s.
95    pub dissolved_neurons_e8s: u64,
96    /// Stake controlled by non-self-authenticating principals.
97    pub total_staked_e8s_non_self_authenticating_controller: Option<u64>,
98    /// Dissolving seed-neuron stake buckets.
99    pub dissolving_neurons_e8s_buckets_seed: Vec<NnsGovernanceMetricBucket<f64>>,
100    /// Stake of neurons with less than six months dissolve delay.
101    pub neurons_with_less_than_6_months_dissolve_delay_e8s: u64,
102    /// Staked-maturity buckets for non-dissolving neurons.
103    pub not_dissolving_neurons_staked_maturity_e8s_equivalent_buckets:
104        Vec<NnsGovernanceMetricBucket<f64>>,
105    /// Count buckets for dissolving neurons.
106    pub dissolving_neurons_count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
107    /// Dissolving early-contributor-token neuron stake buckets.
108    pub dissolving_neurons_e8s_buckets_ect: Vec<NnsGovernanceMetricBucket<f64>>,
109    /// Number of dissolving neurons.
110    pub dissolving_neurons_count: u64,
111    /// Dissolving neuron stake buckets.
112    pub dissolving_neurons_e8s_buckets: Vec<NnsGovernanceMetricBucket<f64>>,
113    /// Total staked maturity of seed neurons.
114    pub total_staked_maturity_e8s_equivalent_seed: u64,
115    /// Total Community Fund stake in e8s.
116    pub community_fund_total_staked_e8s: u64,
117    /// Non-dissolving seed-neuron stake buckets.
118    pub not_dissolving_neurons_e8s_buckets_seed: Vec<NnsGovernanceMetricBucket<f64>>,
119    /// Governance metric collection timestamp in Unix seconds.
120    pub timestamp_seconds: u64,
121    /// Number of seed neurons.
122    pub seed_neuron_count: u64,
123    /// Number of spawning neurons.
124    pub spawning_neurons_count: u64,
125    /// Maturity disbursements currently in progress.
126    pub total_maturity_disbursements_in_progress_e8s_equivalent: u64,
127    /// Metrics for neurons controlled by non-self-authenticating principals.
128    pub non_self_authenticating_controller_neuron_subset_metrics:
129        Option<NnsGovernanceNeuronSubsetMetrics>,
130    /// Metrics for publicly visible neurons.
131    pub public_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
132    /// Metrics for neurons with declining voting power.
133    pub declining_voting_power_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
134    /// Metrics for neurons that have fully lost voting power.
135    pub fully_lost_voting_power_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
136}
137
138///
139/// NnsGovernanceNeuronSubsetMetrics
140///
141/// Native cached Governance metrics for one neuron subset.
142///
143
144#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
145pub struct NnsGovernanceNeuronSubsetMetrics {
146    /// Number of neurons in the subset.
147    pub count: Option<u64>,
148    /// Total subset stake in e8s.
149    pub total_staked_e8s: Option<u64>,
150    /// Total subset maturity in e8s-equivalent.
151    pub total_maturity_e8s_equivalent: Option<u64>,
152    /// Total subset staked maturity in e8s-equivalent.
153    pub total_staked_maturity_e8s_equivalent: Option<u64>,
154    /// Deprecated raw total voting power.
155    pub total_voting_power: Option<u64>,
156    /// Total deciding voting power.
157    pub total_deciding_voting_power: Option<u64>,
158    /// Total potential voting power.
159    pub total_potential_voting_power: Option<u64>,
160    /// Neuron-count buckets.
161    pub count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
162    /// Stake buckets in e8s.
163    pub staked_e8s_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
164    /// Maturity buckets in e8s-equivalent.
165    pub maturity_e8s_equivalent_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
166    /// Staked-maturity buckets in e8s-equivalent.
167    pub staked_maturity_e8s_equivalent_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
168    /// Deprecated voting-power buckets.
169    pub voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
170    /// Deciding-voting-power buckets.
171    pub deciding_voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
172    /// Potential-voting-power buckets.
173    pub potential_voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
174}