white_whale_std/vault_network/
vault_factory.rs

1use crate::fee::VaultFee;
2use crate::pool_network::asset::AssetInfo;
3use crate::vault_network::vault;
4use cosmwasm_schema::{cw_serde, QueryResponses};
5use cosmwasm_std::Addr;
6
7/// The instantiation message
8#[cw_serde]
9pub struct InstantiateMsg {
10    /// The owner of the factory
11    pub owner: String,
12    /// The code ID for the vault contract
13    pub vault_id: u64,
14    /// The code ID for the liquidity token contract
15    pub token_id: u64,
16    /// The address where fees get collected
17    pub fee_collector_addr: String,
18}
19
20/// The execution message
21#[cw_serde]
22pub enum ExecuteMsg {
23    /// Creates a new vault given the asset info the vault should manage deposits and withdrawals
24    /// for and the fees
25    CreateVault {
26        asset_info: AssetInfo,
27        fees: VaultFee,
28        /// If true, the vault will use the token factory to create the LP token. If false, it will
29        /// use a cw20 token instead.
30        token_factory_lp: bool,
31    },
32    /// Migrates vaults to the given code_id. If a [vault_addr] is provided, then migrates only that
33    /// vault.
34    MigrateVaults {
35        vault_addr: Option<String>,
36        vault_code_id: u64,
37    },
38    /// Removes a vault given its [AssetInfo]
39    RemoveVault { asset_info: AssetInfo },
40    /// Updates a vault config
41    UpdateVaultConfig {
42        vault_addr: String,
43        params: vault::UpdateConfigParams,
44    },
45    /// Updates the configuration of the vault factory.
46    /// If a field is not specified, it will not be modified.
47    UpdateConfig {
48        owner: Option<String>,
49        fee_collector_addr: Option<String>,
50        vault_id: Option<u64>,
51        token_id: Option<u64>,
52    },
53}
54
55/// The query message
56#[cw_serde]
57#[derive(QueryResponses)]
58pub enum QueryMsg {
59    /// Retrieves the configuration of the vault.
60    #[returns(Config)]
61    Config {},
62    /// Retrieves the address of a given vault.
63    #[returns(Option<String>)]
64    Vault { asset_info: AssetInfo },
65    /// Retrieves the addresses for all the vaults.
66    #[returns(VaultsResponse)]
67    Vaults {
68        start_after: Option<Vec<u8>>,
69        limit: Option<u32>,
70    },
71}
72
73/// The migrate message
74#[cw_serde]
75pub struct MigrateMsg {}
76
77/// The `reply` code ID for the submessage after instantiating the vault.
78pub const INSTANTIATE_VAULT_REPLY_ID: u64 = 1;
79
80#[cw_serde]
81pub struct Config {
82    pub owner: Addr,
83    pub vault_id: u64,
84    pub token_id: u64,
85    pub fee_collector_addr: Addr,
86}
87
88/// Response for the vaults query
89#[cw_serde]
90pub struct VaultsResponse {
91    pub vaults: Vec<VaultInfo>,
92}
93
94/// Response for the vaults query
95#[cw_serde]
96pub struct VaultInfo {
97    pub vault: String,
98    pub asset_info: AssetInfo,
99    pub asset_info_reference: Vec<u8>,
100}