From 7bd6c3d198ea3c160644fd802c8cd9795b8d32b2 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 30 May 2024 14:20:45 -0300 Subject: [PATCH 1/3] add basic slinky bindings docs --- .../modules/3rdparty/skip/slinky/overview.md | 210 ++++++++++++++++++ sidebars.js | 7 + 2 files changed, 217 insertions(+) create mode 100644 docs/neutron/modules/3rdparty/skip/slinky/overview.md diff --git a/docs/neutron/modules/3rdparty/skip/slinky/overview.md b/docs/neutron/modules/3rdparty/skip/slinky/overview.md new file mode 100644 index 000000000..e8b016daf --- /dev/null +++ b/docs/neutron/modules/3rdparty/skip/slinky/overview.md @@ -0,0 +1,210 @@ +# Overview +We have integrated the [Slinky](https://skip-protocol-docs.netlify.app/slinky/overview) modules (Oracle & MarketMap) into the Neutron and added WASM bindings to facilitate their usage. This integration enhances our blockchain with reliable, real-time price feeds and market data. +Using `neutron-sdk` you can query these modules via contracts + +### Oracle +For example usage of these queries in contract, check our related [dev-contract](https://github.com/neutron-org/neutron-dev-contracts/blob/727aa94dff53373e34226d31d5bdcfc66e3a1aaf/contracts/oracle/src/contract.rs#L53) +```rust + pub enum OracleQuery { + GetAllCurrencyPairs {}, + GetPrice { currency_pair: CurrencyPair }, + GetPrices { currency_pair_ids: Vec }, + } + ``` + +#### GetAllCurrencyPairs +It is possible to query all pairs currently available + +Request: +```rust +GetAllCurrencyPairs {} +``` +Response: +```rust +pub struct GetAllCurrencyPairsResponse { + pub currency_pairs: Vec, +} + +pub struct CurrencyPair { + #[serde(rename(serialize = "Base", deserialize = "Base"))] + pub base: String, + #[serde(rename(serialize = "Quote", deserialize = "Quote"))] + pub quote: String, +} +``` + +#### GetPrice +Get the price of a specific pair + +Request: +```rust +GetPrice { currency_pair: CurrencyPair } +``` +resp: +```rust +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, +} +``` +#### GetPrices +Get the prices of a multiple specific pairs. + +Request: +```rust +GetPrices { currency_pair_ids: Vec } +``` +Response: +```rust +pub struct GetPricesResponse { + /// A list of price responses for the requested currency pairs. + pub prices: Vec, +} +``` + +### Market Map +For more detailed descriptions, refer to the [MarketMap README](https://github.com/skip-mev/slinky/blob/main/x/marketmap/README.md). + +For example usage of these queries in contract, check our related [dev-contract](https://github.com/neutron-org/neutron-dev-contracts/blob/feat/sdk-50/contracts/marketmap/src/contract.rs#L52) +```rust + pub enum MarketMapQuery { + Params {}, + LastUpdated {}, + MarketMap {}, + Market { + currency_pair: CurrencyPair, + }, +} + ``` + +#### Params +Params of the module + +Request: +```rust + Params {} +``` +Response: +```rust +pub struct ParamsResponse { + pub params: Params, +} + +pub struct Params { + pub admin: String, + pub market_authorities: Vec, +} +``` + +#### LastUpdated +The `LastUpdated` endpoint queries the last block height that the market map was updated. This can be consumed by oracle service providers to recognize when their local configurations must be updated using the heavier MarketMap query. +Request: +```rust + LastUpdated {} +``` +Response: +```rust +pub struct LastUpdatedResponse { + pub last_updated: u64, +} +``` + +#### Market +The `MarketMap` queries the full state of the market by given pair. + +Request: +```rust + Market { + currency_pair: CurrencyPair, + } +``` +resp: +```rust +pub struct MarketResponse { + pub market: Market, +} + +ub 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, +} + +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: 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, +} + +pub struct CurrencyPair { + #[serde(rename(serialize = "Base", deserialize = "Base"))] + pub base: String, + #[serde(rename(serialize = "Quote", deserialize = "Quote"))] + pub quote: String, +} + + +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, +} + +``` + +#### MarketMap +The `MarketMap` queries the full state of the market map as well as associated information for every `Market`. + +Request: +```rust + MarketMap {} +``` +resp: +```rust +pub struct MarketMap { + /// A map of Markets with their structures defined above. + pub markets: Map, +} + +``` diff --git a/sidebars.js b/sidebars.js index 4078d9acd..0eb389b36 100644 --- a/sidebars.js +++ b/sidebars.js @@ -271,6 +271,13 @@ const sidebars = { items: [ 'neutron/modules/3rdparty/skip/block-sdk/overview', ] + }, + { + label: 'Slinky', + type: 'category', + items: [ + 'neutron/modules/3rdparty/skip/slinky/overview', + ] } ], }, From 072d6cfc648d671480b802d480faad2895d45949 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Mon, 3 Jun 2024 18:46:33 -0300 Subject: [PATCH 2/3] update related links --- docs/neutron/modules/3rdparty/skip/slinky/overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/neutron/modules/3rdparty/skip/slinky/overview.md b/docs/neutron/modules/3rdparty/skip/slinky/overview.md index e8b016daf..069e5c93b 100644 --- a/docs/neutron/modules/3rdparty/skip/slinky/overview.md +++ b/docs/neutron/modules/3rdparty/skip/slinky/overview.md @@ -1,9 +1,9 @@ # Overview -We have integrated the [Slinky](https://skip-protocol-docs.netlify.app/slinky/overview) modules (Oracle & MarketMap) into the Neutron and added WASM bindings to facilitate their usage. This integration enhances our blockchain with reliable, real-time price feeds and market data. +We have integrated the [Slinky](https://docs.skip.money/slinky/overview) modules (Oracle & MarketMap) into the Neutron and added WASM bindings to facilitate their usage. This integration enhances our blockchain with reliable, real-time price feeds and market data. Using `neutron-sdk` you can query these modules via contracts ### Oracle -For example usage of these queries in contract, check our related [dev-contract](https://github.com/neutron-org/neutron-dev-contracts/blob/727aa94dff53373e34226d31d5bdcfc66e3a1aaf/contracts/oracle/src/contract.rs#L53) +For example usage of these queries in contract, check our related [example contract](https://github.com/neutron-org/neutron-sdk/tree/d9abe67f0f62d4ea42d1943af53189ec6674d29e/contracts/marketmaphttps://github.com/neutron-org/neutron-sdk/tree/d9abe67f0f62d4ea42d1943af53189ec6674d29e/contracts/marketmap) ```rust pub enum OracleQuery { GetAllCurrencyPairs {}, @@ -75,7 +75,7 @@ pub struct GetPricesResponse { ### Market Map For more detailed descriptions, refer to the [MarketMap README](https://github.com/skip-mev/slinky/blob/main/x/marketmap/README.md). -For example usage of these queries in contract, check our related [dev-contract](https://github.com/neutron-org/neutron-dev-contracts/blob/feat/sdk-50/contracts/marketmap/src/contract.rs#L52) +For example usage of these queries in contract, check our related [example conract](https://github.com/neutron-org/neutron-sdk/tree/d9abe67f0f62d4ea42d1943af53189ec6674d29e/contracts/marketmap) ```rust pub enum MarketMapQuery { Params {}, From 193688be43bb4c0ad503621f9264820c7cbb0ea3 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 13 Jun 2024 15:25:16 -0300 Subject: [PATCH 3/3] merge upstream, reorganize files & review fixes --- .../3rdparty/skip/slinky/bindings/messages.md | 208 ++++++++++++++++++ .../3rdparty/skip/slinky/bindings/overview.md | 5 + 2 files changed, 213 insertions(+) create mode 100644 docs/neutron/modules/3rdparty/skip/slinky/bindings/messages.md create mode 100644 docs/neutron/modules/3rdparty/skip/slinky/bindings/overview.md diff --git a/docs/neutron/modules/3rdparty/skip/slinky/bindings/messages.md b/docs/neutron/modules/3rdparty/skip/slinky/bindings/messages.md new file mode 100644 index 000000000..105d23f56 --- /dev/null +++ b/docs/neutron/modules/3rdparty/skip/slinky/bindings/messages.md @@ -0,0 +1,208 @@ +# Messages + +## Oracle +For example usage of these queries in contract, check our related [example contract](https://github.com/neutron-org/neutron-sdk/tree/d9abe67f0f62d4ea42d1943af53189ec6674d29e/contracts/marketmap) +```rust + pub enum OracleQuery { + GetAllCurrencyPairs {}, + GetPrice { currency_pair: CurrencyPair }, + GetPrices { currency_pair_ids: Vec }, + } + ``` + +### GetAllCurrencyPairs +It is possible to query all pairs currently available + +Request: +```rust +GetAllCurrencyPairs {} +``` +Response: +```rust +pub struct GetAllCurrencyPairsResponse { + pub currency_pairs: Vec, +} + +pub struct CurrencyPair { + #[serde(rename(serialize = "Base", deserialize = "Base"))] + pub base: String, + #[serde(rename(serialize = "Quote", deserialize = "Quote"))] + pub quote: String, +} +``` + +### GetPrice +Get the price of a specific pair + +Request: +```rust +GetPrice { currency_pair: CurrencyPair } +``` +resp: +```rust +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, +} +``` +### GetPrices +Get the prices of a multiple specific pairs. + +Request: +```rust +GetPrices { currency_pair_ids: Vec } +``` +Response: +```rust +pub struct GetPricesResponse { + /// A list of price responses for the requested currency pairs. + pub prices: Vec, +} +``` + +## Market Map +For more detailed descriptions, refer to the [MarketMap README](https://github.com/skip-mev/slinky/blob/main/x/marketmap/README.md). + +For example usage of these queries in contract, check our related [example conract](https://github.com/neutron-org/neutron-sdk/tree/d9abe67f0f62d4ea42d1943af53189ec6674d29e/contracts/marketmap) +```rust + pub enum MarketMapQuery { + Params {}, + LastUpdated {}, + MarketMap {}, + Market { + currency_pair: CurrencyPair, + }, +} + ``` + +### Params +Params of the module + +Request: +```rust + Params {} +``` +Response: +```rust +pub struct ParamsResponse { + pub params: Params, +} + +pub struct Params { + pub admin: String, + pub market_authorities: Vec, +} +``` + +### LastUpdated +The `LastUpdated` endpoint queries the last block height that the market map was updated. This can be consumed by oracle service providers to recognize when their local configurations must be updated using the heavier MarketMap query. +Request: +```rust + LastUpdated {} +``` +Response: +```rust +pub struct LastUpdatedResponse { + pub last_updated: u64, +} +``` + +### Market +The `MarketMap` queries the full state of the market by given pair. + +Request: +```rust + Market { + currency_pair: CurrencyPair, + } +``` +Response: +```rust +pub struct MarketResponse { + pub market: Market, +} + +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, +} + +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: 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, +} + +pub struct CurrencyPair { + #[serde(rename(serialize = "Base", deserialize = "Base"))] + pub base: String, + #[serde(rename(serialize = "Quote", deserialize = "Quote"))] + pub quote: String, +} + + +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, +} + +``` + +### MarketMap +The `MarketMap` queries the full state of the market map as well as associated information for every `Market`. + +Request: +```rust + MarketMap {} +``` +Response: +```rust +pub struct MarketMap { + /// A map of Markets with their structures defined above. + pub markets: Map, +} + +``` diff --git a/docs/neutron/modules/3rdparty/skip/slinky/bindings/overview.md b/docs/neutron/modules/3rdparty/skip/slinky/bindings/overview.md new file mode 100644 index 000000000..fd3406239 --- /dev/null +++ b/docs/neutron/modules/3rdparty/skip/slinky/bindings/overview.md @@ -0,0 +1,5 @@ +# Overview +We have integrated the [Slinky](https://docs.skip.money/slinky/overview) modules (Oracle & MarketMap) into the Neutron and added WASM bindings to facilitate their usage. This integration enhances our blockchain with reliable, real-time price feeds and market data. +Using `neutron-sdk` you can query these modules via contracts. + +Want to check out source code? See _neutron-sdk_ [Oracle](https://github.com/neutron-org/neutron-sdk/tree/f72991efc12fd4dcfbdfe3567347351e48f150dd/packages/neutron-sdk/src/bindings/oracle) & [MarketMap](https://github.com/neutron-org/neutron-sdk/tree/f72991efc12fd4dcfbdfe3567347351e48f150dd/packages/neutron-sdk/src/bindings/marketmap) definitions.