sui_json_rpc_types/
sui_governance.rs1use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use serde_with::serde_as;
7use sui_types::base_types::{AuthorityName, EpochId, ObjectID, SuiAddress};
8use sui_types::committee::{Committee, StakeUnit};
9use sui_types::sui_serde::BigInt;
10
11#[serde_as]
13#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
14#[serde(rename = "CommitteeInfo")]
15pub struct SuiCommittee {
16 #[schemars(with = "BigInt<u64>")]
17 #[serde_as(as = "BigInt<u64>")]
18 pub epoch: EpochId,
19 #[schemars(with = "Vec<(AuthorityName, BigInt<u64>)>")]
20 #[serde_as(as = "Vec<(_, BigInt<u64>)>")]
21 pub validators: Vec<(AuthorityName, StakeUnit)>,
22}
23
24impl From<Committee> for SuiCommittee {
25 fn from(committee: Committee) -> Self {
26 Self {
27 epoch: committee.epoch,
28 validators: committee.voting_rights,
29 }
30 }
31}
32
33#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
34#[serde(rename_all = "camelCase")]
35pub struct DelegatedStake {
36 pub validator_address: SuiAddress,
38 pub staking_pool: ObjectID,
40 pub stakes: Vec<Stake>,
41}
42
43#[serde_as]
44#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
45#[serde(tag = "status")]
46pub enum StakeStatus {
47 Pending,
48 #[serde(rename_all = "camelCase")]
49 Active {
50 #[schemars(with = "BigInt<u64>")]
51 #[serde_as(as = "BigInt<u64>")]
52 estimated_reward: u64,
53 },
54 Unstaked,
55}
56
57#[serde_as]
58#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
59#[serde(rename_all = "camelCase")]
60pub struct Stake {
61 pub staked_sui_id: ObjectID,
63 #[schemars(with = "BigInt<u64>")]
64 #[serde_as(as = "BigInt<u64>")]
65 pub stake_request_epoch: EpochId,
66 #[schemars(with = "BigInt<u64>")]
67 #[serde_as(as = "BigInt<u64>")]
68 pub stake_active_epoch: EpochId,
69 #[schemars(with = "BigInt<u64>")]
70 #[serde_as(as = "BigInt<u64>")]
71 pub principal: u64,
72 #[serde(flatten)]
73 pub status: StakeStatus,
74}
75
76#[serde_as]
77#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
78pub struct ValidatorApys {
79 pub apys: Vec<ValidatorApy>,
80 #[schemars(with = "BigInt<u64>")]
81 #[serde_as(as = "BigInt<u64>")]
82 pub epoch: EpochId,
83}
84
85#[serde_as]
86#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
87pub struct ValidatorApy {
88 pub address: SuiAddress,
89 pub apy: f64,
90}