Oracle

The Oracle contract acts as the price source for the Anchor Money Market. Stablecoin-denominated prices of bAssets are periodically reported by oracle feeders, and are made queriable by other smart contracts in the Anchor ecosystem.

Config

InstantiateMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub owner: String, 
    pub base_asset: String, 
}

ExecuteMsg

UpdateConfig

Updates the configuration of the contract. Can only be issued by the owner.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    UpdateConfig {
        owner: Option<String>, 
    }
}

* = optional

RegisterFeeder

Registers a feeder to the specified asset token.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    RegisterFeeder {
        asset: String, 
        feeder: String, 
    }
}

FeedPrice

Feeds new price data. Can only be issued by the owner.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    FeedPrice {
        prices: Vec<(String, Decimal256)>, 
    }
}

QueryMsg

Config

Gets the Oracle contract configuration.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Config {}
}

ConfigResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
    pub owner: String, 
    pub base_asset: String, 
}

Feeder

Gets the feeder for the specified asset.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Feeder {
        asset: String, 
    }
}

FeederResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct FeederResponse {
    pub asset: String, 
    pub feeder: String, 
}

Price

Gets price information for the specified base asset denominated in the quote asset.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Price {
        base: String, 
        quote: String, 
    }
}

* = optional

PriceResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PriceResponse {
    pub rate: Decimal256, 
    pub last_updated_base: u64, 
    pub last_updated_quote: u64, 
}

Prices

Gets price information for all assets

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Prices {
        start_after: Option<String>, 
        limit: Option<u32>, 
    }
}

PricesResponse

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PricesResponse {
    pub prices: Vec<PricesResponseElem>, 
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PricesResponseElem {
    pub asset: String,
    pub price: Decimal256,
    pub last_updated_time: u64,
}

Last updated