mars_core/
ma_token.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::Addr;
5
6#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
7pub struct Config {
8    pub red_bank_address: Addr,
9    pub incentives_address: Addr,
10}
11
12pub mod msg {
13    use cosmwasm_std::{Binary, Uint128};
14    use cw20::{Cw20Coin, Expiration, Logo, MinterResponse};
15    use cw20_base::msg::InstantiateMarketingInfo;
16    use schemars::JsonSchema;
17    use serde::{Deserialize, Serialize};
18
19    #[derive(Serialize, Deserialize, JsonSchema)]
20    pub struct InstantiateMsg {
21        // cw20_base params
22        pub name: String,
23        pub symbol: String,
24        pub decimals: u8,
25        pub initial_balances: Vec<Cw20Coin>,
26        pub mint: Option<MinterResponse>,
27        pub marketing: Option<InstantiateMarketingInfo>,
28
29        // custom_params
30        pub init_hook: Option<InitHook>,
31        pub red_bank_address: String,
32        pub incentives_address: String,
33    }
34
35    /// Hook to be called after token initialization
36    #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
37    pub struct InitHook {
38        pub msg: Binary,
39        pub contract_addr: String,
40    }
41
42    #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
43    #[serde(rename_all = "snake_case")]
44    pub enum ExecuteMsg {
45        /// Transfer is a base message to move tokens to another account. Requires to be finalized
46        /// by the money market.
47        Transfer { recipient: String, amount: Uint128 },
48
49        /// Forced transfer called by the money market when an account is being liquidated
50        TransferOnLiquidation {
51            sender: String,
52            recipient: String,
53            amount: Uint128,
54        },
55
56        /// Burns tokens from user. Only money market can call this.
57        /// Used when user is being liquidated
58        Burn { user: String, amount: Uint128 },
59
60        /// Send is a base message to transfer tokens to a contract and trigger an action
61        /// on the receiving contract.
62        Send {
63            contract: String,
64            amount: Uint128,
65            msg: Binary,
66        },
67
68        /// Only with the "mintable" extension. If authorized, creates amount new tokens
69        /// and adds to the recipient balance.
70        Mint { recipient: String, amount: Uint128 },
71
72        /// Only with "approval" extension. Allows spender to access an additional amount tokens
73        /// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance
74        /// expiration with this one.
75        IncreaseAllowance {
76            spender: String,
77            amount: Uint128,
78            expires: Option<Expiration>,
79        },
80        /// Only with "approval" extension. Lowers the spender's access of tokens
81        /// from the owner's (env.sender) account by amount. If expires is Some(), overwrites current
82        /// allowance expiration with this one.
83        DecreaseAllowance {
84            spender: String,
85            amount: Uint128,
86            expires: Option<Expiration>,
87        },
88        /// Only with "approval" extension. Transfers amount tokens from owner -> recipient
89        /// if `env.sender` has sufficient pre-approval.
90        TransferFrom {
91            owner: String,
92            recipient: String,
93            amount: Uint128,
94        },
95        /// Only with "approval" extension. Sends amount tokens from owner -> contract
96        /// if `info.sender` has sufficient pre-approval.
97        SendFrom {
98            owner: String,
99            contract: String,
100            amount: Uint128,
101            msg: Binary,
102        },
103        /// Only with the "marketing" extension. If authorized, updates marketing metadata.
104        /// Setting None/null for any of these will leave it unchanged.
105        /// Setting Some("") will clear this field on the contract storage
106        UpdateMarketing {
107            /// A URL pointing to the project behind this token.
108            project: Option<String>,
109            /// A longer description of the token and it's utility. Designed for tooltips or such
110            description: Option<String>,
111            /// The address (if any) who can update this data structure
112            marketing: Option<String>,
113        },
114        /// If set as the "marketing" role on the contract, upload a new URL, SVG, or PNG for the token
115        UploadLogo(Logo),
116    }
117
118    #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
119    #[serde(rename_all = "snake_case")]
120    pub enum QueryMsg {
121        /// Returns the current balance of the given address, 0 if unset.
122        /// Return type: BalanceResponse.
123        Balance {
124            address: String,
125        },
126        /// Returns both balance (0 if unset) and total supply
127        /// Used by incentives contract when computing unclaimed rewards
128        /// Return type: BalanceAndTotalSupplyResponse
129        BalanceAndTotalSupply {
130            address: String,
131        },
132        /// Returns metadata on the contract - name, decimals, supply, etc.
133        /// Return type: TokenInfoResponse.
134        TokenInfo {},
135        Minter {},
136        /// Only with "allowance" extension.
137        /// Returns how much spender can use from owner account, 0 if unset.
138        /// Return type: AllowanceResponse.
139        Allowance {
140            owner: String,
141            spender: String,
142        },
143        /// Only with "enumerable" extension (and "allowances")
144        /// Returns all allowances this owner has approved. Supports pagination.
145        /// Return type: AllAllowancesResponse.
146        AllAllowances {
147            owner: String,
148            start_after: Option<String>,
149            limit: Option<u32>,
150        },
151        /// Only with "enumerable" extension
152        /// Returns all accounts that have balances. Supports pagination.
153        /// Return type: AllAccountsResponse.
154        AllAccounts {
155            start_after: Option<String>,
156            limit: Option<u32>,
157        },
158        /// Only with "marketing" extension
159        /// Returns more metadata on the contract to display in the client:
160        /// - description, logo, project url, etc.
161        /// Return type: MarketingInfoResponse
162        MarketingInfo {},
163        /// Only with "marketing" extension
164        /// Downloads the mbeded logo data (if stored on chain). Errors if no logo data ftored for this
165        /// contract.
166        /// Return type: DownloadLogoResponse.
167        DownloadLogo {},
168        /// Returns the underlying asset amount for given address.
169        /// Return type: BalanceResponse.
170        UnderlyingAssetBalance {
171            address: String,
172        },
173    }
174
175    #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
176    pub struct BalanceAndTotalSupplyResponse {
177        pub balance: Uint128,
178        pub total_supply: Uint128,
179    }
180}