white_whale_std/
fee_collector.rs

1use crate::fee_distributor::Epoch;
2use crate::pool_network::asset::{Asset, AssetInfo};
3use cosmwasm_schema::{cw_serde, QueryResponses};
4use cosmwasm_std::{Addr, Coin, Decimal, Uint64};
5
6#[cw_serde]
7pub struct InstantiateMsg {}
8
9#[cw_serde]
10pub enum ExecuteMsg {
11    /// Collects protocol fees based on the configuration indicated by [FeesFor]
12    CollectFees { collect_fees_for: FeesFor },
13    /// Swaps the assets (fees) sitting in the fee collector into the distribution asset set by the
14    /// fee collector. A [SwapRoute] should be available at the router to be able to make the swaps.
15    AggregateFees { aggregate_fees_for: FeesFor },
16    /// Forward fees to the fee distributor. This will collect and aggregate the fees, to send them back to the fee distributor.
17    ForwardFees {
18        epoch: Epoch,
19        forward_fees_as: AssetInfo,
20    },
21    /// Updates the config
22    UpdateConfig {
23        owner: Option<String>,
24        pool_router: Option<String>,
25        fee_distributor: Option<String>,
26        pool_factory: Option<String>,
27        vault_factory: Option<String>,
28        take_rate: Option<Decimal>,
29        take_rate_dao_address: Option<String>,
30        is_take_rate_active: Option<bool>,
31    },
32}
33
34#[cw_serde]
35pub enum FeesFor {
36    /// Refers to the fees on the given contracts
37    Contracts { contracts: Vec<Contract> },
38    /// Refers to the fees on the contracts the given factory created
39    Factory {
40        factory_addr: String,
41        factory_type: FactoryType,
42    },
43}
44
45#[cw_serde]
46#[derive(QueryResponses)]
47pub enum QueryMsg {
48    /// Queries the configuration of this contract
49    #[returns(Config)]
50    Config {},
51    /// Queries fees collected by a given factory's children or individual contracts
52    #[returns(Vec<Asset>)]
53    Fees {
54        query_fees_for: FeesFor,
55        all_time: Option<bool>,
56    },
57    /// Queries the take rate taken for the given epoch id.
58    #[returns(Coin)]
59    TakeRateHistory { epoch_id: Uint64 },
60}
61
62#[cw_serde]
63pub struct MigrateMsg {}
64
65#[cw_serde]
66pub enum FactoryType {
67    /// Vault Factory
68    Vault {
69        start_after: Option<Vec<u8>>,
70        limit: Option<u32>,
71    },
72    /// Pool Factory
73    Pool {
74        start_after: Option<[AssetInfo; 2]>,
75        limit: Option<u32>,
76    },
77}
78
79#[cw_serde]
80pub struct Contract {
81    pub address: String,
82    pub contract_type: ContractType,
83}
84
85#[cw_serde]
86pub enum ContractType {
87    /// Vault contract type
88    Vault {},
89    /// Pool/Pair contract type
90    Pool {},
91}
92
93#[cw_serde]
94pub struct ForwardFeesResponse {
95    pub epoch: Epoch,
96}
97
98#[cw_serde]
99pub struct Config {
100    pub owner: Addr,
101    pub pool_router: Addr,
102    pub fee_distributor: Addr,
103    pub pool_factory: Addr,
104    pub vault_factory: Addr,
105    pub take_rate: Decimal,
106    pub take_rate_dao_address: Addr,
107    pub is_take_rate_active: bool,
108}