VotingInterfaceTesting
VotingInterfaceTesting
#
#
Functionsrounds(uint256 roundId) β struct VotingInterfaceTesting.Round (public)
getPriceRequestStatuses(struct VotingInterface.PendingRequest[] requests) β struct VotingInterfaceTesting.RequestState[] (public)
getPendingPriceRequestsArray() β bytes32[] (external)
constructor(address _timerAddress) (internal)
Constructs the Testable contract. Called by child contracts.
#
Parameters:- _timerAddress: Contract that stores the current time in a testing environment. Must be set to 0x0 for production environments that use live time.
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.
commitVote(bytes32 identifier, uint256 time, bytes32 hash) (external)
/**
Commit a vote for a price request for identifier
at time
.
identifier
, time
must correspond to a price request that's currently in the commit phase.
Commits can be changed.
Since transaction data is public, the salt will be revealed with the vote. While this is the systemβs expected behavior,
voters should never reuse salts. If someone else is able to guess the voted price and knows that a salt will be reused, then
they can determine the vote pre-reveal.
#
Parameters:- identifier: uniquely identifies the committed vote. EG BTC/USD price pair.
- time: unix timestamp of the price being voted on.
- hash: keccak256 hash of the
price
,salt
, voteraddress
,time
, currentroundId
, andidentifier
. /
batchCommit(struct VotingInterface.Commitment[] commits) (public)
Submit a batch of commits in a single transaction.
Using encryptedVote
is optional. If included then commitment is stored on chain.
Look at project-root/common/Constants.js
for the tested maximum number of
commitments that can fit in one transaction.
#
Parameters:- commits: array of structs that encapsulate an
identifier
,time
,hash
and optionalencryptedVote
. /
commitAndEmitEncryptedVote(bytes32 identifier, uint256 time, bytes32 hash, bytes encryptedVote) (public)
commits a vote and logs an event with a data blob, typically an encrypted version of the vote
An encrypted version of the vote is emitted in an event EncryptedVote
to allow off-chain infrastructure to
retrieve the commit. The contents of encryptedVote
are never used on chain: it is purely for convenience.
#
Parameters:- identifier: unique price pair identifier. Eg: BTC/USD price pair.
- time: unix timestamp of for the price request.
- hash: keccak256 hash of the price you want to vote for and a
int256 salt
.
- encryptedVote: offchain encrypted blob containing the voters amount, time and salt. /
snapshotCurrentRound(bytes signature) (external)
snapshot the current round's token balances and lock in the inflation rate and GAT.
This function can be called multiple times but each round will only every have one snapshot at the
time of calling _freezeRoundVariables
.
#
Parameters:- signature: signature required to prove caller is an EOA to prevent flash loans from being included in the snapshot. /
revealVote(bytes32 identifier, uint256 time, int256 price, int256 salt) (public)
Reveal a previously committed vote for identifier
at time
.
The revealed price
, salt
, address
, time
, roundId
, and identifier
, must hash to the latest hash
that commitVote()
was called with. Only the committer can reveal their vote.
#
Parameters:- identifier: voted on in the commit phase. EG BTC/USD price pair.
- time: specifies the unix timestamp of the price is being voted on.
- price: voted on during the commit phase.
- salt: value used to hide the commitment price during the commit phase. /
batchReveal(struct VotingInterface.Reveal[] reveals) (public)
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
.
#
Parameters:- reveals: array of the Reveal struct which contains an identifier, time, price and salt. /
getPendingRequests() β struct VotingAncillaryInterface.PendingRequestAncillary[] (external)
Gets the queries that are being voted on this round.
getVotePhase() β enum VotingAncillaryInterface.Phase (external)
Returns the current voting phase, as a function of the current time.
getCurrentRoundId() β uint256 (external)
Returns the current round ID, as a function of the current time.
retrieveRewards(address voterAddress, uint256 roundId, struct VotingInterface.PendingRequest[] toRetrieve) β struct FixedPoint.Unsigned (public)
Retrieves rewards owed for a set of resolved price requests.
Can only retrieve rewards if calling for a valid round and if the call is done within the timeout threshold (not expired).
#
Parameters:- voterAddress: voter for which rewards will be retrieved. Does not have to be the caller.
- roundId: the round from which voting rewards will be retrieved from.
- toRetrieve: array of PendingRequests which rewards are retrieved from.
setMigrated(address newVotingAddress) (external)
Disables this Voting contract in favor of the migrated one.
Can only be called by the contract owner.
#
Parameters:- newVotingAddress: the newly migrated contract address. /
setInflationRate(struct FixedPoint.Unsigned newInflationRate) (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.
#
Parameters:- newInflationRate: sets the next round's inflation rate. /
setGatPercentage(struct FixedPoint.Unsigned newGatPercentage) (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.
#
Parameters:- newGatPercentage: sets the next round's Gat percentage. /
setRewardsExpirationTimeout(uint256 NewRewardsExpirationTimeout) (public)
Resets the rewards expiration timeout.
This change only applies to rounds that have not yet begun.
#
Parameters:- NewRewardsExpirationTimeout: how long a caller can wait before choosing to withdraw their rewards. /
requestPrice(bytes32 identifier, uint256 time) (public)
Enqueues a request (if a request isn't already present) for the given identifier
, time
pair.
Time must be in the past and the identifier must be supported.
#
Parameters:- identifier: uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested.
- time: unix timestamp for the price request.
hasPrice(bytes32 identifier, uint256 time) β bool (public)
Whether the price for identifier
and time
is available.
Time must be in the past and the identifier must be supported.
#
Parameters:- identifier: uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested.
- time: unix timestamp for the price request.
getPrice(bytes32 identifier, uint256 time) β int256 (public)
Gets the price for identifier
and time
if it has already been requested and resolved.
If the price is not available, the method reverts.
#
Parameters:- identifier: uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested.
- time: unix timestamp for the price request.
#
EventsVoteCommitted(address voter, uint256 roundId, bytes32 identifier, uint256 time, bytes ancillaryData)
EncryptedVote(address voter, uint256 roundId, bytes32 identifier, uint256 time, bytes ancillaryData, bytes encryptedVote)
VoteRevealed(address voter, uint256 roundId, bytes32 identifier, uint256 time, int256 price, bytes ancillaryData, uint256 numTokens)
RewardsRetrieved(address voter, uint256 roundId, bytes32 identifier, uint256 time, bytes ancillaryData, uint256 numTokens)
PriceRequestAdded(uint256 roundId, bytes32 identifier, uint256 time)
PriceResolved(uint256 roundId, bytes32 identifier, uint256 time, int256 price, bytes ancillaryData)
#
ModifiersonlyIfTest()
Reverts if not running in test mode.