-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from neutron-org/feat/sdk-50
Feat/sdk 50
- Loading branch information
Showing
20 changed files
with
399 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod query; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::bindings::marketmap::types::{Market, MarketMap, Params}; | ||
use crate::bindings::oracle::types::CurrencyPair; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum MarketMapQuery { | ||
/// Parameters queries the parameters of the module. | ||
Params {}, | ||
LastUpdated {}, | ||
MarketMap {}, | ||
Market { | ||
currency_pair: CurrencyPair, | ||
}, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct ParamsResponse { | ||
pub params: Params, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct LastUpdatedResponse { | ||
pub last_updated: u64, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct MarketMapResponse { | ||
/// **market_map** defines the global set of market configurations for all providers | ||
/// and markets. | ||
pub market_map: MarketMap, | ||
/// **last_updated** is the last block height that the market map was updated. | ||
/// This field can be used as an optimization for clients checking if there | ||
/// is a new update to the map. | ||
pub last_updated: u64, | ||
/// **chain_id** is the chain identifier for the market map. | ||
pub chain_id: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct MarketResponse { | ||
pub market: Market, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use schemars::{JsonSchema, Map}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct Params { | ||
pub admin: String, | ||
pub market_authorities: Vec<String>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct MarketMap { | ||
pub markets: Map<String, Market>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct Market { | ||
/// **ticker** is the full list of tickers and their associated configurations | ||
/// to be stored on-chain. | ||
pub ticker: Ticker, | ||
pub provider_configs: Vec<ProviderConfig>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct ProviderConfig { | ||
/// **name** corresponds to the name of the provider for which the configuration is | ||
/// being set. | ||
pub name: String, | ||
/// **off_chain_ticker** is the off-chain representation of the ticker i.e. BTC/USD. | ||
/// The off-chain ticker is unique to a given provider and is used to fetch the | ||
/// price of the ticker from the provider. | ||
pub off_chain_ticker: String, | ||
/// **normalize_by_pair** is the currency pair for this ticker to be normalized by. | ||
/// For example, if the desired Ticker is BTC/USD, this market could be reached | ||
/// using: OffChainTicker = BTC/USDT NormalizeByPair = USDT/USD This field is | ||
/// optional and nullable. | ||
pub normalize_by_pair: Option<CurrencyPair>, | ||
/// **invert** is a boolean indicating if the BASE and QUOTE of the market should | ||
/// be inverted. i.e. BASE -> QUOTE, QUOTE -> BASE | ||
#[serde(default)] | ||
pub invert: bool, | ||
/// **metadata_json** is a string of JSON that encodes any extra configuration | ||
/// for the given provider config. | ||
#[serde(rename(serialize = "metadata_JSON", deserialize = "metadata_JSON"))] | ||
pub metadata_json: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
pub struct CurrencyPair { | ||
#[serde(rename(serialize = "Base", deserialize = "Base"))] | ||
pub base: String, | ||
#[serde(rename(serialize = "Quote", deserialize = "Quote"))] | ||
pub quote: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct Ticker { | ||
/// **currency_pair** is the currency pair for this ticker. | ||
pub currency_pair: CurrencyPair, | ||
/// **decimals** is the number of decimal places for the ticker. The number of | ||
/// decimal places is used to convert the price to a human-readable format. | ||
pub decimals: u64, | ||
/// **min_provider_count** is the minimum number of providers required to consider | ||
/// the ticker valid. | ||
pub min_provider_count: u64, | ||
/// **enabled** is the flag that denotes if the Ticker is enabled for price | ||
/// fetching by an oracle. | ||
#[serde(default)] | ||
pub enabled: bool, | ||
/// **metadata_json** is a string of JSON that encodes any extra configuration | ||
/// for the given ticker. , | ||
#[serde(rename(serialize = "metadata_JSON", deserialize = "metadata_JSON"))] | ||
pub metadata_json: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub mod dex; | ||
pub mod marketmap; | ||
#[allow(deprecated)] | ||
pub mod msg; | ||
pub mod oracle; | ||
pub mod query; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod query; | ||
pub mod types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::bindings::oracle::types::{CurrencyPair, QuotePrice}; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum OracleQuery { | ||
GetAllCurrencyPairs {}, | ||
GetPrice { currency_pair: CurrencyPair }, | ||
GetPrices { currency_pair_ids: Vec<String> }, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct GetPriceResponse { | ||
/// **price** represents the quote-price for the CurrencyPair given in | ||
/// GetPriceRequest (possibly nil if no update has been made) | ||
pub price: QuotePrice, | ||
/// **nonce** represents the nonce for the CurrencyPair if it exists in state | ||
pub nonce: u64, | ||
/// **decimals* represents the number of decimals that the quote-price is | ||
/// represented in. For Pairs where ETHEREUM is the quote this will be 18, | ||
/// otherwise it will be 8. | ||
pub decimals: u64, | ||
/// *id** represents the identifier for the CurrencyPair. | ||
#[serde(default)] | ||
pub id: u64, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct GetPricesResponse { | ||
pub prices: Vec<GetPriceResponse>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct GetAllCurrencyPairsResponse { | ||
pub currency_pairs: Vec<CurrencyPair>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use cosmwasm_std::Int128; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
pub struct CurrencyPair { | ||
#[serde(rename(serialize = "Base", deserialize = "Base"))] | ||
pub base: String, | ||
#[serde(rename(serialize = "Quote", deserialize = "Quote"))] | ||
pub quote: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
#[serde(rename_all = "snake_case")] | ||
pub struct QuotePrice { | ||
pub price: Int128, | ||
/// **block_timestamp** tracks the block height associated with this price update. | ||
/// We include block timestamp alongside the price to ensure that smart | ||
/// contracts and applications are not utilizing stale oracle prices | ||
pub block_timestamp: String, | ||
/// **block_height** is height of block mentioned above | ||
pub block_height: Option<u64>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v3.0.3 | ||
3357d418e391c14e1a4800ab640932896ed93fe8 |
Oops, something went wrong.