Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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 @@
# Oracle Adapter Trait

A trait that defines a standard interface for Oracle interactions. This trait should be implemented for each Oracle that the adapter supports.

To implement this trait, create a new package, import this crate and implement the trait for your Oracle.
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 Oracle adapters support the expected functionality.
///
/// Implements the usual Oracle 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>;
}
60 changes: 60 additions & 0 deletions framework/packages/standards/oracle/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use abstract_adapter::AdapterError;
use abstract_sdk::AbstractSdkError;
use abstract_std::{objects::ans_host::AnsHostError, 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("Oracle {0} is not a known oracle on this network.")]
UnknownOracle(String),

#[error("Oracle {0} is not local to this network.")]
ForeignOracle(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("Not implemented for oracle {0}")]
NotImplemented(String),

#[error("Message generation for IBC queries not supported.")]
IbcMsgQuery,

#[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)]
//! # Oracle Adapter API
// re-export response types
use abstract_std::adapter;
use cosmwasm_schema::QueryResponses;
use cosmwasm_std::{Decimal, Empty};

/// The name of the oracle to query prices from.
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 oracle 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
82 changes: 43 additions & 39 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 All @@ -27,52 +28,55 @@ version = "0.25.0"

[workspace.dependencies]
cosmwasm-schema = { version = "2.0" }
cosmwasm-std = { version = "2.0" }
cosmwasm-std = { version = "2.0" }
cw-address-like = { version = "2.0" }
cw-asset = { version = "4.0" }
cw-controllers = "2.0"
cw-orch = { version = "0.27.0" }
cw-ownable = { version = "2.0" }
cw-plus-orch = { version = "0.25.0" }
cw-asset = { version = "4.0" }
cw-controllers = "2.0"
cw-orch = { version = "0.27.0" }
cw-ownable = { version = "2.0" }
cw-plus-orch = { version = "0.25.0" }
cw-storage-plus = "2.0.0"
cw-utils = "2.0"
cw2 = "2.0.0"
cw20 = { version = "2.0.0" }
cw20-base = { version = "2.0.0" }
cw-utils = "2.0"
cw2 = "2.0.0"
cw20 = { version = "2.0.0" }
cw20-base = { version = "2.0.0" }

anyhow = "1.0"

chrono = { version = "0.4.31", default-features = false }
clap = { version = "4.0.32", features = ["derive"] }
protobuf = { version = "2", features = ["with-bytes"] }
schemars = "0.8"
semver = "1.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }
chrono = { version = "0.4.31", default-features = false }
clap = { version = "4.0.32", features = ["derive"] }
protobuf = { version = "2", features = ["with-bytes"] }
schemars = "0.8"
semver = "1.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.50" }

## crates in order of publishing ## see docs/Publishing.md

abstract-adapter = { version = "0.25.0" }
abstract-adapter = { version = "0.25.0" }
abstract-interface = { version = "0.25.0" }
abstract-sdk = { version = "0.25.0" }
abstract-std = { version = "0.25.0" }
abstract-sdk = { version = "0.25.0" }
abstract-std = { version = "0.25.0" }

abstract-adapter-utils = { version = "0.25.0" }
abstract-dex-standard = { 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-staking-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-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-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-money-market-standard = { path = "../framework/packages/standards/money-market" }
abstract-sdk = { path = "../framework/packages/abstract-sdk" }
abstract-staking-standard = { path = "../framework/packages/standards/staking" }
abstract-std = { path = "../framework/packages/abstract-std" }
abstract-oracle-standard = { path = "../framework/packages/standards/oracle" }
abstract-staking-standard = { path = "../framework/packages/standards/staking" }

# In case polytone not released
# abstract-polytone = { git = "https://github.com/AbstractSDK/polytone.git", branch = "bump/cw2" }
Expand All @@ -81,12 +85,12 @@ abstract-std = { path = "../framework/packages/abstract-std" }

# Backup release profile, will result in warnings during optimization
[profile.release]
codegen-units = 1
debug = false
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false
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" }
Loading
Loading