Voting

Voting system for Oracle.

Handles receiving and resolving price requests via a commit-reveal voting scheme.

onlyRegisteredDerivative() modifier

onlyIfNotMigrated() modifier

onlyOwner() modifier

Throws if called by any account other than the owner.

onlyIfTest() modifier

Reverts if not running in test mode.

constructor(uint256 phaseLength, struct FixedPoint.Unsigned _gatPercentage, struct FixedPoint.Unsigned _inflationRate, uint256 _rewardsExpirationTimeout, address _votingToken, address _identifierWhitelist, address _finder, bool _isTest) public

Construct the Voting contract.

Parameters:

  • phaseLength: length of the commit and reveal phases in seconds.

  • _gatPercentage: percentage of the total token supply that must be used in a vote to create a valid price resolution.

  • _isTest: whether this contract is being constructed for the purpose of running automated tests.

requestPrice(bytes32 identifier, uint256 time) external

Enqueues a request (if a request isn’t already present) for the given identifier, time pair.

batchCommit(struct VotingInterface.Commitment[] commits) external

Commit multiple votes in a single transaction. Look at project-root/common/Constants.js for the tested maximum number of commitments that can fit in one transaction.

For more information on commits, review the comment for commitVote.

batchReveal(struct VotingInterface.Reveal[] reveals) external

Reveal multiple votes in a single transaction. Look at project-root/common/Constants.js for the tested maximum number of reveals that can fit in one transaction.

For more information on reveals, review the comment for revealVote.

setMigrated(address newVotingAddress) external

Disables this Voting contract in favor of the migrated one.

hasPrice(bytes32 identifier, uint256 time) → bool _hasPrice external

Whether the price for identifier and time is available.

getPrice(bytes32 identifier, uint256 time) → int256 external

Gets the price for identifier and time if it has already been requested and resolved.

If the price is not available, the method reverts.

getPendingRequests() → struct VotingInterface.PendingRequest[] pendingRequests external

Gets the queries that are being voted on this round.

getVotePhase() → enum VotingInterface.Phase external

Gets the current vote phase (commit or reveal) based on the current block time.

getCurrentRoundId() → uint256 external

Gets the current vote round id based on the current block time.

commitVote(bytes32 identifier, uint256 time, bytes32 hash) public

Commit your vote for a price request for identifier at time.

(identifier, time) must correspond to a price request that’s currently in the commit phase. hash should be the keccak256 hash of the price you want to vote for and a int salt. Commits can be changed.

revealVote(bytes32 identifier, uint256 time, int256 price, int256 salt) public

Reveal a previously committed vote for identifier at time.

The revealed price and salt must match the latest hash that commitVote() was called with. Only the committer can reveal their vote.

commitAndPersistEncryptedVote(bytes32 identifier, uint256 time, bytes32 hash, bytes encryptedVote) public

setInflationRate(struct FixedPoint.Unsigned _inflationRate) public

Resets the inflation rate. Note: this change only applies to rounds that have not yet begun.

This method is public because calldata structs are not currently supported by solidity.

setGatPercentage(struct FixedPoint.Unsigned _gatPercentage) public

Resets the Gat percentage. Note: this change only applies to rounds that have not yet begun.

This method is public because calldata structs are not currently supported by solidity.

setRewardsExpirationTimeout(uint256 _rewardsExpirationTimeout) public

retrieveRewards(address voterAddress, uint256 roundId, struct VotingInterface.PendingRequest[] toRetrieve) → struct FixedPoint.Unsigned totalRewardToIssue public

Retrieves rewards owed for a set of resolved price requests.

getPriceRequestStatuses(struct VotingInterface.PendingRequest[] requests) → struct Voting.RequestState[] requestStates public

addAuthorizedSender(address sender) external

Authorizes sender to send messages to the caller.

removeAuthorizedSender(address sender) external

Revokes `sender’s authorization to send messages to the caller.

getMessage(address recipient, bytes32 topicHash) → bytes external

Gets the current stored message corresponding to recipient and topicHash.

To decrypt messages (this requires access to the recipient’s private keys), use the decryptMessage() function in common/Crypto.js.

getPublicKey(address recipient, bytes32 topicHash) → bytes external

Gets the stored public key for a particular recipient and topicHash. Return value will be 0 length if no public key has been set.

Senders may need this public key to encrypt messages that only the recipient can read. If the public key is communicated offchain, this field may be left empty.

sendMessage(address recipient_, bytes32 topicHash, bytes message) public

Sends message to recipient_ categorized by a particular topicHash. This will overwrite any previous messages sent to this recipient with this topicHash.

To construct an encrypted message, use the encryptMessage() in common/Crypto.js. The public key for the recipient can be obtained using the getPublicKey() method.

removeMessage(address recipient_, bytes32 topicHash) public

setPublicKey(bytes publicKey, bytes32 topicHash) public

Sets the public key for this caller and topicHash.

Note: setting the public key is optional - if the publicKey is communicated or can be derived offchain by the sender, there is no need to set it here. Because there are no specific requirements for the publicKey, there is also no verification of its validity other than its length.

isAuthorizedSender(address sender, address recipient) → bool public

Returns true if the sender is authorized to send to the recipient.

constructor() internal

Initializes the contract setting the deployer as the initial owner.

owner() → address public

Returns the address of the current owner.

isOwner() → bool public

Returns true if the caller is 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.

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

_msgSender() → address payable internal

_msgData() → bytes internal

constructor(bool _isTest) internal

setCurrentTime(uint256 _time) external

Sets the current time.

Will revert if not running in test mode.

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.

VoteCommitted(address voter, uint256 roundId, bytes32 identifier, uint256 time) event

VoteRevealed(address voter, uint256 roundId, bytes32 identifier, uint256 time, int256 price, uint256 numTokens) event

RewardsRetrieved(address voter, uint256 roundId, bytes32 identifier, uint256 time, uint256 numTokens) event

PriceRequestAdded(uint256 votingRoundId, bytes32 identifier, uint256 time) event

PriceResolved(uint256 resolutionRoundId, bytes32 identifier, uint256 time, int256 price) event

OwnershipTransferred(address previousOwner, address newOwner) event

© UMA Project 2018-2019