white_whale_std/pool_network/
factory.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2
3use crate::pool_network::asset::{AssetInfo, PairInfo, PairType, TrioInfo};
4use crate::pool_network::pair::{FeatureToggle, PoolFee};
5use crate::pool_network::trio::{
6    FeatureToggle as TrioFeatureToggle, PoolFee as TrioPoolFee, RampAmp,
7};
8
9#[cw_serde]
10pub struct InstantiateMsg {
11    /// Pair contract code ID, which is used to
12    pub pair_code_id: u64,
13    /// trio code id used for 3 pool stable swap
14    pub trio_code_id: u64,
15    pub token_code_id: u64,
16    pub fee_collector_addr: String,
17}
18
19#[cw_serde]
20pub enum ExecuteMsg {
21    /// Updates contract's config, i.e. relevant code_ids, fee_collector address and owner
22    UpdateConfig {
23        owner: Option<String>,
24        fee_collector_addr: Option<String>,
25        token_code_id: Option<u64>,
26        pair_code_id: Option<u64>,
27        trio_code_id: Option<u64>,
28    },
29    #[cfg(not(feature = "osmosis"))]
30    /// Updates a pair config
31    UpdatePairConfig {
32        pair_addr: String,
33        owner: Option<String>,
34        fee_collector_addr: Option<String>,
35        pool_fees: Option<PoolFee>,
36        feature_toggle: Option<FeatureToggle>,
37    },
38    #[cfg(feature = "osmosis")]
39    /// Updates a pair config
40    UpdatePairConfig {
41        pair_addr: String,
42        owner: Option<String>,
43        fee_collector_addr: Option<String>,
44        pool_fees: Option<PoolFee>,
45        feature_toggle: Option<FeatureToggle>,
46        cosmwasm_pool_interface: Option<String>,
47    },
48    /// Updates a trio config
49    UpdateTrioConfig {
50        trio_addr: String,
51        owner: Option<String>,
52        fee_collector_addr: Option<String>,
53        pool_fees: Option<TrioPoolFee>,
54        feature_toggle: Option<TrioFeatureToggle>,
55        amp_factor: Option<RampAmp>,
56    },
57    /// Instantiates pair contract
58    CreatePair {
59        /// Asset infos
60        asset_infos: [AssetInfo; 2],
61        pool_fees: PoolFee,
62        /// The variant of pair to create
63        pair_type: PairType,
64        /// If true, the pair will use the token factory to create the LP token. If false, it will
65        /// use a cw20 token instead.
66        token_factory_lp: bool,
67    },
68    /// Instantiates pair contract
69    CreateTrio {
70        /// Asset infos
71        asset_infos: [AssetInfo; 3],
72        pool_fees: TrioPoolFee,
73        amp_factor: u64,
74        /// If true, the pair will use the token factory to create the LP token. If false, it will
75        /// use a cw20 token instead.
76        token_factory_lp: bool,
77    },
78    /// Adds native token info to the contract so it can instantiate pair contracts that include it
79    AddNativeTokenDecimals { denom: String, decimals: u8 },
80    /// Migrates a pair contract to a given code_id
81    MigratePair {
82        contract: String,
83        code_id: Option<u64>,
84    },
85    /// Migrates a trio contract to a given code_id
86    MigrateTrio {
87        contract: String,
88        code_id: Option<u64>,
89    },
90    /// Removes pair contract given asset infos
91    RemovePair { asset_infos: [AssetInfo; 2] },
92    /// Removes trio contract given asset infos
93    RemoveTrio { asset_infos: [AssetInfo; 3] },
94}
95
96#[cw_serde]
97#[derive(QueryResponses)]
98pub enum QueryMsg {
99    /// Retrieves the configuration of the factory.
100    #[returns(ConfigResponse)]
101    Config {},
102    /// Retrieves the info for the pair with the given asset_infos.
103    #[returns(PairInfo)]
104    Pair { asset_infos: [AssetInfo; 2] },
105    /// Retrieves the pairs created by the factory. This query has pagination enabled, querying ten
106    /// items by default if not specified otherwise. The max amount of items that can be queried at
107    /// once is 30. `start_after` is the last asset_info of a page.
108    #[returns(PairsResponse)]
109    Pairs {
110        start_after: Option<[AssetInfo; 2]>,
111        limit: Option<u32>,
112    },
113    /// Retrieves the info for the trio with the given asset_infos.
114    #[returns(TrioInfo)]
115    Trio { asset_infos: [AssetInfo; 3] },
116    /// Retrieves the trios created by the factory. This query has pagination enabled, querying ten
117    /// items by default if not specified otherwise. The max amount of items that can be queried at
118    /// once is 30. `start_after` is the last asset_info of a page.
119    #[returns(TriosResponse)]
120    Trios {
121        start_after: Option<[AssetInfo; 3]>,
122        limit: Option<u32>,
123    },
124    /// Retrieves the decimals for the given native or ibc denom.
125    #[returns(NativeTokenDecimalsResponse)]
126    NativeTokenDecimals { denom: String },
127}
128
129// We define a custom struct for each query response
130#[cw_serde]
131pub struct ConfigResponse {
132    pub owner: String,
133    pub fee_collector_addr: String,
134    pub pair_code_id: u64,
135    pub trio_code_id: u64,
136    pub token_code_id: u64,
137}
138
139/// We currently take no arguments for migrations
140#[cw_serde]
141pub struct MigrateMsg {}
142
143// We define a custom struct for each query response
144#[cw_serde]
145pub struct PairsResponse {
146    pub pairs: Vec<PairInfo>,
147}
148
149#[cw_serde]
150pub struct TriosResponse {
151    pub trios: Vec<TrioInfo>,
152}
153
154#[cw_serde]
155pub struct NativeTokenDecimalsResponse {
156    pub decimals: u8,
157}