use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_bignumber::{Decimal256, Uint256};
use cosmwasm_std::HumanAddr;
use cw20::Cw20ReceiveMsg;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct InitMsg {
pub owner_addr: HumanAddr,
pub stable_denom: String,
pub reserve_factor: Decimal256,
pub aterra_code_id: u64,
pub anc_emission_rate: Decimal256,
pub max_borrow_factor: Decimal256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg {
Receive(Cw20ReceiveMsg),
RegisterContracts {
overseer_contract: HumanAddr,
interest_model: HumanAddr,
distribution_model: HumanAddr,
collector_contract: HumanAddr,
distributor_contract: HumanAddr,
},
RegisterATerra {},
UpdateConfig {
owner_addr: Option<HumanAddr>,
reserve_factor: Option<Decimal256>,
max_borrow_factor: Option<Decimal256>,
interest_model: Option<HumanAddr>,
distribution_model: Option<HumanAddr>,
},
RepayStableFromLiquidation {
borrower: HumanAddr,
prev_balance: Uint256,
},
ExecuteEpochOperations {
target_deposit_rate: Decimal256,
deposit_rate: Decimal256,
},
DepositStable {},
BorrowStable {
borrow_amount: Uint256,
to: Option<HumanAddr>,
},
RepayStable {},
ClaimRewards {
to: Option<HumanAddr>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
RedeemStable {},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {},
State {
block_height: Option<u64>,
},
EpochState {
block_height: Option<u64>,
},
BorrowerInfo {
borrower: HumanAddr,
block_height: Option<u64>,
},
BorrowerInfos {
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
pub owner_addr: HumanAddr,
pub aterra_contract: HumanAddr,
pub interest_model: HumanAddr,
pub distribution_model: HumanAddr,
pub overseer_contract: HumanAddr,
pub collector_contract: HumanAddr,
pub distributor_contract: HumanAddr,
pub stable_denom: String,
pub reserve_factor: Decimal256,
pub max_borrow_factor: Decimal256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StateResponse {
pub total_liabilities: Decimal256,
pub total_reserves: Decimal256,
pub last_interest_updated: u64,
pub last_reward_updated: u64,
pub global_interest_index: Decimal256,
pub global_reward_index: Decimal256,
pub anc_emission_rate: Decimal256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct EpochStateResponse {
pub exchange_rate: Decimal256,
pub aterra_supply: Uint256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowerInfoResponse {
pub borrower: HumanAddr,
pub interest_index: Decimal256,
pub reward_index: Decimal256,
pub loan_amount: Uint256,
pub pending_rewards: Decimal256,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct BorrowerInfosResponse {
pub borrower_infos: Vec<BorrowerInfoResponse>,
}