Skip to main content

Governor Bravo

Governor Bravo is an advanced and flexible governance system. It is a key component of the decentralized governance infrastructure, which allows token holders to participate in the decision-making process for the management and future direction of a Hifi protocol. It's responsible for handling proposal creation, voting, and execution of governance actions; and it's designed with upgradeability in mind, which means that its logic can be modified or extended without affecting the existing proposals and voting data.

This is the only upgradeable contract in Hifi governance. The most up to date version is v1.0.0.

Constant Functions

getActions

function getActions(
uint256 proposalId
) external returns (address[] targets, uint256[] values, string[] signatures, bytes[] calldatas)

Gets actions of a proposal

Parameters

NameTypeDescription
proposalIduint256The id of the proposal

Return Values

NameTypeDescription
targetsaddress[]proposal targets
valuesuint256[]proposal values
signaturesstring[]proposal signatures
calldatasbytes[]proposal calldatas

getReceipt

function getReceipt(
uint256 proposalId,
address voter
) external returns (struct GovernorBravoDelegateStorageV1.Receipt)

Returns the receipt of a voter on a given proposal

Parameters

NameTypeDescription
proposalIduint256the id of proposal
voteraddressThe address of the voter

Return Values

NameTypeDescription
[0]struct GovernorBravoDelegateStorageV1.ReceiptThe voting receipt

quorumVotes

function quorumVotes() public returns (uint256)

The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed

state

function state(
uint256 proposalId
) public returns (enum GovernorBravoDelegateStorageV1.ProposalState)

Returns the state of a proposal

Parameters

NameTypeDescription
proposalIduint256The id of the proposal

Return Values

NameTypeDescription
[0]enum GovernorBravoDelegateStorageV1.ProposalStateProposal state

MAX_PROPOSAL_THRESHOLD

function MAX_PROPOSAL_THRESHOLD() public returns (uint256)

The maximum settable proposal threshold

MIN_PROPOSAL_THRESHOLD

function MIN_PROPOSAL_THRESHOLD() public returns (uint256)

The minimum settable proposal threshold

Non-Constant Functions

_acceptAdmin

function _acceptAdmin() external

This function is used to accept the transfer of admin rights. The message sender (i.e., msg.sender) must be the pending admin.

_setPendingAdmin

function _setPendingAdmin(
address newPendingAdmin
) external

Begins transfer of admin rights. The newPendingAdmin must call _acceptAdmin to finalize the transfer.

Admin function to begin change of admin. The newPendingAdmin must call _acceptAdmin to finalize the transfer.

Parameters

NameTypeDescription
newPendingAdminaddressNew pending admin.

_setProposalThreshold

function _setProposalThreshold(
uint256 newProposalThreshold
) external

Admin function for setting the proposal threshold.

newProposalThreshold must be greater than the hardcoded MIN_PROPOSAL_THRESHOLD

Parameters

NameTypeDescription
newProposalThresholduint256new proposal threshold

_setVotingDelay

function _setVotingDelay(
uint256 newVotingDelay
) external

Admin function for setting the voting delay

Parameters

NameTypeDescription
newVotingDelayuint256new voting delay, in blocks

_setVotingPeriod

function _setVotingPeriod(
uint256 newVotingPeriod
) external

Admin function for setting the voting period

Parameters

NameTypeDescription
newVotingPerioduint256new voting period, in blocks

cancel

function cancel(
uint256 proposalId
) external

Cancels a proposal if sender is the proposer, or proposer delegates dropped below proposal threshold

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to cancel

castVote

function castVote(
uint256 proposalId,
uint8 support
) external

Cast a vote on a proposal

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to vote on
supportuint8The support value for the vote. 0=against, 1=for, 2=abstain

castVoteBySig

function castVoteBySig(
uint256 proposalId,
uint8 support,
uint8 v,
bytes32 r,
bytes32 s
) external

Cast a vote on a proposal via an EIP-712 signature.

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to vote on
supportuint8The support value for the vote. 0=against, 1=for, 2=abstain
vuint8The recovery byte of the signature
rbytes32The first 32 bytes of the signature
sbytes32The second 32 bytes of the signature

castVoteWithReason

function castVoteWithReason(
uint256 proposalId,
uint8 support,
string reason
) external

Cast a vote on a proposal with a reason

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to vote on
supportuint8The support value for the vote. 0=against, 1=for, 2=abstain
reasonstringThe reason given for the vote by the voter

execute

function execute(
uint256 proposalId
) external

Executes a queued proposal if eta has passed

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to execute

initialize

function initialize(
address timelock_,
address hifi_,
uint256 votingPeriod_,
uint256 votingDelay_,
uint256 proposalThreshold_
) public

Used to initialize the contract during delegator construction

Parameters

NameTypeDescription
timelock_addressThe address of the Timelock
hifi_addressThe address of the Hifi token
votingPeriod_uint256The initial voting period
votingDelay_uint256The initial voting delay
proposalThreshold_uint256The initial proposal threshold

propose

function propose(
address[] targets,
uint256[] values,
string[] signatures,
bytes[] calldatas,
string description
) public returns (uint256)

Function used to submit a new proposal. Sender must have delegates above the proposal threshold

Parameters

NameTypeDescription
targetsaddress[]Target addresses for proposal calls
valuesuint256[]Eth values for proposal calls
signaturesstring[]Function signatures for proposal calls
calldatasbytes[]Calldatas for proposal calls
descriptionstringString description of the proposal

Return Values

NameTypeDescription
[0]uint256Proposal id of new proposal

queue

function queue(
uint256 proposalId
) external

Queues a proposal of state succeeded

Parameters

NameTypeDescription
proposalIduint256The id of the proposal to queue

Events

ProposalCanceled

event ProposalCanceled(
uint256 id
)

An event emitted when a proposal has been canceled

Parameters

NameTypeDescription
iduint256The id of the proposal which was canceled

ProposalCreated

event ProposalCreated(
uint256 id,
address proposer,
address[] targets,
uint256[] values,
string[] signatures,
bytes[] calldatas,
uint256 startBlock,
uint256 endBlock,
string description
)

An event emitted when a new proposal is created

Parameters

NameTypeDescription
iduint256The id of the proposal
proposeraddressThe address of the proposer
targetsaddress[]The ordered list of target addresses for calls to be made
valuesuint256[]The ordered list of values (i.e. msg.value) to be passed to the calls to be made
signaturesstring[]The ordered list of function signatures to be called
calldatasbytes[]The ordered list of calldata to be passed to each call
startBlockuint256The block at which voting begins: holders must delegate their votes prior to this block
endBlockuint256The block at which voting ends: votes must be cast prior to this block
descriptionstringThe description text for the proposal

ProposalExecuted

event ProposalExecuted(
uint256 id
)

An event emitted when a proposal has been executed in the Timelock

Parameters

NameTypeDescription
iduint256The id of the proposal that was executed

ProposalQueued

event ProposalQueued(
uint256 id,
uint256 eta
)

An event emitted when a proposal has been queued in the Timelock

Parameters

NameTypeDescription
iduint256The id of the proposal that was queued
etauint256The timestamp at which the proposal will be queued in the Timelock

VoteCast

event VoteCast(
address voter,
uint256 proposalId,
uint8 support,
uint256 votes,
string reason
)

An event emitted when a vote has been cast on a proposal

Parameters

NameTypeDescription
voteraddressThe address which casted a vote
proposalIduint256The proposal id which was voted on
supportuint8Support value for the vote. 0=against, 1=for, 2=abstain
votesuint256Number of votes which were cast by the voter
reasonstringThe reason given for the vote by the voter

VotingDelaySet

event VotingDelaySet(
uint256 oldVotingDelay,
uint256 newVotingDelay
)

An event emitted when the voting delay is set

Parameters

NameTypeDescription
oldVotingDelayuint256The old voting delay
newVotingDelayuint256The new voting delay

VotingPeriodSet

event VotingPeriodSet(
uint256 oldVotingPeriod,
uint256 newVotingPeriod
)

An event emitted when the voting period is set

Parameters

NameTypeDescription
oldVotingPerioduint256The old voting period
newVotingPerioduint256The new voting period

NewAdmin

event NewAdmin(
address oldAdmin,
address newAdmin
)

Emitted when pendingAdmin is accepted, which means admin is updated

Parameters

NameTypeDescription
oldAdminaddressThe old admin
newAdminaddressThe new admin

NewImplementation

event NewImplementation(
address oldImplementation,
address newImplementation
)

Emitted when implementation is changed

Parameters

NameTypeDescription
oldImplementationaddressThe old implementation
newImplementationaddressThe new implementation

NewPendingAdmin

event NewPendingAdmin(
address oldPendingAdmin,
address newPendingAdmin
)

Emitted when pendingAdmin is changed

Parameters

NameTypeDescription
oldPendingAdminaddressThe old pending admin
newPendingAdminaddressThe new pending admin

ProposalThresholdSet

event ProposalThresholdSet(
uint256 oldProposalThreshold,
uint256 newProposalThreshold
)

Emitted when proposal threshold is set

Parameters

NameTypeDescription
oldProposalThresholduint256The old proposal threshold
newProposalThresholduint256The new proposal threshold