zellic-audit
Initial commit
f998fcd
raw
history blame
38.8 kB
{
"language": "Solidity",
"sources": {
"contracts/governance/NounsDAOLogicV1.sol": {
"content": "// SPDX-License-Identifier: BSD-3-Clause\n\n/// @title The Nouns DAO logic version 1\n\n/*********************************\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░██░░░████░░██░░░████░░░ *\n * ░░██████░░░████████░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n *********************************/\n\n// LICENSE\n// NounsDAOLogicV1.sol is a modified version of Compound Lab's GovernorBravoDelegate.sol:\n// https://github.com/compound-finance/compound-protocol/blob/b9b14038612d846b83f8a009a82c38974ff2dcfe/contracts/Governance/GovernorBravoDelegate.sol\n//\n// GovernorBravoDelegate.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license.\n// With modifications by Nounders DAO.\n//\n// Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause\n//\n// MODIFICATIONS\n// NounsDAOLogicV1 adds:\n// - Proposal Threshold basis points instead of fixed number\n// due to the Noun token's increasing supply\n//\n// - Quorum Votes basis points instead of fixed number\n// due to the Noun token's increasing supply\n//\n// - Per proposal storing of fixed `proposalThreshold`\n// and `quorumVotes` calculated using the Noun token's total supply\n// at the block the proposal was created and the basis point parameters\n//\n// - `ProposalCreatedWithRequirements` event that emits `ProposalCreated` parameters with\n// the addition of `proposalThreshold` and `quorumVotes`\n//\n// - Votes are counted from the block a proposal is created instead of\n// the proposal's voting start block to align with the parameters\n// stored with the proposal\n//\n// - Veto ability which allows `veteor` to halt any proposal at any stage unless\n// the proposal is executed.\n// The `veto(uint proposalId)` logic is a modified version of `cancel(uint proposalId)`\n// A `vetoed` flag was added to the `Proposal` struct to support this.\n//\n// NounsDAOLogicV1 removes:\n// - `initialProposalId` and `_initiate()` due to this being the\n// first instance of the governance contract unlike\n// GovernorBravo which upgrades GovernorAlpha\n//\n// - Value passed along using `timelock.executeTransaction{value: proposal.value}`\n// in `execute(uint proposalId)`. This contract should not hold funds and does not\n// implement `receive()` or `fallback()` functions.\n//\n\npragma solidity ^0.8.6;\n\nimport './NounsDAOInterfaces.sol';\n\ncontract NounsDAOLogicV1 is NounsDAOStorageV1, NounsDAOEvents {\n /// @notice The name of this contract\n string public constant name = 'Nouns DAO';\n\n /// @notice The minimum setable proposal threshold\n uint256 public constant MIN_PROPOSAL_THRESHOLD_BPS = 1; // 1 basis point or 0.01%\n\n /// @notice The maximum setable proposal threshold\n uint256 public constant MAX_PROPOSAL_THRESHOLD_BPS = 1_000; // 1,000 basis points or 10%\n\n /// @notice The minimum setable voting period\n uint256 public constant MIN_VOTING_PERIOD = 5_760; // About 24 hours\n\n /// @notice The max setable voting period\n uint256 public constant MAX_VOTING_PERIOD = 80_640; // About 2 weeks\n\n /// @notice The min setable voting delay\n uint256 public constant MIN_VOTING_DELAY = 1;\n\n /// @notice The max setable voting delay\n uint256 public constant MAX_VOTING_DELAY = 40_320; // About 1 week\n\n /// @notice The minimum setable quorum votes basis points\n uint256 public constant MIN_QUORUM_VOTES_BPS = 200; // 200 basis points or 2%\n\n /// @notice The maximum setable quorum votes basis points\n uint256 public constant MAX_QUORUM_VOTES_BPS = 2_000; // 2,000 basis points or 20%\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint256 public constant proposalMaxOperations = 10; // 10 actions\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH =\n keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');\n\n /// @notice The EIP-712 typehash for the ballot struct used by the contract\n bytes32 public constant BALLOT_TYPEHASH = keccak256('Ballot(uint256 proposalId,uint8 support)');\n\n /**\n * @notice Used to initialize the contract during delegator contructor\n * @param timelock_ The address of the NounsDAOExecutor\n * @param nouns_ The address of the NOUN tokens\n * @param vetoer_ The address allowed to unilaterally veto proposals\n * @param votingPeriod_ The initial voting period\n * @param votingDelay_ The initial voting delay\n * @param proposalThresholdBPS_ The initial proposal threshold in basis points\n * * @param quorumVotesBPS_ The initial quorum votes threshold in basis points\n */\n function initialize(\n address timelock_,\n address nouns_,\n address vetoer_,\n uint256 votingPeriod_,\n uint256 votingDelay_,\n uint256 proposalThresholdBPS_,\n uint256 quorumVotesBPS_\n ) public virtual {\n require(address(timelock) == address(0), 'NounsDAO::initialize: can only initialize once');\n require(msg.sender == admin, 'NounsDAO::initialize: admin only');\n require(timelock_ != address(0), 'NounsDAO::initialize: invalid timelock address');\n require(nouns_ != address(0), 'NounsDAO::initialize: invalid nouns address');\n require(\n votingPeriod_ >= MIN_VOTING_PERIOD && votingPeriod_ <= MAX_VOTING_PERIOD,\n 'NounsDAO::initialize: invalid voting period'\n );\n require(\n votingDelay_ >= MIN_VOTING_DELAY && votingDelay_ <= MAX_VOTING_DELAY,\n 'NounsDAO::initialize: invalid voting delay'\n );\n require(\n proposalThresholdBPS_ >= MIN_PROPOSAL_THRESHOLD_BPS && proposalThresholdBPS_ <= MAX_PROPOSAL_THRESHOLD_BPS,\n 'NounsDAO::initialize: invalid proposal threshold'\n );\n require(\n quorumVotesBPS_ >= MIN_QUORUM_VOTES_BPS && quorumVotesBPS_ <= MAX_QUORUM_VOTES_BPS,\n 'NounsDAO::initialize: invalid proposal threshold'\n );\n\n emit VotingPeriodSet(votingPeriod, votingPeriod_);\n emit VotingDelaySet(votingDelay, votingDelay_);\n emit ProposalThresholdBPSSet(proposalThresholdBPS, proposalThresholdBPS_);\n emit QuorumVotesBPSSet(quorumVotesBPS, quorumVotesBPS_);\n\n timelock = INounsDAOExecutor(timelock_);\n nouns = NounsTokenLike(nouns_);\n vetoer = vetoer_;\n votingPeriod = votingPeriod_;\n votingDelay = votingDelay_;\n proposalThresholdBPS = proposalThresholdBPS_;\n quorumVotesBPS = quorumVotesBPS_;\n }\n\n struct ProposalTemp {\n uint256 totalSupply;\n uint256 proposalThreshold;\n uint256 latestProposalId;\n uint256 startBlock;\n uint256 endBlock;\n }\n\n /**\n * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold\n * @param targets Target addresses for proposal calls\n * @param values Eth values for proposal calls\n * @param signatures Function signatures for proposal calls\n * @param calldatas Calldatas for proposal calls\n * @param description String description of the proposal\n * @return Proposal id of new proposal\n */\n function propose(\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas,\n string memory description\n ) public returns (uint256) {\n ProposalTemp memory temp;\n\n temp.totalSupply = nouns.totalSupply();\n\n temp.proposalThreshold = bps2Uint(proposalThresholdBPS, temp.totalSupply);\n\n require(\n nouns.getPriorVotes(msg.sender, block.number - 1) > temp.proposalThreshold,\n 'NounsDAO::propose: proposer votes below proposal threshold'\n );\n require(\n targets.length == values.length &&\n targets.length == signatures.length &&\n targets.length == calldatas.length,\n 'NounsDAO::propose: proposal function information arity mismatch'\n );\n require(targets.length != 0, 'NounsDAO::propose: must provide actions');\n require(targets.length <= proposalMaxOperations, 'NounsDAO::propose: too many actions');\n\n temp.latestProposalId = latestProposalIds[msg.sender];\n if (temp.latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(temp.latestProposalId);\n require(\n proposersLatestProposalState != ProposalState.Active,\n 'NounsDAO::propose: one live proposal per proposer, found an already active proposal'\n );\n require(\n proposersLatestProposalState != ProposalState.Pending,\n 'NounsDAO::propose: one live proposal per proposer, found an already pending proposal'\n );\n }\n\n temp.startBlock = block.number + votingDelay;\n temp.endBlock = temp.startBlock + votingPeriod;\n\n proposalCount++;\n Proposal storage newProposal = proposals[proposalCount];\n\n newProposal.id = proposalCount;\n newProposal.proposer = msg.sender;\n newProposal.proposalThreshold = temp.proposalThreshold;\n newProposal.quorumVotes = bps2Uint(quorumVotesBPS, temp.totalSupply);\n newProposal.eta = 0;\n newProposal.targets = targets;\n newProposal.values = values;\n newProposal.signatures = signatures;\n newProposal.calldatas = calldatas;\n newProposal.startBlock = temp.startBlock;\n newProposal.endBlock = temp.endBlock;\n newProposal.forVotes = 0;\n newProposal.againstVotes = 0;\n newProposal.abstainVotes = 0;\n newProposal.canceled = false;\n newProposal.executed = false;\n newProposal.vetoed = false;\n\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n /// @notice Maintains backwards compatibility with GovernorBravo events\n emit ProposalCreated(\n newProposal.id,\n msg.sender,\n targets,\n values,\n signatures,\n calldatas,\n newProposal.startBlock,\n newProposal.endBlock,\n description\n );\n\n /// @notice Updated event with `proposalThreshold` and `quorumVotes`\n emit ProposalCreatedWithRequirements(\n newProposal.id,\n msg.sender,\n targets,\n values,\n signatures,\n calldatas,\n newProposal.startBlock,\n newProposal.endBlock,\n newProposal.proposalThreshold,\n newProposal.quorumVotes,\n description\n );\n\n return newProposal.id;\n }\n\n /**\n * @notice Queues a proposal of state succeeded\n * @param proposalId The id of the proposal to queue\n */\n function queue(uint256 proposalId) external {\n require(\n state(proposalId) == ProposalState.Succeeded,\n 'NounsDAO::queue: proposal can only be queued if it is succeeded'\n );\n Proposal storage proposal = proposals[proposalId];\n uint256 eta = block.timestamp + timelock.delay();\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n queueOrRevertInternal(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n eta\n );\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueOrRevertInternal(\n address target,\n uint256 value,\n string memory signature,\n bytes memory data,\n uint256 eta\n ) internal {\n require(\n !timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))),\n 'NounsDAO::queueOrRevertInternal: identical proposal action already queued at eta'\n );\n timelock.queueTransaction(target, value, signature, data, eta);\n }\n\n /**\n * @notice Executes a queued proposal if eta has passed\n * @param proposalId The id of the proposal to execute\n */\n function execute(uint256 proposalId) external {\n require(\n state(proposalId) == ProposalState.Queued,\n 'NounsDAO::execute: proposal can only be executed if it is queued'\n );\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n timelock.executeTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n emit ProposalExecuted(proposalId);\n }\n\n /**\n * @notice Cancels a proposal only if sender is the proposer, or proposer delegates dropped below proposal threshold\n * @param proposalId The id of the proposal to cancel\n */\n function cancel(uint256 proposalId) external {\n require(state(proposalId) != ProposalState.Executed, 'NounsDAO::cancel: cannot cancel executed proposal');\n\n Proposal storage proposal = proposals[proposalId];\n require(\n msg.sender == proposal.proposer ||\n nouns.getPriorVotes(proposal.proposer, block.number - 1) < proposal.proposalThreshold,\n 'NounsDAO::cancel: proposer above threshold'\n );\n\n proposal.canceled = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n timelock.cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n /**\n * @notice Vetoes a proposal only if sender is the vetoer and the proposal has not been executed.\n * @param proposalId The id of the proposal to veto\n */\n function veto(uint256 proposalId) external {\n require(vetoer != address(0), 'NounsDAO::veto: veto power burned');\n require(msg.sender == vetoer, 'NounsDAO::veto: only vetoer');\n require(state(proposalId) != ProposalState.Executed, 'NounsDAO::veto: cannot veto executed proposal');\n\n Proposal storage proposal = proposals[proposalId];\n\n proposal.vetoed = true;\n for (uint256 i = 0; i < proposal.targets.length; i++) {\n timelock.cancelTransaction(\n proposal.targets[i],\n proposal.values[i],\n proposal.signatures[i],\n proposal.calldatas[i],\n proposal.eta\n );\n }\n\n emit ProposalVetoed(proposalId);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets\n * @return values\n * @return signatures\n * @return calldatas\n */\n function getActions(uint256 proposalId)\n external\n view\n returns (\n address[] memory targets,\n uint256[] memory values,\n string[] memory signatures,\n bytes[] memory calldatas\n )\n {\n Proposal storage p = proposals[proposalId];\n return (p.targets, p.values, p.signatures, p.calldatas);\n }\n\n /**\n * @notice Gets the receipt for a voter on a given proposal\n * @param proposalId the id of proposal\n * @param voter The address of the voter\n * @return The voting receipt\n */\n function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory) {\n return proposals[proposalId].receipts[voter];\n }\n\n /**\n * @notice Gets the state of a proposal\n * @param proposalId The id of the proposal\n * @return Proposal state\n */\n function state(uint256 proposalId) public view returns (ProposalState) {\n require(proposalCount >= proposalId, 'NounsDAO::state: invalid proposal id');\n Proposal storage proposal = proposals[proposalId];\n if (proposal.vetoed) {\n return ProposalState.Vetoed;\n } else if (proposal.canceled) {\n return ProposalState.Canceled;\n } else if (block.number <= proposal.startBlock) {\n return ProposalState.Pending;\n } else if (block.number <= proposal.endBlock) {\n return ProposalState.Active;\n } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < proposal.quorumVotes) {\n return ProposalState.Defeated;\n } else if (proposal.eta == 0) {\n return ProposalState.Succeeded;\n } else if (proposal.executed) {\n return ProposalState.Executed;\n } else if (block.timestamp >= proposal.eta + timelock.GRACE_PERIOD()) {\n return ProposalState.Expired;\n } else {\n return ProposalState.Queued;\n }\n }\n\n /**\n * @notice Cast a vote for a proposal\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n */\n function castVote(uint256 proposalId, uint8 support) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), '');\n }\n\n /**\n * @notice Cast a vote for a proposal with a reason\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @param reason The reason given for the vote by the voter\n */\n function castVoteWithReason(\n uint256 proposalId,\n uint8 support,\n string calldata reason\n ) external {\n emit VoteCast(msg.sender, proposalId, support, castVoteInternal(msg.sender, proposalId, support), reason);\n }\n\n /**\n * @notice Cast a vote for a proposal by signature\n * @dev External function that accepts EIP-712 signatures for voting on proposals.\n */\n function castVoteBySig(\n uint256 proposalId,\n uint8 support,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n bytes32 domainSeparator = keccak256(\n abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this))\n );\n bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));\n bytes32 digest = keccak256(abi.encodePacked('\\x19\\x01', domainSeparator, structHash));\n address signatory = ecrecover(digest, v, r, s);\n require(signatory != address(0), 'NounsDAO::castVoteBySig: invalid signature');\n emit VoteCast(signatory, proposalId, support, castVoteInternal(signatory, proposalId, support), '');\n }\n\n /**\n * @notice Internal function that caries out voting logic\n * @param voter The voter that is casting their vote\n * @param proposalId The id of the proposal to vote on\n * @param support The support value for the vote. 0=against, 1=for, 2=abstain\n * @return The number of votes cast\n */\n function castVoteInternal(\n address voter,\n uint256 proposalId,\n uint8 support\n ) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, 'NounsDAO::castVoteInternal: voting is closed');\n require(support <= 2, 'NounsDAO::castVoteInternal: invalid vote type');\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposal.receipts[voter];\n require(receipt.hasVoted == false, 'NounsDAO::castVoteInternal: voter already voted');\n\n /// @notice: Unlike GovernerBravo, votes are considered from the block the proposal was created in order to normalize quorumVotes and proposalThreshold metrics\n uint96 votes = nouns.getPriorVotes(voter, proposal.startBlock - votingDelay);\n\n if (support == 0) {\n proposal.againstVotes = proposal.againstVotes + votes;\n } else if (support == 1) {\n proposal.forVotes = proposal.forVotes + votes;\n } else if (support == 2) {\n proposal.abstainVotes = proposal.abstainVotes + votes;\n }\n\n receipt.hasVoted = true;\n receipt.support = support;\n receipt.votes = votes;\n\n return votes;\n }\n\n /**\n * @notice Admin function for setting the voting delay\n * @param newVotingDelay new voting delay, in blocks\n */\n function _setVotingDelay(uint256 newVotingDelay) external {\n require(msg.sender == admin, 'NounsDAO::_setVotingDelay: admin only');\n require(\n newVotingDelay >= MIN_VOTING_DELAY && newVotingDelay <= MAX_VOTING_DELAY,\n 'NounsDAO::_setVotingDelay: invalid voting delay'\n );\n uint256 oldVotingDelay = votingDelay;\n votingDelay = newVotingDelay;\n\n emit VotingDelaySet(oldVotingDelay, votingDelay);\n }\n\n /**\n * @notice Admin function for setting the voting period\n * @param newVotingPeriod new voting period, in blocks\n */\n function _setVotingPeriod(uint256 newVotingPeriod) external {\n require(msg.sender == admin, 'NounsDAO::_setVotingPeriod: admin only');\n require(\n newVotingPeriod >= MIN_VOTING_PERIOD && newVotingPeriod <= MAX_VOTING_PERIOD,\n 'NounsDAO::_setVotingPeriod: invalid voting period'\n );\n uint256 oldVotingPeriod = votingPeriod;\n votingPeriod = newVotingPeriod;\n\n emit VotingPeriodSet(oldVotingPeriod, votingPeriod);\n }\n\n /**\n * @notice Admin function for setting the proposal threshold basis points\n * @dev newProposalThresholdBPS must be greater than the hardcoded min\n * @param newProposalThresholdBPS new proposal threshold\n */\n function _setProposalThresholdBPS(uint256 newProposalThresholdBPS) external {\n require(msg.sender == admin, 'NounsDAO::_setProposalThresholdBPS: admin only');\n require(\n newProposalThresholdBPS >= MIN_PROPOSAL_THRESHOLD_BPS &&\n newProposalThresholdBPS <= MAX_PROPOSAL_THRESHOLD_BPS,\n 'NounsDAO::_setProposalThreshold: invalid proposal threshold'\n );\n uint256 oldProposalThresholdBPS = proposalThresholdBPS;\n proposalThresholdBPS = newProposalThresholdBPS;\n\n emit ProposalThresholdBPSSet(oldProposalThresholdBPS, proposalThresholdBPS);\n }\n\n /**\n * @notice Admin function for setting the quorum votes basis points\n * @dev newQuorumVotesBPS must be greater than the hardcoded min\n * @param newQuorumVotesBPS new proposal threshold\n */\n function _setQuorumVotesBPS(uint256 newQuorumVotesBPS) external {\n require(msg.sender == admin, 'NounsDAO::_setQuorumVotesBPS: admin only');\n require(\n newQuorumVotesBPS >= MIN_QUORUM_VOTES_BPS && newQuorumVotesBPS <= MAX_QUORUM_VOTES_BPS,\n 'NounsDAO::_setProposalThreshold: invalid proposal threshold'\n );\n uint256 oldQuorumVotesBPS = quorumVotesBPS;\n quorumVotesBPS = newQuorumVotesBPS;\n\n emit QuorumVotesBPSSet(oldQuorumVotesBPS, quorumVotesBPS);\n }\n\n /**\n * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.\n * @param newPendingAdmin New pending admin.\n */\n function _setPendingAdmin(address newPendingAdmin) external {\n // Check caller = admin\n require(msg.sender == admin, 'NounsDAO::_setPendingAdmin: admin only');\n\n // Save current value, if any, for inclusion in log\n address oldPendingAdmin = pendingAdmin;\n\n // Store pendingAdmin with value newPendingAdmin\n pendingAdmin = newPendingAdmin;\n\n // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)\n emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);\n }\n\n /**\n * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin\n * @dev Admin function for pending admin to accept role and update admin\n */\n function _acceptAdmin() external {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n require(msg.sender == pendingAdmin && msg.sender != address(0), 'NounsDAO::_acceptAdmin: pending admin only');\n\n // Save current values for inclusion in log\n address oldAdmin = admin;\n address oldPendingAdmin = pendingAdmin;\n\n // Store admin with value pendingAdmin\n admin = pendingAdmin;\n\n // Clear the pending value\n pendingAdmin = address(0);\n\n emit NewAdmin(oldAdmin, admin);\n emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);\n }\n\n /**\n * @notice Changes vetoer address\n * @dev Vetoer function for updating vetoer address\n */\n function _setVetoer(address newVetoer) public {\n require(msg.sender == vetoer, 'NounsDAO::_setVetoer: vetoer only');\n\n emit NewVetoer(vetoer, newVetoer);\n\n vetoer = newVetoer;\n }\n\n /**\n * @notice Burns veto priviledges\n * @dev Vetoer function destroying veto power forever\n */\n function _burnVetoPower() public {\n // Check caller is pendingAdmin and pendingAdmin ≠ address(0)\n require(msg.sender == vetoer, 'NounsDAO::_burnVetoPower: vetoer only');\n\n _setVetoer(address(0));\n }\n\n /**\n * @notice Current proposal threshold using Noun Total Supply\n * Differs from `GovernerBravo` which uses fixed amount\n */\n function proposalThreshold() public view returns (uint256) {\n return bps2Uint(proposalThresholdBPS, nouns.totalSupply());\n }\n\n /**\n * @notice Current quorum votes using Noun Total Supply\n * Differs from `GovernerBravo` which uses fixed amount\n */\n function quorumVotes() public view returns (uint256) {\n return bps2Uint(quorumVotesBPS, nouns.totalSupply());\n }\n\n function bps2Uint(uint256 bps, uint256 number) internal pure returns (uint256) {\n return (number * bps) / 10000;\n }\n\n function getChainIdInternal() internal view returns (uint256) {\n uint256 chainId;\n assembly {\n chainId := chainid()\n }\n return chainId;\n }\n}\n"
},
"contracts/governance/NounsDAOInterfaces.sol": {
"content": "// SPDX-License-Identifier: BSD-3-Clause\n\n/// @title Nouns DAO Logic interfaces and events\n\n/*********************************\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░██░░░████░░██░░░████░░░ *\n * ░░██████░░░████████░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░██░░██░░░████░░██░░░████░░░ *\n * ░░░░░░█████████░░█████████░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *\n *********************************/\n\n// LICENSE\n// NounsDAOInterfaces.sol is a modified version of Compound Lab's GovernorBravoInterfaces.sol:\n// https://github.com/compound-finance/compound-protocol/blob/b9b14038612d846b83f8a009a82c38974ff2dcfe/contracts/Governance/GovernorBravoInterfaces.sol\n//\n// GovernorBravoInterfaces.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license.\n// With modifications by Nounders DAO.\n//\n// Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause\n//\n// MODIFICATIONS\n// NounsDAOEvents, NounsDAOProxyStorage, NounsDAOStorageV1 adds support for changes made by Nouns DAO to GovernorBravo.sol\n// See NounsDAOLogicV1.sol for more details.\n\npragma solidity ^0.8.6;\n\ncontract NounsDAOEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(\n uint256 id,\n address proposer,\n address[] targets,\n uint256[] values,\n string[] signatures,\n bytes[] calldatas,\n uint256 startBlock,\n uint256 endBlock,\n string description\n );\n\n event ProposalCreatedWithRequirements(\n uint256 id,\n address proposer,\n address[] targets,\n uint256[] values,\n string[] signatures,\n bytes[] calldatas,\n uint256 startBlock,\n uint256 endBlock,\n uint256 proposalThreshold,\n uint256 quorumVotes,\n string description\n );\n\n /// @notice An event emitted when a vote has been cast on a proposal\n /// @param voter The address which casted a vote\n /// @param proposalId The proposal id which was voted on\n /// @param support Support value for the vote. 0=against, 1=for, 2=abstain\n /// @param votes Number of votes which were cast by the voter\n /// @param reason The reason given for the vote by the voter\n event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint256 id);\n\n /// @notice An event emitted when a proposal has been queued in the NounsDAOExecutor\n event ProposalQueued(uint256 id, uint256 eta);\n\n /// @notice An event emitted when a proposal has been executed in the NounsDAOExecutor\n event ProposalExecuted(uint256 id);\n\n /// @notice An event emitted when a proposal has been vetoed by vetoAddress\n event ProposalVetoed(uint256 id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold basis points is set\n event ProposalThresholdBPSSet(uint256 oldProposalThresholdBPS, uint256 newProposalThresholdBPS);\n\n /// @notice Emitted when quorum votes basis points is set\n event QuorumVotesBPSSet(uint256 oldQuorumVotesBPS, uint256 newQuorumVotesBPS);\n\n /// @notice Emitted when pendingAdmin is changed\n event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);\n\n /// @notice Emitted when pendingAdmin is accepted, which means admin is updated\n event NewAdmin(address oldAdmin, address newAdmin);\n\n /// @notice Emitted when vetoer is changed\n event NewVetoer(address oldVetoer, address newVetoer);\n}\n\ncontract NounsDAOProxyStorage {\n /// @notice Administrator for this contract\n address public admin;\n\n /// @notice Pending administrator for this contract\n address public pendingAdmin;\n\n /// @notice Active brains of Governor\n address public implementation;\n}\n\n/**\n * @title Storage for Governor Bravo Delegate\n * @notice For future upgrades, do not change NounsDAOStorageV1. Create a new\n * contract which implements NounsDAOStorageV1 and following the naming convention\n * NounsDAOStorageVX.\n */\ncontract NounsDAOStorageV1 is NounsDAOProxyStorage {\n /// @notice Vetoer who has the ability to veto any proposal\n address public vetoer;\n\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint256 public votingDelay;\n\n /// @notice The duration of voting on a proposal, in blocks\n uint256 public votingPeriod;\n\n /// @notice The basis point number of votes required in order for a voter to become a proposer. *DIFFERS from GovernerBravo\n uint256 public proposalThresholdBPS;\n\n /// @notice The basis point number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed. *DIFFERS from GovernerBravo\n uint256 public quorumVotesBPS;\n\n /// @notice The total number of proposals\n uint256 public proposalCount;\n\n /// @notice The address of the Nouns DAO Executor NounsDAOExecutor\n INounsDAOExecutor public timelock;\n\n /// @notice The address of the Nouns tokens\n NounsTokenLike public nouns;\n\n /// @notice The official record of all proposals ever proposed\n mapping(uint256 => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping(address => uint256) public latestProposalIds;\n\n struct Proposal {\n /// @notice Unique id for looking up a proposal\n uint256 id;\n /// @notice Creator of the proposal\n address proposer;\n /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo\n uint256 proposalThreshold;\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed at the time of proposal creation. *DIFFERS from GovernerBravo\n uint256 quorumVotes;\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint256 eta;\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint256[] values;\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint256 startBlock;\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint256 endBlock;\n /// @notice Current number of votes in favor of this proposal\n uint256 forVotes;\n /// @notice Current number of votes in opposition to this proposal\n uint256 againstVotes;\n /// @notice Current number of votes for abstaining for this proposal\n uint256 abstainVotes;\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n /// @notice Flag marking whether the proposal has been vetoed\n bool vetoed;\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n /// @notice Receipts of ballots for the entire set of voters\n mapping(address => Receipt) receipts;\n }\n\n /// @notice Ballot receipt record for a voter\n struct Receipt {\n /// @notice Whether or not a vote has been cast\n bool hasVoted;\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n /// @notice The number of votes the voter had, which were cast\n uint96 votes;\n }\n\n /// @notice Possible states that a proposal may be in\n enum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed,\n Vetoed\n }\n}\n\ninterface INounsDAOExecutor {\n function delay() external view returns (uint256);\n\n function GRACE_PERIOD() external view returns (uint256);\n\n function acceptAdmin() external;\n\n function queuedTransactions(bytes32 hash) external view returns (bool);\n\n function queueTransaction(\n address target,\n uint256 value,\n string calldata signature,\n bytes calldata data,\n uint256 eta\n ) external returns (bytes32);\n\n function cancelTransaction(\n address target,\n uint256 value,\n string calldata signature,\n bytes calldata data,\n uint256 eta\n ) external;\n\n function executeTransaction(\n address target,\n uint256 value,\n string calldata signature,\n bytes calldata data,\n uint256 eta\n ) external payable returns (bytes memory);\n}\n\ninterface NounsTokenLike {\n function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96);\n\n function totalSupply() external view returns (uint96);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 10000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}