astro4nit/
generator.rs

1use cosmwasm_std::{Addr, Decimal, Uint128, Uint64};
2use cw20::Cw20ReceiveMsg;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// ## Description
7/// This structure describes the parameters used for creating a contract.
8#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
9pub struct InstantiateMsg {
10    /// Address that can change contract settings
11    pub owner: String,
12    /// ASTRO token contract address
13    pub astro_token: String,
14    /// Amount of ASTRO distributed per block among all pairs
15    pub tokens_per_block: Uint128,
16    /// Start block for distributing ASTRO
17    pub start_block: Uint64,
18    /// Dual rewards proxy contracts allowed to interact with the generator
19    pub allowed_reward_proxies: Vec<String>,
20    /// The ASTRO vesting contract that drips ASTRO rewards
21    pub vesting_contract: String,
22}
23
24#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
25#[serde(rename_all = "snake_case")]
26pub enum ExecuteMsg {
27    /// ## Description
28    /// Update the address of the ASTRO vesting contract
29    /// ## Executor
30    /// Only the owner can execute it
31    UpdateConfig {
32        /// The new vesting contract address
33        vesting_contract: Option<String>,
34    },
35    /// ## Description
36    /// Add a new generator for a LP token
37    /// ## Executor
38    /// Only the owner can execute this
39    Add {
40        /// The LP token contract address
41        lp_token: String,
42        /// The slice of ASTRO emissions this generator gets
43        alloc_point: Uint64,
44        /// This flag determines whether the pool gets 3rd party token rewards
45        has_asset_rewards: bool,
46        /// The address of the 3rd party reward proxy contract
47        reward_proxy: Option<String>,
48    },
49    /// ## Description
50    /// Update the given pool's ASTRO allocation slice
51    /// ## Executor
52    /// Only the owner can execute this.
53    Set {
54        /// The address of the LP token contract address whose allocation we change
55        lp_token: String,
56        /// The new allocation
57        alloc_point: Uint64,
58        /// This flag determines whether the pool gets 3rd party token rewards
59        has_asset_rewards: bool,
60    },
61    /// ## Description
62    /// Updates reward variables for multiple pools
63    MassUpdatePools {},
64    /// ## Description
65    /// Updates reward variables for a specific pool
66    UpdatePool {
67        /// the LP token contract address
68        lp_token: String,
69    },
70    /// ## Description
71    /// Withdraw LP tokens from the Generator
72    Withdraw {
73        /// The address of the LP token to withdraw
74        lp_token: String,
75        /// The amount to withdraw
76        amount: Uint128,
77    },
78    /// ## Description
79    /// Withdraw LP tokens from the Generator without withdrawing outstanding rewards
80    EmergencyWithdraw {
81        /// The address of the LP token to withdraw
82        lp_token: String,
83    },
84    /// ## Description
85    /// Allowed reward proxy contracts that can interact with the Generator
86    SetAllowedRewardProxies {
87        /// The full list of allowed proxy contracts
88        proxies: Vec<String>,
89    },
90    /// ## Description
91    /// Sends orphan proxy rewards (which were left behind after emergency withdrawals) to another address
92    SendOrphanProxyReward {
93        /// The transfer recipient
94        recipient: String,
95        /// The address of the LP token contract for which we send orphaned rewards
96        lp_token: String,
97    },
98    /// ## Description
99    /// Receives a message of type [`Cw20ReceiveMsg`]
100    Receive(Cw20ReceiveMsg),
101    /// ## Description
102    /// Set a new amount of ASTRO to distribute per block
103    /// ## Executor
104    /// Only the owner can execute this.
105    SetTokensPerBlock {
106        /// The new amount of ASTRO to distro per block
107        amount: Uint128,
108    },
109    /// ## Description
110    /// Creates a request to change contract ownership
111    /// ## Executor
112    /// Only the current owner can execute this.
113    ProposeNewOwner {
114        /// The newly proposed owner
115        owner: String,
116        /// The validity period of the proposal to change the contract owner
117        expires_in: u64,
118    },
119    /// ## Description
120    /// Removes a request to change contract ownership
121    /// ## Executor
122    /// Only the current owner can execute this
123    DropOwnershipProposal {},
124    /// ## Description
125    /// Claims contract ownership
126    /// ## Executor
127    /// Only the newly proposed owner can execute this
128    ClaimOwnership {},
129}
130
131#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
132#[serde(rename_all = "snake_case")]
133pub enum QueryMsg {
134    /// PoolLength returns the length of the array that contains all the instantiated pool generators
135    PoolLength {},
136    /// Deposit returns the LP token amount deposited in a specific generator
137    Deposit { lp_token: String, user: String },
138    /// PendingToken returns the amount of rewards that can be claimed by an account that deposited a specific LP token in a generator
139    PendingToken { lp_token: String, user: String },
140    /// Config returns the main contract parameters
141    Config {},
142    /// RewardInfo returns reward information for a specified LP token
143    RewardInfo { lp_token: String },
144    /// OrphanProxyRewards returns orphaned reward information for the specified LP token
145    OrphanProxyRewards { lp_token: String },
146    /// PoolInfo returns information about a pool associated with the specified LP token alongside
147    /// the total pending amount of ASTRO and proxy rewards claimable by generator stakers (for that LP token)
148    PoolInfo { lp_token: String },
149    /// SimulateFutureReward returns the amount of ASTRO that will be distributed until a future block and for a specific generator
150    SimulateFutureReward { lp_token: String, future_block: u64 },
151}
152
153/// ## Description
154/// This structure holds the response returned when querying the total length of the array that keeps track of instantiated generators
155#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
156pub struct PoolLengthResponse {
157    pub length: usize,
158}
159
160/// ## Description
161/// This structure holds the response returned when querying the amount of pending rewards that can be withdrawn from a 3rd party
162/// rewards contract
163#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
164pub struct PendingTokenResponse {
165    /// The amount of pending ASTRO
166    pub pending: Uint128,
167    /// The amount of pending 3rd party reward tokens
168    pub pending_on_proxy: Option<Uint128>,
169}
170
171/// ## Description
172/// This structure holds the response returned when querying for the token addresses used to reward a specific generator
173#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
174pub struct RewardInfoResponse {
175    /// The address of the base reward token
176    pub base_reward_token: Addr,
177    /// The address of the 3rd party reward token
178    pub proxy_reward_token: Option<Addr>,
179}
180
181/// ## Description
182/// This structure holds the response returned when querying for a pool's information
183#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
184pub struct PoolInfoResponse {
185    /// The slice of ASTRO that this pool's generator gets per block
186    pub alloc_point: Uint64,
187    /// Amount of ASTRO tokens being distributed per block to this LP pool
188    pub astro_tokens_per_block: Uint128,
189    /// The last block when token emissions were snapshotted (distributed)
190    pub last_reward_block: u64,
191    /// Current block number. Useful for computing APRs off-chain
192    pub current_block: u64,
193    /// Total amount of ASTRO rewards already accumulated per LP token staked
194    pub accumulated_rewards_per_share: Decimal,
195    /// Pending amount of total ASTRO rewards which are claimable by stakers right now
196    pub pending_astro_rewards: Uint128,
197    /// The address of the 3rd party reward proxy contract
198    pub reward_proxy: Option<Addr>,
199    /// Pending amount of total proxy rewards which are claimable by stakers right now
200    pub pending_proxy_rewards: Option<Uint128>,
201    /// Total amount of 3rd party token rewards already accumulated per LP token staked
202    pub accumulated_proxy_rewards_per_share: Decimal,
203    /// Reward balance for the dual rewards proxy before updating accrued rewards
204    pub proxy_reward_balance_before_update: Uint128,
205    /// The amount of orphan proxy rewards which are left behind by emergency withdrawals and not yet transferred out
206    pub orphan_proxy_rewards: Uint128,
207    /// Total amount of lp tokens staked in the pool's generator
208    pub lp_supply: Uint128,
209}
210
211/// ## Description
212/// This structure holds the response returned when querying the contract for general parameters
213#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
214pub struct ConfigResponse {
215    /// Address that's allowed to change contract parameters
216    pub owner: Addr,
217    /// ASTRO token contract address
218    pub astro_token: Addr,
219    /// Total amount of ASTRO distributed per block
220    pub tokens_per_block: Uint128,
221    /// Sum of total allocation points across all active generators
222    pub total_alloc_point: Uint64,
223    /// Start block for ASTRO incentives
224    pub start_block: Uint64,
225    /// List of 3rd party reward proxies allowed to interact with the Generator contract
226    pub allowed_reward_proxies: Vec<Addr>,
227    /// The ASTRO vesting contract address
228    pub vesting_contract: Addr,
229}
230
231/// ## Description
232/// This structure describes a migration message.
233#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
234pub struct MigrateMsg {}
235
236/// ## Description
237/// This structure describes custom hooks for the CW20.
238#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
239#[serde(rename_all = "snake_case")]
240pub enum Cw20HookMsg {
241    /// Deposit performs a token deposit on behalf of the message sender.
242    Deposit {},
243    /// DepositFor performs a token deposit on behalf of another address that's not the message sender.
244    DepositFor(Addr),
245}