Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): Add TaikoGovernor #15228

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/protocol/contracts/L1/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ contract TaikoToken is
initializer
{
EssentialContract._init(_addressManager);
ERC20Upgradeable.__ERC20_init_unchained(_name, _symbol);
ERC20SnapshotUpgradeable.__ERC20Snapshot_init_unchained();
ERC20VotesUpgradeable.__ERC20Votes_init_unchained();
ERC20Upgradeable.__ERC20_init(_name, _symbol);
ERC20SnapshotUpgradeable.__ERC20Snapshot_init();
ERC20VotesUpgradeable.__ERC20Votes_init();

// Mint 1 billion tokens
_mint(_recipient, 1_000_000_000 ether);
Expand Down
113 changes: 113 additions & 0 deletions packages/protocol/contracts/L1/gov/TaikoGovernor.sol
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);
}
}