OptimisticOracle

Optimistic Oracle.

Modifiers

nonReentrant() modifier

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 make it call a private function that does the actual work.

nonReentrantView() modifier

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

onlyIfTest() modifier

Reverts if not running in test mode.

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.

_getOracle() → contract OracleAncillaryInterface internal

_getCollateralWhitelist() → contract AddressWhitelist internal

_getStore() → contract StoreInterface internal

_getIdentifierWhitelist() → contract IdentifierWhitelistInterface internal

_stampAncillaryData(bytes ancillaryData, address requester) → bytes internal

_preEntranceCheck() internal

_preEntranceSet() internal

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

getCurrentTime() → uint256 public

Gets the current time. Will return the last time set in setCurrentTime if running in test mode. Otherwise, it will return the block timestamp.

RequestPrice(address requester, bytes32 identifier, uint256 timestamp, bytes ancillaryData, address currency, uint256 reward, uint256 finalFee) event

ProposePrice(address requester, address proposer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice, uint256 expirationTimestamp, address currency) event

DisputePrice(address requester, address proposer, address disputer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 proposedPrice) event

Settle(address requester, address proposer, address disputer, bytes32 identifier, uint256 timestamp, bytes ancillaryData, int256 price, uint256 payout) event

© UMA Project 2018-2019