Skip to main content

SkinnyOptimisticOracleProd

SkinnyOptimisticOracleProd#

This is the SkinnyOptimisticOracle contract that should be deployed on live networks. It is exactly the same as the regular SkinnyOptimisticOracle contract, but it overrides getCurrentTime to make the call a simply return block.timestamp with no branching or storage queries.

Functions#

constructor(uint256 _liveness, address _finderAddress, address _timerAddress) (public)
getCurrentTime() โ†’ uint256 (public)
requestPrice(bytes32 identifier, uint32 timestamp, bytes ancillaryData, contract IERC20 currency, uint256 reward, uint256 bond, uint256 customLiveness) โ†’ 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.
  • bond: custom proposal bond to set for request. If set to 0, defaults to the final fee.
  • customLiveness: custom proposal liveness to set for request.
proposePriceFor(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request, address proposer, 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:#

  • 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.
  • request: price request parameters whose hash must match the request that the caller wants to propose a price for.
  • proposer: address to set as the proposer.
  • proposedPrice: price being proposed.
proposePrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request, int256 proposedPrice) โ†’ uint256 totalBond (external)

Proposes a price value where caller is the proposer.

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.
  • request: price request parameters whose hash must match the request that the caller wants to propose a price for.
  • proposedPrice: price being proposed.
requestAndProposePriceFor(bytes32 identifier, uint32 timestamp, bytes ancillaryData, contract IERC20 currency, uint256 reward, uint256 bond, uint256 customLiveness, address proposer, int256 proposedPrice) โ†’ uint256 totalBond (external)

Combines logic of requestPrice and proposePrice while taking advantage of gas savings from not having to overwrite Request params that a normal requestPrice() => proposePrice() flow would entail. Note: The proposer will receive any rewards that come from this proposal. However, any bonds are pulled from the caller.

The caller is the requester, but the proposer can be customized.

Parameters:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • 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.
  • bond: custom proposal bond to set for request. If set to 0, defaults to the final fee.
  • customLiveness: custom proposal liveness to set for request.
  • proposer: address to set as the proposer.
  • proposedPrice: price being proposed.
disputePriceFor(bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request, address disputer, address requester) โ†’ 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:#

  • identifier: price identifier to identify the existing request.
  • timestamp: timestamp to identify the existing request.
  • ancillaryData: ancillary data of the price being requested.
  • request: price request parameters whose hash must match the request that the caller wants to dispute.
  • disputer: address to set as the disputer.
  • requester: sender of the initial price request.
disputePrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request) โ†’ uint256 totalBond (external)

Disputes a price request with an active proposal where caller is the disputer.

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.
  • request: price request parameters whose hash must match the request that the caller wants to dispute.
settle(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request) โ†’ uint256 payout, int256 resolvedPrice (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.
  • request: price request parameters whose hash must match the request that the caller wants to settle.
getState(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request) โ†’ enum OptimisticOracleInterface.State (external)

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.
  • request: price request parameters.
hasPrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request) โ†’ 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.
  • request: price request parameters. The hash of these parameters must match with the request hash that is associated with the price request unique ID {requester, identifier, timestamp, ancillaryData}, or this method will revert.
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.
_storeRequestHash(bytes32 requestId, struct SkinnyOptimisticOracleInterface.Request request) (internal)
_getState(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request) โ†’ 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.

_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.

Events#

RequestPrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request)
ProposePrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request)
DisputePrice(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request)
Settle(address requester, bytes32 identifier, uint32 timestamp, bytes ancillaryData, struct SkinnyOptimisticOracleInterface.Request request)

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.