astrovault/ratio_pool/
handle_msg.rs

1use cw20::Cw20ReceiveMsg;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use cosmwasm_std::Uint128;
6
7use crate::{
8    ratio_pool_factory::handle_msg::RatioPoolSettings,
9    stable_pool::handle_msg::DisabledActionsPerAssetSettings,
10    standard_pool::handle_msg::DirectStaking,
11};
12
13#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
14#[serde(rename_all = "snake_case")]
15pub enum ExecuteMsg {
16    // Token handle: receive CW20 assets and execute actions with it
17    Receive(Cw20ReceiveMsg),
18    // Owner handle: change config fields
19    UpdateConfig {
20        pool_settings: Option<RatioPoolSettings>,
21        owner_settings: Option<OwnerSettings>,
22    },
23    // Owner handle: change disabled action per asset
24    UpdateDisabledActionsPerAssetSettings {
25        disabled_actions_per_asset_settings: Option<DisabledActionsPerAssetSettings>,
26    },
27    // Operator or Factory handle: change deposit or swap permissions
28    UpdatePermissions {
29        is_deposit_enabled: bool,
30        is_swap_enabled: bool,
31    },
32    // Lockups handle: receive info from the respective lockup contract
33    ReceiveLockupMetrics {
34        assets_fee_amount: Vec<Uint128>,
35    },
36    // Owner handle: change cashback contract
37    UpdateCashback {
38        cashback: Option<String>,
39    },
40    // User handle: receive asset to be deposited as liquidity on this contract
41    Deposit {
42        assets_amount: [Uint128; 2],
43        receiver: Option<String>,
44        direct_staking: Option<DirectStaking>,
45        expected_return: Option<Uint128>, // amount of lp tokens (attention that LP tokens are 6 decimals)
46    },
47    // User handle: execute a swap between assets on this contract
48    Swap {
49        to: Option<String>,
50        expected_return: Option<Uint128>,
51    },
52    // Self handle
53    SelfCallback {
54        message: SelfHookMsg,
55    },
56}
57
58#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
59#[serde(rename_all = "snake_case")]
60pub enum SelfHookMsg {
61    // Self handle: Places the LP tokens (created by the deposited liquidity) into the respective lp staking pool
62    DirectStaking {
63        from: String,
64        amount: Uint128,
65        not_claim_rewards: Option<bool>,
66        notify: Option<bool>,
67    },
68}
69
70#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
71#[serde(rename_all = "snake_case")]
72pub enum Cw20HookMsg {
73    // User handle
74    Swap {
75        to: Option<String>,
76        expected_return: Option<Uint128>,
77    },
78    // User handle: withdrawal assets from the liquidity on this contract and place them on the lockups contract that will triggers a soft lockup period with these assets
79    WithdrawalToLockup(RatioWithdrawalToLockupInputs), // programmed this way because other contracts need the WithdrawalToLockupInputs struct imported directly
80}
81
82#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
83pub struct RatioWithdrawalToLockupInputs {
84    pub to: Option<String>, // withdrawal to lockup optional receiver of the lockup tokens, if None its the sender
85    pub is_instant_withdrawal: Option<bool>, // instant withdrawal from lockup sent to "to" address or sender if "to" is None
86    pub expected_return: Option<Vec<Uint128>>,
87}
88
89#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
90pub struct OwnerSettings {
91    pub is_deposit_enabled: bool,
92    pub is_withdrawal_to_lockup_enabled: bool,
93    pub is_swap_enabled: bool,
94}
95
96#[derive(Serialize, Deserialize, JsonSchema)]
97pub struct MigrateMsg {}