CentralizedOracle
CentralizedOracle
Testnet oracle feed
Simple, IOracle-compliant centralized oracle for use with PriceFeed
Addresses
Chain | Address |
---|---|
Arbitrum Sepolia | 0xDBEBb8597399c160A169B89AaD95f1BcB07a7b99 |
Base Sepolia | 0xF6F0b987d3aE536377009aEc796d06c4B7a5E29C |
Base Mainnet | 0x7DC5c655587289f947454e7de59E831f562b2643 |
Functions
constructor
constructor() public
setValue
Update the oracle price for productId
.
function setValue(ProductId productId, FPUnsigned value, uint64 timestamp) external
Parameters
Name | Type | Description |
---|---|---|
productId | ProductId | Product to update |
value | FPUnsigned | New price for product |
timestamp | uint64 | Timestamp 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
Name | Type | Description |
---|---|---|
productId | ProductId | product being updated |
value | FPUnsigned | new value |
timestamp | uint64 | time 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
Name | Type | Description |
---|---|---|
value | FPUnsigned | Latest price set by setValue/setValues |
timestamp | uint64 | Timestamp 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
Name | Type | Description |
---|---|---|
oracle | address | Address whose permissions should be modified |
status | bool | Whether 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
Name | Type | Description |
---|---|---|
timestampIndex | uint256 | index of the submitted timestamp |
OracleOnly
error OracleOnly()
Variables
priceFeed
isOracle
feeds
PriceFeed
struct PriceFeed {
FPUnsigned value;
uint64 timestamp;
}