elys_std/types/elys/
estaking.rs

1use elys_std_deriv::CosmwasmExt;
2/// DexRewardsTracker is used for tracking rewards for stakers and LPs, all
3/// amount here is in USDC
4#[allow(clippy::derive_partial_eq_without_eq)]
5#[derive(
6    Clone,
7    PartialEq,
8    Eq,
9    ::prost::Message,
10    ::serde::Serialize,
11    ::serde::Deserialize,
12    ::schemars::JsonSchema,
13    CosmwasmExt,
14)]
15#[proto_message(type_url = "/elys.estaking.DexRewardsTracker")]
16pub struct DexRewardsTracker {
17    /// Number of blocks since start of epoch (distribution epoch)
18    #[prost(int64, tag = "1")]
19    #[serde(
20        serialize_with = "crate::serde::as_str::serialize",
21        deserialize_with = "crate::serde::as_str::deserialize"
22    )]
23    pub num_blocks: i64,
24    /// Accumulated amount at distribution epoch - recalculated at every
25    /// distribution epoch
26    #[prost(string, tag = "2")]
27    pub amount: ::prost::alloc::string::String,
28}
29/// Elys staked amount is tracked because EdenBoost has to be burnt when unstake
30/// ELYS event happens, and there's no way to track staked amount change from
31/// staking hook and this struct is added.
32#[allow(clippy::derive_partial_eq_without_eq)]
33#[derive(
34    Clone,
35    PartialEq,
36    Eq,
37    ::prost::Message,
38    ::serde::Serialize,
39    ::serde::Deserialize,
40    ::schemars::JsonSchema,
41    CosmwasmExt,
42)]
43#[proto_message(type_url = "/elys.estaking.ElysStaked")]
44pub struct ElysStaked {
45    #[prost(string, tag = "1")]
46    pub address: ::prost::alloc::string::String,
47    #[prost(string, tag = "2")]
48    pub amount: ::prost::alloc::string::String,
49}
50#[allow(clippy::derive_partial_eq_without_eq)]
51#[derive(
52    Clone,
53    PartialEq,
54    Eq,
55    ::prost::Message,
56    ::serde::Serialize,
57    ::serde::Deserialize,
58    ::schemars::JsonSchema,
59    CosmwasmExt,
60)]
61#[proto_message(type_url = "/elys.estaking.IncentiveInfo")]
62pub struct IncentiveInfo {
63    /// reward amount in eden for 1 year
64    #[prost(string, tag = "1")]
65    pub eden_amount_per_year: ::prost::alloc::string::String,
66    /// blocks distributed
67    #[prost(int64, tag = "2")]
68    #[serde(
69        serialize_with = "crate::serde::as_str::serialize",
70        deserialize_with = "crate::serde::as_str::deserialize"
71    )]
72    pub blocks_distributed: i64,
73}
74#[allow(clippy::derive_partial_eq_without_eq)]
75#[derive(
76    Clone,
77    PartialEq,
78    Eq,
79    ::prost::Message,
80    ::serde::Serialize,
81    ::serde::Deserialize,
82    ::schemars::JsonSchema,
83    CosmwasmExt,
84)]
85#[proto_message(type_url = "/elys.estaking.LegacyParams")]
86pub struct LegacyParams {
87    #[prost(message, optional, tag = "1")]
88    pub stake_incentives: ::core::option::Option<IncentiveInfo>,
89    #[prost(string, tag = "2")]
90    pub eden_commit_val: ::prost::alloc::string::String,
91    #[prost(string, tag = "3")]
92    pub edenb_commit_val: ::prost::alloc::string::String,
93    /// Maximum eden reward apr for stakers - [0 - 0.3]
94    #[prost(string, tag = "4")]
95    pub max_eden_reward_apr_stakers: ::prost::alloc::string::String,
96    #[prost(string, tag = "5")]
97    pub eden_boost_apr: ::prost::alloc::string::String,
98    /// Tracking dex rewards given to stakers
99    #[prost(message, optional, tag = "6")]
100    pub dex_rewards_stakers: ::core::option::Option<DexRewardsTracker>,
101}
102/// Params defines the parameters for the module.
103#[allow(clippy::derive_partial_eq_without_eq)]
104#[derive(
105    Clone,
106    PartialEq,
107    Eq,
108    ::prost::Message,
109    ::serde::Serialize,
110    ::serde::Deserialize,
111    ::schemars::JsonSchema,
112    CosmwasmExt,
113)]
114#[proto_message(type_url = "/elys.estaking.Params")]
115pub struct Params {
116    #[prost(message, optional, tag = "1")]
117    pub stake_incentives: ::core::option::Option<IncentiveInfo>,
118    #[prost(string, tag = "2")]
119    pub eden_commit_val: ::prost::alloc::string::String,
120    #[prost(string, tag = "3")]
121    pub edenb_commit_val: ::prost::alloc::string::String,
122    /// Maximum eden reward apr for stakers - [0 - 0.3]
123    #[prost(string, tag = "4")]
124    pub max_eden_reward_apr_stakers: ::prost::alloc::string::String,
125    #[prost(string, tag = "5")]
126    pub eden_boost_apr: ::prost::alloc::string::String,
127    #[prost(string, tag = "6")]
128    #[serde(alias = "provider_vesting_epochIDentifier")]
129    pub provider_vesting_epoch_identifier: ::prost::alloc::string::String,
130    #[prost(string, tag = "7")]
131    pub provider_staking_rewards_portion: ::prost::alloc::string::String,
132}
133/// GenesisState defines the estaking module's genesis state.
134#[allow(clippy::derive_partial_eq_without_eq)]
135#[derive(
136    Clone,
137    PartialEq,
138    Eq,
139    ::prost::Message,
140    ::serde::Serialize,
141    ::serde::Deserialize,
142    ::schemars::JsonSchema,
143    CosmwasmExt,
144)]
145#[proto_message(type_url = "/elys.estaking.GenesisState")]
146pub struct GenesisState {
147    #[prost(message, optional, tag = "1")]
148    pub params: ::core::option::Option<Params>,
149    #[prost(message, repeated, tag = "2")]
150    pub staking_snapshots: ::prost::alloc::vec::Vec<ElysStaked>,
151}
152/// QueryParamsRequest is request type for the Query/Params RPC method.
153#[allow(clippy::derive_partial_eq_without_eq)]
154#[derive(
155    Clone,
156    PartialEq,
157    Eq,
158    ::prost::Message,
159    ::serde::Serialize,
160    ::serde::Deserialize,
161    ::schemars::JsonSchema,
162    CosmwasmExt,
163)]
164#[proto_message(type_url = "/elys.estaking.QueryParamsRequest")]
165#[proto_query(path = "/elys.estaking.Query/Params", response_type = QueryParamsResponse)]
166pub struct QueryParamsRequest {}
167/// QueryParamsResponse is response type for the Query/Params RPC method.
168#[allow(clippy::derive_partial_eq_without_eq)]
169#[derive(
170    Clone,
171    PartialEq,
172    Eq,
173    ::prost::Message,
174    ::serde::Serialize,
175    ::serde::Deserialize,
176    ::schemars::JsonSchema,
177    CosmwasmExt,
178)]
179#[proto_message(type_url = "/elys.estaking.QueryParamsResponse")]
180pub struct QueryParamsResponse {
181    /// params holds all the parameters of this module.
182    #[prost(message, optional, tag = "1")]
183    pub params: ::core::option::Option<Params>,
184}
185#[allow(clippy::derive_partial_eq_without_eq)]
186#[derive(
187    Clone,
188    PartialEq,
189    Eq,
190    ::prost::Message,
191    ::serde::Serialize,
192    ::serde::Deserialize,
193    ::schemars::JsonSchema,
194    CosmwasmExt,
195)]
196#[proto_message(type_url = "/elys.estaking.QueryRewardsRequest")]
197#[proto_query(
198    path = "/elys.estaking.Query/Rewards",
199    response_type = QueryRewardsResponse
200)]
201pub struct QueryRewardsRequest {
202    #[prost(string, tag = "1")]
203    pub address: ::prost::alloc::string::String,
204}
205#[allow(clippy::derive_partial_eq_without_eq)]
206#[derive(
207    Clone,
208    PartialEq,
209    Eq,
210    ::prost::Message,
211    ::serde::Serialize,
212    ::serde::Deserialize,
213    ::schemars::JsonSchema,
214    CosmwasmExt,
215)]
216#[proto_message(type_url = "/elys.estaking.DelegationDelegatorReward")]
217pub struct DelegationDelegatorReward {
218    #[prost(string, tag = "1")]
219    pub validator_address: ::prost::alloc::string::String,
220    #[prost(message, repeated, tag = "2")]
221    pub reward: ::prost::alloc::vec::Vec<super::super::cosmos::base::v1beta1::Coin>,
222}
223#[allow(clippy::derive_partial_eq_without_eq)]
224#[derive(
225    Clone,
226    PartialEq,
227    Eq,
228    ::prost::Message,
229    ::serde::Serialize,
230    ::serde::Deserialize,
231    ::schemars::JsonSchema,
232    CosmwasmExt,
233)]
234#[proto_message(type_url = "/elys.estaking.QueryRewardsResponse")]
235pub struct QueryRewardsResponse {
236    /// rewards defines all the rewards accrued by a delegator.
237    #[prost(message, repeated, tag = "1")]
238    pub rewards: ::prost::alloc::vec::Vec<DelegationDelegatorReward>,
239    /// total defines the sum of all the rewards.
240    #[prost(message, repeated, tag = "2")]
241    pub total: ::prost::alloc::vec::Vec<super::super::cosmos::base::v1beta1::Coin>,
242}
243#[allow(clippy::derive_partial_eq_without_eq)]
244#[derive(
245    Clone,
246    PartialEq,
247    Eq,
248    ::prost::Message,
249    ::serde::Serialize,
250    ::serde::Deserialize,
251    ::schemars::JsonSchema,
252    CosmwasmExt,
253)]
254#[proto_message(type_url = "/elys.estaking.QueryInvariantRequest")]
255#[proto_query(
256    path = "/elys.estaking.Query/Invariant",
257    response_type = QueryInvariantResponse
258)]
259pub struct QueryInvariantRequest {}
260#[allow(clippy::derive_partial_eq_without_eq)]
261#[derive(
262    Clone,
263    PartialEq,
264    Eq,
265    ::prost::Message,
266    ::serde::Serialize,
267    ::serde::Deserialize,
268    ::schemars::JsonSchema,
269    CosmwasmExt,
270)]
271#[proto_message(type_url = "/elys.estaking.QueryInvariantResponse")]
272pub struct QueryInvariantResponse {
273    #[prost(string, tag = "1")]
274    pub total_bonded: ::prost::alloc::string::String,
275    #[prost(string, tag = "2")]
276    pub bonded_validator_tokens_sum: ::prost::alloc::string::String,
277}
278/// MsgUpdateParams is the Msg/UpdateParams request type.
279#[allow(clippy::derive_partial_eq_without_eq)]
280#[derive(
281    Clone,
282    PartialEq,
283    Eq,
284    ::prost::Message,
285    ::serde::Serialize,
286    ::serde::Deserialize,
287    ::schemars::JsonSchema,
288    CosmwasmExt,
289)]
290#[proto_message(type_url = "/elys.estaking.MsgUpdateParams")]
291pub struct MsgUpdateParams {
292    #[prost(string, tag = "1")]
293    pub authority: ::prost::alloc::string::String,
294    #[prost(message, optional, tag = "2")]
295    pub params: ::core::option::Option<Params>,
296}
297/// MsgUpdateParamsResponse defines the response structure for executing a
298/// MsgUpdateParams message.
299#[allow(clippy::derive_partial_eq_without_eq)]
300#[derive(
301    Clone,
302    PartialEq,
303    Eq,
304    ::prost::Message,
305    ::serde::Serialize,
306    ::serde::Deserialize,
307    ::schemars::JsonSchema,
308    CosmwasmExt,
309)]
310#[proto_message(type_url = "/elys.estaking.MsgUpdateParamsResponse")]
311pub struct MsgUpdateParamsResponse {}
312/// MsgWithdrawReward represents delegation withdrawal to a delegator from a
313/// single validator.
314#[allow(clippy::derive_partial_eq_without_eq)]
315#[derive(
316    Clone,
317    PartialEq,
318    Eq,
319    ::prost::Message,
320    ::serde::Serialize,
321    ::serde::Deserialize,
322    ::schemars::JsonSchema,
323    CosmwasmExt,
324)]
325#[proto_message(type_url = "/elys.estaking.MsgWithdrawReward")]
326pub struct MsgWithdrawReward {
327    #[prost(string, tag = "1")]
328    pub delegator_address: ::prost::alloc::string::String,
329    #[prost(string, tag = "2")]
330    pub validator_address: ::prost::alloc::string::String,
331}
332/// MsgWithdrawRewardResponse defines the Msg/WithdrawDelegatorReward response
333/// type.
334#[allow(clippy::derive_partial_eq_without_eq)]
335#[derive(
336    Clone,
337    PartialEq,
338    Eq,
339    ::prost::Message,
340    ::serde::Serialize,
341    ::serde::Deserialize,
342    ::schemars::JsonSchema,
343    CosmwasmExt,
344)]
345#[proto_message(type_url = "/elys.estaking.MsgWithdrawRewardResponse")]
346pub struct MsgWithdrawRewardResponse {
347    #[prost(message, repeated, tag = "1")]
348    pub amount: ::prost::alloc::vec::Vec<super::super::cosmos::base::v1beta1::Coin>,
349}
350/// MsgWithdrawElysStakingRewards represents delegation withdrawal to a delegator
351/// from all the validators.
352#[allow(clippy::derive_partial_eq_without_eq)]
353#[derive(
354    Clone,
355    PartialEq,
356    Eq,
357    ::prost::Message,
358    ::serde::Serialize,
359    ::serde::Deserialize,
360    ::schemars::JsonSchema,
361    CosmwasmExt,
362)]
363#[proto_message(type_url = "/elys.estaking.MsgWithdrawElysStakingRewards")]
364pub struct MsgWithdrawElysStakingRewards {
365    #[prost(string, tag = "1")]
366    pub delegator_address: ::prost::alloc::string::String,
367}
368/// MsgWithdrawElysStakingRewards defines the Msg/WithdrawElysStakingRewards
369/// response type.
370#[allow(clippy::derive_partial_eq_without_eq)]
371#[derive(
372    Clone,
373    PartialEq,
374    Eq,
375    ::prost::Message,
376    ::serde::Serialize,
377    ::serde::Deserialize,
378    ::schemars::JsonSchema,
379    CosmwasmExt,
380)]
381#[proto_message(type_url = "/elys.estaking.MsgWithdrawElysStakingRewardsResponse")]
382pub struct MsgWithdrawElysStakingRewardsResponse {
383    #[prost(message, repeated, tag = "1")]
384    pub amount: ::prost::alloc::vec::Vec<super::super::cosmos::base::v1beta1::Coin>,
385}
386/// MsgWithdrawAllRewards represents delegation withdrawal to a delegator from
387/// all the validators and Eden/EdenB commitment.
388#[allow(clippy::derive_partial_eq_without_eq)]
389#[derive(
390    Clone,
391    PartialEq,
392    Eq,
393    ::prost::Message,
394    ::serde::Serialize,
395    ::serde::Deserialize,
396    ::schemars::JsonSchema,
397    CosmwasmExt,
398)]
399#[proto_message(type_url = "/elys.estaking.MsgWithdrawAllRewards")]
400pub struct MsgWithdrawAllRewards {
401    #[prost(string, tag = "1")]
402    pub delegator_address: ::prost::alloc::string::String,
403}
404/// MsgWithdrawAllRewardsResponse defines the Msg/WithdrawAllRewards response
405/// type.
406#[allow(clippy::derive_partial_eq_without_eq)]
407#[derive(
408    Clone,
409    PartialEq,
410    Eq,
411    ::prost::Message,
412    ::serde::Serialize,
413    ::serde::Deserialize,
414    ::schemars::JsonSchema,
415    CosmwasmExt,
416)]
417#[proto_message(type_url = "/elys.estaking.MsgWithdrawAllRewardsResponse")]
418pub struct MsgWithdrawAllRewardsResponse {
419    #[prost(message, repeated, tag = "1")]
420    pub amount: ::prost::alloc::vec::Vec<super::super::cosmos::base::v1beta1::Coin>,
421}
422pub struct EstakingQuerier<'a, Q: cosmwasm_std::CustomQuery> {
423    querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>,
424}
425impl<'a, Q: cosmwasm_std::CustomQuery> EstakingQuerier<'a, Q> {
426    pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>) -> Self {
427        Self { querier }
428    }
429    pub fn params(&self) -> Result<QueryParamsResponse, cosmwasm_std::StdError> {
430        QueryParamsRequest {}.query(self.querier)
431    }
432    pub fn rewards(
433        &self,
434        address: ::prost::alloc::string::String,
435    ) -> Result<QueryRewardsResponse, cosmwasm_std::StdError> {
436        QueryRewardsRequest { address }.query(self.querier)
437    }
438    pub fn invariant(&self) -> Result<QueryInvariantResponse, cosmwasm_std::StdError> {
439        QueryInvariantRequest {}.query(self.querier)
440    }
441}