1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{Decimal256, Uint256};
5use cw20::Cw20ReceiveMsg;
6
7use crate::tokens::TokensHuman;
8
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
10pub struct InstantiateMsg {
11 pub owner: String,
12 pub oracle_contract: String,
13 pub stable_denom: String,
14 pub safe_ratio: Decimal256,
17 pub bid_fee: Decimal256,
20 pub max_premium_rate: Decimal256,
23 pub liquidation_threshold: Uint256,
27 pub price_timeframe: u64,
29}
30
31#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
32#[serde(rename_all = "snake_case")]
33pub enum ExecuteMsg {
34 Receive(Cw20ReceiveMsg),
35 UpdateConfig {
36 owner: Option<String>,
37 oracle_contract: Option<String>,
38 stable_denom: Option<String>,
39 safe_ratio: Option<Decimal256>,
40 bid_fee: Option<Decimal256>,
41 max_premium_rate: Option<Decimal256>,
42 liquidation_threshold: Option<Uint256>,
43 price_timeframe: Option<u64>,
44 },
45 SubmitBid {
46 collateral_token: String,
47 premium_rate: Decimal256,
48 },
49 RetractBid {
50 collateral_token: String,
51 amount: Option<Uint256>,
52 },
53}
54
55#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
56#[serde(rename_all = "snake_case")]
57pub enum Cw20HookMsg {
58 ExecuteBid {
59 liquidator: String,
60 fee_address: Option<String>,
61 repay_address: Option<String>,
62 borrower_address: Option<String>,
63 },
64}
65#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
66#[serde(rename_all = "snake_case")]
67
68pub enum MarketExecuteMsg {
69 RepayStableFromLiquidation { borrower: String },
70}
71
72#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
73#[serde(rename_all = "snake_case")]
74pub enum QueryMsg {
75 Config {},
76 LiquidationAmount {
77 borrow_amount: Uint256,
78 borrow_limit: Uint256,
79 collaterals: TokensHuman,
80 collateral_prices: Vec<Decimal256>,
81 },
82 Bid {
83 collateral_token: String,
84 bidder: String,
85 },
86 BidsByUser {
87 bidder: String,
88 start_after: Option<String>,
89 limit: Option<u32>,
90 },
91 BidsByCollateral {
92 collateral_token: String,
93 start_after: Option<String>,
94 limit: Option<u32>,
95 },
96}
97
98#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
100pub struct ConfigResponse {
101 pub owner: String,
102 pub oracle_contract: String,
103 pub stable_denom: String,
104 pub safe_ratio: Decimal256,
105 pub bid_fee: Decimal256,
106 pub max_premium_rate: Decimal256,
107 pub liquidation_threshold: Uint256,
108 pub price_timeframe: u64,
109}
110
111#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
113pub struct LiquidationAmountResponse {
114 pub collaterals: TokensHuman,
115}
116
117#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
119pub struct BidResponse {
120 pub collateral_token: String,
121 pub bidder: String,
122 pub amount: Uint256,
123 pub premium_rate: Decimal256,
124}
125
126#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
128pub struct BidsResponse {
129 pub bids: Vec<BidResponse>,
130}