Skip to main content

CentralizedOracle

CentralizedOracle

Testnet oracle feed

Simple, IOracle-compliant centralized oracle for use with PriceFeed

Addresses

ChainAddress
Arbitrum Sepolia0xDBEBb8597399c160A169B89AaD95f1BcB07a7b99
Base Sepolia0xF6F0b987d3aE536377009aEc796d06c4B7a5E29C
Base Mainnet0x7DC5c655587289f947454e7de59E831f562b2643

Functions

constructor

constructor() public

setValue

Update the oracle price for productId.

function setValue(ProductId productId, FPUnsigned value, uint64 timestamp) external

Parameters

NameTypeDescription
productIdProductIdProduct to update
valueFPUnsignedNew price for product
timestampuint64Timestamp at which this price was generated. Must increase

setValues

Set oracle price for multiple products. See setValue()

function setValues(ProductId[] productIds, FPUnsigned[] values, uint64[] timestamps) external
Dev note

Reverts if any timestamp is <= previous timestamp

notifyPriceFeed

Notify PriceFeed, if registered, of all price updates

function notifyPriceFeed(ProductId productId, FPUnsigned value, uint64 timestamp) internal
Dev note

No-op if unregistered, so oracles can set up before PriceFeed or be used for other things

Parameters

NameTypeDescription
productIdProductIdproduct being updated
valueFPUnsignednew value
timestampuint64time new value was generated

getValue

Get latest price for productId. Reverts if unavailable

function getValue(ProductId productId) external view returns (FPUnsigned value, uint64 timestamp)

Return Values

NameTypeDescription
valueFPUnsignedLatest price set by setValue/setValues
timestampuint64Timestamp of last update

setPriceFeed

function setPriceFeed(contract IPriceFeed newPriceFeed) external

setOracle

Allow an EOA to update prices

function setOracle(address oracle, bool status) external

Parameters

NameTypeDescription
oracleaddressAddress whose permissions should be modified
statusboolWhether this address is allowed to update prices

Modifiers

onlyOracle

modifier onlyOracle()

Errors

OracleValueUnset

error OracleValueUnset()

InvalidTimestamp

One of the submitted timestamps was invalid

error InvalidTimestamp(uint256 timestampIndex)

Parameters

NameTypeDescription
timestampIndexuint256index of the submitted timestamp

OracleOnly

error OracleOnly()

Variables

priceFeed

isOracle

feeds

PriceFeed

struct PriceFeed {
FPUnsigned value;
uint64 timestamp;
}