1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::Decimal;
5
6pub const DEFAULT_PRIORITY: u8 = 10;
7pub const MAX_WHITELISTED_PROXIES: u8 = 15;
8
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
10pub struct InstantiateMsg {
11 pub owner: String,
12 pub base_denom: String,
13 pub max_proxies_per_symbol: u8,
14}
15
16#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
17#[serde(rename_all = "snake_case")]
18pub enum HubExecuteMsg {
19 UpdateOwner { owner: String },
21 UpdateMaxProxies { max_proxies_per_symbol: u8 },
23 RegisterSource {
25 symbol: String,
26 proxy_addr: String,
27 priority: Option<u8>,
28 },
29 BulkRegisterSource {
31 sources: Vec<(String, String, Option<u8>)>, },
33 UpdateSourcePriorityList {
35 symbol: String,
36 priority_list: Vec<(String, u8)>,
37 },
38 RemoveSource { symbol: String, proxy_addr: String },
40 WhitelistProxy {
43 proxy_addr: String,
44 provider_name: String,
45 },
46 RemoveProxy { proxy_addr: String },
48 InsertAssetSymbolMap {
51 map: Vec<(String, String)>, },
53}
54
55#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
56#[serde(rename_all = "snake_case")]
57pub enum HubQueryMsg {
58 Config {},
60 ProxyWhitelist {},
62 AllSources {
64 start_after: Option<String>, limit: Option<u32>,
66 },
67 Sources { asset_token: String },
69 SourcesBySymbol { symbol: String },
71 Price {
74 asset_token: String,
75 timeframe: Option<u64>,
76 },
77 PriceBySymbol {
80 symbol: String,
81 timeframe: Option<u64>,
82 },
83 PriceList { asset_token: String },
85 PriceListBySymbol { symbol: String },
87 AssetSymbolMap {
89 start_after: Option<String>, limit: Option<u32>,
91 },
92 CheckSource { proxy_addr: String, symbol: String },
97}
98
99#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
100pub struct ConfigResponse {
101 pub owner: String,
102 pub base_denom: String,
103 pub max_proxies_per_symbol: u8,
104}
105
106#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
107pub struct PriceResponse {
108 pub rate: Decimal,
109 pub last_updated: u64,
110}
111
112#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
113#[serde(rename_all = "snake_case")]
114pub enum PriceQueryResult {
115 Success(PriceResponse),
116 Fail,
117}
118
119#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
120pub struct PriceListResponse {
121 pub price_list: Vec<(u8, ProxyInfoResponse, PriceQueryResult)>, }
123
124#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
125pub struct SourcesResponse {
126 pub symbol: String,
127 pub proxies: Vec<(u8, ProxyInfoResponse)>,
128}
129
130#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
131pub struct AllSourcesResponse {
132 pub list: Vec<SourcesResponse>,
133}
134
135impl From<crate::proxy::ProxyPriceResponse> for PriceResponse {
136 fn from(proxy_res: crate::proxy::ProxyPriceResponse) -> Self {
137 PriceResponse {
138 rate: proxy_res.rate,
139 last_updated: proxy_res.last_updated,
140 }
141 }
142}
143
144#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
145pub struct ProxyWhitelistResponse {
146 pub proxies: Vec<ProxyInfoResponse>,
147}
148
149#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
150pub struct ProxyInfoResponse {
151 pub address: String,
152 pub provider_name: String,
153}
154
155#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
156pub struct AssetSymbolMapResponse {
157 pub map: Vec<(String, String)>, }