-
Notifications
You must be signed in to change notification settings - Fork 26
Oracle Adapter #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kayanski
wants to merge
23
commits into
main
Choose a base branch
from
nicolas/abs-589-oracle-adapter-implementation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Oracle Adapter #545
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0833341
Added oracle adapter first implementation
Kayanski 49d4edf
Added pyth oracle tests
Kayanski c5deb17
Doc and builds
Kayanski 981f0ee
Added documentation and deployment and tests
Kayanski 88b02d7
Readme
Kayanski 5c4486a
rEMOVE TESTING for oracle
Kayanski 84f8b4e
Revert wasm alll script comments
Kayanski bd220ae
Revert just file
Kayanski eff065f
Update framework/packages/standards/oracle/README.md
Kayanski 961972b
remove dex references inside oracle
Kayanski 1fe48ec
remove dex references inside oracle
Kayanski 7ab80c9
Update integrations/oracles/pyth/README.md
Kayanski e4c132c
Merge remote-tracking branch 'origin/main' into nicolas/abs-589-oracl…
Buckram123 e52f504
bump adapter version for oracle
Buckram123 c302d5f
Update modules/contracts/adapters/oracle/src/lib.rs
Kayanski ed568fa
Update modules/contracts/adapters/oracle/src/lib.rs
Kayanski 9a6d5e2
Remove failling code
Kayanski 652c94a
Merge branch 'nicolas/abs-589-oracle-adapter-implementation' of githu…
Kayanski 8796f49
nits
Kayanski f9aa4a2
Clippy
Kayanski c56e58c
Removed execution layer
Kayanski 7767035
Removed unused deps
Kayanski 5b2e031
Removed unused deps
Kayanski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,52 @@ | ||
| [package] | ||
| description = "The oracle adapter is a Abstract adapter for querying oracle prices. It provides a common interface for all oracles" | ||
| name = "abstract-oracle-standard" | ||
|
|
||
| authors = { workspace = true } | ||
| edition = { workspace = true } | ||
| license = { workspace = true } | ||
| version = { workspace = true } | ||
|
|
||
| exclude = ["contract.wasm", "hash.txt"] | ||
| resolver = "2" | ||
|
|
||
|
|
||
| [lib] | ||
| crate-type = ["cdylib", "rlib"] | ||
|
|
||
| [features] | ||
| default = ["export"] | ||
| export = [] | ||
|
|
||
| # Keep as is until TendermintStake updates. | ||
| [dependencies] | ||
| cosmwasm-schema = { workspace = true } | ||
| cosmwasm-std = { workspace = true } | ||
| cw-address-like = { workspace = true } | ||
| cw-asset = { workspace = true } | ||
| cw-storage-plus = { workspace = true } | ||
| cw20 = { workspace = true } | ||
| schemars = { workspace = true } | ||
| serde = { workspace = true } | ||
| thiserror = { workspace = true } | ||
|
|
||
| abstract-adapter = { version = "0.25.0", path = "../../abstract-adapter" } | ||
| abstract-adapter-utils = { workspace = true } | ||
| abstract-sdk = { workspace = true } | ||
| abstract-std = { workspace = true } | ||
| cw-orch = { workspace = true } | ||
|
|
||
| abstract-interface = { version = "0.25.0", path = "../../abstract-interface" } | ||
|
|
||
| [target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
| workspace-hack = { version = "0.1", path = "../../../workspace-hack" } | ||
|
|
||
| [dev-dependencies] | ||
| abstract-interface = { workspace = true, features = ["daemon"] } | ||
| abstract-sdk = { workspace = true, features = ["test-utils"] } | ||
| abstract-testing = { workspace = true } | ||
| anyhow = { workspace = true } | ||
| clap = { workspace = true } | ||
| dotenv = "0.15.0" | ||
| env_logger = "0.11.3" | ||
| semver = { workspace = true } |
This file contains hidden or 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,5 @@ | ||
| # Dex Adapter Trait | ||
|
|
||
| A trait that defines a standard interface for Dex interactions. This trait should be implemented for each Dex that the adapter supports. | ||
|
|
||
| To implement this trait, create a new package, import this crate and implement the trait for your Dex. | ||
This file contains hidden or 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,22 @@ | ||
| use abstract_adapter_utils::identity::Identify; | ||
| use abstract_sdk::feature_objects::AnsHost; | ||
| use cosmwasm_std::{Deps, Env}; | ||
|
|
||
| use crate::error::OracleError; | ||
| use crate::msg::{PriceResponse, Seconds}; | ||
|
|
||
| /// # OracleCommand | ||
| /// ensures DEX adapters support the expected functionality. | ||
Kayanski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// | ||
| /// Implements the usual DEX operations. | ||
| pub trait OracleCommand: Identify { | ||
| /// Return oracle price given pair id | ||
| fn price( | ||
| &self, | ||
| deps: Deps, | ||
| env: &Env, | ||
| ans_host: &AnsHost, | ||
| price_id: String, | ||
| no_older_than: Seconds, | ||
| ) -> Result<PriceResponse, OracleError>; | ||
| } | ||
This file contains hidden or 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,75 @@ | ||
| use abstract_adapter::AdapterError; | ||
| use abstract_sdk::AbstractSdkError; | ||
| use abstract_std::{ | ||
| objects::{ans_host::AnsHostError, DexAssetPairing}, | ||
| AbstractError, | ||
| }; | ||
| use cosmwasm_std::StdError; | ||
| use cw_asset::AssetError; | ||
| use thiserror::Error; | ||
|
|
||
| #[derive(Error, Debug, PartialEq)] | ||
| pub enum OracleError { | ||
| #[error(transparent)] | ||
| Std(#[from] StdError), | ||
|
|
||
| #[error(transparent)] | ||
| AbstractOs(#[from] AbstractError), | ||
|
|
||
| #[error(transparent)] | ||
| AbstractSdk(#[from] AbstractSdkError), | ||
|
|
||
| #[error(transparent)] | ||
| Asset(#[from] AssetError), | ||
|
|
||
| #[error(transparent)] | ||
| AdapterError(#[from] AdapterError), | ||
|
|
||
| #[error(transparent)] | ||
| AnsHostError(#[from] AnsHostError), | ||
|
|
||
| #[error("DEX {0} is not a known dex on this network.")] | ||
| UnknownDex(String), | ||
Kayanski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #[error("DEX {0} is not local to this network.")] | ||
| ForeignDex(String), | ||
|
|
||
| #[error("Asset type: {0} is unsupported.")] | ||
| UnsupportedAssetType(String), | ||
|
|
||
| #[error("Can't provide liquidity with less than two assets")] | ||
| TooFewAssets {}, | ||
|
|
||
| #[error("Can't provide liquidity with more than {0} assets")] | ||
| TooManyAssets(u8), | ||
|
|
||
| #[error("Provided asset {0} not in pool with assets {1:?}.")] | ||
| ArgumentMismatch(String, Vec<String>), | ||
|
|
||
| #[error("Balancer pool not supported for dex {0}.")] | ||
| BalancerNotSupported(String), | ||
|
|
||
| #[error("Pair {0} on DEX {1} does not match with pair address {2}")] | ||
| DexMismatch(String, String, String), | ||
|
|
||
| #[error("Not implemented for dex {0}")] | ||
| NotImplemented(String), | ||
|
|
||
| #[error("Maximum spread {0} exceeded for dex {1}")] | ||
| MaxSlippageAssertion(String, String), | ||
|
|
||
| #[error("Message generation for IBC queries not supported.")] | ||
| IbcMsgQuery, | ||
|
|
||
| #[error("Asset pairing {} not found.", asset_pairing)] | ||
| AssetPairingNotFound { asset_pairing: DexAssetPairing }, | ||
|
|
||
| #[error("Invalid Generate Message")] | ||
| InvalidGenerateMessage, | ||
|
|
||
| #[error("Pool address not specified. You need to specify it when using raw asset addresses or denom")] | ||
| PoolAddressEmpty, | ||
|
|
||
| #[error("Only account of abstract namespace can update configuration")] | ||
| Unauthorized {}, | ||
| } | ||
This file contains hidden or 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,11 @@ | ||
| mod command; | ||
| mod error; | ||
|
|
||
| pub mod msg; | ||
|
|
||
| // Export interface for use in SDK modules | ||
| pub use abstract_adapter_utils::{coins_in_assets, cw_approve_msgs, Identify}; | ||
| pub use command::OracleCommand; | ||
| pub use error::OracleError; | ||
|
|
||
| pub const ORACLE_ADAPTER_ID: &str = "abstract:oracle"; |
This file contains hidden or 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,51 @@ | ||
| #![warn(missing_docs)] | ||
| //! # Dex Adapter API | ||
| // re-export response types | ||
| use abstract_std::adapter; | ||
| use cosmwasm_schema::QueryResponses; | ||
| use cosmwasm_std::{Decimal, Empty}; | ||
|
|
||
| /// The name of the dex to trade on. | ||
| pub type OracleName = String; | ||
|
|
||
| /// Top-level Abstract Adapter execute message. This is the message that is passed to the `execute` entrypoint of the smart-contract. | ||
| pub type ExecuteMsg = adapter::ExecuteMsg<Empty>; | ||
| /// Top-level Abstract Adapter instantiate message. This is the message that is passed to the `instantiate` entrypoint of the smart-contract. | ||
| pub type InstantiateMsg = adapter::InstantiateMsg<Empty>; | ||
| /// Top-level Abstract Adapter query message. This is the message that is passed to the `query` entrypoint of the smart-contract. | ||
| pub type QueryMsg = adapter::QueryMsg<OracleQueryMsg>; | ||
|
|
||
| impl adapter::AdapterQueryMsg for OracleQueryMsg {} | ||
|
|
||
| /// Query messages for the dex adapter | ||
| #[cosmwasm_schema::cw_serde] | ||
| #[derive(QueryResponses, cw_orch::QueryFns)] | ||
| pub enum OracleQueryMsg { | ||
| /// Query the oracle adapter config | ||
| #[returns(Config)] | ||
| Config {}, | ||
| /// Query the latest price attached to the price source key | ||
| #[returns(PriceResponse)] | ||
| Price { | ||
| /// Identifier of the oracle value that you wish to query on the oracle | ||
| price_source_key: String, | ||
| /// Identifier of the oracle | ||
| oracle: OracleName, | ||
| /// Maximum age of the price | ||
| max_age: Seconds, | ||
| }, | ||
| } | ||
|
|
||
| /// Alias to document time unit the oracle adapter expects data to be in. | ||
| pub type Seconds = u64; | ||
|
|
||
| /// Price Response returned by an adapter query | ||
| #[cosmwasm_schema::cw_serde] | ||
| pub struct PriceResponse { | ||
| /// Price response | ||
| pub price: Decimal, | ||
| } | ||
|
|
||
| /// No Config for this adapter | ||
| #[cosmwasm_schema::cw_serde] | ||
| pub struct Config {} | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| ../taplo.toml |
This file contains hidden or 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 hidden or 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,26 @@ | ||
| [package] | ||
| authors = ["Abstract Money <contact@abstract.money>"] | ||
| description = "Abstract OracleCommand implementation for Pyth" | ||
| edition = "2021" | ||
| license = "MIT OR Apache-2.0" | ||
| name = "abstract-pyth-adapter" | ||
| version = "0.26.0" | ||
|
|
||
| [features] | ||
| default = ["full_integration"] | ||
| full_integration = ["dep:cw20", "dep:cw-asset", "dep:cw-utils", "dep:osmosis-std"] | ||
|
|
||
| [dependencies] | ||
| osmosis-std = { version = "0.26.0", optional = true } | ||
|
|
||
| abstract-oracle-standard = { workspace = true } | ||
| abstract-sdk = { workspace = true } | ||
| abstract-staking-standard = { workspace = true } | ||
| cosmwasm-std = { workspace = true, features = ["stargate"] } | ||
| cw-asset = { workspace = true, optional = true } | ||
| cw-utils = { workspace = true, optional = true } | ||
| cw20 = { workspace = true, optional = true } | ||
|
|
||
| cosmwasm-schema = { workspace = true } | ||
| # pyth-sdk-cw = "1.2.0" | ||
| pyth-sdk-cw = { git = "https://github.com/lvn-hasky-dragon/pyth-crosschain", branch = "update-deps" } |
This file contains hidden or 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,10 @@ | ||
| Pyth oracle is available on the following chains: | ||
|
|
||
| Xion Testnet | ||
| Neutron Testnet | ||
| Osmosis Mainnet | ||
| Neutron Mainnet | ||
| Osmosis Mainnet | ||
Kayanski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| The available pariss can bd found under this link: https://www.pyth.network/developers/price-feed-ids#stable | ||
Kayanski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.