mirror_protocol/
collateral_oracle.rs

1use cosmwasm_std::Decimal;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4use std::fmt;
5use terraswap::asset::AssetInfo;
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8pub struct InstantiateMsg {
9    pub owner: String,
10    pub mint_contract: String,
11    pub base_denom: String,
12    pub mirror_oracle: String,
13    pub anchor_oracle: String,
14    pub band_oracle: String,
15}
16
17#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
18#[serde(rename_all = "snake_case")]
19pub enum ExecuteMsg {
20    UpdateConfig {
21        owner: Option<String>,
22        mint_contract: Option<String>,
23        base_denom: Option<String>,
24        mirror_oracle: Option<String>,
25        anchor_oracle: Option<String>,
26        band_oracle: Option<String>,
27    },
28    RegisterCollateralAsset {
29        asset: AssetInfo,
30        price_source: SourceType,
31        multiplier: Decimal,
32    },
33    RevokeCollateralAsset {
34        asset: AssetInfo,
35    },
36    UpdateCollateralPriceSource {
37        asset: AssetInfo,
38        price_source: SourceType,
39    },
40    UpdateCollateralMultiplier {
41        asset: AssetInfo,
42        multiplier: Decimal,
43    },
44}
45
46#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
47#[serde(rename_all = "snake_case")]
48pub enum QueryMsg {
49    Config {},
50    CollateralPrice {
51        asset: String,
52        block_height: Option<u64>,
53    },
54    CollateralAssetInfo {
55        asset: String,
56    },
57    CollateralAssetInfos {},
58}
59
60#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
61pub struct ConfigResponse {
62    pub owner: String,
63    pub mint_contract: String,
64    pub base_denom: String,
65    pub mirror_oracle: String,
66    pub anchor_oracle: String,
67    pub band_oracle: String,
68}
69
70#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
71pub struct CollateralPriceResponse {
72    pub asset: String,
73    pub rate: Decimal,
74    pub last_updated: u64,
75    pub multiplier: Decimal,
76    pub is_revoked: bool,
77}
78
79#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
80pub struct CollateralInfoResponse {
81    pub asset: String,
82    pub multiplier: Decimal,
83    pub source_type: String,
84    pub is_revoked: bool,
85}
86
87#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
88pub struct CollateralInfosResponse {
89    pub collaterals: Vec<CollateralInfoResponse>,
90}
91
92/// We currently take no arguments for migrations
93#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
94pub struct MigrateMsg {}
95
96#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
97#[serde(rename_all = "snake_case")]
98pub enum SourceType {
99    MirrorOracle {},
100    AnchorOracle {},
101    BandOracle {},
102    FixedPrice {
103        price: Decimal,
104    },
105    Terraswap {
106        terraswap_pair_addr: String,
107        intermediate_denom: Option<String>,
108    },
109    AnchorMarket {
110        anchor_market_addr: String,
111    },
112    Native {
113        native_denom: String,
114    },
115}
116
117impl fmt::Display for SourceType {
118    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
119        match *self {
120            SourceType::MirrorOracle { .. } => write!(f, "mirror_oracle"),
121            SourceType::AnchorOracle { .. } => write!(f, "anchor_oracle"),
122            SourceType::BandOracle { .. } => write!(f, "band_oracle"),
123            SourceType::FixedPrice { .. } => write!(f, "fixed_price"),
124            SourceType::Terraswap { .. } => write!(f, "terraswap"),
125            SourceType::AnchorMarket { .. } => write!(f, "anchor_market"),
126            SourceType::Native { .. } => write!(f, "native"),
127        }
128    }
129}