Skip to main content

OracleChildTunnel

OracleChildTunnel#

The intended client of this contract is an OptimisticOracle on sidechain that needs price resolution secured by the DVM on mainnet.

Functions#

constructor(address _fxChild, address _finderAddress) (public)
requestPrice(bytes32 identifier, uint256 time, bytes ancillaryData) (public)

This should be called to bridge a price request to mainnet.

Can be called only by a registered contract that is allowed to make DVM price requests. Will mark this price request as Requested, and therefore able to receive the price resolution data from mainnet. Emits a message that will be included in regular checkpoint of all sidechain transactions to mainnet.

Parameters:#

  • identifier: Identifier of price request.
  • time: Timestamp of price request.
  • ancillaryData: extra data of price request.
_processMessageFromRoot(uint256, address sender, bytes data) (internal)

Resolves a price request.

The data will be received automatically from the state receiver when the state is synced between Ethereum and Polygon. This will revert if the Root chain sender is not the fxRootTunnel contract.

Parameters:#

  • sender: The sender of data from the Root chain.
  • data: ABI encoded params with which to call _publishPrice.
hasPrice(bytes32 identifier, uint256 time, bytes ancillaryData) โ†’ bool (public)

Returns whether a price has resolved for the request.

Parameters:#

  • identifier: Identifier of price request.
  • time: Timestamp of price request
  • ancillaryData: extra data of price request.
getPrice(bytes32 identifier, uint256 time, bytes ancillaryData) โ†’ int256 (public)

Returns resolved price for the request.

Reverts if price is not available.

Parameters:#

  • identifier: Identifier of price request.
  • time: Timestamp of price request
  • ancillaryData: extra data of price request.
stampAncillaryData(bytes ancillaryData, address requester) โ†’ bytes (public)

Generates stamped ancillary data in the format that it would be used in the case of a price request.

Parameters:#

  • ancillaryData: ancillary data of the price being requested.
  • requester: sender of the initial price request.
_stampAncillaryData(bytes ancillaryData, address requester) โ†’ bytes (internal)

We don't handle specifically the case where ancillaryData is not already readily translatable in utf8. For those cases, we assume that the client will be able to strip out the utf8-translatable part of the ancillary data that this contract stamps.

_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
setFxRootTunnel(address _fxRootTunnel) (external)
processMessageFromRoot(uint256 stateId, address rootMessageSender, bytes data) (external)
_sendMessageToRoot(bytes message) (internal)

Emit message that can be received on Root Tunnel

Call the internal function when need to emit message

Parameters:#

  • message: bytes message that will be sent to Root Tunnel some message examples - abi.encode(tokenId); abi.encode(tokenId, tokenMetadata); abi.encode(messageType, messageData);
_requestPrice(bytes32 identifier, uint256 time, bytes ancillaryData) (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. Will only emit an event if the request has never been 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#

MessageSent(bytes message)
PriceRequestAdded(bytes32 identifier, uint256 time, bytes ancillaryData, bytes32 requestHash)
PushedPrice(bytes32 identifier, uint256 time, bytes ancillaryData, int256 price, bytes32 requestHash)

Modifiers#

onlyRegisteredContract()
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.

validateSender(address sender)