Skip to content

Commit

Permalink
feat(protocol): Add TaikoGovernor (#15228)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Wang <dong77@gmail.com>
  • Loading branch information
dantaik and dong77 committed Nov 17, 2023
1 parent 28000b3 commit f4a007b
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 3 deletions.
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);
}
}

0 comments on commit f4a007b

Please sign in to comment.