levana_perpswap_cosmos/contracts/faucet/
entry.rs

1use crate::prelude::*;
2use cosmwasm_schema::{cw_serde, QueryResponses};
3use cosmwasm_std::{Addr, Uint128};
4
5use crate::contracts::cw20::Cw20Coin;
6
7#[cw_serde]
8pub struct InstantiateMsg {
9    /// Given in seconds
10    pub tap_limit: Option<u32>,
11    /// Code ID of the CW20 contract we'll deploy
12    pub cw20_code_id: u64,
13    /// Configuration of the gas coin allowance
14    pub gas_allowance: Option<GasAllowance>,
15}
16
17#[cw_serde]
18pub enum ExecuteMsg {
19    Tap {
20        assets: Vec<FaucetAsset>,
21        recipient: RawAddr,
22        amount: Option<Number>,
23    },
24    Multitap {
25        recipients: Vec<MultitapRecipient>,
26    },
27    OwnerMsg(OwnerMsg),
28}
29
30#[cw_serde]
31pub struct MultitapRecipient {
32    pub addr: RawAddr,
33    pub assets: Vec<FaucetAsset>,
34}
35
36#[cw_serde]
37pub enum FaucetAsset {
38    Cw20(RawAddr),
39    Native(String),
40}
41
42#[cw_serde]
43pub enum OwnerMsg {
44    AddAdmin {
45        admin: RawAddr,
46    },
47    RemoveAdmin {
48        admin: RawAddr,
49    },
50    /// Given in seconds
51    SetTapLimit {
52        tap_limit: Option<u32>,
53    },
54    SetTapAmount {
55        asset: FaucetAsset,
56        amount: Number,
57    },
58    DeployToken {
59        /// Name of the asset, used as both CW20 name and symbol. Example: `ATOM`.
60        name: String,
61        tap_amount: Number,
62        /// Each trading competition token for an asset is assigned an index to
63        /// disambiguate them. It also makes it easier to find the token you
64        /// just created with a deploy. These are intended to be monotonically
65        /// increasing. When deploying a new trading competition token, consider
66        /// using [QueryMsg::NextTradingIndex] to find the next available
67        /// number.
68        ///
69        /// By providing [None], you're saying that you want to deploy an
70        /// unrestricted token which can be tapped multiple times and be used
71        /// with any contract.
72        trading_competition_index: Option<u32>,
73        initial_balances: Vec<Cw20Coin>,
74    },
75    SetMarketAddress {
76        name: String,
77        trading_competition_index: u32,
78        market: RawAddr,
79    },
80    SetCw20CodeId {
81        cw20_code_id: u64,
82    },
83    Mint {
84        cw20: String,
85        balances: Vec<Cw20Coin>,
86    },
87    SetGasAllowance {
88        allowance: GasAllowance,
89    },
90    ClearGasAllowance {},
91    /// Set the tap amount for a named asset
92    SetMultitapAmount {
93        name: String,
94        amount: Decimal256,
95    },
96}
97
98#[cw_serde]
99#[derive(QueryResponses)]
100pub enum QueryMsg {
101    /// * returns [cw2::ContractVersion]
102    #[returns(cw2::ContractVersion)]
103    Version {},
104
105    /// * returns [ConfigResponse]
106    #[returns(ConfigResponse)]
107    Config {},
108
109    /// * returns [GetTokenResponse]
110    #[returns(GetTokenResponse)]
111    GetToken {
112        name: String,
113        trading_competition_index: Option<u32>,
114    },
115
116    /// Returns the next trading competition index we can use for the given asset name
117    ///
118    /// * returns [NextTradingIndexResponse]
119    #[returns(NextTradingIndexResponse)]
120    NextTradingIndex { name: String },
121
122    /// * returns [GasAllowanceResp]
123    #[returns(GasAllowanceResp)]
124    GetGasAllowance {},
125
126    /// * returns [TapEligibleResponse]
127    #[returns(TapEligibleResponse)]
128    IsTapEligible {
129        addr: RawAddr,
130        #[serde(default)]
131        assets: Vec<FaucetAsset>,
132    },
133
134    /// * returns [IsAdminResponse]
135    #[returns(IsAdminResponse)]
136    IsAdmin { addr: RawAddr },
137
138    /// * returns [TapAmountResponse]
139    #[returns(TapAmountResponse)]
140    TapAmount { asset: FaucetAsset },
141
142    /// * returns [TapAmountResponse]
143    #[returns(TapAmountResponse)]
144    TapAmountByName { name: String },
145
146    /// Find out the cumulative amount of funds transferred at a given timestamp.
147    #[returns(FundsSentResponse)]
148    FundsSent {
149        asset: FaucetAsset,
150        timestamp: Option<Timestamp>,
151    },
152
153    /// Enumerate all wallets that tapped the faucet
154    #[returns(TappersResp)]
155    Tappers {
156        start_after: Option<RawAddr>,
157        limit: Option<u32>,
158    },
159}
160
161#[cw_serde]
162pub enum GetTokenResponse {
163    Found { address: Addr },
164    NotFound {},
165}
166
167#[cw_serde]
168pub struct NextTradingIndexResponse {
169    pub next_index: u32,
170}
171
172/// Placeholder migration message
173#[cw_serde]
174pub struct MigrateMsg {}
175
176#[cw_serde]
177pub struct ConfigResponse {
178    pub admins: Vec<Addr>,
179    /// Given in seconds
180    pub tap_limit: Option<u32>,
181}
182
183#[cw_serde]
184pub struct GasAllowance {
185    pub denom: String,
186    pub amount: Uint128,
187}
188
189#[cw_serde]
190pub enum GasAllowanceResp {
191    Enabled { denom: String, amount: Uint128 },
192    Disabled {},
193}
194
195#[cw_serde]
196pub enum TapEligibleResponse {
197    Eligible {},
198    Ineligible {
199        seconds: Decimal256,
200        message: String,
201        reason: IneligibleReason,
202    },
203}
204
205#[cw_serde]
206pub enum IneligibleReason {
207    TooSoon,
208    AlreadyTapped,
209}
210
211#[cw_serde]
212pub struct IsAdminResponse {
213    pub is_admin: bool,
214}
215
216#[cw_serde]
217pub enum TapAmountResponse {
218    CannotTap {},
219    CanTap { amount: Decimal256 },
220}
221
222#[cw_serde]
223pub struct FundsSentResponse {
224    pub amount: Decimal256,
225}
226
227#[cw_serde]
228pub struct TappersResp {
229    pub tappers: Vec<Addr>,
230}