Skip to main content

OptimisticOracle

OptimisticOracle#

Pre-DVM escalation contract that allows faster settlement.

Functions#

constructor(uint256 _liveness, address _finderAddress, address _timerAddress) (public)

Constructor.

Parameters:#

  • _liveness: default liveness applied to each price request.
  • _finderAddress: finder to use to get addresses of DVM contracts.
  • _timerAddress: address of the timer contract. Should be 0x0 in prod.
requestPrice(bytes32 identifier, uint256 timestamp, bytes ancillaryData, contract IERC20 currency, uint256 reward) โ†’ uint256 totalBond (external)

Requests a new price.

Parameters:#

  • identifier: price identifier being requested.
  • timestamp: timestamp of the price being requested.
  • ancillaryData: ancillary data representing additional args being passed with the price request.
  • currency: ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.
  • reward: reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0, which could make sense if the contract requests and proposes the value in the same call or provides its own reward system.
setBond(bytes32 identifier, uint256 timestamp, bytes ancillaryData, uint256 bond) โ†’ uint256 totalBond (external)

Set the proposal bond associated with a price request.

Parameters:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • bond: custom bond amount to set.
setRefundOnDispute(bytes32 identifier, uint256 timestamp, bytes ancillaryData) (external)

Sets the request to refund the reward if the proposal is disputed. This can help to "hedge" the caller in the event of a dispute-caused delay. Note: in the event of a dispute, the winner still receives the other's bond, so there is still profit to be made even if the reward is refunded.

Parameters:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
setCustomLiveness(bytes32 identifier, uint256 timestamp, bytes ancillaryData, uint256 customLiveness) (external)

Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait before being auto-resolved.

Parameters:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • customLiveness: new custom liveness.
proposePriceFor(address proposer, address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice) โ†’ uint256 totalBond (public)

Proposes a price value on another address' behalf. Note: this address will receive any rewards that come from this proposal. However, any bonds are pulled from the caller.

Parameters:#

  • proposer: address to set as the proposer.
  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • proposedPrice: price being proposed.
proposePrice(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice) โ†’ uint256 totalBond (external)

Proposes a price value for an existing price request.

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • proposedPrice: price being proposed.
disputePriceFor(address disputer, address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ uint256 totalBond (public)

Disputes a price request with an active proposal on another address' behalf. Note: this address will receive any rewards that come from this dispute. However, any bonds are pulled from the caller.

Parameters:#

  • disputer: address to set as the disputer.
  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
disputePrice(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ uint256 totalBond (external)

Disputes a price value for an existing price request with an active proposal.

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
settleAndGetPrice(bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ int256 (external)

Retrieves a price that was previously requested by a caller. Reverts if the request is not settled or settleable. Note: this method is not view so that this call may actually settle the price request if it hasn't been settled.

Parameters:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
settle(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ uint256 payout (external)

Attempts to settle an outstanding price request. Will revert if it isn't settleable.

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
getRequest(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ struct OptimisticOracleInterface.Request (public)

Gets the current data structure containing all information about a price request.

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
getState(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ enum OptimisticOracleInterface.State (public)

Computes the current state of a price request. See the State enum for more details.

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
hasPrice(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ bool (public)

Checks if a given request has resolved, expired or been settled (i.e the optimistic oracle has a price).

Parameters:#

  • requester: sender of the initial price request.
  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
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 dispute.

Parameters:#

  • ancillaryData: ancillary data of the price being requested.
  • requester: sender of the initial price request.
_getState(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData) โ†’ enum OptimisticOracleInterface.State (internal)
_getOracle() โ†’ contract OracleAncillaryInterface (internal)
_getCollateralWhitelist() โ†’ contract AddressWhitelist (internal)
_getStore() โ†’ contract StoreInterface (internal)
_getIdentifierWhitelist() โ†’ contract IdentifierWhitelistInterface (internal)
_stampAncillaryData(bytes ancillaryData, address requester) โ†’ bytes (internal)

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

getCurrentTime() โ†’ uint256 (public)
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
_startReentrantGuardDisabled() (internal)
_endReentrantGuardDisabled() (internal)
setCurrentTime(uint256 time) (external)

Sets the current time.

Will revert if not running in test mode.

Parameters:#

  • time: timestamp to set current Testable time to.
defaultLiveness() โ†’ uint256 (external)
finder() โ†’ contract FinderInterface (external)

Events#

RequestPrice(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData, address currency, uint256 reward, uint256 finalFee)
ProposePrice(address requester, address proposer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice, uint256 expirationTimestamp, address currency)
DisputePrice(address requester, address proposer, address disputer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice)
Settle(address requester, address proposer, address disputer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 price, uint256 payout)

Modifiers#

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.

onlyIfTest()

Reverts if not running in test mode.