Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions framework/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions framework/packages/standards/oracle/Cargo.toml
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 }
5 changes: 5 additions & 0 deletions framework/packages/standards/oracle/README.md
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.
22 changes: 22 additions & 0 deletions framework/packages/standards/oracle/src/command.rs
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.
///
/// 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>;
}
75 changes: 75 additions & 0 deletions framework/packages/standards/oracle/src/error.rs
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),

#[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 {},
}
11 changes: 11 additions & 0 deletions framework/packages/standards/oracle/src/lib.rs
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";
51 changes: 51 additions & 0 deletions framework/packages/standards/oracle/src/msg.rs
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)]

Check warning on line 22 in framework/packages/standards/oracle/src/msg.rs

View check run for this annotation

Codecov / codecov/patch

framework/packages/standards/oracle/src/msg.rs#L21-L22

Added lines #L21 - L22 were not covered by tests
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]

Check warning on line 43 in framework/packages/standards/oracle/src/msg.rs

View check run for this annotation

Codecov / codecov/patch

framework/packages/standards/oracle/src/msg.rs#L43

Added line #L43 was not covered by tests
pub struct PriceResponse {
/// Price response
pub price: Decimal,
}

/// No Config for this adapter
#[cosmwasm_schema::cw_serde]

Check warning on line 50 in framework/packages/standards/oracle/src/msg.rs

View check run for this annotation

Codecov / codecov/patch

framework/packages/standards/oracle/src/msg.rs#L50

Added line #L50 was not covered by tests
pub struct Config {}
7 changes: 0 additions & 7 deletions framework/taplo.toml

This file was deleted.

1 change: 1 addition & 0 deletions framework/taplo.toml
15 changes: 10 additions & 5 deletions integrations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
# "wyndex-adapter",
# "kujira-adapter",
# "mars-adapter",
"oracles/pyth",
]

resolver = "2"
Expand Down Expand Up @@ -60,19 +61,23 @@ abstract-std = { version = "0.25.0" }
abstract-adapter-utils = { version = "0.25.0" }
abstract-dex-standard = { version = "0.25.0" }
abstract-money-market-standard = { version = "0.25.0" }
abstract-oracle-standard = { version = "0.25.0" }
abstract-staking-standard = { version = "0.25.0" }

# TODO: REMOVE As soon as new dex-standard published
[patch.crates-io]
abstract-adapter = { path = "../framework/packages/abstract-adapter" }
abstract-macros = { path = "../framework/packages/abstract-macros" }
abstract-sdk = { path = "../framework/packages/abstract-sdk" }
abstract-std = { path = "../framework/packages/abstract-std" }

abstract-adapter = { path = "../framework/packages/abstract-adapter" }
abstract-interface = { path = "../framework/packages/abstract-interface" }

abstract-adapter-utils = { path = "../framework/packages/standards/utils" }
abstract-dex-standard = { path = "../framework/packages/standards/dex" }
abstract-interface = { path = "../framework/packages/abstract-interface" }
abstract-macros = { path = "../framework/packages/abstract-macros" }
abstract-money-market-standard = { path = "../framework/packages/standards/money-market" }
abstract-sdk = { path = "../framework/packages/abstract-sdk" }
abstract-oracle-standard = { path = "../framework/packages/standards/oracle" }
abstract-staking-standard = { path = "../framework/packages/standards/staking" }
abstract-std = { path = "../framework/packages/abstract-std" }

# In case polytone not released
# abstract-polytone = { git = "https://github.com/AbstractSDK/polytone.git", branch = "bump/cw2" }
Expand Down
26 changes: 26 additions & 0 deletions integrations/oracles/pyth/Cargo.toml
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" }
10 changes: 10 additions & 0 deletions integrations/oracles/pyth/README.md
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


The available pariss can bd found under this link: https://www.pyth.network/developers/price-feed-ids#stable
Loading
Loading