use crate::{denom::Denom, merkle::Proof};
use cosmwasm_std::{Addr, Decimal, Uint128};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub owner: Addr,
pub bid_denom: Denom,
pub collateral_denom: Denom,
pub bid_threshold: Uint128,
pub max_slot: u8,
pub premium_rate_per_slot: Decimal,
pub waiting_period: u64,
pub liquidation_fee: Decimal,
pub withdrawal_fee: Decimal,
pub fee_address: Addr,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[allow(clippy::large_enum_variant)]
pub enum ExecuteMsg {
UpdateConfig {
owner: Option<Addr>,
waiting_period: Option<u64>,
bid_threshold: Option<Uint128>,
premium_rate_per_slot: Option<Decimal>,
closed_slots: Option<Vec<u8>>,
liquidation_fee: Option<Decimal>,
withdrawal_fee: Option<Decimal>,
fee_address: Option<Addr>,
},
AddMarket { address: Addr },
RemoveMarket { address: Addr },
SetMerkleRoot { root: String },
UnsetMerkleRoot {},
SubmitBid {
premium_slot: u8,
delegate: Option<Addr>,
proof: Option<Proof>,
},
RetractBid {
bid_idx: Uint128,
amount: Option<Uint128>,
},
ActivateBids {
bids_idx: Option<Vec<Uint128>>,
},
ClaimLiquidations {
bids_idx: Option<Vec<Uint128>>,
},
ExecuteLiquidation {
repay_address: Option<Addr>,
repay_denom: Denom,
exchange_rate: Decimal,
},
AddSwapper {
denom: Denom,
address: Addr,
},
RemoveSwapper { denom: Denom },
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {},
Verify { address: Addr, proof: Proof },
Simulate {
collateral_amount: Uint128,
repay_denom: Denom,
exchange_rate: Decimal,
},
SimulateReverse {
repay_amount: Uint128,
repay_denom: Denom,
exchange_rate: Decimal,
},
Bid { bid_idx: Uint128 },
BidsByUser {
bidder: Addr,
start_after: Option<Uint128>,
limit: Option<u8>,
},
BidPool { bid_slot: u8 },
BidPools {
start_after: Option<u8>,
limit: Option<u8>,
},
Swappers {
start_after: Option<String>,
limit: Option<u8>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
pub owner: Addr,
pub markets: Vec<Addr>,
pub bid_denom: Denom,
pub collateral_denom: Denom,
pub bid_threshold: Uint128,
pub max_slot: u8,
pub premium_rate_per_slot: Decimal,
pub closed_slots: Vec<u8>,
pub waiting_period: u64,
pub liquidation_fee: Decimal,
pub withdrawal_fee: Decimal,
pub fee_address: Addr,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SimulationResponse {
pub collateral_amount: Uint128,
pub repay_amount: Uint128,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidResponse {
pub idx: Uint128,
pub premium_slot: u8,
pub bidder: Addr,
pub amount: Uint128,
pub pending_liquidated_collateral: Uint128,
pub wait_end: Option<u64>,
pub delegate: Option<Addr>,
pub product_snapshot: Decimal,
pub sum_snapshot: Decimal,
pub epoch_snapshot: Uint128,
pub scale_snapshot: Uint128,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidsResponse {
pub bids: Vec<BidResponse>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidPoolResponse {
pub total_bid_amount: Uint128,
pub premium_rate: Decimal,
pub is_closed: bool,
pub sum_snapshot: Decimal,
pub product_snapshot: Decimal,
pub current_epoch: Uint128,
pub current_scale: Uint128,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BidPoolsResponse {
pub bid_pools: Vec<BidPoolResponse>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SwappersResponse {
pub swappers: Vec<SwapperResponse>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SwapperResponse {
pub repay_denom: Denom,
pub addr: Addr,
}