{ "language": "Solidity", "sources": { "contracts/upkeeps/GovernorBravoAutomator.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.10;\nimport \"../interfaces/KeeperCompatibleInterface.sol\";\nimport \"../vendor/GovernorBravoDelegate.sol\";\n\n/// @title Chainlink Automation Compatible GovernorBravoDelegate Automator\ncontract GovernorBravoAutomator is KeeperCompatibleInterface {\n /// @notice Possible actions that can be taken in the performUpkeep function.\n /// QUEUE => calls 'queue(id)' on the governance contract\n /// EXECUTE => calls 'execute(id)' on the governance contract\n /// CANCEL => calls 'cancel(id)' on the governance contract\n /// UPDATE_INDEX => updates the starting proposal index within the\n /// upkeep contract to reduce the amount of proposals\n /// the need to be checked\n enum Action {\n QUEUE,\n EXECUTE,\n CANCEL,\n UPDATE_INDEX\n }\n\n GovernorBravoDelegate public immutable s_governanceContract;\n IGovernorBravoToken public immutable s_governanceTokenContract;\n uint256 public s_proposalStartingIndex;\n Action public action;\n\n constructor(\n GovernorBravoDelegate _governanceContract,\n uint256 _proposalStartingIndex,\n IGovernorBravoToken _tokenContract\n ) {\n s_governanceContract = _governanceContract;\n s_proposalStartingIndex = (_proposalStartingIndex > 0) ? _proposalStartingIndex : 1; // proposals start at 1.\n s_governanceTokenContract = _tokenContract;\n }\n\n ///@notice Simulated at each block by the Chainlink Automation network. Checks if there are any actions (queue() or execute()) required on a governance contract. Also tracks a 'starting index'.\n ///@return upkeepNeeded return true if performUpkeep should be called\n ///@return performData bytes encoded: (governance action required, index of proposal)\n function checkUpkeep(\n bytes calldata /* checkData */\n ) external view override returns (bool upkeepNeeded, bytes memory performData) {\n //Get number of proposal\n uint256 proposalCount = s_governanceContract.proposalCount();\n\n //Find starting index\n uint256 newStartingIndex = findStartingIndex();\n\n //If new starting index found, update in performUpkeep\n if (newStartingIndex > s_proposalStartingIndex) {\n performData = abi.encode(Action.UPDATE_INDEX, newStartingIndex);\n return (true, performData);\n }\n\n //Go through each proposal and check the current state\n for (uint256 i = newStartingIndex; i <= proposalCount; i++) {\n GovernorBravoDelegateStorageV1.ProposalState state = s_governanceContract.state(i);\n (, address proposer, , , , , , , , ) = s_governanceContract.proposals(i);\n\n if (state == GovernorBravoDelegateStorageV1.ProposalState.Succeeded) {\n //If the state is 'Succeeded' then call 'queue' with the Proposal ID\n performData = abi.encode(Action.QUEUE, i);\n return (true, performData);\n } else if (state == GovernorBravoDelegateStorageV1.ProposalState.Queued) {\n //If the state is 'Queued' then call 'execute' with the Proposal ID\n performData = abi.encode(Action.EXECUTE, i);\n return (true, performData);\n } else if (\n s_governanceTokenContract.getPriorVotes(proposer, sub256(block.number, 1)) <\n s_governanceContract.proposalThreshold()\n ) {\n performData = abi.encode(Action.CANCEL, i);\n return (true, performData);\n }\n }\n\n revert(\"no action needed\");\n }\n\n ///@notice Chainlink Automation will execute when checkUpkeep returns 'true'. Decodes the 'performData' passed in from checkUpkeep and performs an action as needed.\n ///@param performData bytes encoded: (governance action required, index of proposal)\n ///@dev The governance contract has action validation built-in\n function performUpkeep(bytes calldata performData) external override {\n //Decode performData\n (Action performAction, uint256 proposalIndex) = abi.decode(performData, (Action, uint256));\n\n //Check state of proposal at index\n GovernorBravoDelegateStorageV1.ProposalState state = s_governanceContract.state(proposalIndex);\n\n //Revalidate state and action of provided index\n if (performAction == Action.QUEUE && state == GovernorBravoDelegateStorageV1.ProposalState.Succeeded) {\n s_governanceContract.queue(proposalIndex);\n } else if (performAction == Action.EXECUTE && state == GovernorBravoDelegateStorageV1.ProposalState.Queued) {\n s_governanceContract.execute(proposalIndex);\n } else if (performAction == Action.CANCEL && state != GovernorBravoDelegateStorageV1.ProposalState.Executed) {\n s_governanceContract.cancel(proposalIndex);\n } else if (performAction == Action.UPDATE_INDEX) {\n uint256 newStartingIndex = findStartingIndex();\n require(newStartingIndex > s_proposalStartingIndex, \"No update required\");\n s_proposalStartingIndex = newStartingIndex;\n }\n }\n\n ///@notice Goes through each proposal, if any proposal is in a state that needs to be checked OR its the last proposal, will set it as the starting proposal index for future checks\n ///@return index The proposal index to start checking from\n\n function findStartingIndex() public view returns (uint256 index) {\n // Set current starting index\n uint256 pendings_proposalStartIndex = s_proposalStartingIndex;\n // Get current proposal count\n uint256 proposalCount = s_governanceContract.proposalCount();\n\n for (uint256 i = pendings_proposalStartIndex; i <= proposalCount; i++) {\n GovernorBravoDelegateStorageV1.ProposalState state = s_governanceContract.state(i);\n if (\n state == GovernorBravoDelegateStorageV1.ProposalState.Pending ||\n state == GovernorBravoDelegateStorageV1.ProposalState.Active ||\n state == GovernorBravoDelegateStorageV1.ProposalState.Succeeded ||\n state == GovernorBravoDelegateStorageV1.ProposalState.Queued ||\n i == proposalCount\n ) {\n pendings_proposalStartIndex = i;\n break;\n }\n }\n return (pendings_proposalStartIndex);\n }\n\n function sub256(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"subtraction underflow\");\n return a - b;\n }\n}\n\ninterface IGovernorBravoToken {\n function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96);\n}\n" }, "contracts/interfaces/KeeperCompatibleInterface.sol": { "content": "// SPDX-License-Identifier: MIT\n/**\n * @notice This is a deprecated interface. Please use AutomationCompatibleInterface directly.\n */\npragma solidity ^0.8.0;\nimport {AutomationCompatibleInterface as KeeperCompatibleInterface} from \"./AutomationCompatibleInterface.sol\";\n" }, "contracts/vendor/GovernorBravoDelegate.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.10;\n\nimport \"./GovernorBravoInterfaces.sol\";\n\ncontract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {\n\n /// @notice The name of this contract\n string public constant name = \"Compound Governor Bravo\";\n\n /// @notice The minimum setable proposal threshold\n uint public constant MIN_PROPOSAL_THRESHOLD = 1000e18; // 1,000 Comp\n\n /// @notice The maximum setable proposal threshold\n uint public constant MAX_PROPOSAL_THRESHOLD = 100000e18; //100,000 Comp\n\n /// @notice The minimum setable voting period\n uint public constant MIN_VOTING_PERIOD = 5760; // About 24 hours\n\n /// @notice The max setable voting period\n uint public constant MAX_VOTING_PERIOD = 80640; // About 2 weeks\n\n /// @notice The min setable voting delay\n uint public constant MIN_VOTING_DELAY = 1;\n\n /// @notice The max setable voting delay\n uint public constant MAX_VOTING_DELAY = 40320; // About 1 week\n\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\n uint public constant quorumVotes = 400000e18; // 400,000 = 4% of Comp\n\n /// @notice The maximum number of actions that can be included in a proposal\n uint public constant proposalMaxOperations = 10; // 10 actions\n\n /// @notice The EIP-712 typehash for the contract's domain\n bytes32 public constant DOMAIN_TYPEHASH = 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 constructor\n * @param timelock_ The address of the Timelock\n * @param comp_ The address of the COMP token\n * @param votingPeriod_ The initial voting period\n * @param votingDelay_ The initial voting delay\n * @param proposalThreshold_ The initial proposal threshold\n */\n function initialize(address timelock_, address comp_, uint votingPeriod_, uint votingDelay_, uint proposalThreshold_) virtual public {\n require(address(timelock) == address(0), \"GovernorBravo::initialize: can only initialize once\");\n // require(msg.sender == admin, \"GovernorBravo::initialize: admin only\"); -- FOR TESTING PURPOSES\n require(timelock_ != address(0), \"GovernorBravo::initialize: invalid timelock address\");\n require(comp_ != address(0), \"GovernorBravo::initialize: invalid comp address\");\n require(votingPeriod_ >= MIN_VOTING_PERIOD && votingPeriod_ <= MAX_VOTING_PERIOD, \"GovernorBravo::initialize: invalid voting period\");\n require(votingDelay_ >= MIN_VOTING_DELAY && votingDelay_ <= MAX_VOTING_DELAY, \"GovernorBravo::initialize: invalid voting delay\");\n require(proposalThreshold_ >= MIN_PROPOSAL_THRESHOLD && proposalThreshold_ <= MAX_PROPOSAL_THRESHOLD, \"GovernorBravo::initialize: invalid proposal threshold\");\n\n timelock = TimelockInterface(timelock_);\n comp = CompInterface(comp_);\n votingPeriod = votingPeriod_;\n votingDelay = votingDelay_;\n proposalThreshold = proposalThreshold_;\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(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {\n // Reject proposals before initiating as Governor\n // require(initialProposalId != 0, \"GovernorBravo::propose: Governor Bravo not active\"); -- FOR TESTING PURPOSES\n // Allow addresses above proposal threshold and whitelisted addresses to propose\n require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold || isWhitelisted(msg.sender), \"GovernorBravo::propose: proposer votes below proposal threshold\");\n require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, \"GovernorBravo::propose: proposal function information arity mismatch\");\n require(targets.length != 0, \"GovernorBravo::propose: must provide actions\");\n require(targets.length <= proposalMaxOperations, \"GovernorBravo::propose: too many actions\");\n\n uint latestProposalId = latestProposalIds[msg.sender];\n if (latestProposalId != 0) {\n ProposalState proposersLatestProposalState = state(latestProposalId);\n require(proposersLatestProposalState != ProposalState.Active, \"GovernorBravo::propose: one live proposal per proposer, found an already active proposal\");\n require(proposersLatestProposalState != ProposalState.Pending, \"GovernorBravo::propose: one live proposal per proposer, found an already pending proposal\");\n }\n\n uint startBlock = add256(block.number, votingDelay);\n uint endBlock = add256(startBlock, votingPeriod);\n\n proposalCount++;\n uint newProposalID = proposalCount;\n Proposal storage newProposal = proposals[newProposalID];\n // This should never happen but add a check in case.\n require(newProposal.id == 0, \"GovernorBravo::propose: ProposalID collsion\");\n newProposal.id = newProposalID;\n newProposal.proposer = msg.sender;\n newProposal.eta = 0;\n newProposal.targets = targets;\n newProposal.values = values;\n newProposal.signatures = signatures;\n newProposal.calldatas = calldatas;\n newProposal.startBlock = startBlock;\n newProposal.endBlock = endBlock;\n newProposal.forVotes = 0;\n newProposal.againstVotes = 0;\n newProposal.abstainVotes = 0;\n newProposal.canceled = false;\n newProposal.executed = false;\n\n latestProposalIds[newProposal.proposer] = newProposal.id;\n\n emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);\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(uint proposalId) external {\n require(state(proposalId) == ProposalState.Succeeded, \"GovernorBravo::queue: proposal can only be queued if it is succeeded\");\n Proposal storage proposal = proposals[proposalId];\n uint eta = add256(block.timestamp, timelock.delay());\n for (uint i = 0; i < proposal.targets.length; i++) {\n queueOrRevertInternal(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);\n }\n proposal.eta = eta;\n emit ProposalQueued(proposalId, eta);\n }\n\n function queueOrRevertInternal(address target, uint value, string memory signature, bytes memory data, uint eta) internal {\n require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), \"GovernorBravo::queueOrRevertInternal: identical proposal action already queued at eta\");\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(uint proposalId) external payable {\n require(state(proposalId) == ProposalState.Queued, \"GovernorBravo::execute: proposal can only be executed if it is queued\");\n Proposal storage proposal = proposals[proposalId];\n proposal.executed = true;\n for (uint i = 0; i < proposal.targets.length; i++) {\n timelock.executeTransaction{value: proposal.values[i]}(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);\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(uint proposalId) external {\n require(state(proposalId) != ProposalState.Executed, \"GovernorBravo::cancel: cannot cancel executed proposal\");\n\n Proposal storage proposal = proposals[proposalId];\n\n // Proposer can cancel\n if(msg.sender != proposal.proposer) {\n // Whitelisted proposers can't be canceled for falling below proposal threshold\n if(isWhitelisted(proposal.proposer)) {\n require((comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold) && msg.sender == whitelistGuardian, \"GovernorBravo::cancel: whitelisted proposer\");\n }\n else {\n require((comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold), \"GovernorBravo::cancel: proposer above threshold\");\n }\n }\n\n proposal.canceled = true;\n for (uint i = 0; i < proposal.targets.length; i++) {\n timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);\n }\n\n emit ProposalCanceled(proposalId);\n }\n\n /**\n * @notice Gets actions of a proposal\n * @param proposalId the id of the proposal\n * @return targets of the proposal actions\n * @return values of the proposal actions\n * @return signatures of the proposal actions\n * @return calldatas of the proposal actions\n */\n function getActions(uint proposalId) external view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {\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(uint 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(uint proposalId) public view returns (ProposalState) {\n require(proposalCount >= proposalId && proposalId > initialProposalId, \"GovernorBravo::state: invalid proposal id\");\n Proposal storage proposal = proposals[proposalId];\n 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 < 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 >= add256(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(uint 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(uint proposalId, uint8 support, string calldata reason) 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(uint proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s) external {\n bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainIdInternal(), address(this)));\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), \"GovernorBravo::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(address voter, uint proposalId, uint8 support) internal returns (uint96) {\n require(state(proposalId) == ProposalState.Active, \"GovernorBravo::castVoteInternal: voting is closed\");\n require(support <= 2, \"GovernorBravo::castVoteInternal: invalid vote type\");\n Proposal storage proposal = proposals[proposalId];\n Receipt storage receipt = proposal.receipts[voter];\n require(receipt.hasVoted == false, \"GovernorBravo::castVoteInternal: voter already voted\");\n uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);\n\n if (support == 0) {\n proposal.againstVotes = add256(proposal.againstVotes, votes);\n } else if (support == 1) {\n proposal.forVotes = add256(proposal.forVotes, votes);\n } else if (support == 2) {\n proposal.abstainVotes = add256(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 View function which returns if an account is whitelisted\n * @param account Account to check white list status of\n * @return If the account is whitelisted\n */\n function isWhitelisted(address account) public view returns (bool) {\n return (whitelistAccountExpirations[account] > block.timestamp);\n }\n\n /**\n * @notice Admin function for setting the voting delay\n * @param newVotingDelay new voting delay, in blocks\n */\n function _setVotingDelay(uint newVotingDelay) external {\n require(msg.sender == admin, \"GovernorBravo::_setVotingDelay: admin only\");\n require(newVotingDelay >= MIN_VOTING_DELAY && newVotingDelay <= MAX_VOTING_DELAY, \"GovernorBravo::_setVotingDelay: invalid voting delay\");\n uint 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(uint newVotingPeriod) external {\n require(msg.sender == admin, \"GovernorBravo::_setVotingPeriod: admin only\");\n require(newVotingPeriod >= MIN_VOTING_PERIOD && newVotingPeriod <= MAX_VOTING_PERIOD, \"GovernorBravo::_setVotingPeriod: invalid voting period\");\n uint oldVotingPeriod = votingPeriod;\n votingPeriod = newVotingPeriod;\n\n emit VotingPeriodSet(oldVotingPeriod, votingPeriod);\n }\n\n /**\n * @notice Admin function for setting the proposal threshold\n * @dev newProposalThreshold must be greater than the hardcoded min\n * @param newProposalThreshold new proposal threshold\n */\n function _setProposalThreshold(uint newProposalThreshold) external {\n require(msg.sender == admin, \"GovernorBravo::_setProposalThreshold: admin only\");\n require(newProposalThreshold >= MIN_PROPOSAL_THRESHOLD && newProposalThreshold <= MAX_PROPOSAL_THRESHOLD, \"GovernorBravo::_setProposalThreshold: invalid proposal threshold\");\n uint oldProposalThreshold = proposalThreshold;\n proposalThreshold = newProposalThreshold;\n\n emit ProposalThresholdSet(oldProposalThreshold, proposalThreshold);\n }\n\n /**\n * @notice Admin function for setting the whitelist expiration as a timestamp for an account. Whitelist status allows accounts to propose without meeting threshold\n * @param account Account address to set whitelist expiration for\n * @param expiration Expiration for account whitelist status as timestamp (if now < expiration, whitelisted)\n */\n function _setWhitelistAccountExpiration(address account, uint expiration) external {\n require(msg.sender == admin || msg.sender == whitelistGuardian, \"GovernorBravo::_setWhitelistAccountExpiration: admin only\");\n whitelistAccountExpirations[account] = expiration;\n\n emit WhitelistAccountExpirationSet(account, expiration);\n }\n\n /**\n * @notice Admin function for setting the whitelistGuardian. WhitelistGuardian can cancel proposals from whitelisted addresses\n * @param account Account to set whitelistGuardian to (0x0 to remove whitelistGuardian)\n */\n function _setWhitelistGuardian(address account) external {\n require(msg.sender == admin, \"GovernorBravo::_setWhitelistGuardian: admin only\");\n address oldGuardian = whitelistGuardian;\n whitelistGuardian = account;\n\n emit WhitelistGuardianSet(oldGuardian, whitelistGuardian);\n }\n\n /**\n * @notice Initiate the GovernorBravo contract\n * @dev Admin only. Sets initial proposal id which initiates the contract, ensuring a continuous proposal id count\n * @param governorAlpha The address for the Governor to continue the proposal id count from\n */\n function _initiate(address governorAlpha) external {\n require(msg.sender == admin, \"GovernorBravo::_initiate: admin only\");\n require(initialProposalId == 0, \"GovernorBravo::_initiate: can only initiate once\");\n proposalCount = GovernorAlpha(governorAlpha).proposalCount();\n initialProposalId = proposalCount;\n timelock.acceptAdmin();\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, \"GovernorBravo:_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), \"GovernorBravo:_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 function add256(uint256 a, uint256 b) internal pure returns (uint) {\n uint c = a + b;\n require(c >= a, \"addition overflow\");\n return c;\n }\n\n function sub256(uint256 a, uint256 b) internal pure returns (uint) {\n require(b <= a, \"subtraction underflow\");\n return a - b;\n }\n\n function getChainIdInternal() internal view returns (uint) {\n uint chainId;\n assembly { chainId := chainid() }\n return chainId;\n }\n}\n" }, "contracts/interfaces/AutomationCompatibleInterface.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AutomationCompatibleInterface {\n /**\n * @notice method that is simulated by the keepers to see if any work actually\n * needs to be performed. This method does does not actually need to be\n * executable, and since it is only ever simulated it can consume lots of gas.\n * @dev To ensure that it is never called, you may want to add the\n * cannotExecute modifier from KeeperBase to your implementation of this\n * method.\n * @param checkData specified in the upkeep registration so it is always the\n * same for a registered upkeep. This can easily be broken down into specific\n * arguments using `abi.decode`, so multiple upkeeps can be registered on the\n * same contract and easily differentiated by the contract.\n * @return upkeepNeeded boolean to indicate whether the keeper should call\n * performUpkeep or not.\n * @return performData bytes that the keeper should call performUpkeep with, if\n * upkeep is needed. If you would like to encode data to decode later, try\n * `abi.encode`.\n */\n function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);\n\n /**\n * @notice method that is actually executed by the keepers, via the registry.\n * The data returned by the checkUpkeep simulation will be passed into\n * this method to actually be executed.\n * @dev The input to this method should not be trusted, and the caller of the\n * method should not even be restricted to any single registry. Anyone should\n * be able call it, and the input should be validated, there is no guarantee\n * that the data passed in is the performData returned from checkUpkeep. This\n * could happen due to malicious keepers, racing keepers, or simply a state\n * change while the performUpkeep transaction is waiting for confirmation.\n * Always validate the data passed in.\n * @param performData is the data which was passed back from the checkData\n * simulation. If it is encoded, it can easily be decoded into other types by\n * calling `abi.decode`. This data should not be trusted, and should be\n * validated against the contract's current state.\n */\n function performUpkeep(bytes calldata performData) external;\n}\n" }, "contracts/vendor/GovernorBravoInterfaces.sol": { "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.10;\n\n\ncontract GovernorBravoEvents {\n /// @notice An event emitted when a new proposal is created\n event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);\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, uint proposalId, uint8 support, uint votes, string reason);\n\n /// @notice An event emitted when a proposal has been canceled\n event ProposalCanceled(uint id);\n\n /// @notice An event emitted when a proposal has been queued in the Timelock\n event ProposalQueued(uint id, uint eta);\n\n /// @notice An event emitted when a proposal has been executed in the Timelock\n event ProposalExecuted(uint id);\n\n /// @notice An event emitted when the voting delay is set\n event VotingDelaySet(uint oldVotingDelay, uint newVotingDelay);\n\n /// @notice An event emitted when the voting period is set\n event VotingPeriodSet(uint oldVotingPeriod, uint newVotingPeriod);\n\n /// @notice Emitted when implementation is changed\n event NewImplementation(address oldImplementation, address newImplementation);\n\n /// @notice Emitted when proposal threshold is set\n event ProposalThresholdSet(uint oldProposalThreshold, uint newProposalThreshold);\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 whitelist account expiration is set\n event WhitelistAccountExpirationSet(address account, uint expiration);\n\n /// @notice Emitted when the whitelistGuardian is set\n event WhitelistGuardianSet(address oldGuardian, address newGuardian);\n}\n\ncontract GovernorBravoDelegatorStorage {\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/**\n * @title Storage for Governor Bravo Delegate\n * @notice For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new\n * contract which implements GovernorBravoDelegateStorageV1 and following the naming convention\n * GovernorBravoDelegateStorageVX.\n */\ncontract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage {\n\n /// @notice The delay before voting on a proposal may take place, once proposed, in blocks\n uint public votingDelay;\n\n /// @notice The duration of voting on a proposal, in blocks\n uint public votingPeriod;\n\n /// @notice The number of votes required in order for a voter to become a proposer\n uint public proposalThreshold;\n\n /// @notice Initial proposal id set at become\n uint public initialProposalId;\n\n /// @notice The total number of proposals\n uint public proposalCount;\n\n /// @notice The address of the Compound Protocol Timelock\n TimelockInterface public timelock;\n\n /// @notice The address of the Compound governance token\n CompInterface public comp;\n\n /// @notice The official record of all proposals ever proposed\n mapping (uint => Proposal) public proposals;\n\n /// @notice The latest proposal for each proposer\n mapping (address => uint) public latestProposalIds;\n\n\n struct Proposal {\n /// @notice Unique id for looking up a proposal\n uint id;\n\n /// @notice Creator of the proposal\n address proposer;\n\n /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds\n uint eta;\n\n /// @notice the ordered list of target addresses for calls to be made\n address[] targets;\n\n /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made\n uint[] values;\n\n /// @notice The ordered list of function signatures to be called\n string[] signatures;\n\n /// @notice The ordered list of calldata to be passed to each call\n bytes[] calldatas;\n\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\n uint startBlock;\n\n /// @notice The block at which voting ends: votes must be cast prior to this block\n uint endBlock;\n\n /// @notice Current number of votes in favor of this proposal\n uint forVotes;\n\n /// @notice Current number of votes in opposition to this proposal\n uint againstVotes;\n\n /// @notice Current number of votes for abstaining for this proposal\n uint abstainVotes;\n\n /// @notice Flag marking whether the proposal has been canceled\n bool canceled;\n\n /// @notice Flag marking whether the proposal has been executed\n bool executed;\n\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\n /// @notice Whether or not the voter supports the proposal or abstains\n uint8 support;\n\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 }\n}\n\ncontract GovernorBravoDelegateStorageV2 is GovernorBravoDelegateStorageV1 {\n /// @notice Stores the expiration of account whitelist status as a timestamp\n mapping (address => uint) public whitelistAccountExpirations;\n\n /// @notice Address which manages whitelisted proposals and whitelist accounts\n address public whitelistGuardian;\n}\n\ninterface TimelockInterface {\n function delay() external view returns (uint);\n function GRACE_PERIOD() external view returns (uint);\n function acceptAdmin() external;\n function queuedTransactions(bytes32 hash) external view returns (bool);\n function queueTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external returns (bytes32);\n function cancelTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external;\n function executeTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external payable returns (bytes memory);\n}\n\ninterface CompInterface {\n function getPriorVotes(address account, uint blockNumber) external view returns (uint96);\n}\n\ninterface GovernorAlpha {\n /// @notice The total number of proposals\n function proposalCount() external returns (uint);\n}\n" } }, "settings": { "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "bytecodeHash": "none" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} } }