LateStageGovernor

Git Source

Inherits: ProposalGovernor, ModifiedGovernorUpgradeable, ILateStageGovernor

Author: Daniel Yamagata & Naveen Ailawadi

A governance contract that is based off of OpenZeppelin's Governor contract. This contract enables the voting of arbitrary on-chain actions, which are represented as proposals. Only 'for-votes' are counted towards the quorum

Many of these contract's functions run in O(n), where n is the number of shares that a treasury has. The maximum number of share classes that a Treasury can have is 15. This contract used a modified version of GovernorUpgradeable to allow access to the the Governor Upgradeable storage internally This is specifically used in propose() and state() to allow for the board of directors to propose and a proposal with a super majority to instantly be executable, respectively.

Functions

constructor

constructor(address _mezzHub, address _mezzMigrator) MezzGovernor(_mezzHub, _mezzMigrator);

init

Intializes the Governor's state

function init(address initTreasury, bytes memory) external virtual override initializer;

Parameters

Name
Type
Description

initTreasury

address

The address of the Treasury that the Governor is in charge of

<none>

bytes

__LateStageGovernor_init

The 'params' argument is maintained in case future versions require additional initialization parameters

propose

Creates a new proposal. Vote starts after the delay specified by votingDelay()

Overridden propose function to add pausable modifier and enable the treasury to make proposals Reference: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/4d9d9073b84f56fe3eea360e5067c6ffd864c43d/contracts/governance/GovernorUpgradeable.sol#L277-L330

Parameters

Name
Type
Description

targets

address[]

Target addresses for proposal calls

values

uint256[]

Blockchain native currency values for proposal calls

calldatas

bytes[]

Calldatas for proposal calls

description

string

Returns

Name
Type
Description

<none>

uint256

The proposal ID for the proposal

cancel

Cancels a proposal. Only callable by the Proposer, the Mezz Hub Owner, or a 'Defender'

Parameters

Name
Type
Description

targets

address[]

Target addresses for proposal calls

values

uint256[]

Blockchain native currency values for proposal calls

calldatas

bytes[]

Calldatas for proposal calls

descriptionHash

bytes32

Hash of the proposal description

Returns

Name
Type
Description

<none>

uint256

The proposal ID for the proposal

execute

Executes a proposal that succeeded.

Parameters

Name
Type
Description

targets

address[]

Target addresses for proposal calls

values

uint256[]

Blockchain native currency values for proposal calls

calldatas

bytes[]

Calldatas for proposal calls

descriptionHash

bytes32

Hash of the proposal description

Returns

Name
Type
Description

<none>

uint256

The proposal ID for the proposal

state

Returns the state of a proposal associated with 'proposalId' as a ProposalState enum

quorum

Changed the following line such that if a super majority is reached before the voting period ends, the proposal is instantly executable. There's no need to check if _quorumReached() or _voteSucceeded(), since a super majority will always have more for-votes than a quorum, and a super majority will always more for-votes than against-votes, since it is a majority of the total votes.

The quorum is not a raw value: it is a percentage of the total votes across all share classes

Parameters

Name
Type
Description

timepoint

uint256

The timepoint to get the quorum for

Returns

Name
Type
Description

<none>

uint256

The quorum

proposalThreshold

Returns the proposal threshold, which is the minimum number of votes that the sender must have for a proposal to be created

The proposal threshold is not a raw value: it is a percentage of the total votes across all share classes

Returns

Name
Type
Description

<none>

uint256

The proposal threxwshold

superMajority

Returns the nominal value for a super majority at a 'timepoint', which is the number of for-votes needed to execute a proposal instantaneously during the voting period

proposalSnapshot

Returns a proposal's snapshot, which is the time at which votes are counted. Any votes accumulated past this point are not counted towards the proposal

The snapshot is set during the proposal's and is the sum of the voting delay and block.timestamp

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal

Returns

Name
Type
Description

<none>

uint256

The snapshot of the proposal, which is measured in seconds from the Unix epoch

proposalDeadline

Returns a proposal's deadline, which is the time at which the proposal can no longer be voted on

The deadline is set during the proposal's creation and is the sum of the voting delay, voting period, and block.timestamp

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal

Returns

Name
Type
Description

<none>

uint256

The deadline of the proposal, which is measured in seconds from the Unix epoch

proposalProposer

Returns the proposer of a proposal

Returns

Name
Type
Description

<none>

address

The address of the proposer

votingDelay

Returns the voting delay in seconds

Returns

Name
Type
Description

<none>

uint256

The voting delay in seconds

votingPeriod

Returns the voting period

Returns

Name
Type
Description

<none>

uint256

The voting period in seconds

hasVoted

Returns true if 'account' has voted on a proposal with 'proposalId', false otherwise

Returns

Name
Type
Description

<none>

bool

True if the account has voted, false otherwise

clock

EIP-6372 support

CLOCK_MODE

EIP-6372 support

COUNTING_MODE

Returns a URL-encoded sequence of key-value pairs that each describe one aspect of voting

Mezzanine Proposal Governors use votes in line with Bravo. The quorum also only counts for votes, like in Bravo. Reference: https://docs.openzeppelin.com/contracts/4.x/api/governance#IGovernor-COUNTING_MODE--

Returns

Name
Type
Description

<none>

string

The URL-encoded sequence of key-value pairs

name

Returns the name of the governor

coreId

Returns the coreId of the implementation as a bytes32

The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))

version

Returns the version of the implementation as a uint256

castVote

Casts the caller's votes towards the proposal associated with 'proposalId' There are three different vote types defined by the following enum:

  • 0: Against

  • 1: For

  • 2: Abstain

A voter can only vote once and cannot revoke or change their vote. Votes are calculated from the proposal's snapshot and the counting of votes is bespoke and must be implemented by the inheritor

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal to cast the vote for

support

uint8

The vote type

Returns

Name
Type
Description

<none>

uint256

The number of votes of the caller

castVoteWithReason

Casts the caller's votes with a 'reason' towards the proposal associated with 'proposalId'

The 'reason' is not stored on-chain but, rather, emitted in an event

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal to cast the vote for

support

uint8

The vote type

reason

string

The reason for the vote

Returns

Name
Type
Description

<none>

uint256

The number of votes of the caller

castVoteWithReasonAndParams

Casts the caller's votes with a 'reason' and 'params' towards the proposal associated with 'proposalId'

'params' are bespoke, abi-encoded arguments that could be used for casting a vote

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal to cast the vote for

support

uint8

The vote type

reason

string

The reason for the vote

params

bytes

The abi-encoded parameters for the vote

Returns

Name
Type
Description

<none>

uint256

The number of votes of the caller

castVoteBySig

Casts the votes of 'voter' towards the proposal associated with 'proposalId' via an EIP-712 signature

Reference: https://eips.ethereum.org/EIPS/eip-712

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal to cast the vote for

support

uint8

The vote type

voter

address

The address of the voter

signature

bytes

The EIP-712 signature of the voter

Returns

Name
Type
Description

<none>

uint256

The number of votes of the voter

castVoteWithReasonAndParamsBySig

Casts the votes of 'voter' towards the proposal associated with 'proposalId' via an EIP-712 signature

Reference: https://eips.ethereum.org/EIPS/eip-712 'params' are bespoke, abi-encoded arguments that could be used for casting a vote

Parameters

Name
Type
Description

proposalId

uint256

The ID of the proposal to cast the vote for

support

uint8

The vote type

voter

address

The address of the voter

reason

string

The reason for the vote

params

bytes

The abi-encoded parameters for the vote

signature

bytes

The EIP-712 signature of the voter

Returns

Name
Type
Description

<none>

uint256

The number of votes of the voter

_castVote

_castVote

OZ's GovernorUpgradeable vote casting is used directly here

_countVote

Counts a vote for a given proposal. Sets the receipt in storage. Assumes that weight has already been calculated

_getTotalVotesAtTimepoint

Queries all the shares and returns the summation of the total votes at the given timepoint

_getVotes

Queries all the shares and returns the summation of the votes for the account at the given timepoint

_superMajorityReached

Returns whether or not a super majority has been reached for a given proposal. Only for-votes are counted towards the super majority

Returns

Name
Type
Description

<none>

bool

True if the for-votes are greater than the super majority, false otherwise

_quorumReached

Returns whether or not the quourum has been reached for a given proposal. Only for-votes are counted towards the quorum

Returns

Name
Type
Description

<none>

bool

True if the for votes are greater than the quorum, false otherwise

_voteSucceeded

Returns whether or not the vote succeeded for a given proposal

Returns

Name
Type
Description

<none>

bool

True if the for votes are greater than the against votes, false otherwise

eip712Domain

EIP-5267 support. Reference: https://eips.ethereum.org/EIPS/eip-5267

supportsInterface

EIP-165 support. Reference: https://eips.ethereum.org/EIPS/eip-165

Last updated