Oracles
Here we'll take a look at a core piece of infrastructure of the protocol, the Oracles.
Package Name: oracle
Source Code: oracle on GitHub
oracle.move
FAQ
Smart Contracts
NaviOracle
NaviOracleThe NaviOracle is a registry that maps Asset → Oracle Implementation. This is used so that when any of the liquidity protocol code needs to query the price of an asset, it can simply call this contract to get an address of an oracle, then call the given address with a standard interface which implements the oracle.
Read Methods
priceReturns the price of an asset, in native asset (i.e. SUI).
Params
asset_id: Address of an asset to get a price for.
Write Methods
set_price_oracleONLY allowed to be called by owner (eventually will be DAO).
Sets a price oracle for a specific asset.
Set to null (0?) to remove an oracle.
MockPriceOracle - ONLY for testing
MockPriceOracle - ONLY for testingRead Methods
priceReturns a hardcoded price for testing.
Params
asset_id: Address of an asset to get a price for.
SupraPriceOracle
SupraPriceOracleRead Methods
priceCalls Supra oracle for particular asset and returns a price in native asset (i.e. SUI).
Params
asset_id: Address of an asset to get a price for.
Implementation
Query Supra oracle and get price.
(Possibly?) Keep an internal registry of Supra oracles for a given asset.
Code Sample
NaviOracle
Last updated