1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{Binary, Coin, Decimal, HumanAddr, Uint128}; use cw20::Expiration; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InitMsg { /// name of the derivative token pub name: String, /// symbol / ticker of the derivative token pub symbol: String, /// decimal places of the derivative token (for UI) pub decimals: u8, /// This is the validator that all tokens will be bonded to pub validator: HumanAddr, /// this is how much the owner takes as a cut when someone unbonds pub exit_tax: Decimal, /// This is the minimum amount we will pull out to reinvest, as well as a minumum /// that can be unbonded (to avoid needless staking tx) pub min_withdrawal: Uint128, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum HandleMsg { /// Bond will bond all staking tokens sent with the message and release derivative tokens Bond {}, /// Unbond will "burn" the given amount of derivative tokens and send the unbonded /// staking tokens to the message sender (after exit tax is deducted) Unbond { amount: Uint128 }, /// Claim is used to claim your native tokens that you previously "unbonded" /// after the chain-defined waiting period (eg. 3 weeks) Claim {}, /// Reinvest will check for all accumulated rewards, withdraw them, and /// re-bond them to the same validator. Anyone can call this, which updates /// the value of the token (how much under custody). Reinvest {}, /// _BondAllTokens can only be called by the contract itself, after all rewards have been /// withdrawn. This is an example of using "callbacks" in message flows. /// This can only be invoked by the contract itself as a return from Reinvest _BondAllTokens {}, /// Implements CW20. Transfer is a base message to move tokens to another account without triggering actions Transfer { recipient: HumanAddr, amount: Uint128, }, /// Implements CW20. Burn is a base message to destroy tokens forever Burn { amount: Uint128 }, /// Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action /// on the receiving contract. Send { contract: HumanAddr, amount: Uint128, msg: Option<Binary>, }, /// Implements CW20 "approval" extension. Allows spender to access an additional amount tokens /// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance /// expiration with this one. IncreaseAllowance { spender: HumanAddr, amount: Uint128, expires: Option<Expiration>, }, /// Implements CW20 "approval" extension. Lowers the spender's access of tokens /// from the owner's (env.sender) account by amount. If expires is Some(), overwrites current /// allowance expiration with this one. DecreaseAllowance { spender: HumanAddr, amount: Uint128, expires: Option<Expiration>, }, /// Implements CW20 "approval" extension. Transfers amount tokens from owner -> recipient /// if `env.sender` has sufficient pre-approval. TransferFrom { owner: HumanAddr, recipient: HumanAddr, amount: Uint128, }, /// Implements CW20 "approval" extension. Sends amount tokens from owner -> contract /// if `env.sender` has sufficient pre-approval. SendFrom { owner: HumanAddr, contract: HumanAddr, amount: Uint128, msg: Option<Binary>, }, /// Implements CW20 "approval" extension. Destroys tokens forever BurnFrom { owner: HumanAddr, amount: Uint128 }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { /// Claims shows the number of tokens this address can access when they are done unbonding Claims { address: HumanAddr }, /// Investment shows metadata on the staking info of the contract Investment {}, /// Implements CW20. Returns the current balance of the given address, 0 if unset. Balance { address: HumanAddr }, /// Implements CW20. Returns metadata on the contract - name, decimals, supply, etc. TokenInfo {}, /// Implements CW20 "allowance" extension. /// Returns how much spender can use from owner account, 0 if unset. Allowance { owner: HumanAddr, spender: HumanAddr, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct ClaimsResponse { pub claims: Uint128, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InvestmentResponse { pub token_supply: Uint128, pub staked_tokens: Coin, // ratio of staked_tokens / token_supply (or how many native tokens that one derivative token is nominally worth) pub nominal_value: Decimal, /// owner created the contract and takes a cut pub owner: HumanAddr, /// this is how much the owner takes as a cut when someone unbonds pub exit_tax: Decimal, /// All tokens are bonded to this validator pub validator: HumanAddr, /// This is the minimum amount we will pull out to reinvest, as well as a minumum /// that can be unbonded (to avoid needless staking tx) pub min_withdrawal: Uint128, }