Skip to main content

anchor_token/
staking.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{Decimal, Uint128};
5use cw20::Cw20ReceiveMsg;
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8pub struct InstantiateMsg {
9    pub anchor_token: String,
10    pub staking_token: String, // lp token of ANC-UST pair contract
11    pub distribution_schedule: Vec<(u64, u64, Uint128)>,
12}
13
14#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
15#[serde(rename_all = "snake_case")]
16pub enum ExecuteMsg {
17    Receive(Cw20ReceiveMsg),
18    Unbond {
19        amount: Uint128,
20    },
21    /// Withdraw pending rewards
22    Withdraw {},
23    /// Owner operation to stop distribution on current staking contract
24    /// and send remaining tokens to the new contract
25    MigrateStaking {
26        new_staking_contract: String,
27    },
28    UpdateConfig {
29        distribution_schedule: Vec<(u64, u64, Uint128)>,
30    },
31}
32
33#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
34#[serde(rename_all = "snake_case")]
35pub enum Cw20HookMsg {
36    Bond {},
37}
38
39/// migrate struct for distribution schedule
40/// block-based schedule to a time-based schedule
41#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
42pub struct MigrateMsg {}
43
44#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub enum QueryMsg {
47    Config {},
48    State {
49        block_time: Option<u64>,
50    },
51    StakerInfo {
52        staker: String,
53        block_time: Option<u64>,
54    },
55}
56
57// We define a custom struct for each query response
58#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
59pub struct ConfigResponse {
60    pub anchor_token: String,
61    pub staking_token: String,
62    pub distribution_schedule: Vec<(u64, u64, Uint128)>,
63}
64
65// We define a custom struct for each query response
66#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
67pub struct StateResponse {
68    pub last_distributed: u64,
69    pub total_bond_amount: Uint128,
70    pub global_reward_index: Decimal,
71}
72
73// We define a custom struct for each query response
74#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
75pub struct StakerInfoResponse {
76    pub staker: String,
77    pub reward_index: Decimal,
78    pub bond_amount: Uint128,
79    pub pending_reward: Uint128,
80}