Skip to main content

liquid_finance/staking/
query_msg.rs

1use cosmwasm_std::{Uint128, Decimal, Coin};
2use cosmwasm_schema::QueryResponses;
3use cw20::BalanceResponse;
4use cw_utils::Expiration;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8use crate::staking_linked_list::{LinkedList, NodeWithId};
9use super::init_msg::DelegationPercentage;
10
11#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema, QueryResponses)]
12#[serde(rename_all = "snake_case")]
13pub enum QueryMsg {
14    /// Returns the amount of native token the address can claim. Returns "0" if the address is
15    /// unknown to the contract.
16    #[returns(BalanceResponse)]
17    ClaimableOf { address: String },
18    /// Returns the configuration of the contract.
19    #[returns(ConfigResponse)]
20    ConfigInfo {},
21    /// Returns the staking status of the contract.
22    #[returns(StatusResponse)]
23    StatusInfo {},
24    /// Returns the first 50 nodes in the unstaking queue of the contract.
25    #[returns(UnstakingQueueResponse)]
26    UnstakingQueue {},
27    /// Returns the total amount of native token the address has in the unstaking queue.
28    #[returns(BalanceResponse)]
29    UnderUnstakingOf { address: String },
30    /// Returns the limit status of the contract.
31    #[returns(LimitResponse)]
32    LimitInfo {},
33    /// Returns the unclaimed staking rewards.
34    #[returns(UnclaimedRewardsResponse)]
35    UnclaimedRewards {},
36}
37
38#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
39pub struct ConfigResponse {
40    /// Should be multi-sig, is able to update the config
41    pub admin: String,
42    /// Should be single-sig, is able to pause the contract
43    pub pause_admin: String,
44    /// This is the denomination we can stake (and only one we accept for payments)
45    pub bond_denom: String,
46    /// Liquid token address
47    pub liquid_token_addr: String,
48    /// Swap contract address
49    pub swap_contract_addr: String,
50    /// Liquid Treasury contract address
51    pub treasury_contract_addr: String,
52    /// Team wallet address
53    pub team_wallet_addr: String,
54    /// percentage of commission taken off of staking rewards
55    pub commission_percentage: u16,
56    /// percentage of rewards for the team
57    pub team_percentage: u16,
58    /// percentage of rewards for the liquidity providers
59    pub liquidity_percentage: u16,
60    /// Delegations preferences for a whitelist of validators, each validator has a delegation percentage
61    pub delegations: Vec<DelegationPercentage>,
62    /// contract state (active/paused)
63    pub contract_state: bool,
64}
65
66#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
67pub struct StatusResponse {
68    /// issued is how many derivative tokens this contract has issued
69    pub issued: Uint128,
70    /// native is how many total supply of native tokens liquid token holders can withdraw
71    pub native: Coin,
72    /// unstakings is how many total native tokens in unstaking queue
73    pub unstakings: Uint128,
74    /// claims is how many tokens need to be reserved paying back those who unbonded
75    pub claims: Uint128,
76    /// bonded is how many native tokens exist bonded to the validator
77    pub bonded: Uint128,
78    /// available native token balance of this contract
79    pub balance: Uint128,
80    /// ratio of native / issued (or how many native tokens that one derivative token is nominally worth)
81    pub ratio: Decimal,
82}
83
84#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
85pub struct UnstakingQueueResponse {
86    pub state: LinkedList,
87    pub queue: Vec<NodeWithId>,
88}
89
90#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
91pub struct LimitResponse {
92    /// current max unstake processing amount allowed in the period
93    pub maximum_processed: Uint128,
94    // total processed amount for the current period
95    pub current_processed: Uint128,
96    // the minimum number of blocks between each unstake processing limit period
97    pub processed_time: u64,
98    // current_processed reset to 0 after this period
99    pub processed_period: Expiration,
100    /// the minimum number of blocks between each contract unstaking request
101    pub unstaking_time: u64,
102    /// contract can only call unbound after this period
103    pub unstaking_period: Expiration,
104    /// current max amount of liquid token can be minted
105    pub mint_cap: Uint128,
106}
107
108#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
109pub struct UnclaimedRewardsResponse {
110    /// the unclaimed rewards for the team
111    pub team_portion: Uint128,
112    /// the unclaimed rewards for liquidity providers
113    pub liquidity_portion: Uint128,
114    /// the unclaimed rewards for treasury
115    pub treasury_portion: Uint128,
116    // the unclaimed rewards for liquid token holders
117    pub staking_pool: Uint128,
118}