cw4_stake/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::Uint128;
3
4use cw20::{Cw20ReceiveMsg, Denom};
5pub use cw_controllers::ClaimsResponse;
6use cw_utils::Duration;
7
8#[cw_serde]
9pub struct InstantiateMsg {
10    /// denom of the token to stake
11    pub denom: Denom,
12    pub tokens_per_weight: Uint128,
13    pub min_bond: Uint128,
14    pub unbonding_period: Duration,
15
16    // admin can only add/remove hooks, not change other parameters
17    pub admin: Option<String>,
18}
19
20#[cw_serde]
21pub enum ExecuteMsg {
22    /// Bond will bond all staking tokens sent with the message and update membership weight
23    Bond {},
24    /// Unbond will start the unbonding process for the given number of tokens.
25    /// The sender immediately loses weight from these tokens, and can claim them
26    /// back to his wallet after `unbonding_period`
27    Unbond { tokens: Uint128 },
28    /// Claim is used to claim your native tokens that you previously "unbonded"
29    /// after the contract-defined waiting period (eg. 1 week)
30    Claim {},
31
32    /// Change the admin
33    UpdateAdmin { admin: Option<String> },
34    /// Add a new hook to be informed of all membership changes. Must be called by Admin
35    AddHook { addr: String },
36    /// Remove a hook. Must be called by Admin
37    RemoveHook { addr: String },
38
39    /// This accepts a properly-encoded ReceiveMsg from a cw20 contract
40    Receive(Cw20ReceiveMsg),
41}
42
43#[cw_serde]
44pub enum ReceiveMsg {
45    /// Only valid cw20 message is to bond the tokens
46    Bond {},
47}
48
49#[cw_serde]
50#[derive(QueryResponses)]
51pub enum QueryMsg {
52    /// Claims shows the tokens in process of unbonding for this address
53    #[returns(cw_controllers::ClaimsResponse)]
54    Claims { address: String },
55    // Show the number of tokens currently staked by this address.
56    #[returns(StakedResponse)]
57    Staked { address: String },
58
59    #[returns(cw_controllers::AdminResponse)]
60    Admin {},
61    #[returns(cw4::TotalWeightResponse)]
62    TotalWeight {},
63    #[returns(cw4::MemberListResponse)]
64    ListMembers {
65        start_after: Option<String>,
66        limit: Option<u32>,
67    },
68    #[returns(cw4::MemberResponse)]
69    Member {
70        addr: String,
71        at_height: Option<u64>,
72    },
73    /// Shows all registered hooks.
74    #[returns(cw_controllers::HooksResponse)]
75    Hooks {},
76}
77
78#[cw_serde]
79pub struct StakedResponse {
80    pub stake: Uint128,
81    pub denom: Denom,
82}