1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use cw20::Cw20ReceiveMsg;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::Uint128;

use crate::{
    ratio_pool_factory::handle_msg::RatioPoolSettings,
    stable_pool::handle_msg::DisabledActionsPerAssetSettings,
    standard_pool::handle_msg::DirectStaking,
};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    // Token handle: receive CW20 assets and execute actions with it
    Receive(Cw20ReceiveMsg),
    // Owner handle: change config fields
    UpdateConfig {
        pool_settings: Option<RatioPoolSettings>,
        owner_settings: Option<OwnerSettings>,
    },
    // Owner handle: change disabled action per asset
    UpdateDisabledActionsPerAssetSettings {
        disabled_actions_per_asset_settings: Option<DisabledActionsPerAssetSettings>,
    },
    // Operator or Factory handle: change deposit or swap permissions
    UpdatePermissions {
        is_deposit_enabled: bool,
        is_swap_enabled: bool,
    },
    // Lockups handle: receive info from the respective lockup contract
    ReceiveLockupMetrics {
        assets_fee_amount: Vec<Uint128>,
    },
    // Owner handle: change cashback contract
    UpdateCashback {
        cashback: Option<String>,
    },
    // User handle: receive asset to be deposited as liquidity on this contract
    Deposit {
        assets_amount: [Uint128; 2],
        receiver: Option<String>,
        direct_staking: Option<DirectStaking>,
        expected_return: Option<Uint128>, // amount of lp tokens (attention that LP tokens are 6 decimals)
    },
    // User handle: execute a swap between assets on this contract
    Swap {
        to: Option<String>,
        expected_return: Option<Uint128>,
    },
    // Self handle
    SelfCallback {
        message: SelfHookMsg,
    },
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SelfHookMsg {
    // Self handle: Places the LP tokens (created by the deposited liquidity) into the respective lp staking pool
    DirectStaking {
        from: String,
        amount: Uint128,
        not_claim_rewards: Option<bool>,
        notify: Option<bool>,
    },
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
    // User handle
    Swap {
        to: Option<String>,
        expected_return: Option<Uint128>,
    },
    // 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
    WithdrawalToLockup(RatioWithdrawalToLockupInputs), // programmed this way because other contracts need the WithdrawalToLockupInputs struct imported directly
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
pub struct RatioWithdrawalToLockupInputs {
    pub to: Option<String>, // withdrawal to lockup optional receiver of the lockup tokens, if None its the sender
    pub is_instant_withdrawal: Option<bool>, // instant withdrawal from lockup sent to "to" address or sender if "to" is None
    pub expected_return: Option<Vec<Uint128>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
pub struct OwnerSettings {
    pub is_deposit_enabled: bool,
    pub is_withdrawal_to_lockup_enabled: bool,
    pub is_swap_enabled: bool,
}

#[derive(Serialize, Deserialize, JsonSchema)]
pub struct MigrateMsg {}