ThresholdGovernor

Git Source

Inherits: IThresholdGovernor, BatchGovernor

Author: M^0 Labs

State Variables

_MIN_THRESHOLD_RATIO

The minimum allowed threshold ratio.

uint16 internal constant _MIN_THRESHOLD_RATIO = 271;

ONE

Returns the value used as 100%, to be used to correctly ascertain the threshold ratio.

uint256 public constant ONE = 10_000;

thresholdRatio

Returns the threshold ratio to be applied to determine the success threshold for a proposal.

For all intents and purposes, this is the same as quorumNumerator.

uint16 public thresholdRatio;

Functions

constructor

Construct a new ThresholdGovernor contract.

constructor(string memory name_, address voteToken_, uint16 thresholdRatio_) BatchGovernor(name_, voteToken_);

Parameters

Name
Type
Description

name_

string

The name of the contract. Used to compute EIP712 domain separator.

voteToken_

address

The address of the token used to vote.

thresholdRatio_

uint16

The ratio of yes votes votes required for a proposal to meet quorum and succeed.

execute

Allows the caller to execute a proposal.

function execute(address[] memory targets_, uint256[] memory values_, bytes[] memory callDatas_, bytes32)
    external
    payable
    returns (uint256 proposalId_);

Parameters

Name
Type
Description

targets_

address[]

values_

uint256[]

callDatas_

bytes[]

<none>

bytes32

Returns

Name
Type
Description

proposalId_

uint256

proposalId The unique identifier for the proposal.

propose

Allows the caller to create a proposal.

function propose(
    address[] memory targets_,
    uint256[] memory values_,
    bytes[] memory callDatas_,
    string memory description_
) external returns (uint256 proposalId_);

Parameters

Name
Type
Description

targets_

address[]

values_

uint256[]

callDatas_

bytes[]

description_

string

Returns

Name
Type
Description

proposalId_

uint256

proposalId The unique identifier for the proposal.

COUNTING_MODE

module:voting

A description of the possible "support" values for castVote and the way these votes are counted, meant to be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of key-value pairs that each describe one aspect, for example support=for,against&quorum=for. The string can be decoded by the standard URLSearchParams JavaScript class.

function COUNTING_MODE() external pure returns (string memory);

getProposal

Returns all data of a proposal with identifier proposalId.

function getProposal(uint256 proposalId_)
    external
    view
    returns (
        uint48 voteStart_,
        uint48 voteEnd_,
        ProposalState state_,
        uint256 noVotes_,
        uint256 yesVotes_,
        address proposer_,
        uint256 quorum_,
        uint16 quorumNumerator_
    );

Parameters

Name
Type
Description

proposalId_

uint256

Returns

Name
Type
Description

voteStart_

uint48

voteStart The first clock value when voting on the proposal is allowed.

voteEnd_

uint48

voteEnd The last clock value when voting on the proposal is allowed.

state_

ProposalState

state The state of the proposal.

noVotes_

uint256

noVotes The amount of votes cast against the proposal.

yesVotes_

uint256

yesVotes The amount of votes cast for the proposal.

proposer_

address

proposer The address of the account that created the proposal.

quorum_

uint256

quorum The threshold/quorum of yes votes required for the proposal to succeed.

quorumNumerator_

uint16

quorumNumerator The threshold/quorum numerator used to calculate the quorum.

proposalQuorum

Returns the quorum of yes votes needed for a specific proposal to succeed.

function proposalQuorum(uint256 proposalId) external view returns (uint256);

Parameters

Name
Type
Description

proposalId

uint256

The unique identifier for the proposal.

Returns

Name
Type
Description

<none>

uint256

The quorum of yes votes needed for the proposal to succeed.

quorum

Returns the minimum number of eligible (COUNTING_MODE) votes for a proposal to succeed.

function quorum() external view returns (uint256);

quorumNumerator

Returns the quorum numerator used to determine the quorum for a proposal.

For all intents and purposes, this is the same as thresholdRatio.

function quorumNumerator() external view returns (uint256);

quorumDenominator

Returns the quorum denominator used to determine the quorum for a proposal.

function quorumDenominator() external pure returns (uint256);

state

Returns the state of a proposal with identifier proposalId.

function state(uint256 proposalId_) public view override(BatchGovernor, IGovernor) returns (ProposalState state_);

Parameters

Name
Type
Description

proposalId_

uint256

Returns

Name
Type
Description

state_

ProposalState

The state of the proposal.

_createProposal

Creates a new proposal with the given parameters.

function _createProposal(uint256 proposalId_, uint16 voteStart_) internal override;

Parameters

Name
Type
Description

proposalId_

uint256

The unique identifier of the proposal.

voteStart_

uint16

The epoch at which the proposal will start collecting votes.

_setThresholdRatio

Set the threshold ratio to be applied to determine the threshold/quorum for a proposal.

function _setThresholdRatio(uint16 newThresholdRatio_) internal;

Parameters

Name
Type
Description

newThresholdRatio_

uint16

The new threshold ratio.

_getQuorum

Returns the quorum given a snapshot and quorum numerator.

function _getQuorum(uint16 voteStart_, uint16 quorumNumerator_) internal view returns (uint256 quorum_);

Parameters

Name
Type
Description

voteStart_

uint16

The epoch at which the proposal will start collecting votes.

quorumNumerator_

uint16

The quorum numerator.

Returns

Name
Type
Description

quorum_

uint256

The quorum of yes voted needed for a successful proposal.

_votingDelay

Returns the number of clock values that must elapse before voting begins for a newly created proposal.

function _votingDelay() internal pure override returns (uint16);

Returns

Name
Type
Description

<none>

uint16

The voting delay.

_votingPeriod

Returns the number of clock values between the vote start and vote end.

function _votingPeriod() internal pure override returns (uint16);

Returns

Name
Type
Description

<none>

uint16

The voting period.

Copyright 2024 M^0 Foundation