ic-query 0.22.7

Internet Computer query library for NNS, SNS, ICRC, system canisters, and public network metadata
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
//! Module: nns::governance::model
//!
//! Responsibility: define direct NNS Governance report models.
//! Does not own: live transport, CLI parsing, caching, or text rendering.
//! Boundary: preserves native Governance values and explicit query provenance.

#[cfg(feature = "host")]
use candid::CandidType;
use serde::{Deserialize as SerdeDeserialize, Serialize};

///
/// NnsGovernanceReportContext
///
/// Shared provenance flattened into every direct NNS Governance report.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceReportContext {
    /// Report schema version.
    pub schema_version: u32,
    /// Queried network identity.
    pub network: String,
    /// NNS Governance canister principal.
    pub governance_canister_id: String,
    /// UTC collection timestamp.
    pub fetched_at: String,
    /// Replica endpoint used for the query.
    pub source_endpoint: String,
    /// Collector identity.
    pub fetched_by: String,
}

///
/// NnsGovernanceMetricBucket
///
/// One native Governance metric bucket represented as a named key/value row.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceMetricBucket<Value> {
    /// Raw unlabeled Candid bucket key.
    pub key: u64,
    /// Raw unlabeled Candid bucket value.
    pub value: Value,
}

///
/// NnsGovernanceEconomicsReport
///
/// Serializable live snapshot of the NNS Governance economics parameters.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceEconomicsReport {
    /// Shared Governance query provenance.
    #[serde(flatten)]
    pub context: NnsGovernanceReportContext,
    /// Native Governance economics parameters.
    pub economics: NnsGovernanceEconomics,
}

///
/// NnsGovernanceEconomics
///
/// Native NNS Governance network economics parameters.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceEconomics {
    /// Minimum neuron stake in e8s.
    pub neuron_minimum_stake_e8s: u64,
    /// Maximum retained proposals per Governance topic.
    pub max_proposals_to_keep_per_topic: u32,
    /// Neuron-management proposal fee in e8s.
    pub neuron_management_fee_per_proposal_e8s: u64,
    /// Proposal rejection cost in e8s.
    pub reject_cost_e8s: u64,
    /// Ledger transaction fee in e8s.
    pub transaction_fee_e8s: u64,
    /// Spawned-neuron dissolve delay in seconds.
    pub neuron_spawn_dissolve_delay_seconds: u64,
    /// Raw minimum ICP/XDR rate.
    pub minimum_icp_xdr_rate: u64,
    /// Maximum node-provider rewards in e8s.
    pub maximum_node_provider_rewards_e8s: u64,
    /// Optional Neurons' Fund economics.
    pub neurons_fund_economics: Option<NnsNeuronsFundEconomics>,
    /// Optional voting-power economics.
    pub voting_power_economics: Option<NnsVotingPowerEconomics>,
}

///
/// NnsNeuronsFundEconomics
///
/// Native optional parameters governing Neurons' Fund participation.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsNeuronsFundEconomics {
    /// Maximum ICP/XDR rate.
    pub maximum_icp_xdr_rate: Option<NnsGovernancePercentage>,
    /// Matched-funding curve coefficients.
    pub neurons_fund_matched_funding_curve_coefficients:
        Option<NnsNeuronsFundMatchedFundingCurveCoefficients>,
    /// Maximum theoretical Neurons' Fund participation amount in XDR.
    pub max_theoretical_neurons_fund_participation_amount_xdr: Option<NnsGovernanceDecimal>,
    /// Minimum ICP/XDR rate.
    pub minimum_icp_xdr_rate: Option<NnsGovernancePercentage>,
}

///
/// NnsNeuronsFundMatchedFundingCurveCoefficients
///
/// Native decimal-string parameters for the Neurons' Fund matching curve.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsNeuronsFundMatchedFundingCurveCoefficients {
    /// Contribution threshold in XDR.
    pub contribution_threshold_xdr: Option<NnsGovernanceDecimal>,
    /// One-third participation milestone in XDR.
    pub one_third_participation_milestone_xdr: Option<NnsGovernanceDecimal>,
    /// Full participation milestone in XDR.
    pub full_participation_milestone_xdr: Option<NnsGovernanceDecimal>,
}

///
/// NnsGovernancePercentage
///
/// Native optional-basis-points percentage wrapper used by Governance.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernancePercentage {
    /// Percentage value in basis points when supplied.
    pub basis_points: Option<u64>,
}

///
/// NnsGovernanceDecimal
///
/// Native human-readable decimal wrapper used by Governance.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceDecimal {
    /// Decimal representation when supplied.
    pub human_readable: Option<String>,
}

///
/// NnsVotingPowerEconomics
///
/// Native optional parameters governing NNS neuron voting power.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsVotingPowerEconomics {
    /// Inactivity duration before voting power starts decreasing.
    pub start_reducing_voting_power_after_seconds: Option<u64>,
    /// Reduction duration after which following is cleared.
    pub clear_following_after_seconds: Option<u64>,
    /// Minimum dissolve delay required to vote.
    pub neuron_minimum_dissolve_delay_to_vote_seconds: Option<u64>,
}

///
/// NnsGovernanceMetricsReport
///
/// Serializable live snapshot of cached NNS Governance metrics.
///

#[derive(Clone, Debug, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceMetricsReport {
    /// Shared Governance query provenance.
    #[serde(flatten)]
    pub context: NnsGovernanceReportContext,
    /// Native Governance metrics.
    pub metrics: NnsGovernanceMetrics,
}

///
/// NnsGovernanceMetrics
///
/// Native cached metrics returned by the NNS Governance canister.
///

#[derive(Clone, Debug, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceMetrics {
    /// Total maturity in e8s-equivalent.
    pub total_maturity_e8s_equivalent: u64,
    /// Non-dissolving neuron stake buckets.
    pub not_dissolving_neurons_e8s_buckets: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Staked maturity of dissolving neurons in e8s-equivalent.
    pub dissolving_neurons_staked_maturity_e8s_equivalent_sum: u64,
    /// Number of garbage-collectable neurons.
    pub garbage_collectable_neurons_count: u64,
    /// Staked-maturity buckets for dissolving neurons.
    pub dissolving_neurons_staked_maturity_e8s_equivalent_buckets:
        Vec<NnsGovernanceMetricBucket<f64>>,
    /// Number of neurons with invalid stake.
    pub neurons_with_invalid_stake_count: u64,
    /// Count buckets for non-dissolving neurons.
    pub not_dissolving_neurons_count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Number of early-contributor-token neurons.
    pub ect_neuron_count: u64,
    /// Total ICP supply reported by Governance.
    pub total_supply_icp: u64,
    /// Number of neurons with less than six months dissolve delay.
    pub neurons_with_less_than_6_months_dissolve_delay_count: u64,
    /// Number of dissolved neurons.
    pub dissolved_neurons_count: u64,
    /// Community Fund maturity in e8s-equivalent.
    pub community_fund_total_maturity_e8s_equivalent: u64,
    /// Total seed-neuron stake in e8s.
    pub total_staked_e8s_seed: u64,
    /// Total staked maturity of early-contributor-token neurons.
    pub total_staked_maturity_e8s_equivalent_ect: u64,
    /// Total neuron stake in e8s.
    pub total_staked_e8s: u64,
    /// Number of non-dissolving neurons.
    pub not_dissolving_neurons_count: u64,
    /// Total locked stake in e8s.
    pub total_locked_e8s: u64,
    /// Number of active Neurons' Fund neurons.
    pub neurons_fund_total_active_neurons: u64,
    /// Voting power controlled by non-self-authenticating principals.
    pub total_voting_power_non_self_authenticating_controller: Option<u64>,
    /// Total staked maturity in e8s-equivalent.
    pub total_staked_maturity_e8s_equivalent: u64,
    /// Non-dissolving early-contributor-token neuron stake buckets.
    pub not_dissolving_neurons_e8s_buckets_ect: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Total stake of early-contributor-token neurons in e8s.
    pub total_staked_e8s_ect: u64,
    /// Staked maturity of non-dissolving neurons in e8s-equivalent.
    pub not_dissolving_neurons_staked_maturity_e8s_equivalent_sum: u64,
    /// Total dissolved-neuron stake in e8s.
    pub dissolved_neurons_e8s: u64,
    /// Stake controlled by non-self-authenticating principals.
    pub total_staked_e8s_non_self_authenticating_controller: Option<u64>,
    /// Dissolving seed-neuron stake buckets.
    pub dissolving_neurons_e8s_buckets_seed: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Stake of neurons with less than six months dissolve delay.
    pub neurons_with_less_than_6_months_dissolve_delay_e8s: u64,
    /// Staked-maturity buckets for non-dissolving neurons.
    pub not_dissolving_neurons_staked_maturity_e8s_equivalent_buckets:
        Vec<NnsGovernanceMetricBucket<f64>>,
    /// Count buckets for dissolving neurons.
    pub dissolving_neurons_count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Dissolving early-contributor-token neuron stake buckets.
    pub dissolving_neurons_e8s_buckets_ect: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Number of dissolving neurons.
    pub dissolving_neurons_count: u64,
    /// Dissolving neuron stake buckets.
    pub dissolving_neurons_e8s_buckets: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Total staked maturity of seed neurons.
    pub total_staked_maturity_e8s_equivalent_seed: u64,
    /// Total Community Fund stake in e8s.
    pub community_fund_total_staked_e8s: u64,
    /// Non-dissolving seed-neuron stake buckets.
    pub not_dissolving_neurons_e8s_buckets_seed: Vec<NnsGovernanceMetricBucket<f64>>,
    /// Governance metric collection timestamp in Unix seconds.
    pub timestamp_seconds: u64,
    /// Number of seed neurons.
    pub seed_neuron_count: u64,
    /// Number of spawning neurons.
    pub spawning_neurons_count: u64,
    /// Maturity disbursements currently in progress.
    pub total_maturity_disbursements_in_progress_e8s_equivalent: u64,
    /// Metrics for neurons controlled by non-self-authenticating principals.
    pub non_self_authenticating_controller_neuron_subset_metrics:
        Option<NnsGovernanceNeuronSubsetMetrics>,
    /// Metrics for publicly visible neurons.
    pub public_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
    /// Metrics for neurons with declining voting power.
    pub declining_voting_power_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
    /// Metrics for neurons that have fully lost voting power.
    pub fully_lost_voting_power_neuron_subset_metrics: Option<NnsGovernanceNeuronSubsetMetrics>,
}

///
/// NnsGovernanceNeuronSubsetMetrics
///
/// Native cached Governance metrics for one neuron subset.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceNeuronSubsetMetrics {
    /// Number of neurons in the subset.
    pub count: Option<u64>,
    /// Total subset stake in e8s.
    pub total_staked_e8s: Option<u64>,
    /// Total subset maturity in e8s-equivalent.
    pub total_maturity_e8s_equivalent: Option<u64>,
    /// Total subset staked maturity in e8s-equivalent.
    pub total_staked_maturity_e8s_equivalent: Option<u64>,
    /// Deprecated raw total voting power.
    pub total_voting_power: Option<u64>,
    /// Total deciding voting power.
    pub total_deciding_voting_power: Option<u64>,
    /// Total potential voting power.
    pub total_potential_voting_power: Option<u64>,
    /// Neuron-count buckets.
    pub count_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Stake buckets in e8s.
    pub staked_e8s_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Maturity buckets in e8s-equivalent.
    pub maturity_e8s_equivalent_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Staked-maturity buckets in e8s-equivalent.
    pub staked_maturity_e8s_equivalent_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Deprecated voting-power buckets.
    pub voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Deciding-voting-power buckets.
    pub deciding_voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
    /// Potential-voting-power buckets.
    pub potential_voting_power_buckets: Vec<NnsGovernanceMetricBucket<u64>>,
}

///
/// NnsGovernanceRewardEventReport
///
/// Serializable live snapshot of the latest NNS voting reward event.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceRewardEventReport {
    /// Shared Governance query provenance.
    #[serde(flatten)]
    pub context: NnsGovernanceReportContext,
    /// Latest native Governance reward event.
    pub reward_event: NnsGovernanceRewardEvent,
}

///
/// NnsGovernanceRewardEvent
///
/// Latest native NNS Governance voting reward event.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceRewardEvent {
    /// Rounds elapsed since the previous distribution when supplied.
    pub rounds_since_last_distribution: Option<u64>,
    /// Reward day after NNS genesis.
    pub day_after_genesis: u64,
    /// Actual reward-event timestamp in Unix seconds.
    pub actual_timestamp_seconds: u64,
    /// Total rewards available in e8s-equivalent.
    pub total_available_e8s_equivalent: u64,
    /// Rewards available in the latest round when supplied.
    pub latest_round_available_e8s_equivalent: Option<u64>,
    /// Rewards distributed in e8s-equivalent.
    pub distributed_e8s_equivalent: u64,
    /// Proposals settled by the event, in Governance order.
    pub settled_proposals: Vec<NnsGovernanceProposalId>,
}

///
/// NnsGovernanceProposalId
///
/// Native NNS Governance proposal identifier wrapper.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceProposalId {
    /// Governance proposal identifier.
    pub id: u64,
}

///
/// NnsGovernanceMaturityModulationReport
///
/// Serializable live snapshot of NNS maturity modulation.
///

#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceMaturityModulationReport {
    /// Shared Governance query provenance.
    #[serde(flatten)]
    pub context: NnsGovernanceReportContext,
    /// Current modulation when Governance supplies it.
    pub maturity_modulation: Option<NnsGovernanceMaturityModulation>,
}

///
/// NnsGovernanceMaturityModulation
///
/// Current native NNS Governance maturity-modulation value.
///

#[cfg_attr(feature = "host", derive(CandidType))]
#[derive(Clone, Debug, Eq, PartialEq, SerdeDeserialize, Serialize)]
pub struct NnsGovernanceMaturityModulation {
    /// Current signed modulation in permyriad when supplied.
    pub current_value_permyriad: Option<i32>,
    /// Last update timestamp in Unix seconds when supplied.
    pub updated_at_timestamp_seconds: Option<u64>,
}