Skip to main content

solid_moneymarket/
overseer.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::tokens::TokensHuman;
5use cosmwasm_std::{Decimal256, Uint256};
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
8#[serde(rename_all = "snake_case")]
9pub struct InstantiateMsg {
10    /// Initial owner address
11    pub owner_addr: String,
12    /// Oracle contract address for collateral tokens
13    pub oracle_contract: String,
14    /// Market contract address to receive missing interest buffer
15    pub market_contract: String,
16    /// Liquidation model contract address to compute liquidation amount
17    pub liquidation_contract: String,
18    /// Collector contract address which is collect fees from protocol and divide them between the team and the stakers
19    pub collector_contract: String,
20    /// The base denomination used when fetching oracle price,
21    /// reward distribution, and borrow
22    pub stable_contract: String,
23
24    pub price_timeframe: u64,
25}
26
27#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
28#[serde(rename_all = "snake_case")]
29pub struct MigrateMsg {}
30
31#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
32#[serde(rename_all = "snake_case")]
33#[allow(clippy::large_enum_variant)]
34pub enum ExecuteMsg {
35    ////////////////////
36    /// Owner operations
37    ////////////////////
38    /// Update Configs
39    UpdateConfig {
40        owner_addr: Option<String>,
41        oracle_contract: Option<String>,
42        liquidation_contract: Option<String>,
43        price_timeframe: Option<u64>,
44    },
45    /// Create new custody contract for the given collateral token
46    Whitelist {
47        name: String,             // bAsset name
48        symbol: String,           // bAsset symbol
49        collateral_token: String, // bAsset token contract
50        custody_contract: String, // bAsset custody contract
51        max_ltv: Decimal256,      // Loan To Value ratio
52    },
53    /// Update registered whitelist info
54    UpdateWhitelist {
55        collateral_token: String,         // bAsset token contract
56        custody_contract: Option<String>, // bAsset custody contract
57        max_ltv: Option<Decimal256>,      // Loan To Value ratio
58    },
59
60    ////////////////////
61    /// User operations
62    ////////////////////
63    LockCollateral {
64        collaterals: TokensHuman, // <(Collateral Token, Amount)>
65    },
66    UnlockCollateral {
67        collaterals: TokensHuman, // <(Collateral Token, Amount)>
68    },
69
70    /////////////////////////////
71    /// Permissionless operations
72    /////////////////////////////
73    LiquidateCollateral { borrower: String },
74}
75
76#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
77#[serde(rename_all = "snake_case")]
78pub enum Cw20HookMsg {
79    FundReserve {},
80}
81
82#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
83#[serde(rename_all = "snake_case")]
84pub enum QueryMsg {
85    Config {},
86    Whitelist {
87        collateral_token: Option<String>,
88        start_after: Option<String>,
89        limit: Option<u32>,
90    },
91    Collaterals {
92        borrower: String,
93    },
94    AllCollaterals {
95        start_after: Option<String>,
96        limit: Option<u32>,
97    },
98    BorrowLimit {
99        borrower: String,
100        block_time: Option<u64>,
101    },
102}
103
104// We define a custom struct for each query response
105#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
106pub struct ConfigResponse {
107    pub owner_addr: String,
108    pub oracle_contract: String,
109    pub market_contract: String,
110    pub liquidation_contract: String,
111    pub collector_contract: String,
112    pub stable_contract: String,
113    pub price_timeframe: u64,
114}
115
116// We define a custom struct for each query response
117#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
118pub struct WhitelistResponseElem {
119    pub name: String,
120    pub symbol: String,
121    pub max_ltv: Decimal256,
122    pub custody_contract: String,
123    pub collateral_token: String,
124}
125
126// We define a custom struct for each query response
127#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
128pub struct WhitelistResponse {
129    pub elems: Vec<WhitelistResponseElem>,
130}
131
132// We define a custom struct for each query response
133#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
134pub struct CollateralsResponse {
135    pub borrower: String,
136    pub collaterals: TokensHuman, // <(Collateral Token, Amount)>
137}
138
139// We define a custom struct for each query response
140#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
141pub struct AllCollateralsResponse {
142    pub all_collaterals: Vec<CollateralsResponse>,
143}
144
145#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
146pub struct BorrowLimitResponse {
147    pub borrower: String,
148    pub borrow_limit: Uint256,
149}