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>,
}
* = optional
InitMsg
#[cw_serde]
pub struct InstantiateMsg {
pub pyth_contract: String,
pub owner: Addr,
}
{
"owner": "sei...address...",
"pyth_contract": "sei...address..."
}
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
}
}
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..."
}
}
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
}
}
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..."
}
}
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"
}
}
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
}
}
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"
]
}
}
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"
}
}
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
}
}
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"
}
}