github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/dev/wasm/cw4-stake/README.md (about)

     1  # CW4 Stake
     2  
     3  This is a second implementation of the [cw4 spec](../../packages/cw4/README.md).
     4  It fulfills all elements of the spec, including the raw query lookups,
     5  and is designed to be used as a backing storage for 
     6  [cw3 compliant contracts](../../packages/cw3/README.md).
     7  
     8  It provides a similar API to [`cw4-group`] (which handles elected membership),
     9  but rather than appointing members (by admin or multisig), their
    10  membership and weight are based on the number of tokens they have staked.
    11  This is similar to many DAOs.
    12  
    13  Only one denom can be bonded with both `min_bond` as the minimum amount
    14  that must be sent by one address to enter, as well as `tokens_per_weight`,
    15  which can be used to normalize the weight (eg. if the token is uatom
    16  and you want 1 weight per ATOM, you can set `tokens_per_weight = 1_000_000`).
    17  
    18  There is also an unbonding period (`Duration`) which sets how long the
    19  tokens are frozen before being released. These frozen tokens can neither
    20  be used for voting, nor claimed by the original owner. Only after the period
    21  can you get your tokens back. This liquidity loss is the "skin in the game"
    22  provided by staking to this contract.
    23  
    24  ## Instantiation
    25  
    26  **TODO**
    27  
    28  To create it, you must pass in a list of members, as well as an optional
    29  `admin`, if you wish it to be mutable.
    30  
    31  ```rust
    32  pub struct InstantiateMsg {
    33      /// denom of the token to stake
    34      pub stake: String,
    35      pub tokens_per_weight: u64,
    36      pub min_bond: Uint128,
    37      pub unbonding_period: Duration,
    38  }
    39  ```
    40  
    41  Members are defined by an address and a weight. This is transformed
    42  and stored under their `CanonicalAddr`, in a format defined in
    43  [cw4 raw queries](../../packages/cw4/README.md#raw).
    44  
    45  Note that 0 *is an allowed weight*. This doesn't give any voting rights, 
    46  but it does define this address is part of the group, which may be
    47  meaningful in some circumstances.
    48  
    49  The weights of the members will be computed as the funds they send 
    50  (in tokens) divided by `tokens_per_weight`, rounded down to the nearest
    51  whole number (i.e. using integer division). If the total sent is less than
    52  `min_bond`, the stake will remain, but they will not be counted as a
    53  member. If `min_bond` is higher than `tokens_per_weight`, you cannot
    54  have any member with 0 weight.
    55  
    56  ## Messages
    57  
    58  Most messages and queries are defined by the 
    59  [cw4 spec](../../packages/cw4/README.md). Please refer to it for more info.
    60  
    61  The following messages have been added to handle un/staking tokens:
    62  
    63  `Bond{}` - bond all staking tokens sent with the message and update membership weight
    64  
    65  `Unbond{tokens}` - starts the unbonding process for the given number 
    66    of tokens. The sender immediately loses weight from these tokens,
    67    and can claim them back to his wallet after `unbonding_period`
    68  
    69  `Claim{}` -  used to claim your native tokens that you previously "unbonded"
    70    after the contract-defined waiting period (eg. 1 week)
    71  
    72  And the corresponding queries:
    73  
    74  `Claims{address}` - Claims shows the tokens in process of unbonding
    75      for this address
    76  
    77  `Staked{address}` - Show the number of tokens currently staked by this address.