Skip to main content

solid_moneymarket/
market.rs

1use cosmwasm_std::Binary;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use cosmwasm_std::{Decimal256, Uint256};
6use cw20::Cw20ReceiveMsg;
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
8#[serde(rename_all = "snake_case")]
9pub struct InstantiateMsg {
10    /// Owner address for config update
11    pub owner_addr: String,
12    /// Cw20 code id for Solid
13    pub stable_code_id: u64,
14    /// Base borrow fee:
15    pub base_borrow_fee: Decimal256,
16    // Base fee increase factor
17    pub fee_increase_factor: Decimal256,
18    // Base flash mint fee
19    pub flash_mint_fee: Option<Decimal256>,
20}
21
22#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
23#[serde(rename_all = "snake_case")]
24pub enum ExecuteMsg {
25    Receive(Cw20ReceiveMsg),
26
27    ////////////////////
28    /// Owner operations
29    ////////////////////
30    /// Register Contracts contract address
31    RegisterContracts {
32        overseer_contract: String,
33        /// The contract has the logics for
34        /// Collector contract to send all the reserve
35        collector_contract: String,
36        /// Faucet contract to drip CAPA token to users
37        liquidation_contract: String,
38
39        oracle_contract: String,
40    },
41
42    /// Update config values
43    UpdateConfig {
44        owner_addr: Option<String>,
45        liquidation_contract: Option<String>,
46        base_borrow_fee: Option<Decimal256>,
47        fee_increase_factor: Option<Decimal256>,
48        flash_mint_fee: Option<Decimal256>,
49        oracle_addr: Option<String>,
50    },
51
52    /// Borrow stable asset with collaterals in overseer contract
53    BorrowStable {
54        borrow_amount: Uint256,
55        to: Option<String>,
56    },
57
58    /// Require a flash mint specifying a callback msg that will be send back to the calling contract
59    FlashMint {
60        amount: Uint256,
61        msg_callback: Binary,
62    },
63
64    /// Private msg that burn the requested amount from the flash minter and send fee to the collector
65    PrivateFlashEnd {
66        flash_minter: String,
67        burn_amount: Uint256,
68        fee_amount: Uint256,
69    },
70}
71
72#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
73#[serde(rename_all = "snake_case")]
74pub enum Cw20HookMsg {
75    /// Return stable coins to a user
76    /// according to exchange rate
77    RepayStable {},
78    RepayStableFromLiquidation {
79        borrower: String,
80    },
81}
82
83#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
84#[serde(rename_all = "snake_case")]
85pub enum QueryMsg {
86    Config {},
87    State {},
88    BorrowerInfo {
89        borrower: String,
90    },
91    BorrowerInfos {
92        start_after: Option<String>,
93        limit: Option<u32>,
94    },
95}
96
97// We define a custom struct for each query response
98#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
99pub struct ConfigResponse {
100    pub owner_addr: String,
101    pub stable_contract: String,
102    pub overseer_contract: String,
103    pub collector_contract: String,
104    pub liquidation_contract: String,
105    pub oracle_contract: String,
106    pub flash_mint_fee: Option<Decimal256>,
107}
108
109// We define a custom struct for each query response
110#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
111pub struct StateResponse {
112    pub total_liabilities: Decimal256,
113}
114
115// We define a custom struct for each query response
116#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
117pub struct BorrowerInfoResponse {
118    pub borrower: String,
119    pub loan_amount: Uint256,
120}
121
122// We define a custom struct for each query response
123#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
124pub struct BorrowerInfosResponse {
125    pub borrower_infos: Vec<BorrowerInfoResponse>,
126}
127
128#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
129#[serde(rename_all = "snake_case")]
130pub struct MigrateMsg {}