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

Key
Type
Description
owner
CanonicalAddr
Address of contract owner that can feed in price values
base_asset
String
Asset which fed-in prices will be denominated in

InstantiateMsg

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InstantiateMsg {
3
pub owner: String,
4
pub base_asset: String,
5
}
Copied!
1
{
2
"owner": "terra1...",
3
"base_asset": "uusd"
4
}
Copied!
Key
Type
Description
owner
String
Address of contract owner that can feed in price values
base_asset
String
Asset which fed-in prices will be denominated in

ExecuteMsg

UpdateConfig

Updates the configuration of the contract. Can only be issued by the owner.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UpdateConfig {
5
owner: Option<String>,
6
}
7
}
Copied!
1
{
2
"update_config": {
3
"owner": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
owner*
String
Address of new owner
* = optional

RegisterFeeder

Registers a feeder to the specified asset token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
RegisterFeeder {
5
asset: String,
6
feeder: String,
7
}
8
}
Copied!
1
{
2
"register_feeder": {
3
"asset": "terra1...", // Stringified Cw20 contract address
4
"feeder": "terra1..."
5
}
6
}
Copied!
Key
Type
Description
asset
String
Asset to register feeder
feeder
String
Address of feeder to register

FeedPrice

Feeds new price data. Can only be issued by the owner.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
FeedPrice {
5
prices: Vec<(String, Decimal256)>,
6
}
7
}
Copied!
1
{
2
"feed_price": {
3
"prices": [
4
["terra1...", "123.456789"], // (Stringified Cw20 contract address, price)
5
["terra1...", "123.456789"]
6
]
7
}
8
}
Copied!
Key
Type
Description
prices
Vec<(String, Decimal256)>
Vector of assets and their prices

QueryMsg

Config

Gets the Oracle contract configuration.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Config {}
5
}
Copied!
1
{
2
"config": {}
3
}
Copied!
Key
Type
Description

ConfigResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub base_asset: String,
5
}
Copied!
1
{
2
"owner": "terra1...",
3
"base_asset": "uusd"
4
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
base_asset
String
Asset in which fed-in prices will be denominated

Feeder

Gets the feeder for the specified asset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Feeder {
5
asset: String,
6
}
7
}
Copied!
1
{
2
"feeder": {
3
"asset": "terra1..." // Stringified Cw20 Token contract address
4
}
5
}
Copied!
Key
Type
Description
asset
String
Asset to get feeder information

FeederResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct FeederResponse {
3
pub asset: String,
4
pub feeder: String,
5
}
Copied!
1
{
2
"asset": "terra1...", // Stringified Cw20 Token contract address
3
"feeder": "terra1..."
4
}
Copied!
Key
Type
Description
asset
String
Asset type
feeder
String
Address of feeder allowed to feed prices for this asset

Price

Gets price information for the specified base asset denominated in the quote asset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Price {
5
base: String,
6
quote: String,
7
}
8
}
Copied!
1
{
2
"price": {
3
"base": "terra1...", // Asset token contract HumanAddr in String form
4
"quote": "uusd"
5
}
6
}
Copied!
Key
Type
Description
base
String
Asset for which to get price
quote
String
Asset in which calculated price will be denominated
* = optional

PriceResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PriceResponse {
3
pub rate: Decimal256,
4
pub last_updated_base: u64,
5
pub last_updated_quote: u64,
6
}
Copied!
1
{
2
"rate": "123.456789",
3
"last_updated_base": 123456,
4
"last_updated_quote": 123456
5
}
Copied!
Key
Type
Description
rate
Decimal256
Price of base asset denominated in quote assets
last_updated_base
u64
Unix block timestamp when the base asset price was last fed in
last_updated_quote
u64
Unix block timestamp when the quote asset price was last fed in

Prices

Gets price information for all assets
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Prices {
5
start_after: Option<String>,
6
limit: Option<u32>,
7
}
8
}
Copied!
1
{
2
"prices": {
3
"start_after": "terra1...", // Asset token contract HumanAddr in String form
4
"limit": 10
5
}
6
}
Copied!
Key
Type
Description
start_after*
String
Asset to start query
limit*
u32
Maximum number of query entries

PricesResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PricesResponse {
3
pub prices: Vec<PricesResponseElem>,
4
}
5
6
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
7
pub struct PricesResponseElem {
8
pub asset: String,
9
pub price: Decimal256,
10
pub last_updated_time: u64,
11
}
Copied!
1
{
2
"prices": [
3
{
4
"asset": "terra1...", // Stringified Cw20 token contract HumanAddr
5
"price": "123.45678",
6
"last_updated_time": 10000
7
}
8
{
9
"asset": "terra1...", // Stringified Cw20 token contract HumanAddr
10
"price": "123.45678",
11
"last_updated_time": 10000
12
}
13
]
14
}
Copied!
Key
Type
Description
prices
Vec<PricesResponseElem>
Vector of Asset price information
Key
Type
Description
asset
String
Asset whose price is being read
price
Decimal256
Price of Asset
last_updated_time
u64
Unix block timestamp when the price was last updated
Last modified 17d ago