use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_bignumber::{Decimal256, Uint256};
use cosmwasm_std::HumanAddr;
use cw20::Cw20ReceiveMsg;
use crate::tokens::TokensHuman;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
pub owner: HumanAddr,
pub oracle_contract: HumanAddr,
pub stable_denom: String,
pub safe_ratio: Decimal256,
pub bid_fee: Decimal256,
pub max_premium_rate: Decimal256,
pub liquidation_threshold: Uint256,
pub price_timeframe: u64,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
Receive(Cw20ReceiveMsg),
UpdateConfig {
owner: Option<HumanAddr>,
oracle_contract: Option<HumanAddr>,
stable_denom: Option<String>,
safe_ratio: Option<Decimal256>,
bid_fee: Option<Decimal256>,
max_premium_rate: Option<Decimal256>,
liquidation_threshold: Option<Uint256>,
price_timeframe: Option<u64>,
},
SubmitBid {
collateral_token: HumanAddr,
premium_rate: Decimal256,
},
RetractBid {
collateral_token: HumanAddr,
amount: Option<Uint256>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
ExecuteBid {
liquidator: HumanAddr,
fee_address: Option<HumanAddr>,
repay_address: Option<HumanAddr>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {},
LiquidationAmount {
borrow_amount: Uint256,
borrow_limit: Uint256,
collaterals: TokensHuman,
collateral_prices: Vec<Decimal256>,
},
Bid {
collateral_token: HumanAddr,
bidder: HumanAddr,
},
BidsByUser {
bidder: HumanAddr,
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
BidsByCollateral {
collateral_token: HumanAddr,
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
pub owner: HumanAddr,
pub oracle_contract: HumanAddr,
pub stable_denom: String,
pub safe_ratio: Decimal256,
pub bid_fee: Decimal256,
pub max_premium_rate: Decimal256,
pub liquidation_threshold: Uint256,
pub price_timeframe: u64,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct LiquidationAmountResponse {
pub collaterals: TokensHuman,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidResponse {
pub collateral_token: HumanAddr,
pub bidder: HumanAddr,
pub amount: Uint256,
pub premium_rate: Decimal256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidsResponse {
pub bids: Vec<BidResponse>,
}