near_api_types/
stake.rs

1use near_account_id::AccountId;
2use near_token::NearToken;
3use serde::{Deserialize, Serialize};
4
5/// Aggregate information about the staking pool.
6///
7/// The type is related to the [StakingPool](https://github.com/near/core-contracts/tree/master/staking-pool) smart contract.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub struct StakingPoolInfo {
10    /// The validator that is running the pool.
11    pub validator_id: AccountId,
12    /// The fee that is taken by the pool contract.
13    pub fee: Option<RewardFeeFraction>,
14    /// The number of delegators on the pool.
15    pub delegators: Option<u64>,
16    /// The total staked balance on the pool (by all delegators).
17    pub stake: NearToken,
18}
19
20/// The reward fee that is taken by the pool contract.
21///
22/// This represents the percentage of the reward that is taken by the pool contract.
23/// The type is a part of the [StakingPool](https://github.com/near/core-contracts/tree/master/staking-pool) interface
24///
25/// The fraction is equal to numerator/denominator, e.g. 3/1000 = 0.3%
26#[derive(Debug, Clone, PartialEq, Default, Eq, Serialize, Deserialize)]
27pub struct RewardFeeFraction {
28    /// The numerator of the fraction.
29    pub numerator: u32,
30    /// The denominator of the fraction.
31    pub denominator: u32,
32}
33
34/// The total user balance on a pool contract
35///
36/// The type is related to the [StakingPool](https://github.com/near/core-contracts/tree/master/staking-pool) smart contract.
37#[derive(Debug, Clone, PartialEq, Default, Eq, Serialize, Deserialize)]
38pub struct UserStakeBalance {
39    /// The balance that currently is staked. The user can't withdraw this balance until `unstake` is called
40    /// and withdraw period is over.
41    pub staked: NearToken,
42    /// The balance that is not staked. The user can start withdrawing this balance. Some pools
43    /// have a withdraw period.
44    pub unstaked: NearToken,
45    /// The total balance of the user on a contract (staked + unstaked)
46    pub total: NearToken,
47}