Skip to main content

OracleHub

OracleHub#

Gatekeeper contract deployed on mainnet that validates and sends price requests from sidechain to the DVM on mainnet. This is a "gate keeper" contract because it performs the final validation for any messages originating from a child chain's oracle before submitting price requests to the DVM. This contract also can publish DVM price resolution data to OracleSpokes on any chainId via the messenger for that chainId.

This contract must be a registered financial contract in order to make and query DVM price requests.

Functions#

constructor(address _finderAddress, contract IERC20 _token) (public)
setMessenger(uint256 chainId, contract ParentMessengerInterface messenger) (public)

Set new ParentMessenger contract for chainId.

Only callable by the owner (presumably the Ethereum Governor contract).

Parameters:#

  • chainId: network that has a child messenger contract that parent messenger contract will communicate with.
  • messenger: ParentMessenger contract that sends messages to ChildMessenger on network with ID chainId.
publishPrice(uint256 chainId, bytes32 identifier, uint256 time, bytes ancillaryData) (public)

Publishes a DVM resolved price to the OracleSpoke deployed on the network linked with chainId, or reverts if not resolved yet. This contract must be registered with the DVM to query price requests. The DVM price resolution is communicated to the OracleSpoke via the Parent-->Child messenger channel.

This method will always attempt to call messenger.sendMessageToChild even if it is a duplicate call for this price request. Therefore the Messenger contract for this chainId should determine how to handle duplicate calls. This method is payable so that ETH can be forwarded to Messenger contracts that need to send ETH from L1 to L2, like Arbitrum messengers for example. For networks that do not use ETH, the caller will lose ETH, therefore it is the caller's responsibility to know when to send ETH. This is allowed to be payable because any EOA can call this function.

Parameters:#

  • chainId: Network to resolve price for.
  • identifier: Identifier of price request to resolve.
  • time: Timestamp of price request to resolve.
  • ancillaryData: extra data of price request to resolve.
processMessageFromChild(uint256 chainId, bytes data) (public)

Submits a price request originating from an OracleSpoke. Request data must be sent via the Child --> Parent Messenger communication channel. Returns silently if price request is a duplicate.

This contract must be registered to submit price requests to the DVM. Only the ParentMessenger can call this method. If the original requester on the child chain wants to expedite the Child --> Parent message, then they can call requestPrice on this contract for the same unique price request.

Parameters:#

  • chainId: id of the child chain that sent the price request.
  • data: ABI encoded params with which to call _requestPrice.
requestPrice(bytes32 identifier, uint256 time, bytes ancillaryData) (public)

Anyone can call this method to directly request a price to the DVM. This could be used by the child chain requester in the case where Child --> Parent communication takes too long and the requester wants to speed up the price resolution process. Returns silently if price request is a duplicate. Calling this method from the user's point of view is no different than calling the OptimisticOracle.requestPrice method, but with a different interface.

The caller must pay a final fee and have approved this contract to pull final fee from it. If the price request params including the ancillary data does not match exactly the price request submitted on the child chain, then the child chain's price request will not resolve. The caller is recommended to use the stampAncillaryData method on the OracleSpoke to reconstruct the ancillary data.

Parameters:#

  • identifier: Identifier for price request.
  • time: time for price request.
  • ancillaryData: Extra data for price request.
_getOracle() โ†’ contract OracleAncillaryInterface (internal)
_getStore() โ†’ contract StoreInterface (internal)
multicall(bytes[] data) โ†’ bytes[] results (external)
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
_startReentrantGuardDisabled() (internal)
_endReentrantGuardDisabled() (internal)
owner() โ†’ address (public)

Returns the address of the current owner.

renounceOwnership() (public)

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership(address newOwner) (public)

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

_transferOwnership(address newOwner) (internal)

Transfers ownership of the contract to a new account (newOwner). Internal function without access restriction.

_msgSender() โ†’ address (internal)
_msgData() โ†’ bytes (internal)
_requestPrice(bytes32 identifier, uint256 time, bytes ancillaryData) โ†’ bool (internal)

Enqueues a request (if a request isn't already present) for the given (identifier, time, ancillary data) combination. Will only emit an event if the request has never been requested.

_publishPrice(bytes32 identifier, uint256 time, bytes ancillaryData, int256 price) (internal)

Publishes price for a requested query.

Does not update price state if price is already resolved.

_encodePriceRequest(bytes32 identifier, uint256 time, bytes ancillaryData) โ†’ bytes32 (internal)

Returns the convenient way to store price requests, uniquely identified by {identifier, time, ancillaryData }.

Events#

SetParentMessenger(uint256 chainId, address parentMessenger)
OwnershipTransferred(address previousOwner, address newOwner)
PriceRequestAdded(bytes32 identifier, uint256 time, bytes ancillaryData, bytes32 requestHash)
PushedPrice(bytes32 identifier, uint256 time, bytes ancillaryData, int256 price, bytes32 requestHash)

Modifiers#

onlyMessenger(uint256 chainId)
nonReentrant()

Prevents a contract from calling itself, directly or indirectly. Calling a nonReentrant function from another nonReentrant function is not supported. It is possible to prevent this from happening by making the nonReentrant function external, and making it call a private function that does the actual state modification.

nonReentrantView()

Designed to prevent a view-only method from being re-entered during a call to a nonReentrant() state-changing method.

onlyOwner()

Throws if called by any account other than the owner.