Oracle
Oracle Contract Address: inj1u6cclz0qh5tep9m2qayry9k97dm46pnlqf8nre
The Oracle Contract is service developed to provide accurate and timely asset pricing data. It aggregates pricing information from multiple sources (e.g., Pyth, Ojo, and on-chain feeds) and supplies these data to other protocol modules such as the market and querier contracts. This ensures that collateral values and debt positions are evaluated based on current market prices.
Price Feeds
Multiple price feeds can be utilised in the oracle contract to retrieve a source of truth for asset price data, including external sources like Pyth that push price updates to chain or utilising on-chain markets to aggregate asset price.
Query Messages
1. Get Single Asset Price
The Oracle contract retrieves the current price information for a specified asset.
Query: get_price
Purpose: Retrieves the latest price data for a given asset.
Query Input:
asset
AssetInfo
Object specifying the asset to retrieve price data for. Must be either native_token
or token
object
Yes
native_token
object
Object containing native token information
Yes
denom
string
Token denomination (if using native_token
) or contract address (if using token
)
Yes
Query Response:
price
Decimal256
The reported asset price
decimals
u8
The number of decimals the price uses
time_last_updated
Timestamp
The timestamp indicating when the price was last updated
confidence
Decimal256
A measure of uncertainty associated with the reported price, as provided by Pyth
2. Get Multiple Asset Prices
This query retrieves pricing data for a list of specified assets simultaneously.
Query: get_prices
Purpose: Retrieves the price information for multiple assets in a single query.
Query Input:
assets
Array<AssetInfo>
An array of asset information objects to query prices for
Yes
assets.
native_token
object
Object representing a native token asset
Yes
assets.
native_token.
denom
string
The denomination of the native token
Yes
assets.
token
object
Object representing a CW20 token asset
Yes
assets.token.
contract_addr
Addr
The contract address of the token
Yes
*Note: For each asset in the assets
array, you should use either the native_token
object (with its denom
) or the token
object (with its contract_addr
), depending on the asset type.
Query Response:
price
Decimal256
The reported asset price
decimals
u8
The number of decimals the price uses
time_last_updated
Timestamp
The timestamp indicating when the price was last updated
confidence
Decimal256
A measure of uncertainty associated with the reported price, as provided by Pyth
3. Get All Asset Prices
The query supports pagination to retrieve pricing data for all registered assets.
Query: get_all_prices
Purpose: Retrieves price information for all supported assets, with optional pagination.
Query Input:
start_after
AssetInfo
Object specifying which token to start after. If not used, returns all price data
No
limit
u32
How many records to fetch starting after target token
No
Query Response:
price
Decimal256
The reported asset price
decimals
u8
The number of decimals the price uses
time_last_updated
Timestamp
The timestamp indicating when the price was last updated
confidence
Decimal256
A measure of uncertainty associated with the reported price, as provided by Pyth
4. Get Asset Details
This query retrieves detailed oracle asset information, including metadata about the price source or asset type.
Query: get_all_asset_details
Purpose: Retrieves detailed configurations of all asset entries stored in the Oracle, such as the oracle type (e.g., Pyth, Ojo, Regular, or Receipt Token).
Query Input:
start_after
object
Object specifying which token to start after. If not used, returns all asset details
No
start_after.
native_token
object
Token type.
Can be native_token
or token
Yes
start_after.
native_token.
denom
object
Token address.
Can be denom
(IF native_token
) or contract_address
(IF token
)
Yes
limit
object
How many records to fetch starting after target token
No
Query Response:
In this response, each asset is mapped to its detailed oracle configuration. For example, a "Regular" asset directly contains its current price_info
, while tokens relying on an external feed (e.g., Pyth) include details like the symbol and decimal precision.
Execute Messages
1.1 Update Asset
Execute: update_asset
Purpose: Adds a new asset or updates the details of an existing asset in the Oracle. This message registers asset metadata—including the source of pricing data (e.g., Regular, Pyth, Ojo, or Receipt Token)—and, when applicable, its current price information.
Execute Input:
asset_details
OracleAssetDetails
An object that contains the asset configuration
Yes
asset_details.
pyth
object
Oracle source feed type.
Can be Pyth
, Ojo
, Regular
, or ReceiptToken
Yes
asset_details.
pyth.
decimals
u8
Decimal precision of target token
Yes
asset_details.
price_id
string
The price ID string provided by the oracle source
Yes
asset_info
AssetInfo
An object that uniquely identifies the asset. Use either the native_token
field (with its denom
) or the token
field (with its contract_addr
).
Yes
1.2 Update Asset (nToken)
Execute: update_asset
Purpose: Adding a receipt token, nToken, to the oracle requires the origin path to its original token
Execute Input:
asset_details
object
Contains details of the asset
Yes
asset_details.
receipt_token
object
Specifies receipt token information
Yes
asset_details.
receipt_token.
origin_info
object
Origin details of the receipt token
Yes
asset_details.
receipt_token.
origin_info.
native_token
object
Native token details
Yes
asset_details.
receipt_token.
origin_info.
native_token.
denom
string
The denomination identifier for the native token
Yes
asset_info
object
Contains asset identification details
Yes
asset_info.
token
object
Token contract details
Yes
asset_info.
token.
contract_addr
string
The contract address of the token
Yes
2. Update Prices
Execute: update_prices
Purpose: Updates the prices of multiple assets in a single transaction. This message is useful for batch-updating price information for various assets. The block's timestamp is automatically used to update the time_last_updated
field.
Execute Input:
assets
Array<[AssetInfo, UpdatePrice]>
An array of tuples containing asset info and price update information
Yes
assets[].
price
Decimal256
New price for target token
Yes
assets[].
confidence
Decimal256
New confidence value for target token
Yes
Note:
For each asset entry in the
assets
array, the first element identifies the asset and the second element provides the new price data.The
time_last_updated
field is automatically set to the current block time.
Last updated