Oracles
Last updated
Last updated
Here we'll take a look at a core piece of infrastructure of the protocol, the Oracles.
Package Name: oracle
Source Code:
oracle.move
NaviOracle
The 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.
price
Returns the price of an asset, in native asset (i.e. SUI).
Params
asset_id
: Address of an asset to get a price for.
set_price_oracle
ONLY 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 testingprice
Returns a hardcoded price for testing.
Params
asset_id
: Address of an asset to get a price for.
SupraPriceOracle
price
Calls 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.
NaviOracle