neutron_sdk/bindings/oracle/
query.rs

1use crate::bindings::oracle::types::{CurrencyPair, QuotePrice};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
6#[serde(rename_all = "snake_case")]
7pub enum OracleQuery {
8    GetAllCurrencyPairs {},
9    GetPrice { currency_pair: CurrencyPair },
10    GetPrices { currency_pair_ids: Vec<String> },
11}
12
13#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
14#[serde(rename_all = "snake_case")]
15pub struct GetPriceResponse {
16    /// **price** represents the quote-price for the CurrencyPair given in
17    /// GetPriceRequest (possibly nil if no update has been made)
18    pub price: QuotePrice,
19    /// **nonce** represents the nonce for the CurrencyPair if it exists in state
20    pub nonce: u64,
21    /// **decimals* represents the number of decimals that the quote-price is
22    /// represented in. For Pairs where ETHEREUM is the quote this will be 18,
23    /// otherwise it will be 8.
24    pub decimals: u64,
25    /// *id** represents the identifier for the CurrencyPair.
26    #[serde(default)]
27    pub id: u64,
28}
29
30#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
31#[serde(rename_all = "snake_case")]
32pub struct GetPricesResponse {
33    pub prices: Vec<GetPriceResponse>,
34}
35
36#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
37#[serde(rename_all = "snake_case")]
38pub struct GetAllCurrencyPairsResponse {
39    pub currency_pairs: Vec<CurrencyPair>,
40}