Skip to main content

DesignatedVotingV2

DesignatedVotingV2#

Allows a UMA token holder to designate another address to vote on their behalf. Each voter must deploy their own instance of this contract.

Functions#

constructor(address finderAddress, address ownerAddress, address voterAddress) (public)

Construct the DesignatedVoting contract.

Parameters:#

  • finderAddress: keeps track of all contracts within the system based on their interfaceName.
  • ownerAddress: address of the owner of the DesignatedVoting contract.
  • voterAddress: address to which the owner has delegated their voting power.
commitVote(bytes32 identifier, uint256 time, bytes ancillaryData, bytes32 hash) (external)

Forwards a commit to Voting.

Parameters:#

  • identifier: uniquely identifies the feed for this vote. EG BTC/USD price pair.
  • time: specifies the unix timestamp of the price being voted on.
  • hash: the keccak256 hash of the price you want to vote for and a random integer salt value.
batchCommit(struct VotingAncillaryInterface.CommitmentAncillary[] commits) (external)

Forwards a batch commit to Voting.

Parameters:#

  • commits: struct to encapsulate an identifier, time, hash and optional encryptedVote.
revealVote(bytes32 identifier, uint256 time, int256 price, bytes ancillaryData, int256 salt) (external)

Forwards a reveal to Voting.

Parameters:#

  • identifier: voted on in the commit phase. EG BTC/USD price pair.
  • time: specifies the unix timestamp of the price being voted on.
  • price: used along with the salt to produce the hash during the commit phase.
  • salt: used along with the price to produce the hash during the commit phase.
batchReveal(struct VotingAncillaryInterface.RevealAncillary[] reveals) (external)

Forwards a batch reveal to Voting.

Parameters:#

  • reveals: is an array of the Reveal struct which contains an identifier, time, price and salt.
retrieveRewards() → uint256 (public)

Forwards a reward retrieval to Voting.

Rewards are added to the tokens already held by this contract.

stake(uint256 amount, address votingContract) (external)

Stake ERC20 tokens from this contract to the votingContract.

Parameters:#

  • amount: amount of tokens to stake.
  • votingContract: Address of the voting contract to stake into.
requestUnstake(uint256 amount, address votingContract) (external)

Request unstaking of ERC20 tokens from this contract to the votingContract.

Parameters:#

  • amount: amount of tokens to unstake.
  • votingContract: Address of the voting contract to unstake from.
executeUnstake(address votingContract) (external)

Execute an unstake request that has passed liveness on the voting contract.

Parameters:#

  • votingContract: Address of the voting contract to execute the unstake from.
_setStakeRole(uint256 setRoleId) (internal)

Internal method that allows derived contracts to choose the role for stakeable.

The role setRoleId must exist. Either this method or _setStakeRole must be called by the derived class for this contract to function properly.

Parameters:#

  • setRoleId: ID corresponding to role whose members can stakeable.
withdraw(uint256 amount) (external)

Withdraws ETH from the contract.

withdrawErc20(address erc20Address, uint256 amount) (external)

Withdraws ERC20 tokens from the contract.

Parameters:#

  • erc20Address: ERC20 token to withdraw.
  • amount: amount of tokens to withdraw.
_createWithdrawRole(uint256 newRoleId, uint256 managingRoleId, address withdrawerAddress) (internal)

Internal method that allows derived contracts to create a role for withdrawal.

Either this method or _setWithdrawRole must be called by the derived class for this contract to function properly.

Parameters:#

  • newRoleId: ID corresponding to role whose members can withdraw.
  • managingRoleId: ID corresponding to managing role who can modify the withdrawable role's membership.
  • withdrawerAddress: new manager of withdrawable role.
_setWithdrawRole(uint256 setRoleId) (internal)

Internal method that allows derived contracts to choose the role for withdrawal.

The role setRoleId must exist. Either this method or _createWithdrawRole must be called by the derived class for this contract to function properly.

Parameters:#

  • setRoleId: ID corresponding to role whose members can withdraw.
holdsRole(uint256 roleId, address memberToCheck) → bool (public)

Whether memberToCheck is a member of roleId.

Reverts if roleId does not correspond to an initialized role.

Parameters:#

  • roleId: the Role to check.
  • memberToCheck: the address to check.
resetMember(uint256 roleId, address newMember) (public)

Changes the exclusive role holder of roleId to newMember.

Reverts if the caller is not a member of the managing role for roleId or if roleId is not an initialized, ExclusiveRole.

Parameters:#

  • roleId: the ExclusiveRole membership to modify.
  • newMember: the new ExclusiveRole member.
getMember(uint256 roleId) → address (public)

Gets the current holder of the exclusive role, roleId.

Reverts if roleId does not represent an initialized, exclusive role.

Parameters:#

  • roleId: the ExclusiveRole membership to check.
addMember(uint256 roleId, address newMember) (public)

Adds newMember to the shared role, roleId.

Reverts if roleId does not represent an initialized, SharedRole or if the caller is not a member of the managing role for roleId.

Parameters:#

  • roleId: the SharedRole membership to modify.
  • newMember: the new SharedRole member.
removeMember(uint256 roleId, address memberToRemove) (public)

Removes memberToRemove from the shared role, roleId.

Reverts if roleId does not represent an initialized, SharedRole or if the caller is not a member of the managing role for roleId.

Parameters:#

  • roleId: the SharedRole membership to modify.
  • memberToRemove: the current SharedRole member to remove.
renounceMembership(uint256 roleId) (public)

Removes caller from the role, roleId.

Reverts if the caller is not a member of the role for roleId or if roleId is not an initialized, SharedRole.

Parameters:#

  • roleId: the SharedRole membership to modify.
_createSharedRole(uint256 roleId, uint256 managingRoleId, address[] initialMembers) (internal)

Internal method to initialize a shared role, roleId, which will be managed by managingRoleId. initialMembers will be immediately added to the role.

Should be called by derived contracts, usually at construction time. Will revert if the role is already initialized.

_createExclusiveRole(uint256 roleId, uint256 managingRoleId, address initialMember) (internal)

Internal method to initialize an exclusive role, roleId, which will be managed by managingRoleId. initialMember will be immediately added to the role.

Should be called by derived contracts, usually at construction time. Will revert if the role is already initialized.

Events#

ResetExclusiveMember(uint256 roleId, address newMember, address manager)
AddedSharedMember(uint256 roleId, address newMember, address manager)
RemovedSharedMember(uint256 roleId, address oldMember, address manager)

Modifiers#

onlyRoleHolder(uint256 roleId)

Reverts unless the caller is a member of the specified roleId.

onlyRoleManager(uint256 roleId)

Reverts unless the caller is a member of the manager role for the specified roleId.

onlyExclusive(uint256 roleId)

Reverts unless the roleId represents an initialized, exclusive roleId.

onlyShared(uint256 roleId)

Reverts unless the roleId represents an initialized, shared roleId.

onlyValidRole(uint256 roleId)

Reverts if roleId is not initialized.

onlyInvalidRole(uint256 roleId)

Reverts if roleId is initialized.