abstract_cw4_stake/
msg.rs

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