Skip to main content

solid_moneymarket/
custody.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::Uint256;
5use cw20::Cw20ReceiveMsg;
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
8#[serde(rename_all = "snake_case")]
9pub struct InstantiateMsg {
10    /// owner address
11    pub owner: String,
12    /// bAsset token address
13    pub collateral_token: String,
14    /// overseer contract address
15    pub overseer_contract: String,
16    /// market contract address
17    pub market_contract: String,
18    /// liquid staking staking contract
19    pub liquidation_contract: String,
20    // Collector contract address
21    pub collector_contract: String,
22}
23
24#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
25#[serde(rename_all = "snake_case")]
26pub enum ExecuteMsg {
27    /// CW20 token receiver
28    Receive(Cw20ReceiveMsg),
29
30    ////////////////////
31    /// Overseer operations
32    ////////////////////
33
34    /// Update config
35    UpdateConfig {
36        owner: Option<String>,
37        liquidation_contract: Option<String>,
38        collector_contract: Option<String>,
39    },
40    /// Make specified amount of tokens unspendable
41    LockCollateral { borrower: String, amount: Uint256 },
42    /// Make specified amount of collateral tokens spendable
43    UnlockCollateral { borrower: String, amount: Uint256 },
44    /// Liquidate collateral and send liquidated collateral to `to` address
45    LiquidateCollateral {
46        liquidator: String,
47        borrower: String,
48        amount: Uint256,
49    },
50
51    ////////////////////
52    /// User operations
53    ////////////////////
54
55    /// Withdraw spendable collateral token.
56    /// If the amount is not given,
57    /// return all spendable collateral
58    WithdrawCollateral { amount: Option<Uint256> },
59}
60
61#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
62#[serde(rename_all = "snake_case")]
63pub enum Cw20HookMsg {
64    /// Deposit collateral token
65    DepositCollateral {},
66}
67
68#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
69#[serde(rename_all = "snake_case")]
70pub struct MigrateMsg {}
71
72#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
73#[serde(rename_all = "snake_case")]
74pub enum QueryMsg {
75    Config {},
76    Borrower {
77        address: String,
78    },
79    Borrowers {
80        start_after: Option<String>,
81        limit: Option<u32>,
82    },
83}
84
85// We define a custom struct for each query response
86#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
87pub struct ConfigResponse {
88    pub owner: String,
89    pub collateral_token: String,
90    pub overseer_contract: String,
91    pub market_contract: String,
92    pub liquidation_contract: String,
93    pub collector_contract: String,
94}
95
96// We define a custom struct for each query response
97#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
98pub struct BorrowerResponse {
99    pub borrower: String,
100    pub balance: Uint256,
101    pub spendable: Uint256,
102}
103
104// We define a custom struct for each query response
105#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
106pub struct BorrowersResponse {
107    pub borrowers: Vec<BorrowerResponse>,
108}
109
110#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
111pub struct BAssetInfo {
112    pub name: String,
113    pub symbol: String,
114    pub decimals: u8,
115}