Search…
Oracle
The Oracle Contract exposes an interface for accessing the latest reported price for mAssets. Price quotes are kept up-to-date by oracle feeders that are tasked with periodically fetching exchange rates from reputable sources and reporting them to the Oracle contract.
Prices are only considered valid for 60 seconds. If no new prices are published after the data has expired, Mirror will disable CDP operations (mint, burn, deposit, withdraw) until the price feed resumes.

InitMsg

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InitMsg {
3
pub owner: HumanAddr,
4
pub base_asset: String,
5
}
Copied!
Key
Type
Description
owner
HumanAddr
Address of the owner who can register new assets
base_asset
String
Asset in which prices will be denominated (default TerraUSD)

HandleMsg

UpdateConfig

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

RegisterAsset

Registers a new asset with the oracle, enabling a price feed for the asset. The feeder account responsible for reporting the price is assigned at this step. Can also be used to update an existing asset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
RegisterAsset {
5
asset_token: HumanAddr,
6
feeder: HumanAddr,
7
}
8
}
Copied!
1
{
2
"register_asset": {
3
"asset_token": "terra1...",
4
"feeder": "terra1..."
5
}
6
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token
feeder
HumanAddr
Address of Oracle Feeder for the asset

FeedPrice

Publish a price for one or multiple assets. Caller should be the designated oracle feeder for each of the assets for which price information is provided.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
FeedPrice {
5
prices: Vec<(HumanAddr, Decimal)>,
6
}
7
}
Copied!
1
{
2
"feed_price": {
3
"prices": [
4
["terra1...", "123.456789"],
5
["terra1...", "123.456789"]
6
]
7
}
8
}
Copied!
Key
Type
Description
prices
Vec<(HumanAddr, Decimal)>
Price information for assets

QueryMsg

Config

Get the Mirror 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!

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: HumanAddr,
4
pub base_asset: String,
5
}
Copied!
Key
Type
Description
owner
HumanAddr
Owner address
base_asset
String/'uusd'
Asset in which prices will be denominated (default TerraUSD)
1
{
2
"config": {}
3
}
Copied!

Response

1
{
2
"config_response": {
3
"owner": "terra1...",
4
"base_asset": "uusd"
5
}
6
}
Copied!
Key
Type
Description
owner
HumanAddr
Owner address
base_asset
String/'uusd'
Asset in which prices will be denominated (default TerraUSD)

Feeder

Get asset token details, such as designated oracle feeder.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Feeder {
5
asset_token: HumanAddr,
6
}
7
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token to query

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct FeederResponse {
3
pub asset_token: HumanAddr,
4
pub feeder: HumanAddr,
5
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token to query
feeder
HumanAddr
Terra address of price feeder
1
{
2
"asset": {
3
"asset_token": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token to query

Response

1
{
2
"feeder_response": {
3
"asset_token": "terra1...",
4
"feeder": "terra1..."
5
}
6
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address of asset token to query
feeder
HumanAddr
Terra address of price feeder

Price

Get price information for the specified mAsset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Price {
5
base_asset: String,
6
quote_asset: String
7
}
8
}
Copied!
Key
Type
Description
base_asset
HumanAddr
Asset for which to get price
quote_asset
HumanAddr / 'uusd'
Asset in which price will be denominated

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PriceResponse {
3
pub rate: Decimal,
4
pub last_updated_base: u64,
5
pub last_updated_quote: u64,
6
}
Copied!
Key
Type
Description
rate
HumanAddr
Asset for which to get price
last_updated_base
u64
Block height which the base_asset price has been updated at
last_updated_quote
u64
Block height which the quote_asset price has been updated at
1
{
2
"price": {
3
"base_asset": "terra1...",
4
"quote_asset": "uusd"
5
}
6
}
Copied!
Key
Type
Description
base_asset
HumanAddr
Asset for which to get price
quote_asset
HumanAddr / 'uusd'
Asset in which price will be denominated

Response

1
{
2
"price_response": {
3
"rate": "123.456789",
4
"last_updated_base": 10
5
"last_updated_quote": 10
6
}
7
}
Copied!
Key
Type
Description
rate
HumanAddr
Asset for which to get price
last_updated_base
u64
Block height which the base_asset price has been updated at
last_updated_quote
u64
Block height which the quote_asset price has been updated at

Prices

Get price information for all registered mAssets.
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<HumanAddr>,
6
limit: Option<u32>
7
}
8
}
Copied!
Key
Type
Description
start_after*
HumanAddr
Contract address to start query from
limit
u32
Max number of results to report

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PricesResponseElem {
3
pub asset_token: HumanAddr,
4
pub price: Decimal,
5
pub last_updated_time: u64,
6
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address to start query from
price
Decimal
Current price of the asset_token
last_updated_time
u64
Block height which theasset_tokenprice has been updated at
1
{
2
"prices": {
3
"start_after": "terra1...",
4
"limit": 8
5
}
6
}
Copied!
Key
Type
Description
start_after*
HumanAddr
Contract address to start query from
limit
u32
Max number of results to report

Response

1
{
2
"prices_response": {
3
"asset_token": "terra1...",
4
"price": "123.456789",
5
"last_updated_time": 10,
6
}
7
...
8
}
Copied!
Key
Type
Description
asset_token
HumanAddr
Contract address to start query from
price
Decimal
Current price of the asset_token
last_updated_time
u64
Block height which theasset_tokenprice has been updated at
Last modified 4mo ago