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
use andromeda_std::{
amp::Recipient, andr_exec, andr_instantiate, andr_instantiate_modules, andr_query,
common::withdraw::WithdrawalType,
};
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Uint128, VoteOption};
use cw_utils::Duration;
#[andr_instantiate]
#[andr_instantiate_modules]
#[cw_serde]
pub struct InstantiateMsg {
/// The recipient of all funds locked in this contract.
pub recipient: Recipient,
/// Whether or not multi-batching has been enabled.
pub is_multi_batch_enabled: bool,
/// The denom of the coin being vested.
pub denom: String,
/// The unbonding duration of the native staking module.
pub unbonding_duration: Duration,
}
#[andr_exec]
#[cw_serde]
pub enum ExecuteMsg {
/// Claim the number of batches specified starting from the beginning. If not
/// specified then the max will be claimed.
Claim {
number_of_claims: Option<u64>,
batch_id: u64,
},
/// Claims tokens from all batches using a paginated approach. If `up_to_time`
/// is specified then it will only claim up to a specific time, otherwise it
/// it will claim to the most recent release.
ClaimAll {
up_to_time: Option<u64>,
limit: Option<u32>,
},
/// Creates a new batch
CreateBatch {
/// Specifying None would mean no lock up period and funds start vesting right away.
lockup_duration: Option<u64>,
/// How often releases occur in seconds.
release_unit: u64,
/// Specifies how much is to be released after each `release_unit`. If
/// it is a percentage, it would be the percentage of the original amount.
release_amount: WithdrawalType,
/// The validator to delegate to. If specified, funds will be delegated to it.
validator_to_delegate_to: Option<String>,
},
/// Delegates the given amount of tokens, or all if not specified.
Delegate {
amount: Option<Uint128>,
validator: String,
},
/// Redelegates the given amount of tokens, or all from the `from` validator to the `to`
/// validator.
Redelegate {
amount: Option<Uint128>,
from: String,
to: String,
},
/// Undelegates the given amount of tokens, or all if not specified.
Undelegate {
amount: Option<Uint128>,
validator: String,
},
/// Withdraws rewards from all delegations to the sender.
WithdrawRewards {},
/// Votes on the specified proposal with the specified vote.
Vote { proposal_id: u64, vote: VoteOption },
}
#[andr_query]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
/// Queries the config.
#[returns(Config)]
Config {},
/// Queries the batch with the given id.
#[returns(BatchResponse)]
Batch { id: u64 },
/// Queries the batches with pagination.
#[returns(Vec<BatchResponse>)]
Batches {
start_after: Option<u64>,
limit: Option<u32>,
},
}
#[cw_serde]
pub struct Config {
/// The recipient of each batch.
pub recipient: Recipient,
/// Whether or not multiple batches are supported.
pub is_multi_batch_enabled: bool,
/// The denom of the coin being vested.
pub denom: String,
/// The unbonding duration of the native staking module.
pub unbonding_duration: Duration,
}
#[cw_serde]
pub struct BatchResponse {
/// The id.
pub id: u64,
/// The amount of tokens in the batch
pub amount: Uint128,
/// The amount of tokens that have been claimed.
pub amount_claimed: Uint128,
/// The amount of tokens available to claim right now.
pub amount_available_to_claim: Uint128,
/// The number of available claims.
pub number_of_available_claims: Uint128,
/// When the lockup ends.
pub lockup_end: u64,
/// How often releases occur.
pub release_unit: u64,
/// Specifies how much is to be released after each `release_unit`. If
/// it is a percentage, it would be the percentage of the original amount.
pub release_amount: WithdrawalType,
/// The time at which the last claim took place in seconds.
pub last_claimed_release_time: u64,
}