Vote

Cast Votes

Cast Vote

Cast a vote on a proposal. The account’s voting weight is determined by the number of votes the account had delegated to it at the time the proposal state became active.

function castVote(uint proposalId, uint8 support)
  • proposalId: ID of a proposal in which to cast a vote.

  • support: An integer of 0 for against, 1 for in-favor, and 2 for abstain.

  • RETURN: The voting weight of voter.

  • Emits a VoteCast event.

Cast Vote With Reason

Cast a vote on a proposal with a reason attached to the vote.

function castVoteWithReason(uint proposalId, uint8 support, string calldata reason)
  • proposalId: ID of a proposal in which to cast a vote.

  • support: An integer of 0 for against, 1 for in-favor, and 2 for abstain.

  • reason: A string containing the voter’s reason for their vote selection.

  • RETURN: The voting weight of voter.

  • Emits a VoteCast event.

Cast Vote With Reason And Params

Cast a vote with a reason and additional encoded parameters

function castVoteWithReasonAndParams(uint proposalId, uint8 support,string reason,bytes params)
  • proposalId: ID of a proposal in which to cast a vote.

  • support: An integer of 0 for against, 1 for in-favor, and 2 for abstain.

  • reason: A string containing the voter’s reason for their vote selection.

  • params: Additional encoded parameters.

  • RETURN: The voting weight of voter.

  • Emits a VoteCast or VoteCastWithParams event depending on the length of params.

Cast Vote By Signature

This method has the same purpose as Cast Vote but it instead enables offline signatures to participate in Lybra governance voting. For more details on how to create an offline signature, review EIP-712.

function castVoteBySig(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s)
  • proposalId: ID of a proposal in which to cast a vote.

  • support: An integer of 0 for against, 1 for in-favor, and 2 for abstain.

  • v: The recovery byte of the signature.

  • r: Half of the ECDSA signature pair.

  • s: Half of the ECDSA signature pair.

  • RETURN: The voting weight of voter.

  • Emits a VoteCast event.

Cast Vote With Reason And Params By Signature

Cast a vote with a reason and additional encoded parameters using the user’s cryptographic signature.

function castVoteWithReasonAndParamsBySig(uint256 proposalId, uint8 support, string reason, bytes params, uint8 v, bytes32 r, bytes32 s)
  • proposalId: ID of a proposal in which to cast a vote.

  • support: An integer of 0 for against, 1 for in-favor, and 2 for abstain.

  • reason: A string containing the voter’s reason for their vote selection.

  • params: Additional encoded parameters.

  • v: The recovery byte of the signature.

  • r: Half of the ECDSA signature pair.

  • s: Half of the ECDSA signature pair.

  • RETURN: The voting weight of voter.

  • Emits a VoteCast or VoteCastWithParams event depending on the length of params.

Counting Votes

Clock

CLOCK MODE

COUNTING MODE

quorum

Minimum number of cast voted required for a proposal to be successful.

We will use a module that offers 3 options to voters: For, Against, and Abstain, and where only For and Abstain votes are counted towards quorum.

function quorum(uint256 timepoint) 
  • timepoint: The timepoint parameter corresponds to the snapshot used for counting vote. This allows to scale the quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).

  • RETURN: The number of cast voted required for a proposal to be successful.

Votes info

Voting Delay

Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see EIP-6372) this contract uses.

This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.

function votingDelay()
  • RETURN:The blocks between the proposal is created and the vote starts.

Voting Period

Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see EIP-6372) this contract uses.

function votingPeriod()
  • RETURN: The blocks between the vote start and vote end.

Get Votes

Voting power of an account at a specific timepoint.

function getVotes(address account, uint256 timepoint) 
  • timepoint: The timepoint parameter corresponds to the snapshot used for counting vote.

  • account: The address of the voter.

  • RETURN: The voting power of an account.

Get Votes With Params

Voting power of an account at a specific timepoint given additional encoded parameters.

function getVotesWithParams(address account, uint256 timepoint, bytes params) 
  • timepoint: The timepoint parameter corresponds to the snapshot used for counting vote.

  • account: The address of the voter.

  • params: The description of the vote.

  • RETURN: The voting power of an account.

Has Voted

function hasVoted(uint256 proposalId, address account)
  • proposalId: ID of a proposal in which to cast a vote.

  • account: The address of the voter.

  • RETURN: Whether account has cast a vote on proposalId.

Receipt

Returns a proposal ballot receipt of a given voter.

function getReceipt(uint256 proposalId, address account)
  • proposalId: ID of a proposal in which to cast a vote.

  • account: The address of the voter.

  • RETURN: Return hasVoted, support and votes of a voter.

Last updated