-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): Add TaikoGovernor (#15228)
Co-authored-by: Daniel Wang <dong77@gmail.com>
- Loading branch information
Showing
2 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.2; | ||
|
||
import "lib/openzeppelin-contracts/contracts/governance/Governor.sol"; | ||
import | ||
"lib/openzeppelin-contracts/contracts/governance/compatibility/GovernorCompatibilityBravo.sol"; | ||
import | ||
"lib/openzeppelin-contracts/contracts/governance/extensions/GovernorVotes.sol"; | ||
import | ||
"lib/openzeppelin-contracts/contracts/governance/extensions/GovernorVotesQuorumFraction.sol"; | ||
import | ||
"lib/openzeppelin-contracts/contracts/governance/extensions/GovernorTimelockControl.sol"; | ||
|
||
contract TaikoGovernor is | ||
Governor, | ||
GovernorCompatibilityBravo, | ||
GovernorVotes, | ||
GovernorVotesQuorumFraction, | ||
GovernorTimelockControl | ||
{ | ||
constructor( | ||
IVotes _token, | ||
TimelockController _timelock | ||
) | ||
Governor("MyGovernor") | ||
GovernorVotes(_token) | ||
GovernorVotesQuorumFraction(4) | ||
GovernorTimelockControl(_timelock) | ||
{ } | ||
|
||
// How long after a proposal is created should voting power be fixed. A | ||
// large voting delay gives users time to unstake tokens if necessary. | ||
function votingDelay() public pure override returns (uint256) { | ||
return 7200; // 1 day | ||
} | ||
|
||
// How long does a proposal remain open to votes. | ||
function votingPeriod() public pure override returns (uint256) { | ||
return 50_400; // 1 week | ||
} | ||
|
||
// The number of votes required in order for a voter to become a proposer | ||
function proposalThreshold() public pure override returns (uint256) { | ||
return 1_000_000_000 ether / 10_000; // 0.01% of Taiko Token | ||
} | ||
|
||
// The functions below are overrides required by Solidity. | ||
function state(uint256 proposalId) | ||
public | ||
view | ||
override(Governor, IGovernor, GovernorTimelockControl) | ||
returns (ProposalState) | ||
{ | ||
return super.state(proposalId); | ||
} | ||
|
||
function propose( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
string memory description | ||
) | ||
public | ||
override(Governor, IGovernor, GovernorCompatibilityBravo) | ||
returns (uint256) | ||
{ | ||
return super.propose(targets, values, calldatas, description); | ||
} | ||
|
||
function _execute( | ||
uint256 proposalId, | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) | ||
internal | ||
override(Governor, GovernorTimelockControl) | ||
{ | ||
super._execute(proposalId, targets, values, calldatas, descriptionHash); | ||
} | ||
|
||
function _cancel( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) | ||
internal | ||
override(Governor, GovernorTimelockControl) | ||
returns (uint256) | ||
{ | ||
return super._cancel(targets, values, calldatas, descriptionHash); | ||
} | ||
|
||
function _executor() | ||
internal | ||
view | ||
override(Governor, GovernorTimelockControl) | ||
returns (address) | ||
{ | ||
return super._executor(); | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
override(Governor, IERC165, GovernorTimelockControl) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
} |