Search…
TeFi Oracle
The TeFi oracle is a set of smart contracts that support price oracles used across multiple DeFi protocols built on top of Terra blockchain, providing an interface for accessing the latest reported prices for the assets provided by its whitelisted oracle services. Price quotes are kept up-to-date by oracle providers that fetch exchange rates for real-world assets from reputable sources.
On the Mirror Protocol, these prices are used for CDP operations (mint, burn, short, deposit, withdraw) while the price feed is active. Prices are considered stale when there is no new valid price for 60 seconds.

Smart Contracts

Contract
Function
Hub
A central directory that holds whitelisted oracle provider information and their proxies
Proxy
Storage of price information maintained by the oracle provider

Hub

The Hub contract is a central directory for all oracle price providers and their proxies. On the Mirror Protocol, the Hub contract is owned by the Mirror Governance contract, and transactions can only be called through Mirror’s governance consensus.
Through the interaction with the Hub contract, the following actions can happen:
  • Whitelisting a new oracle service provider
  • Registering new price sources on an existing proxy
  • Removing and changing priorities of already existing prices

InstantiateMsg

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InstantiateMsg {
3
pub owner: String,
4
pub base_denom: String,
5
pub max_proxies_per_symbol: u8,
6
}
Copied!
Key
Type
Description
owner
String
Owner of Hub contract (Mirror Factory)
base_denom
String
Token in which the price will be displayed
max_proxies_per_symbol
u8
Number of sources that can be registered to a single mAsset

ExecuteMsg

All Oracle Hub contract operations can be only called by owner - Mirror Factory, which is owned by Mirror Governance.

UpdateOwner

Operation to update owner of the Hub contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
UpdateOwner {
5
owner: String
6
},
Copied!
Key
Type
Description
owner
String
Address of the owner to be changed to
1
{
2
"update_owner": {
3
"owner": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
owner
String
Address of the owner to be changed to

UpdateMaxProxies

Operation used to update the maximum number of price sources that can be registered per mAsset
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
UpdateMaxProxies { max_proxies_per_symbol: u8 },
Copied!
Key
Type
Description
max_proxies_per_symbol
u8
Max number of price sources that can be registered per mAsset
1
{
2
"update_max_proxies": {
3
"max_proxies_per_symbol": 3
4
}
5
}
Copied!
Key
Type
Description
max_proxies_per_symbol
u8
Max number of price sources that can be registered per mAsset

RegisterSource

The operation used to register a new price source for an asset. Source can only be registered once a proxy is whitelisted to the Hub contract through the WhitelistProxy operation.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
RegisterSource {
5
symbol: String,
6
proxy_addr: String,
7
priority: Option<u8>,
8
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to register price source for
proxy_addr
String
Address of the proxy contract through which the price is updated
priority
u8
Defines the priority for this price source over other existing ones
1
{
2
"register_source": {
3
"symbol": "AAPL",
4
"proxy_addr": "terra1...",
5
"priority": 30
6
}
7
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to register price source for
proxy_addr
String
Address of the proxy contract through which the price is updated
priority
u8
Defines the priority for this price source over other existing ones

BulkRegisterSource

Registers multiple sources in one transaction.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
BulkRegisterSource {
5
sources: Vec<(String, String, Option<u8>)>, // (symbol, proxy_addr, priority)
6
},
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to register price source for
proxy_addr
String
Address of the proxy contract which the price is updated in
priority
u8
Defines the priority of this price source over other existing ones for an asset
1
{
2
"bulk_register_source": {
3
"sources": [
4
("AAPL", "terra1...", 10),
5
("GOOGL", "terra1...", 20)
6
]
7
}
8
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to register price source for
proxy_addr
String
Address of the proxy contract which the price is updated in
priority
u8
Defines the priority of this price source over other existing ones for an asset

UpdateSourcePriorityList

Updates the priorities for proxies that are already registered
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
UpdateSourcePriorityList {
5
symbol: String,
6
priority_list: Vec<(String, u8)>,
7
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to change source priority for
priority_list
Vec<(String, u8)>
Vector of Source address (String) and priority number (u8)
1
{
2
"update_source_priority_list": {
3
"symbol": "AAPL",
4
"priority_list": [
5
("terra1...", 10),
6
("terra1...", 20)
7
]
8
}
9
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to change source priority for
priority_list
Vec<(String, u8)>
Vector of Source address (String) and priority number (u8)

RemoveSource

Removes a price source of a specified asset symbol from a proxy address.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
RemoveSource {
5
symbol: String,
6
proxy_addr: String
7
},
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to remove price source from
proxy_addr
String
The address of the proxy contract from which the price source is provided
1
{
2
"remove_source": {
3
"symbol": "AAPL",
4
"proxy_addr": "terra1..."
5
}
6
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to remove price source from
proxy_addr
String
The address of the proxy contract from which the price source is provided

WhitelistProxy

Whitelists a new proxy contract as a price source. After the proxy is whitelisted, it can be registered as a source.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
WhitelistProxy {
5
proxy_addr: String,
6
provider_name: String,
7
},
Copied!
Key
Type
Description
proxy_addr
String
Address of the proxy contract to whitelist to Hub
provider_name
String
Name to give to the newly whitelisted proxy
1
{
2
"whitelist_proxy": {
3
"proxy_addr": "terra1...",
4
"provider_name": "Band Protocol Feeder"
5
}
6
}
Copied!
Key
Type
Description
proxy_addr
String
Address of the proxy contract to whitelist to Hub
provider_name
String
Name to give to the newly whitelisted proxy

RemoveProxy

Removes a whitelisted proxy contract entirely from the Hub contract. This is different from RemoveSource which only removes a single price of an asset, instead of removing the entire set of prices from the proxy.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
RemoveProxy {
5
proxy_addr: String
6
},
Copied!
Key
Type
Description
proxy_addr
String
Address of the proxy to remove from Hub contract
1
{
2
"remove_proxy": {
3
"proxy_addr": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
proxy_addr
String
Address of the proxy to remove from Hub contract

InsertAssetSymbolMap

Updates the map of asset_token to symbol. Asset mapping storage is overwritten by this operation if it already exists.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubExecuteMsg {
4
InsertAssetSymbolMap {
5
map: Vec<(String, String)>, // (address, symbol)
6
},
Copied!
Key
Type
Description
address
String
Address of the asset token contract
symbol
String
Symbol applied to the specified address
1
{
2
"insert_asset_symbol_map": {
3
"map": [
4
("terra1...", "AAPL"),
5
("terra1...", "GOOGL")
6
]
7
}
8
}
Copied!
Key
Type
Description
address
String
Address of the asset token contract
symbol
String
Symbol applied to the specified address

QueryMsg

Config

Returns the configuration of the Oracle Hub contract
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
Config {},
Copied!

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub base_denom: String,
5
pub max_proxies_per_symbol: u8,
6
}
Copied!
Key
Type
Description
owner
String
Owner of oracle hub contract (Factory)
base_denom
String
Base price denomination unit (UST)
max_proxies_per_symbol
u8
Maximum number of proxies that can be registered to a symbol
1
{
2
"config": {}
3
}
Copied!

Response

1
{
2
"config_response": {
3
"owner": "terra1...",
4
"base_denom": "uusd",
5
"max_proxies_per_symbol": 2
6
}
7
}
Copied!
Key
Type
Description
owner
String
Owner of oracle hub contract (Factory)
base_denom
String
Base price denomination unit (UST)
max_proxies_per_symbol
u8
Maximum number of proxies that can be registered to a symbol

ProxyWhitelist

Returns the list of whitelisted proxies / oracle providers.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
ProxyWhitelist {},
Copied!

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ProxyWhitelistResponse {
3
pub proxies: Vec<ProxyInfoResponse>,
4
}
5
6
//ProxyInfoResponse
7
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8
pub struct ProxyInfoResponse {
9
pub address: String,
10
pub provider_name: String,
11
}
Copied!
Key
Type
Description
proxies
Vec<ProxyInfoResponse>
Vector list of proxies whitelisted in Oracle Hub
address
String
Address of the whitelisted proxy
provider_name
String
Name applied to the given proxy address
1
{
2
"proxy_whitelist": {}
3
}
Copied!

Response

1
{
2
"proxy_whitelist_response": {
3
"proxies": [
4
("terra1...", "Band Protocol Feeder"),
5
("terra1...", "Band protocol Feeder")
6
]
7
}
8
}
Copied!
Key
Type
Description
proxies
Vec<ProxyInfoResponse>
Vector list of proxies whitelisted in Oracle Hub
address
String
Address of the whitelisted proxy
provider_name
String
Name applied to the given proxy address

AllSources

Returns the list of all symbols with all the sources
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
AllSources {
5
start_after: Option<String>, // symbol for pagination
6
limit: Option<u32>,
7
},
Copied!
Key
Type
Description
start_after
String
Symbol of asset to start from
limit
u32
Max number of entries to return

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct AllSourcesResponse {
3
pub list: Vec<SourcesResponse>,
4
}
5
6
//SourceResponse
7
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8
pub struct PriceListResponse {
9
pub price_list: Vec<(u8, ProxyInfoResponse, PriceQueryResult)>, // (priority, proxy_info, result)
10
}
Copied!
Key
Type
Description
list
Vec<SourceResponse>
Vector list of price list entries
price_list
Vec<(u8, ProxyInfoResponse, PriceQueryResult)>
Returns a list of price priority (u8), proxy information and price results
1
{
2
"all_sources": {
3
"start_after": "AAPL",
4
"limit": 10
5
}
6
}
Copied!
Key
Type
Description
start_after
String
Symbol of asset to start from
limit
u32
Max number of entries to return

Sources

Returns the information all registered proxies for the provided asset_token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
Sources { asset_token: String },
Copied!
Key
Type
Description
asset_token
String
Address of the asset token to return responses for

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct SourcesResponse {
3
pub symbol: String,
4
pub proxies: Vec<(u8, ProxyInfoResponse)>,
5
}
Copied!
Key
Type
Description
list
Vec<SourceResponse>
Vector list of price list entries
price_list
Vec<(u8, ProxyInfoResponse, PriceQueryResult)>
Returns a list of price priority (u8), proxy information and price results
1
{
2
"sources": {
3
"asset_token": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
asset_token
String
Address of the asset token to return responses for

Response

1
{
2
"sources_response": {
3
"symbol": "AAPL",
4
"proxies": [
5
(10, "terra1...", "Band Protocol Feeder"),
6
(10, "terra1...", "Band Protocol Feeder")
7
]
8
}
9
}
Copied!
list
Vec<SourceResponse>
Vector list of price list entries
price_list
Vec<(u8, ProxyInfoResponse, PriceQueryResult)>
Returns a list of price priority (u8), proxy information and price results

SourcesBySymbol

Returns the information of all registered proxies for a provided asset_token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
SourcesBySymbol { symbol: String },
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return source information for

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct SourcesResponse {
3
pub symbol: String,
4
pub proxies: Vec<(u8, ProxyInfoResponse)>,
5
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return source information for
proxies
Vec<(u8, ProxyInfoResponse)>
Returns proxy priority (u8), and general proxy information
1
{
2
"sources_by_symbol": {
3
"symbol": "AAPL"
4
}
5
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return source information for

Response

1
{
2
"sources_response": {
3
"symbol": "AAPL",
4
"proxies": [
5
(10, "terra1...", "Band Protocol Feeder")
6
]
7
}
8
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return source information for
proxies
Vec<(u8, ProxyInfoResponse)>
Returns proxy priority (u8), and general proxy information

Price

Queries the highest priority available price within the timeframe. If timeframe is not provided, the age of the price will be ignored.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
Price {
5
asset_token: String,
6
timeframe: Option<u64>,
7
},
Copied!
Key
Type
Description
asset_token
String
Address of the asset to query prices for
timeframe
Option<u64>
Optional field to enter timeframe of the asset's price to return

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PriceResponse {
3
pub rate: Decimal,
4
pub last_updated: u64,
5
}
Copied!
Key
Type
Description
rate
Decimal
Price denominated in base_denom
last_updated
u64
Last updated time of the given asset's price
1
{
2
"price": {
3
"asset_token": "terra1...",
4
"timeframe": 23451234
5
}
6
}
Copied!
Key
Type
Description
asset_token
String
Address of the asset to query prices for
timeframe
u64
Optional field to enter timeframe of the asset's price to return

Response

1
{
2
"price_response": {
3
"rate": 142.123,
4
"last_updated": 23451234
5
}
6
}
Copied!
Key
Type
Description
rate
Decimal
Price denominated in base_denom
last_updated
u64
Last updated time of the given asset's price

PriceBySymbol

Returns the highest priority available price within the time frame, using the symbol instead of the asset token address. If timeframe is not provided, it will be ignored.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
PriceBySymbol {
5
symbol: String,
6
timeframe: Option<u64>,
7
},
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return price for (ex. AAPL)
timeframe
u64
Optional timeframe to return the price at

Response

Same as Price QueryMsg
1
{
2
"price_by_symbol": {
3
"symbol": "AAPL",
4
"timeframe": 23451234
5
}
6
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return price for (ex. AAPL)
timeframe
u64
Optional timeframe to return the price at

Response

Same as Price QueryMsg

PriceList

Returns all registered proxy prices for the provided asset_token
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
PriceList { asset_token: String },
Copied!
Key
Type
Description
asset_token
String
Address of the asset token contract to return all available prices for

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct PriceListResponse {
3
pub price_list: Vec<(u8, ProxyInfoResponse, PriceQueryResult)>, // (priority, proxy_info, result)
4
}
Copied!
Key
Type
Description
price_list
Vec<(u8, ProxyInfoResponse, PriceQueryResult)>
Returns all proxy sources available for a given symbol asset, including priority, proxy information and price queries.
1
{
2
"price_list": {
3
"asset_token": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
asset_token
String
Address of the token contract to return price list for

PriceListBySymbol

Returns all registered proxy prices for the provided asset_token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
PriceListBySymbol { symbol: String },
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return all price sources for

Response

Same as PriceList
1
{
2
"price_list_by_symbol": {
3
"symbol": "AAPL"
4
}
5
}
Copied!
Key
Type
Description
symbol
String
Symbol of the asset to return all price sources for

Response

Same as PriceList

AssetSymbolMap

Returns the map of asset_token to symbol
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
AssetSymbolMap {
5
start_after: Option<String>, // address for pagination
6
limit: Option<u32>,
7
},
Copied!
Key
Type
Description
start_after
String
Address for pagination
limit
u32
Max number of entries to return

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct AssetSymbolMapResponse {
3
pub map: Vec<(String, String)>, // address, symbol
4
}
Copied!
Key
Type
Description
address
String
Address of the proxy contract
symbol
String
Symbol of the asset
1
{
2
"asset_symbol_map": {
3
"start_after": "terra1...",
4
"limit": 10
5
}
6
}
Copied!
Key
Type
Description
start_after
String
Address for pagination
limit
u32
Max number of entries to return

Response

1
{
2
"asset_symbol_map_response": {
3
"map": [
4
("terra1...", "AAPL"),
5
("terra1...", "GOOGL"),
6
...
7
]
8
}
9
}
Copied!
Key
Type
Description
address
String
Address of the proxy contract
symbol
String
Symbol of the asset

CheckSource

Check to see if proxy_addr is whitelisted and has price feed for the specified symbol. Returns the PriceResponse or error to check if the price feed is valid or not.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HubQueryMsg {
4
CheckSource { proxy_addr: String, symbol: String },
Copied!
Key
Type
Description
proxy_addr
String
Address of the proxy contract
symbol
String
Symbol of the asset

Response

Same as PriceResponse or an Error
1
{
2
"check_source": {
3
"proxy_addr": "terra1...",
4
"symbol": "AAPL"
5
}
6
}
Copied!

Response

Same as PriceResponse or an Error