Oracle

Encapsulated the call to PythOracle.

Config

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Config {
    pub owner: CanonicalAddr,
    pub pyth_contract: CanonicalAddr,
    pub new_owner: Option<CanonicalAddr>,
}
Key
Type
Description

owner

CanonicalAddr

The address of the contract's owner

pyth_contract

CanonicalAddr

The address of pyth oracle contract

new_owner*

CanonicalAddr

The address of the contract's new owner

* = optional

InitMsg

#[cw_serde]
pub struct InstantiateMsg {
    pub pyth_contract: String,
    pub owner: Addr,
}
{
  "owner": "sei...address...",
  "pyth_contract": "sei...address..."
}
Key
Type
Description

owner

string

The address of the contract's owner

pyth_contract

string

The address of pyth oracle contract

ExecuteMsg

ConfigFeedInfo

Set the relevant information for updating oracle.

#[cw_serde]
pub enum ExecuteMsg {
    ConfigFeedInfo {
        asset: String,
        price_feed_id: String,
        price_feed_symbol: String,
        price_feed_decimal: u32,
        check_feed_age: bool,
        price_feed_age: u64,
    },
}
{
  "config_feed_info": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "price_feed_id": "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
    "price_feed_symbol": "Crypto.ETH/USD",
    "price_feed_decimal": 8,
    "price_feed_age": 360,
    "check_feed_age": true
  }
}
Key
Type
Description

asset

string

The address of the asset

price_feed_id

string

The pyth price feed id

price_feed_symbol

string

The pyth price feed symbol

price_feed_decimal

u32

The pyth price feed decimal

check_feed_age

bool

Whether to check the age of the price feed

price_feed_age

u64

The maximum age of the price feed in seconds

ChangeOwner

Change the contract owner, only can issued by current owner.

#[cw_serde]
pub enum ExecuteMsg {
    ChangeOwner {
        new_owner: String,
    },
}
{
  "change_owner": {
    "new_owner": "sei...addr..."
  }
}
Key
Type
Description

new_owner

string

The address of the new contract owner.

SetConfigFeedValid

Set whether the oracle is available, the default is available, the type is bool.

#[cw_serde]
pub enum ExecuteMsg {
    SetConfigFeedValid {
        asset: String,
        valid: bool,
    },
}
{
  "set_config_feed_valid": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "valid": true
  }
}
Key
Type
Description

asset

string

The address of the asset

valid

bool

Whether the oracle is available

ChangePythContract

Change the pyth contract address, only can issued by current owner.

#[cw_serde]
pub enum ExecuteMsg {
    ChangePythContract {
        pyth_contract: String,
    },
}
{
  "change_pyth_contract": {
    "pyth_contract": "sei...addr..."
  }
}
Key
Type
Description

pyth_contract

String

The pyth contract address

QueryMsg

All query messages are described below. A custom struct is defined for each query response.

QueryPrice

Returns the price of the asset.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(PriceResponse)]
    QueryPrice { asset: String },
}
{
  "query_price": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
  }
}
Key
Type
Description

asset

string

The address of the asset

PriceResponse

#[cw_serde]
pub struct PriceResponse {
    pub asset: String,
    pub emv_price: Decimal256,
    pub emv_price_raw: i64,
    pub price: Decimal256,
    pub price_raw: i64,
    pub last_updated_base: u64,
    pub last_updated_quote: u64,
}
{
  "price_response": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "emv_price": "1.00000000",
    "emv_price_raw": 100000000,
    "price": "1.00000000",
    "price_raw": 100000000,
    "last_updated_base": 1634160000,
    "last_updated_quote": 1634160000
  }
}
Key
Type
Description

asset

string

The address of the asset

emv_price

decimal

The emv price of the asset in the base currency

emv_price_raw

i64

The emv price of the asset in the base currency, multiplied by 10^8

price

decimal

The price of the asset in the quote currency

price_raw

i64

The price of the asset in the quote currency, multiplied by 10^8

last_updated_base

u64

The timestamp of the last update of the price of the asset in the base currency

last_updated_quote

u64

The timestamp of the last update of the price of the asset in the quote currency

QueryPrices

Returns the prices of the assets.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(Vec < PriceResponse >)]
    QueryPrices { assets: Vec<String> },
}
{
  "query_prices": {
    "assets": [
      "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
      "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/eth"
    ]
  }
}
Key
Type
Description

assets

Vec<String>

The list of asset addresses

QueryConfig

Returns information about global config.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(ConfigResponse)]
    QueryConfig {},
}
{
  "query_config": {}
}

ConfigResponse

#[cw_serde]
pub struct PythFeederConfigResponse {
    pub price_feed_id: PriceIdentifier,
    pub price_feed_symbol: String,
    pub price_feed_decimal: u32,
    pub price_feed_age: u64,
    pub check_feed_age: bool,
    pub is_valid: bool,
}
{
  "config_response": {
    "price_feed_id": "fff...",
    "price_feed_symbol": "USDT",
    "price_feed_decimal": 6,
    "price_feed_age": 1634160000,
    "check_feed_age": true,
    "is_valid": true
  }
}

QueryPythFeederConfig

Returns the pyth feeder config.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(PythFeederConfigResponse)]
    QueryPythFeederConfig { asset: String },
}
{
  "query_pyth_feeder_config": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
  }
}
Key
Type
Description

asset

string

The address of the asset

PythFeederConfigResponse

#[cw_serde]
pub struct PythFeederConfigResponse {
    pub price_feed_id: PriceIdentifier,
    pub price_feed_symbol: String,
    pub price_feed_decimal: u32,
    pub price_feed_age: u64,
    pub check_feed_age: bool,
    pub is_valid: bool,
}
{
  "pyth_feeder_config_response": {
    "price_feed_id": "fff...",
    "price_feed_symbol": "USDT",
    "price_feed_decimal": 6,
    "price_feed_age": 1634160000,
    "check_feed_age": true,
    "is_valid": true
  }
}
Key
Type
Description

price_feed_id

string

The price feed id

price_feed_symbol

string

The price feed symbol

price_feed_decimal

u32

The price feed decimal

price_feed_age

u64

The price feed age

check_feed_age

bool

Whether to check the price feed age

is_valid

bool

Whether the config is valid

QueryExchangeRateByAssetLabel

Returns the exchange rate of the asset label.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(Decimal256)]
    QueryExchangeRateByAssetLabel { base_label: String, quote_label: String },
}
{
  "query_exchange_rate_by_asset_label": {
    "base_label": "USDT",
    "quote_label": "ETH"
  }
}
Key
Type
Description

base_label

String

The base label

quote_label

String

The quote label

Last updated