cw20_staking/
state.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{Addr, Decimal, Uint128};
5use cw_controllers::Claims;
6use cw_storage_plus::Item;
7use cw_utils::Duration;
8
9pub const CLAIMS: Claims = Claims::new("claims");
10
11/// Investment info is fixed at instantiation, and is used to control the function of the contract
12#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13pub struct InvestmentInfo {
14    /// Owner created the contract and takes a cut
15    pub owner: Addr,
16    /// This is the denomination we can stake (and only one we accept for payments)
17    pub bond_denom: String,
18    /// This is the unbonding period of the native staking module
19    /// We need this to only allow claims to be redeemed after the money has arrived
20    pub unbonding_period: Duration,
21    /// This is how much the owner takes as a cut when someone unbonds
22    pub exit_tax: Decimal,
23    /// All tokens are bonded to this validator
24    /// FIXME: address validation doesn't work for validator addresses
25    pub validator: String,
26    /// This is the minimum amount we will pull out to reinvest, as well as a minimum
27    /// that can be unbonded (to avoid needless staking tx)
28    pub min_withdrawal: Uint128,
29}
30
31/// Supply is dynamic and tracks the current supply of staked and ERC20 tokens.
32#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)]
33pub struct Supply {
34    /// issued is how many derivative tokens this contract has issued
35    pub issued: Uint128,
36    /// bonded is how many native tokens exist bonded to the validator
37    pub bonded: Uint128,
38    /// claims is how many tokens need to be reserved paying back those who unbonded
39    pub claims: Uint128,
40}
41
42pub const INVESTMENT: Item<InvestmentInfo> = Item::new("invest");
43pub const TOTAL_SUPPLY: Item<Supply> = Item::new("total_supply");