Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
NounsDAOLogicV3
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BSD-3-Clause /// @title The Nouns DAO logic version 3 /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ // LICENSE // NounsDAOLogicV2.sol is a modified version of Compound Lab's GovernorBravoDelegate.sol: // https://github.com/compound-finance/compound-protocol/blob/b9b14038612d846b83f8a009a82c38974ff2dcfe/contracts/Governance/GovernorBravoDelegate.sol // // GovernorBravoDelegate.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // MODIFICATIONS // See NounsDAOLogicV1 for initial GovernorBravoDelegate modifications. // See NounsDAOLogicV2 for additional modifications // // NounsDAOLogicV3 adds: // - Contract has been broken down to use libraries because of contract size limitations // - Proposal editing: allowing proposers to update their proposal’s transactions and text description, // during the Updatable period only, which is the state upon proposal creation. Editing also works with signatures, // assuming the proposer is able to accumulate signatures from the same signers. // - Propose by signature: allowing Nouners and delegates to pool their voting power towards submitting a proposal, // by submitting their signature, instead of the current approach where sponsors must delegate their votes to help // a proposer achieve threshold. // - Objection-only Period: a conditional voting period that gets activated upon a last-minute proposal swing // from defeated to successful, affording against voters more reaction time. // Only against votes are possible during the objection period. // - Votes snapshot after voting delay: moving votes snapshot up, to provide Nouners with reaction time per proposal, // to get their votes ready (e.g. some might want to move their delegations around). // In NounsDAOLogicV2 the vote snapshot block is the proposal creation block. // - Nouns fork: any token holder can signal to fork (exit) in response to a governance proposal. // If a quorum of a configured threshold amount of tokens signals to exit, the fork will succeed. // This will deploy a new DAO and send part of the treasury to the new DAO. // // 2 new states have been added to the proposal state machine: Updatable, ObjectionPeriod // // Updated state machine: // Updatable -> Pending -> Active -> ObjectionPeriod (conditional) -> Succeeded -> Queued -> Executed // ┖> Defeated // pragma solidity ^0.8.19; import './NounsDAOInterfaces.sol'; import { NounsDAOV3Admin } from './NounsDAOV3Admin.sol'; import { NounsDAOV3DynamicQuorum } from './NounsDAOV3DynamicQuorum.sol'; import { NounsDAOV3Votes } from './NounsDAOV3Votes.sol'; import { NounsDAOV3Proposals } from './NounsDAOV3Proposals.sol'; import { NounsDAOV3Fork } from './fork/NounsDAOV3Fork.sol'; contract NounsDAOLogicV3 is NounsDAOStorageV3, NounsDAOEventsV3 { using NounsDAOV3Admin for StorageV3; using NounsDAOV3DynamicQuorum for StorageV3; using NounsDAOV3Votes for StorageV3; using NounsDAOV3Proposals for StorageV3; using NounsDAOV3Fork for StorageV3; /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * CONSTANTS * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /// @notice The minimum setable proposal threshold function MIN_PROPOSAL_THRESHOLD_BPS() public pure returns (uint256) { return NounsDAOV3Admin.MIN_PROPOSAL_THRESHOLD_BPS; } /// @notice The maximum setable proposal threshold function MAX_PROPOSAL_THRESHOLD_BPS() public pure returns (uint256) { return NounsDAOV3Admin.MAX_PROPOSAL_THRESHOLD_BPS; } /// @notice The minimum setable voting period in blocks function MIN_VOTING_PERIOD() public pure returns (uint256) { return NounsDAOV3Admin.MIN_VOTING_PERIOD_BLOCKS; } /// @notice The max setable voting period in blocks function MAX_VOTING_PERIOD() public pure returns (uint256) { return NounsDAOV3Admin.MAX_VOTING_PERIOD_BLOCKS; } /// @notice The min setable voting delay in blocks function MIN_VOTING_DELAY() public pure returns (uint256) { return NounsDAOV3Admin.MIN_VOTING_DELAY_BLOCKS; } /// @notice The max setable voting delay in blocks function MAX_VOTING_DELAY() public pure returns (uint256) { return NounsDAOV3Admin.MAX_VOTING_DELAY_BLOCKS; } /// @notice The maximum number of actions that can be included in a proposal function proposalMaxOperations() public pure returns (uint256) { return NounsDAOV3Proposals.PROPOSAL_MAX_OPERATIONS; } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * ERRORS * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ error AdminOnly(); error CanOnlyInitializeOnce(); error InvalidTimelockAddress(); error InvalidNounsAddress(); /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * INITIALIZER * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Used to initialize the contract during delegator contructor * @dev This will only be called for a newly deployed DAO, not as part of an upgrade from V2 to V3 * @param timelock_ The address of the NounsDAOExecutor * @param nouns_ The address of the NOUN tokens * @param forkEscrow_ The escrow contract used for creating forks * @param forkDAODeployer_ The contract used to deploy new forked DAOs * @param vetoer_ The address allowed to unilaterally veto proposals * @param daoParams_ Initial DAO parameters * @param dynamicQuorumParams_ The initial dynamic quorum parameters */ function initialize( address timelock_, address nouns_, address forkEscrow_, address forkDAODeployer_, address vetoer_, NounsDAOParams calldata daoParams_, DynamicQuorumParams calldata dynamicQuorumParams_ ) public virtual { if (address(ds.timelock) != address(0)) revert CanOnlyInitializeOnce(); if (msg.sender != ds.admin) revert AdminOnly(); if (timelock_ == address(0)) revert InvalidTimelockAddress(); if (nouns_ == address(0)) revert InvalidNounsAddress(); ds._setVotingPeriod(daoParams_.votingPeriod); ds._setVotingDelay(daoParams_.votingDelay); ds._setProposalThresholdBPS(daoParams_.proposalThresholdBPS); ds.timelock = INounsDAOExecutorV2(timelock_); ds.nouns = NounsTokenLike(nouns_); ds.forkEscrow = INounsDAOForkEscrow(forkEscrow_); ds.forkDAODeployer = IForkDAODeployer(forkDAODeployer_); ds.vetoer = vetoer_; _setDynamicQuorumParams( dynamicQuorumParams_.minQuorumVotesBPS, dynamicQuorumParams_.maxQuorumVotesBPS, dynamicQuorumParams_.quorumCoefficient ); ds._setLastMinuteWindowInBlocks(daoParams_.lastMinuteWindowInBlocks); ds._setObjectionPeriodDurationInBlocks(daoParams_.objectionPeriodDurationInBlocks); ds._setProposalUpdatablePeriodInBlocks(daoParams_.proposalUpdatablePeriodInBlocks); } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * PROPOSALS * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold * @param targets Target addresses for proposal calls * @param values Eth values for proposal calls * @param signatures Function signatures for proposal calls * @param calldatas Calldatas for proposal calls * @param description String description of the proposal * @return uint256 Proposal id of new proposal */ function propose( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) { return ds.propose(NounsDAOV3Proposals.ProposalTxs(targets, values, signatures, calldatas), description); } /** * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold. * This proposal would be executed via the timelockV1 contract. This is meant to be used in case timelockV1 * is still holding funds or has special permissions to execute on certain contracts. * @param targets Target addresses for proposal calls * @param values Eth values for proposal calls * @param signatures Function signatures for proposal calls * @param calldatas Calldatas for proposal calls * @param description String description of the proposal * @return uint256 Proposal id of new proposal */ function proposeOnTimelockV1( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) public returns (uint256) { return ds.proposeOnTimelockV1( NounsDAOV3Proposals.ProposalTxs(targets, values, signatures, calldatas), description ); } /** * @notice Function used to propose a new proposal. Sender and signers must have delegates above the proposal threshold * Signers are regarded as co-proposers, and therefore have the ability to cancel the proposal at any time. * @param proposerSignatures Array of signers who have signed the proposal and their signatures. * @dev The signatures follow EIP-712. See `PROPOSAL_TYPEHASH` in NounsDAOV3Proposals.sol * @param targets Target addresses for proposal calls * @param values Eth values for proposal calls * @param signatures Function signatures for proposal calls * @param calldatas Calldatas for proposal calls * @param description String description of the proposal * @return uint256 Proposal id of new proposal */ function proposeBySigs( ProposerSignature[] memory proposerSignatures, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description ) external returns (uint256) { return ds.proposeBySigs( proposerSignatures, NounsDAOV3Proposals.ProposalTxs(targets, values, signatures, calldatas), description ); } /** * @notice Invalidates a signature that may be used for signing a new proposal. * Once a signature is canceled, the sender can no longer use it again. * If the sender changes their mind and want to sign the proposal, they can change the expiry timestamp * in order to produce a new signature. * The signature will only be invalidated when used by the sender. If used by a different account, it will * not be invalidated. * Cancelling a signature for an existing proposal will have no effect. Signers have the ability to cancel * a proposal they signed if necessary. * @param sig The signature to cancel */ function cancelSig(bytes calldata sig) external { ds.cancelSig(sig); } /** * @notice Update a proposal transactions and description. * Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param targets Updated target addresses for proposal calls * @param values Updated eth values for proposal calls * @param signatures Updated function signatures for proposal calls * @param calldatas Updated calldatas for proposal calls * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposal( uint256 proposalId, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description, string memory updateMessage ) external { ds.updateProposal(proposalId, targets, values, signatures, calldatas, description, updateMessage); } /** * @notice Updates the proposal's description. Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposalDescription( uint256 proposalId, string calldata description, string calldata updateMessage ) external { ds.updateProposalDescription(proposalId, description, updateMessage); } /** * @notice Updates the proposal's transactions. Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param targets Updated target addresses for proposal calls * @param values Updated eth values for proposal calls * @param signatures Updated function signatures for proposal calls * @param calldatas Updated calldatas for proposal calls * @param updateMessage Short message to explain the update */ function updateProposalTransactions( uint256 proposalId, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory updateMessage ) external { ds.updateProposalTransactions(proposalId, targets, values, signatures, calldatas, updateMessage); } /** * @notice Update a proposal's transactions and description that was created with proposeBySigs. * Only the proposer can update it, during the updateable period. * Requires the original signers to sign the update. * @param proposalId Proposal's id * @param proposerSignatures Array of signers who have signed the proposal and their signatures. * @dev The signatures follow EIP-712. See `UPDATE_PROPOSAL_TYPEHASH` in NounsDAOV3Proposals.sol * @param targets Updated target addresses for proposal calls * @param values Updated eth values for proposal calls * @param signatures Updated function signatures for proposal calls * @param calldatas Updated calldatas for proposal calls * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposalBySigs( uint256 proposalId, ProposerSignature[] memory proposerSignatures, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description, string memory updateMessage ) external { ds.updateProposalBySigs( proposalId, proposerSignatures, NounsDAOV3Proposals.ProposalTxs(targets, values, signatures, calldatas), description, updateMessage ); } /** * @notice Queues a proposal of state succeeded * @param proposalId The id of the proposal to queue */ function queue(uint256 proposalId) external { ds.queue(proposalId); } /** * @notice Executes a queued proposal if eta has passed * @param proposalId The id of the proposal to execute */ function execute(uint256 proposalId) external { ds.execute(proposalId); } /** * @notice Executes a queued proposal on timelockV1 if eta has passed * This is only required for proposal that were queued on timelockV1, but before the upgrade to DAO V3. * These proposals will not have the `executeOnTimelockV1` bool turned on. */ function executeOnTimelockV1(uint256 proposalId) external { ds.executeOnTimelockV1(proposalId); } /** * @notice Cancels a proposal only if sender is the proposer or a signer, or proposer & signers voting power * dropped below proposal threshold * @param proposalId The id of the proposal to cancel */ function cancel(uint256 proposalId) external { ds.cancel(proposalId); } /** * @notice Gets the state of a proposal * @param proposalId The id of the proposal * @return Proposal state */ function state(uint256 proposalId) public view returns (ProposalState) { return ds.state(proposalId); } /** * @notice Gets actions of a proposal * @param proposalId the id of the proposal * @return targets * @return values * @return signatures * @return calldatas */ function getActions(uint256 proposalId) external view returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas ) { return ds.getActions(proposalId); } /** * @notice Gets the receipt for a voter on a given proposal * @param proposalId the id of proposal * @param voter The address of the voter * @return The voting receipt */ function getReceipt(uint256 proposalId, address voter) external view returns (Receipt memory) { return ds.getReceipt(proposalId, voter); } /** * @notice Returns the proposal details given a proposal id. * The `quorumVotes` member holds the *current* quorum, given the current votes. * @param proposalId the proposal id to get the data for * @return A `ProposalCondensed` struct with the proposal data, backwards compatible with V1 and V2 */ function proposals(uint256 proposalId) external view returns (NounsDAOStorageV2.ProposalCondensed memory) { return ds.proposals(proposalId); } /** * @notice Returns the proposal details given a proposal id. * The `quorumVotes` member holds the *current* quorum, given the current votes. * @param proposalId the proposal id to get the data for * @return A `ProposalCondensed` struct with the proposal data, not backwards compatible as it contains additional values * like `objectionPeriodEndBlock` and `signers` */ function proposalsV3(uint256 proposalId) external view returns (ProposalCondensed memory) { return ds.proposalsV3(proposalId); } /** * @notice Current proposal threshold using Noun Total Supply * Differs from `GovernerBravo` which uses fixed amount */ function proposalThreshold() public view returns (uint256) { return ds.proposalThreshold(ds.adjustedTotalSupply()); } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * DAO FORK * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Escrow Nouns to contribute to the fork threshold * @dev Requires approving the tokenIds or the entire noun token to the DAO contract * @param tokenIds the tokenIds to escrow. They will be sent to the DAO once the fork threshold is reached and the escrow is closed. * @param proposalIds array of proposal ids which are the reason for wanting to fork. This will only be used to emit event. * @param reason the reason for want to fork. This will only be used to emit event. */ function escrowToFork( uint256[] calldata tokenIds, uint256[] calldata proposalIds, string calldata reason ) external { ds.escrowToFork(tokenIds, proposalIds, reason); } /** * @notice Withdraw Nouns from the fork escrow. Only possible if the fork has not been executed. * Only allowed to withdraw tokens that the sender has escrowed. * @param tokenIds the tokenIds to withdraw */ function withdrawFromForkEscrow(uint256[] calldata tokenIds) external { ds.withdrawFromForkEscrow(tokenIds); } /** * @notice Execute the fork. Only possible if the fork threshold has been met. * This will deploy a new DAO and send part of the treasury to the new DAO's treasury. * This will also close the active escrow and all nouns in the escrow belong to the original DAO. * @return forkTreasury The address of the new DAO's treasury * @return forkToken The address of the new DAO's token */ function executeFork() external returns (address forkTreasury, address forkToken) { return ds.executeFork(); } /** * @notice Joins a fork while a fork is active * @param tokenIds the tokenIds to send to the DAO in exchange for joining the fork * @param proposalIds array of proposal ids which are the reason for wanting to fork. This will only be used to emit event. * @param reason the reason for want to fork. This will only be used to emit event. */ function joinFork( uint256[] calldata tokenIds, uint256[] calldata proposalIds, string calldata reason ) external { ds.joinFork(tokenIds, proposalIds, reason); } /** * @notice Withdraws nouns from the fork escrow to the treasury after the fork has been executed * @dev Only the DAO can call this function * @param tokenIds the tokenIds to withdraw */ function withdrawDAONounsFromEscrowToTreasury(uint256[] calldata tokenIds) external { ds.withdrawDAONounsFromEscrowToTreasury(tokenIds); } /** * @notice Withdraws nouns from the fork escrow after the fork has been executed to an address other than the treasury * @dev Only the DAO can call this function * @param tokenIds the tokenIds to withdraw * @param to the address to send the nouns to */ function withdrawDAONounsFromEscrowIncreasingTotalSupply(uint256[] calldata tokenIds, address to) external { ds.withdrawDAONounsFromEscrowIncreasingTotalSupply(tokenIds, to); } /** * @notice Returns the number of nouns in supply minus nouns owned by the DAO, i.e. held in the treasury or in an * escrow after it has closed. * This is used when calculating proposal threshold, quorum, fork threshold & treasury split. */ function adjustedTotalSupply() external view returns (uint256) { return ds.adjustedTotalSupply(); } /** * @notice returns the required number of tokens to escrow to trigger a fork */ function forkThreshold() external view returns (uint256) { return ds.forkThreshold(); } /** * @notice Returns the number of tokens currently in escrow, contributing to the fork threshold */ function numTokensInForkEscrow() external view returns (uint256) { return ds.numTokensInForkEscrow(); } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * VOTES * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Vetoes a proposal only if sender is the vetoer and the proposal has not been executed. * @param proposalId The id of the proposal to veto */ function veto(uint256 proposalId) external { ds.veto(proposalId); } /** * @notice Cast a vote for a proposal * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain */ function castVote(uint256 proposalId, uint8 support) external { ds.castVote(proposalId, support); } /** * @notice Cast a vote for a proposal, asking the DAO to refund gas costs. * Users with > 0 votes receive refunds. Refunds are partial when using a gas priority fee higher than the DAO's cap. * Refunds are partial when the DAO's balance is insufficient. * No refund is sent when the DAO's balance is empty. No refund is sent to users with no votes. * Voting takes place regardless of refund success. * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @dev Reentrancy is defended against in `castVoteInternal` at the `receipt.hasVoted == false` require statement. */ function castRefundableVote(uint256 proposalId, uint8 support) external { ds.castRefundableVote(proposalId, support); } /** * @notice Cast a vote for a proposal, asking the DAO to refund gas costs. * Users with > 0 votes receive refunds. Refunds are partial when using a gas priority fee higher than the DAO's cap. * Refunds are partial when the DAO's balance is insufficient. * No refund is sent when the DAO's balance is empty. No refund is sent to users with no votes. * Voting takes place regardless of refund success. * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @param reason The reason given for the vote by the voter * @dev Reentrancy is defended against in `castVoteInternal` at the `receipt.hasVoted == false` require statement. */ function castRefundableVoteWithReason( uint256 proposalId, uint8 support, string calldata reason ) external { ds.castRefundableVoteWithReason(proposalId, support, reason); } /** * @notice Cast a vote for a proposal with a reason * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @param reason The reason given for the vote by the voter */ function castVoteWithReason( uint256 proposalId, uint8 support, string calldata reason ) external { ds.castVoteWithReason(proposalId, support, reason); } /** * @notice Cast a vote for a proposal by signature * @dev External function that accepts EIP-712 signatures for voting on proposals. */ function castVoteBySig( uint256 proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s ) external { ds.castVoteBySig(proposalId, support, v, r, s); } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * ADMIN * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Admin function for setting the voting delay. Best to set voting delay to at least a few days, to give * voters time to make sense of proposals, e.g. 21,600 blocks which should be at least 3 days. * @param newVotingDelay new voting delay, in blocks */ function _setVotingDelay(uint256 newVotingDelay) external { ds._setVotingDelay(newVotingDelay); } /** * @notice Admin function for setting the voting period * @param newVotingPeriod new voting period, in blocks */ function _setVotingPeriod(uint256 newVotingPeriod) external { ds._setVotingPeriod(newVotingPeriod); } /** * @notice Admin function for setting the proposal threshold basis points * @dev newProposalThresholdBPS must be in [`MIN_PROPOSAL_THRESHOLD_BPS`,`MAX_PROPOSAL_THRESHOLD_BPS`] * @param newProposalThresholdBPS new proposal threshold */ function _setProposalThresholdBPS(uint256 newProposalThresholdBPS) external { ds._setProposalThresholdBPS(newProposalThresholdBPS); } /** * @notice Admin function for setting the objection period duration * @param newObjectionPeriodDurationInBlocks new objection period duration, in blocks */ function _setObjectionPeriodDurationInBlocks(uint32 newObjectionPeriodDurationInBlocks) external { ds._setObjectionPeriodDurationInBlocks(newObjectionPeriodDurationInBlocks); } /** * @notice Admin function for setting the objection period last minute window * @param newLastMinuteWindowInBlocks new objection period last minute window, in blocks */ function _setLastMinuteWindowInBlocks(uint32 newLastMinuteWindowInBlocks) external { ds._setLastMinuteWindowInBlocks(newLastMinuteWindowInBlocks); } /** * @notice Admin function for setting the proposal updatable period * @param newProposalUpdatablePeriodInBlocks the new proposal updatable period, in blocks */ function _setProposalUpdatablePeriodInBlocks(uint32 newProposalUpdatablePeriodInBlocks) external { ds._setProposalUpdatablePeriodInBlocks(newProposalUpdatablePeriodInBlocks); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. */ function _setPendingAdmin(address newPendingAdmin) external { ds._setPendingAdmin(newPendingAdmin); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin */ function _acceptAdmin() external { ds._acceptAdmin(); } /** * @notice Begins transition of vetoer. The newPendingVetoer must call _acceptVetoer to finalize the transfer. * @param newPendingVetoer New Pending Vetoer */ function _setPendingVetoer(address newPendingVetoer) public { ds._setPendingVetoer(newPendingVetoer); } /** * @notice Called by the pendingVetoer to accept role and update vetoer */ function _acceptVetoer() external { ds._acceptVetoer(); } /** * @notice Burns veto priviledges * @dev Vetoer function destroying veto power forever */ function _burnVetoPower() public { ds._burnVetoPower(); } /** * @notice Admin function for setting the minimum quorum votes bps * @param newMinQuorumVotesBPS minimum quorum votes bps * Must be between `MIN_QUORUM_VOTES_BPS_LOWER_BOUND` and `MIN_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be lower than or equal to maxQuorumVotesBPS */ function _setMinQuorumVotesBPS(uint16 newMinQuorumVotesBPS) external { ds._setMinQuorumVotesBPS(newMinQuorumVotesBPS); } /** * @notice Admin function for setting the maximum quorum votes bps * @param newMaxQuorumVotesBPS maximum quorum votes bps * Must be lower than `MAX_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be higher than or equal to minQuorumVotesBPS */ function _setMaxQuorumVotesBPS(uint16 newMaxQuorumVotesBPS) external { ds._setMaxQuorumVotesBPS(newMaxQuorumVotesBPS); } /** * @notice Admin function for setting the dynamic quorum coefficient * @param newQuorumCoefficient the new coefficient, as a fixed point integer with 6 decimals */ function _setQuorumCoefficient(uint32 newQuorumCoefficient) external { ds._setQuorumCoefficient(newQuorumCoefficient); } /** * @notice Admin function for setting all the dynamic quorum parameters * @param newMinQuorumVotesBPS minimum quorum votes bps * Must be between `MIN_QUORUM_VOTES_BPS_LOWER_BOUND` and `MIN_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be lower than or equal to maxQuorumVotesBPS * @param newMaxQuorumVotesBPS maximum quorum votes bps * Must be lower than `MAX_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be higher than or equal to minQuorumVotesBPS * @param newQuorumCoefficient the new coefficient, as a fixed point integer with 6 decimals */ function _setDynamicQuorumParams( uint16 newMinQuorumVotesBPS, uint16 newMaxQuorumVotesBPS, uint32 newQuorumCoefficient ) public { ds._setDynamicQuorumParams(newMinQuorumVotesBPS, newMaxQuorumVotesBPS, newQuorumCoefficient); } /** * @notice Withdraws all the ETH in the contract. This is callable only by the admin (timelock). */ function _withdraw() external returns (uint256, bool) { return ds._withdraw(); } /** * @notice Admin function for setting the fork period * @param newForkPeriod the new fork proposal period, in seconds */ function _setForkPeriod(uint256 newForkPeriod) external { ds._setForkPeriod(newForkPeriod); } /** * @notice Admin function for setting the fork threshold * @param newForkThresholdBPS the new fork proposal threshold, in basis points */ function _setForkThresholdBPS(uint256 newForkThresholdBPS) external { ds._setForkThresholdBPS(newForkThresholdBPS); } /** * @notice Admin function for setting the proposal id at which vote snapshots start using the voting start block * instead of the proposal creation block. * Sets it to the next proposal id. */ function _setVoteSnapshotBlockSwitchProposalId() external { ds._setVoteSnapshotBlockSwitchProposalId(); } /** * @notice Admin function for setting the fork DAO deployer contract */ function _setForkDAODeployer(address newForkDAODeployer) external { ds._setForkDAODeployer(newForkDAODeployer); } /** * @notice Admin function for setting the ERC20 tokens that are used when splitting funds to a fork */ function _setErc20TokensToIncludeInFork(address[] calldata erc20tokens) external { ds._setErc20TokensToIncludeInFork(erc20tokens); } /** * @notice Admin function for setting the fork escrow contract */ function _setForkEscrow(address newForkEscrow) external { ds._setForkEscrow(newForkEscrow); } /** * @notice Admin function for setting the fork related parameters * @param forkEscrow_ the fork escrow contract * @param forkDAODeployer_ the fork dao deployer contract * @param erc20TokensToIncludeInFork_ the ERC20 tokens used when splitting funds to a fork * @param forkPeriod_ the period during which it's possible to join a fork after exeuction * @param forkThresholdBPS_ the threshold required of escrowed nouns in order to execute a fork */ function _setForkParams( address forkEscrow_, address forkDAODeployer_, address[] calldata erc20TokensToIncludeInFork_, uint256 forkPeriod_, uint256 forkThresholdBPS_ ) external { ds._setForkEscrow(forkEscrow_); ds._setForkDAODeployer(forkDAODeployer_); ds._setErc20TokensToIncludeInFork(erc20TokensToIncludeInFork_); ds._setForkPeriod(forkPeriod_); ds._setForkThresholdBPS(forkThresholdBPS_); } /** * @notice Admin function for setting the timelocks and admin * @param newTimelock the new timelock contract * @param newTimelockV1 the new timelockV1 contract * @param newAdmin the new admin address */ function _setTimelocksAndAdmin( address newTimelock, address newTimelockV1, address newAdmin ) external { ds._setTimelocksAndAdmin(newTimelock, newTimelockV1, newAdmin); } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * DYNAMIC QUORUM * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ /** * @notice Quorum votes required for a specific proposal to succeed * Differs from `GovernerBravo` which uses fixed amount */ function quorumVotes(uint256 proposalId) public view returns (uint256) { return ds.quorumVotes(proposalId); } /** * @notice Calculates the required quorum of for-votes based on the amount of against-votes * The more against-votes there are for a proposal, the higher the required quorum is. * The quorum BPS is between `params.minQuorumVotesBPS` and params.maxQuorumVotesBPS. * The additional quorum is calculated as: * quorumCoefficient * againstVotesBPS * @dev Note the coefficient is a fixed point integer with 6 decimals * @param againstVotes Number of against-votes in the proposal * @param adjustedTotalSupply_ The adjusted total supply of Nouns at the time of proposal creation * @param params Configurable parameters for calculating the quorum based on againstVotes. See `DynamicQuorumParams` definition for additional details. * @return quorumVotes The required quorum */ function dynamicQuorumVotes( uint256 againstVotes, uint256 adjustedTotalSupply_, DynamicQuorumParams memory params ) public pure returns (uint256) { return NounsDAOV3DynamicQuorum.dynamicQuorumVotes(againstVotes, adjustedTotalSupply_, params); } /** * @notice returns the dynamic quorum parameters values at a certain block number * @dev The checkpoints array must not be empty, and the block number must be higher than or equal to * the block of the first checkpoint * @param blockNumber_ the block number to get the params at * @return The dynamic quorum parameters that were set at the given block number */ function getDynamicQuorumParamsAt(uint256 blockNumber_) public view returns (DynamicQuorumParams memory) { return ds.getDynamicQuorumParamsAt(blockNumber_); } /** * @notice Current min quorum votes using Nouns adjusted total supply */ function minQuorumVotes() public view returns (uint256) { return ds.minQuorumVotes(ds.adjustedTotalSupply()); } /** * @notice Current max quorum votes using Nouns adjusted total supply */ function maxQuorumVotes() public view returns (uint256) { return ds.maxQuorumVotes(ds.adjustedTotalSupply()); } /** * @notice Get all quorum params checkpoints */ function quorumParamsCheckpoints() public view returns (DynamicQuorumParamsCheckpoint[] memory) { return ds.quorumParamsCheckpoints; } /** * @notice Get a quorum params checkpoint by its index */ function quorumParamsCheckpoints(uint256 index) public view returns (DynamicQuorumParamsCheckpoint memory) { return ds.quorumParamsCheckpoints[index]; } /** * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * STATE VARIABLE GETTERS * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ function vetoer() public view returns (address) { return ds.vetoer; } function pendingVetoer() public view returns (address) { return ds.pendingVetoer; } function votingDelay() public view returns (uint256) { return ds.votingDelay; } function votingPeriod() public view returns (uint256) { return ds.votingPeriod; } function proposalThresholdBPS() public view returns (uint256) { return ds.proposalThresholdBPS; } function quorumVotesBPS() public view returns (uint256) { return ds.quorumVotesBPS; } function proposalCount() public view returns (uint256) { return ds.proposalCount; } function timelock() public view returns (INounsDAOExecutor) { return ds.timelock; } function nouns() public view returns (NounsTokenLike) { return ds.nouns; } function latestProposalIds(address account) public view returns (uint256) { return ds.latestProposalIds[account]; } function lastMinuteWindowInBlocks() public view returns (uint256) { return ds.lastMinuteWindowInBlocks; } function objectionPeriodDurationInBlocks() public view returns (uint256) { return ds.objectionPeriodDurationInBlocks; } function erc20TokensToIncludeInFork() public view returns (address[] memory) { return ds.erc20TokensToIncludeInFork; } function forkEscrow() public view returns (INounsDAOForkEscrow) { return ds.forkEscrow; } function forkDAODeployer() public view returns (IForkDAODeployer) { return ds.forkDAODeployer; } function forkEndTimestamp() public view returns (uint256) { return ds.forkEndTimestamp; } function forkPeriod() public view returns (uint256) { return ds.forkPeriod; } function forkThresholdBPS() public view returns (uint256) { return ds.forkThresholdBPS; } function proposalUpdatablePeriodInBlocks() public view returns (uint256) { return ds.proposalUpdatablePeriodInBlocks; } function timelockV1() public view returns (address) { return address(ds.timelockV1); } function voteSnapshotBlockSwitchProposalId() public view returns (uint256) { return ds.voteSnapshotBlockSwitchProposalId; } receive() external payable {} }
// SPDX-License-Identifier: BSD-3-Clause /// @title Nouns DAO Logic interfaces and events /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ // LICENSE // NounsDAOInterfaces.sol is a modified version of Compound Lab's GovernorBravoInterfaces.sol: // https://github.com/compound-finance/compound-protocol/blob/b9b14038612d846b83f8a009a82c38974ff2dcfe/contracts/Governance/GovernorBravoInterfaces.sol // // GovernorBravoInterfaces.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // MODIFICATIONS // NounsDAOEvents, NounsDAOProxyStorage, NounsDAOStorageV1 add support for changes made by Nouns DAO to GovernorBravo.sol // See NounsDAOLogicV1.sol for more details. // NounsDAOStorageV1Adjusted and NounsDAOStorageV2 add support for a dynamic vote quorum. // See NounsDAOLogicV2.sol for more details. // NounsDAOStorageV3 // See NounsDAOLogicV3.sol for more details. pragma solidity ^0.8.6; contract NounsDAOEvents { /// @notice An event emitted when a new proposal is created event ProposalCreated( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /// @notice An event emitted when a new proposal is created, which includes additional information event ProposalCreatedWithRequirements( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, uint256 proposalThreshold, uint256 quorumVotes, string description ); /// @notice An event emitted when a vote has been cast on a proposal /// @param voter The address which casted a vote /// @param proposalId The proposal id which was voted on /// @param support Support value for the vote. 0=against, 1=for, 2=abstain /// @param votes Number of votes which were cast by the voter /// @param reason The reason given for the vote by the voter event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 votes, string reason); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint256 id); /// @notice An event emitted when a proposal has been queued in the NounsDAOExecutor event ProposalQueued(uint256 id, uint256 eta); /// @notice An event emitted when a proposal has been executed in the NounsDAOExecutor event ProposalExecuted(uint256 id); /// @notice An event emitted when a proposal has been vetoed by vetoAddress event ProposalVetoed(uint256 id); /// @notice An event emitted when the voting delay is set event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay); /// @notice An event emitted when the voting period is set event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod); /// @notice Emitted when implementation is changed event NewImplementation(address oldImplementation, address newImplementation); /// @notice Emitted when proposal threshold basis points is set event ProposalThresholdBPSSet(uint256 oldProposalThresholdBPS, uint256 newProposalThresholdBPS); /// @notice Emitted when quorum votes basis points is set event QuorumVotesBPSSet(uint256 oldQuorumVotesBPS, uint256 newQuorumVotesBPS); /// @notice Emitted when pendingAdmin is changed event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /// @notice Emitted when pendingAdmin is accepted, which means admin is updated event NewAdmin(address oldAdmin, address newAdmin); /// @notice Emitted when vetoer is changed event NewVetoer(address oldVetoer, address newVetoer); } contract NounsDAOEventsV2 is NounsDAOEvents { /// @notice Emitted when minQuorumVotesBPS is set event MinQuorumVotesBPSSet(uint16 oldMinQuorumVotesBPS, uint16 newMinQuorumVotesBPS); /// @notice Emitted when maxQuorumVotesBPS is set event MaxQuorumVotesBPSSet(uint16 oldMaxQuorumVotesBPS, uint16 newMaxQuorumVotesBPS); /// @notice Emitted when quorumCoefficient is set event QuorumCoefficientSet(uint32 oldQuorumCoefficient, uint32 newQuorumCoefficient); /// @notice Emitted when a voter cast a vote requesting a gas refund. event RefundableVote(address indexed voter, uint256 refundAmount, bool refundSent); /// @notice Emitted when admin withdraws the DAO's balance. event Withdraw(uint256 amount, bool sent); /// @notice Emitted when pendingVetoer is changed event NewPendingVetoer(address oldPendingVetoer, address newPendingVetoer); } contract NounsDAOEventsV3 is NounsDAOEventsV2 { /// @notice An event emitted when a new proposal is created, which includes additional information /// @dev V3 adds `signers`, `updatePeriodEndBlock` compared to the V1/V2 event. event ProposalCreatedWithRequirements( uint256 id, address proposer, address[] signers, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, uint256 updatePeriodEndBlock, uint256 proposalThreshold, uint256 quorumVotes, string description ); /// @notice Emitted when a proposal is created to be executed on timelockV1 event ProposalCreatedOnTimelockV1(uint256 id); /// @notice Emitted when a proposal is updated event ProposalUpdated( uint256 indexed id, address indexed proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string description, string updateMessage ); /// @notice Emitted when a proposal's transactions are updated event ProposalTransactionsUpdated( uint256 indexed id, address indexed proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string updateMessage ); /// @notice Emitted when a proposal's description is updated event ProposalDescriptionUpdated( uint256 indexed id, address indexed proposer, string description, string updateMessage ); /// @notice Emitted when a proposal is set to have an objection period event ProposalObjectionPeriodSet(uint256 indexed id, uint256 objectionPeriodEndBlock); /// @notice Emitted when someone cancels a signature event SignatureCancelled(address indexed signer, bytes sig); /// @notice An event emitted when the objection period duration is set event ObjectionPeriodDurationSet( uint32 oldObjectionPeriodDurationInBlocks, uint32 newObjectionPeriodDurationInBlocks ); /// @notice An event emitted when the objection period last minute window is set event LastMinuteWindowSet(uint32 oldLastMinuteWindowInBlocks, uint32 newLastMinuteWindowInBlocks); /// @notice An event emitted when the proposal updatable period is set event ProposalUpdatablePeriodSet( uint32 oldProposalUpdatablePeriodInBlocks, uint32 newProposalUpdatablePeriodInBlocks ); /// @notice Emitted when the proposal id at which vote snapshot block changes is set event VoteSnapshotBlockSwitchProposalIdSet( uint256 oldVoteSnapshotBlockSwitchProposalId, uint256 newVoteSnapshotBlockSwitchProposalId ); /// @notice Emitted when the erc20 tokens to include in a fork are set event ERC20TokensToIncludeInForkSet(address[] oldErc20Tokens, address[] newErc20tokens); /// @notice Emitted when the fork DAO deployer is set event ForkDAODeployerSet(address oldForkDAODeployer, address newForkDAODeployer); /// @notice Emitted when the during of the forking period is set event ForkPeriodSet(uint256 oldForkPeriod, uint256 newForkPeriod); /// @notice Emitted when the threhsold for forking is set event ForkThresholdSet(uint256 oldForkThreshold, uint256 newForkThreshold); /// @notice Emitted when the main timelock, timelockV1 and admin are set event TimelocksAndAdminSet(address timelock, address timelockV1, address admin); /// @notice Emitted when someones adds nouns to the fork escrow event EscrowedToFork( uint32 indexed forkId, address indexed owner, uint256[] tokenIds, uint256[] proposalIds, string reason ); /// @notice Emitted when the owner withdraws their nouns from the fork escrow event WithdrawFromForkEscrow(uint32 indexed forkId, address indexed owner, uint256[] tokenIds); /// @notice Emitted when the fork is executed and the forking period begins event ExecuteFork( uint32 indexed forkId, address forkTreasury, address forkToken, uint256 forkEndTimestamp, uint256 tokensInEscrow ); /// @notice Emitted when someone joins a fork during the forking period event JoinFork( uint32 indexed forkId, address indexed owner, uint256[] tokenIds, uint256[] proposalIds, string reason ); /// @notice Emitted when the DAO withdraws nouns from the fork escrow after a fork has been executed event DAOWithdrawNounsFromEscrow(uint256[] tokenIds, address to); /// @notice Emitted when withdrawing nouns from escrow increases adjusted total supply event DAONounsSupplyIncreasedFromEscrow(uint256 numTokens, address to); } contract NounsDAOProxyStorage { /// @notice Administrator for this contract address public admin; /// @notice Pending administrator for this contract address public pendingAdmin; /// @notice Active brains of Governor address public implementation; } /** * @title Storage for Governor Bravo Delegate * @notice For future upgrades, do not change NounsDAOStorageV1. Create a new * contract which implements NounsDAOStorageV1 and following the naming convention * NounsDAOStorageVX. */ contract NounsDAOStorageV1 is NounsDAOProxyStorage { /// @notice Vetoer who has the ability to veto any proposal address public vetoer; /// @notice The delay before voting on a proposal may take place, once proposed, in blocks uint256 public votingDelay; /// @notice The duration of voting on a proposal, in blocks uint256 public votingPeriod; /// @notice The basis point number of votes required in order for a voter to become a proposer. *DIFFERS from GovernerBravo uint256 public proposalThresholdBPS; /// @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 uint256 public quorumVotesBPS; /// @notice The total number of proposals uint256 public proposalCount; /// @notice The address of the Nouns DAO Executor NounsDAOExecutor INounsDAOExecutor public timelock; /// @notice The address of the Nouns tokens NounsTokenLike public nouns; /// @notice The official record of all proposals ever proposed mapping(uint256 => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping(address => uint256) public latestProposalIds; struct Proposal { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo uint256 proposalThreshold; /// @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 uint256 quorumVotes; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint256[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Current number of votes for abstaining for this proposal uint256 abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been vetoed bool vetoed; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping(address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal or abstains uint8 support; /// @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed, Vetoed } } /** * @title Extra fields added to the `Proposal` struct from NounsDAOStorageV1 * @notice The following fields were added to the `Proposal` struct: * - `Proposal.totalSupply` * - `Proposal.creationBlock` */ contract NounsDAOStorageV1Adjusted is NounsDAOProxyStorage { /// @notice Vetoer who has the ability to veto any proposal address public vetoer; /// @notice The delay before voting on a proposal may take place, once proposed, in blocks uint256 public votingDelay; /// @notice The duration of voting on a proposal, in blocks uint256 public votingPeriod; /// @notice The basis point number of votes required in order for a voter to become a proposer. *DIFFERS from GovernerBravo uint256 public proposalThresholdBPS; /// @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 uint256 public quorumVotesBPS; /// @notice The total number of proposals uint256 public proposalCount; /// @notice The address of the Nouns DAO Executor NounsDAOExecutor INounsDAOExecutor public timelock; /// @notice The address of the Nouns tokens NounsTokenLike public nouns; /// @notice The official record of all proposals ever proposed mapping(uint256 => Proposal) internal _proposals; /// @notice The latest proposal for each proposer mapping(address => uint256) public latestProposalIds; struct Proposal { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo uint256 proposalThreshold; /// @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 uint256 quorumVotes; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint256[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Current number of votes for abstaining for this proposal uint256 abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been vetoed bool vetoed; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping(address => Receipt) receipts; /// @notice The total supply at the time of proposal creation uint256 totalSupply; /// @notice The block at which this proposal was created uint256 creationBlock; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal or abstains uint8 support; /// @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed, Vetoed } } /** * @title Storage for Governor Bravo Delegate * @notice For future upgrades, do not change NounsDAOStorageV2. Create a new * contract which implements NounsDAOStorageV2 and following the naming convention * NounsDAOStorageVX. */ contract NounsDAOStorageV2 is NounsDAOStorageV1Adjusted { DynamicQuorumParamsCheckpoint[] public quorumParamsCheckpoints; /// @notice Pending new vetoer address public pendingVetoer; struct DynamicQuorumParams { /// @notice The minimum 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. uint16 minQuorumVotesBPS; /// @notice The maximum 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. uint16 maxQuorumVotesBPS; /// @notice The dynamic quorum coefficient /// @dev Assumed to be fixed point integer with 6 decimals, i.e 0.2 is represented as 0.2 * 1e6 = 200000 uint32 quorumCoefficient; } /// @notice A checkpoint for storing dynamic quorum params from a given block struct DynamicQuorumParamsCheckpoint { /// @notice The block at which the new values were set uint32 fromBlock; /// @notice The parameter values of this checkpoint DynamicQuorumParams params; } struct ProposalCondensed { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo uint256 proposalThreshold; /// @notice The minimum 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 uint256 quorumVotes; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Current number of votes for abstaining for this proposal uint256 abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been vetoed bool vetoed; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice The total supply at the time of proposal creation uint256 totalSupply; /// @notice The block at which this proposal was created uint256 creationBlock; } } interface INounsDAOExecutor { function delay() external view returns (uint256); function GRACE_PERIOD() external view returns (uint256); function acceptAdmin() external; function queuedTransactions(bytes32 hash) external view returns (bool); function queueTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external returns (bytes32); function cancelTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external; function executeTransaction( address target, uint256 value, string calldata signature, bytes calldata data, uint256 eta ) external payable returns (bytes memory); } interface NounsTokenLike { function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96); function totalSupply() external view returns (uint256); function transferFrom( address from, address to, uint256 tokenId ) external; function safeTransferFrom( address from, address to, uint256 tokenId ) external; function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function minter() external view returns (address); function mint() external returns (uint256); function setApprovalForAll(address operator, bool approved) external; } interface IForkDAODeployer { function deployForkDAO(uint256 forkingPeriodEndTimestamp, INounsDAOForkEscrow forkEscrowAddress) external returns (address treasury, address token); function tokenImpl() external view returns (address); function auctionImpl() external view returns (address); function governorImpl() external view returns (address); function treasuryImpl() external view returns (address); } interface INounsDAOExecutorV2 is INounsDAOExecutor { function sendETH(address recipient, uint256 ethToSend) external; function sendERC20( address recipient, address erc20Token, uint256 tokensToSend ) external; } interface INounsDAOForkEscrow { function markOwner(address owner, uint256[] calldata tokenIds) external; function returnTokensToOwner(address owner, uint256[] calldata tokenIds) external; function closeEscrow() external returns (uint32); function numTokensInEscrow() external view returns (uint256); function numTokensOwnedByDAO() external view returns (uint256); function withdrawTokens(uint256[] calldata tokenIds, address to) external; function forkId() external view returns (uint32); function nounsToken() external view returns (NounsTokenLike); function dao() external view returns (address); function ownerOfEscrowedToken(uint32 forkId_, uint256 tokenId) external view returns (address); } contract NounsDAOStorageV3 { StorageV3 ds; struct StorageV3 { // ================ PROXY ================ // /// @notice Administrator for this contract address admin; /// @notice Pending administrator for this contract address pendingAdmin; /// @notice Active brains of Governor address implementation; // ================ V1 ================ // /// @notice Vetoer who has the ability to veto any proposal address vetoer; /// @notice The delay before voting on a proposal may take place, once proposed, in blocks uint256 votingDelay; /// @notice The duration of voting on a proposal, in blocks uint256 votingPeriod; /// @notice The basis point number of votes required in order for a voter to become a proposer. *DIFFERS from GovernerBravo uint256 proposalThresholdBPS; /// @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 uint256 quorumVotesBPS; /// @notice The total number of proposals uint256 proposalCount; /// @notice The address of the Nouns DAO Executor NounsDAOExecutor INounsDAOExecutorV2 timelock; /// @notice The address of the Nouns tokens NounsTokenLike nouns; /// @notice The official record of all proposals ever proposed mapping(uint256 => Proposal) _proposals; /// @notice The latest proposal for each proposer mapping(address => uint256) latestProposalIds; // ================ V2 ================ // DynamicQuorumParamsCheckpoint[] quorumParamsCheckpoints; /// @notice Pending new vetoer address pendingVetoer; // ================ V3 ================ // /// @notice user => sig => isCancelled: signatures that have been cancelled by the signer and are no longer valid mapping(address => mapping(bytes32 => bool)) cancelledSigs; /// @notice The number of blocks before voting ends during which the objection period can be initiated uint32 lastMinuteWindowInBlocks; /// @notice Length of the objection period in blocks uint32 objectionPeriodDurationInBlocks; /// @notice Length of proposal updatable period in block uint32 proposalUpdatablePeriodInBlocks; /// @notice address of the DAO's fork escrow contract INounsDAOForkEscrow forkEscrow; /// @notice address of the DAO's fork deployer contract IForkDAODeployer forkDAODeployer; /// @notice ERC20 tokens to include when sending funds to a deployed fork address[] erc20TokensToIncludeInFork; /// @notice The treasury contract of the last deployed fork address forkDAOTreasury; /// @notice The token contract of the last deployed fork address forkDAOToken; /// @notice Timestamp at which the last fork period ends uint256 forkEndTimestamp; /// @notice Fork period in seconds uint256 forkPeriod; /// @notice Threshold defined in basis points (10,000 = 100%) required for forking uint256 forkThresholdBPS; /// @notice Address of the original timelock INounsDAOExecutor timelockV1; /// @notice The proposal at which to start using `startBlock` instead of `creationBlock` for vote snapshots /// @dev Make sure this stays the last variable in this struct, so we can delete it in the next version /// @dev To be zeroed-out and removed in a V3.1 fix version once the switch takes place uint256 voteSnapshotBlockSwitchProposalId; } struct Proposal { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo uint256 proposalThreshold; /// @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 uint256 quorumVotes; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice the ordered list of target addresses for calls to be made address[] targets; /// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint256[] values; /// @notice The ordered list of function signatures to be called string[] signatures; /// @notice The ordered list of calldata to be passed to each call bytes[] calldatas; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Current number of votes for abstaining for this proposal uint256 abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been vetoed bool vetoed; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice Receipts of ballots for the entire set of voters mapping(address => Receipt) receipts; /// @notice The total supply at the time of proposal creation uint256 totalSupply; /// @notice The block at which this proposal was created uint64 creationBlock; /// @notice The last block which allows updating a proposal's description and transactions uint64 updatePeriodEndBlock; /// @notice Starts at 0 and is set to the block at which the objection period ends when the objection period is initiated uint64 objectionPeriodEndBlock; /// @dev unused for now uint64 placeholder; /// @notice The signers of a proposal, when using proposeBySigs address[] signers; /// @notice When true, a proposal would be executed on timelockV1 instead of the current timelock bool executeOnTimelockV1; } /// @notice Ballot receipt record for a voter struct Receipt { /// @notice Whether or not a vote has been cast bool hasVoted; /// @notice Whether or not the voter supports the proposal or abstains uint8 support; /// @notice The number of votes the voter had, which were cast uint96 votes; } struct ProposerSignature { /// @notice Signature of a proposal bytes sig; /// @notice The address of the signer address signer; /// @notice The timestamp until which the signature is valid uint256 expirationTimestamp; } struct ProposalCondensed { /// @notice Unique id for looking up a proposal uint256 id; /// @notice Creator of the proposal address proposer; /// @notice The number of votes needed to create a proposal at the time of proposal creation. *DIFFERS from GovernerBravo uint256 proposalThreshold; /// @notice The minimum 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 uint256 quorumVotes; /// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint256 eta; /// @notice The block at which voting begins: holders must delegate their votes prior to this block uint256 startBlock; /// @notice The block at which voting ends: votes must be cast prior to this block uint256 endBlock; /// @notice Current number of votes in favor of this proposal uint256 forVotes; /// @notice Current number of votes in opposition to this proposal uint256 againstVotes; /// @notice Current number of votes for abstaining for this proposal uint256 abstainVotes; /// @notice Flag marking whether the proposal has been canceled bool canceled; /// @notice Flag marking whether the proposal has been vetoed bool vetoed; /// @notice Flag marking whether the proposal has been executed bool executed; /// @notice The total supply at the time of proposal creation uint256 totalSupply; /// @notice The block at which this proposal was created uint256 creationBlock; /// @notice The signers of a proposal, when using proposeBySigs address[] signers; /// @notice The last block which allows updating a proposal's description and transactions uint256 updatePeriodEndBlock; /// @notice Starts at 0 and is set to the block at which the objection period ends when the objection period is initiated uint256 objectionPeriodEndBlock; /// @notice When true, a proposal would be executed on timelockV1 instead of the current timelock bool executeOnTimelockV1; } struct DynamicQuorumParams { /// @notice The minimum 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. uint16 minQuorumVotesBPS; /// @notice The maximum 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. uint16 maxQuorumVotesBPS; /// @notice The dynamic quorum coefficient /// @dev Assumed to be fixed point integer with 6 decimals, i.e 0.2 is represented as 0.2 * 1e6 = 200000 uint32 quorumCoefficient; } struct NounsDAOParams { uint256 votingPeriod; uint256 votingDelay; uint256 proposalThresholdBPS; uint32 lastMinuteWindowInBlocks; uint32 objectionPeriodDurationInBlocks; uint32 proposalUpdatablePeriodInBlocks; } /// @notice A checkpoint for storing dynamic quorum params from a given block struct DynamicQuorumParamsCheckpoint { /// @notice The block at which the new values were set uint32 fromBlock; /// @notice The parameter values of this checkpoint DynamicQuorumParams params; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed, Vetoed, ObjectionPeriod, Updatable } }
// SPDX-License-Identifier: GPL-3.0 /// @title Library for NounsDAOLogicV3 contract containing admin related functions /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import './NounsDAOInterfaces.sol'; import { NounsDAOV3DynamicQuorum } from './NounsDAOV3DynamicQuorum.sol'; library NounsDAOV3Admin { using NounsDAOV3DynamicQuorum for NounsDAOStorageV3.StorageV3; error AdminOnly(); error VetoerOnly(); error PendingVetoerOnly(); error InvalidMinQuorumVotesBPS(); error InvalidMaxQuorumVotesBPS(); error MinQuorumBPSGreaterThanMaxQuorumBPS(); error ForkPeriodTooLong(); error ForkPeriodTooShort(); error InvalidObjectionPeriodDurationInBlocks(); error InvalidProposalUpdatablePeriodInBlocks(); error VoteSnapshotSwitchAlreadySet(); error DuplicateTokenAddress(); /// @notice Emitted when proposal threshold basis points is set event ProposalThresholdBPSSet(uint256 oldProposalThresholdBPS, uint256 newProposalThresholdBPS); /// @notice An event emitted when the voting delay is set event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay); /// @notice An event emitted when the voting period is set event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod); /// @notice An event emitted when the objection period duration is set event ObjectionPeriodDurationSet( uint32 oldObjectionPeriodDurationInBlocks, uint32 newObjectionPeriodDurationInBlocks ); /// @notice An event emitted when the objection period last minute window is set event LastMinuteWindowSet(uint32 oldLastMinuteWindowInBlocks, uint32 newLastMinuteWindowInBlocks); /// @notice An event emitted when the proposal updatable period is set event ProposalUpdatablePeriodSet( uint32 oldProposalUpdatablePeriodInBlocks, uint32 newProposalUpdatablePeriodInBlocks ); /// @notice Emitted when pendingAdmin is changed event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /// @notice Emitted when pendingAdmin is accepted, which means admin is updated event NewAdmin(address oldAdmin, address newAdmin); /// @notice Emitted when pendingVetoer is changed event NewPendingVetoer(address oldPendingVetoer, address newPendingVetoer); /// @notice Emitted when vetoer is changed event NewVetoer(address oldVetoer, address newVetoer); /// @notice Emitted when minQuorumVotesBPS is set event MinQuorumVotesBPSSet(uint16 oldMinQuorumVotesBPS, uint16 newMinQuorumVotesBPS); /// @notice Emitted when maxQuorumVotesBPS is set event MaxQuorumVotesBPSSet(uint16 oldMaxQuorumVotesBPS, uint16 newMaxQuorumVotesBPS); /// @notice Emitted when quorumCoefficient is set event QuorumCoefficientSet(uint32 oldQuorumCoefficient, uint32 newQuorumCoefficient); /// @notice Emitted when admin withdraws the DAO's balance. event Withdraw(uint256 amount, bool sent); /// @notice Emitted when the proposal id at which vote snapshot block changes is set event VoteSnapshotBlockSwitchProposalIdSet( uint256 oldVoteSnapshotBlockSwitchProposalId, uint256 newVoteSnapshotBlockSwitchProposalId ); /// @notice Emitted when the fork DAO deployer is set event ForkDAODeployerSet(address oldForkDAODeployer, address newForkDAODeployer); /// @notice Emitted when the erc20 tokens to include in a fork are set event ERC20TokensToIncludeInForkSet(address[] oldErc20Tokens, address[] newErc20tokens); /// @notice Emitted when the fork escrow contract address is set event ForkEscrowSet(address oldForkEscrow, address newForkEscrow); /// @notice Emitted when the during of the forking period is set event ForkPeriodSet(uint256 oldForkPeriod, uint256 newForkPeriod); /// @notice Emitted when the threhsold for forking is set event ForkThresholdSet(uint256 oldForkThreshold, uint256 newForkThreshold); /// @notice Emitted when the main timelock, timelockV1 and admin are set event TimelocksAndAdminSet(address timelock, address timelockV1, address admin); /// @notice The minimum setable proposal threshold uint256 public constant MIN_PROPOSAL_THRESHOLD_BPS = 1; // 1 basis point or 0.01% /// @notice The maximum setable proposal threshold uint256 public constant MAX_PROPOSAL_THRESHOLD_BPS = 1_000; // 1,000 basis points or 10% /// @notice The minimum setable voting period in blocks uint256 public constant MIN_VOTING_PERIOD_BLOCKS = 1 days / 12; /// @notice The max setable voting period in blocks uint256 public constant MAX_VOTING_PERIOD_BLOCKS = 2 weeks / 12; /// @notice The min setable voting delay in blocks uint256 public constant MIN_VOTING_DELAY_BLOCKS = 1; /// @notice The max setable voting delay in blocks uint256 public constant MAX_VOTING_DELAY_BLOCKS = 2 weeks / 12; /// @notice The lower bound of minimum quorum votes basis points uint256 public constant MIN_QUORUM_VOTES_BPS_LOWER_BOUND = 200; // 200 basis points or 2% /// @notice The upper bound of minimum quorum votes basis points uint256 public constant MIN_QUORUM_VOTES_BPS_UPPER_BOUND = 2_000; // 2,000 basis points or 20% /// @notice The upper bound of maximum quorum votes basis points uint256 public constant MAX_QUORUM_VOTES_BPS_UPPER_BOUND = 6_000; // 6,000 basis points or 60% /// @notice Upper bound for forking period. If forking period is too high it can block proposals for too long. uint256 public constant MAX_FORK_PERIOD = 14 days; /// @notice Lower bound for forking period uint256 public constant MIN_FORK_PERIOD = 2 days; /// @notice Upper bound for objection period duration in blocks. uint256 public constant MAX_OBJECTION_PERIOD_BLOCKS = 7 days / 12; /// @notice Upper bound for proposal updatable period duration in blocks. uint256 public constant MAX_UPDATABLE_PERIOD_BLOCKS = 7 days / 12; modifier onlyAdmin(NounsDAOStorageV3.StorageV3 storage ds) { if (msg.sender != ds.admin) { revert AdminOnly(); } _; } /** * @notice Admin function for setting the voting delay. Best to set voting delay to at least a few days, to give * voters time to make sense of proposals, e.g. 21,600 blocks which should be at least 3 days. * @param newVotingDelay new voting delay, in blocks */ function _setVotingDelay(NounsDAOStorageV3.StorageV3 storage ds, uint256 newVotingDelay) external onlyAdmin(ds) { require( newVotingDelay >= MIN_VOTING_DELAY_BLOCKS && newVotingDelay <= MAX_VOTING_DELAY_BLOCKS, 'NounsDAO::_setVotingDelay: invalid voting delay' ); uint256 oldVotingDelay = ds.votingDelay; ds.votingDelay = newVotingDelay; emit VotingDelaySet(oldVotingDelay, newVotingDelay); } /** * @notice Admin function for setting the voting period * @param newVotingPeriod new voting period, in blocks */ function _setVotingPeriod(NounsDAOStorageV3.StorageV3 storage ds, uint256 newVotingPeriod) external onlyAdmin(ds) { require( newVotingPeriod >= MIN_VOTING_PERIOD_BLOCKS && newVotingPeriod <= MAX_VOTING_PERIOD_BLOCKS, 'NounsDAO::_setVotingPeriod: invalid voting period' ); uint256 oldVotingPeriod = ds.votingPeriod; ds.votingPeriod = newVotingPeriod; emit VotingPeriodSet(oldVotingPeriod, newVotingPeriod); } /** * @notice Admin function for setting the proposal threshold basis points * @dev newProposalThresholdBPS must be in [`MIN_PROPOSAL_THRESHOLD_BPS`,`MAX_PROPOSAL_THRESHOLD_BPS`] * @param newProposalThresholdBPS new proposal threshold */ function _setProposalThresholdBPS(NounsDAOStorageV3.StorageV3 storage ds, uint256 newProposalThresholdBPS) external onlyAdmin(ds) { require( newProposalThresholdBPS >= MIN_PROPOSAL_THRESHOLD_BPS && newProposalThresholdBPS <= MAX_PROPOSAL_THRESHOLD_BPS, 'NounsDAO::_setProposalThreshold: invalid proposal threshold bps' ); uint256 oldProposalThresholdBPS = ds.proposalThresholdBPS; ds.proposalThresholdBPS = newProposalThresholdBPS; emit ProposalThresholdBPSSet(oldProposalThresholdBPS, newProposalThresholdBPS); } /** * @notice Admin function for setting the objection period duration * @param newObjectionPeriodDurationInBlocks new objection period duration, in blocks */ function _setObjectionPeriodDurationInBlocks( NounsDAOStorageV3.StorageV3 storage ds, uint32 newObjectionPeriodDurationInBlocks ) external onlyAdmin(ds) { if (newObjectionPeriodDurationInBlocks > MAX_OBJECTION_PERIOD_BLOCKS) revert InvalidObjectionPeriodDurationInBlocks(); uint32 oldObjectionPeriodDurationInBlocks = ds.objectionPeriodDurationInBlocks; ds.objectionPeriodDurationInBlocks = newObjectionPeriodDurationInBlocks; emit ObjectionPeriodDurationSet(oldObjectionPeriodDurationInBlocks, newObjectionPeriodDurationInBlocks); } /** * @notice Admin function for setting the objection period last minute window * @param newLastMinuteWindowInBlocks new objection period last minute window, in blocks */ function _setLastMinuteWindowInBlocks(NounsDAOStorageV3.StorageV3 storage ds, uint32 newLastMinuteWindowInBlocks) external onlyAdmin(ds) { uint32 oldLastMinuteWindowInBlocks = ds.lastMinuteWindowInBlocks; ds.lastMinuteWindowInBlocks = newLastMinuteWindowInBlocks; emit LastMinuteWindowSet(oldLastMinuteWindowInBlocks, newLastMinuteWindowInBlocks); } /** * @notice Admin function for setting the proposal updatable period * @param newProposalUpdatablePeriodInBlocks the new proposal updatable period, in blocks */ function _setProposalUpdatablePeriodInBlocks( NounsDAOStorageV3.StorageV3 storage ds, uint32 newProposalUpdatablePeriodInBlocks ) external onlyAdmin(ds) { if (newProposalUpdatablePeriodInBlocks > MAX_UPDATABLE_PERIOD_BLOCKS) revert InvalidProposalUpdatablePeriodInBlocks(); uint32 oldProposalUpdatablePeriodInBlocks = ds.proposalUpdatablePeriodInBlocks; ds.proposalUpdatablePeriodInBlocks = newProposalUpdatablePeriodInBlocks; emit ProposalUpdatablePeriodSet(oldProposalUpdatablePeriodInBlocks, newProposalUpdatablePeriodInBlocks); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. */ function _setPendingAdmin(NounsDAOStorageV3.StorageV3 storage ds, address newPendingAdmin) external onlyAdmin(ds) { // Save current value, if any, for inclusion in log address oldPendingAdmin = ds.pendingAdmin; // Store pendingAdmin with value newPendingAdmin ds.pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin */ function _acceptAdmin(NounsDAOStorageV3.StorageV3 storage ds) external { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) require( msg.sender == ds.pendingAdmin && msg.sender != address(0), 'NounsDAO::_acceptAdmin: pending admin only' ); // Save current values for inclusion in log address oldAdmin = ds.admin; address oldPendingAdmin = ds.pendingAdmin; // Store admin with value pendingAdmin ds.admin = ds.pendingAdmin; // Clear the pending value ds.pendingAdmin = address(0); emit NewAdmin(oldAdmin, ds.admin); emit NewPendingAdmin(oldPendingAdmin, address(0)); } /** * @notice Begins transition of vetoer. The newPendingVetoer must call _acceptVetoer to finalize the transfer. * @param newPendingVetoer New Pending Vetoer */ function _setPendingVetoer(NounsDAOStorageV3.StorageV3 storage ds, address newPendingVetoer) public { if (msg.sender != ds.vetoer) { revert VetoerOnly(); } emit NewPendingVetoer(ds.pendingVetoer, newPendingVetoer); ds.pendingVetoer = newPendingVetoer; } /** * @notice Called by the pendingVetoer to accept role and update vetoer */ function _acceptVetoer(NounsDAOStorageV3.StorageV3 storage ds) external { if (msg.sender != ds.pendingVetoer) { revert PendingVetoerOnly(); } // Update vetoer emit NewVetoer(ds.vetoer, ds.pendingVetoer); ds.vetoer = ds.pendingVetoer; // Clear the pending value emit NewPendingVetoer(ds.pendingVetoer, address(0)); ds.pendingVetoer = address(0); } /** * @notice Burns veto priviledges * @dev Vetoer function destroying veto power forever */ function _burnVetoPower(NounsDAOStorageV3.StorageV3 storage ds) public { // Check caller is vetoer require(msg.sender == ds.vetoer, 'NounsDAO::_burnVetoPower: vetoer only'); // Update vetoer to 0x0 emit NewVetoer(ds.vetoer, address(0)); ds.vetoer = address(0); // Clear the pending value emit NewPendingVetoer(ds.pendingVetoer, address(0)); ds.pendingVetoer = address(0); } /** * @notice Admin function for setting the minimum quorum votes bps * @param newMinQuorumVotesBPS minimum quorum votes bps * Must be between `MIN_QUORUM_VOTES_BPS_LOWER_BOUND` and `MIN_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be lower than or equal to maxQuorumVotesBPS */ function _setMinQuorumVotesBPS(NounsDAOStorageV3.StorageV3 storage ds, uint16 newMinQuorumVotesBPS) external onlyAdmin(ds) { NounsDAOStorageV3.DynamicQuorumParams memory params = ds.getDynamicQuorumParamsAt(block.number); require( newMinQuorumVotesBPS >= MIN_QUORUM_VOTES_BPS_LOWER_BOUND && newMinQuorumVotesBPS <= MIN_QUORUM_VOTES_BPS_UPPER_BOUND, 'NounsDAO::_setMinQuorumVotesBPS: invalid min quorum votes bps' ); require( newMinQuorumVotesBPS <= params.maxQuorumVotesBPS, 'NounsDAO::_setMinQuorumVotesBPS: min quorum votes bps greater than max' ); uint16 oldMinQuorumVotesBPS = params.minQuorumVotesBPS; params.minQuorumVotesBPS = newMinQuorumVotesBPS; _writeQuorumParamsCheckpoint(ds, params); emit MinQuorumVotesBPSSet(oldMinQuorumVotesBPS, newMinQuorumVotesBPS); } /** * @notice Admin function for setting the maximum quorum votes bps * @param newMaxQuorumVotesBPS maximum quorum votes bps * Must be lower than `MAX_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be higher than or equal to minQuorumVotesBPS */ function _setMaxQuorumVotesBPS(NounsDAOStorageV3.StorageV3 storage ds, uint16 newMaxQuorumVotesBPS) external onlyAdmin(ds) { NounsDAOStorageV3.DynamicQuorumParams memory params = ds.getDynamicQuorumParamsAt(block.number); require( newMaxQuorumVotesBPS <= MAX_QUORUM_VOTES_BPS_UPPER_BOUND, 'NounsDAO::_setMaxQuorumVotesBPS: invalid max quorum votes bps' ); require( params.minQuorumVotesBPS <= newMaxQuorumVotesBPS, 'NounsDAO::_setMaxQuorumVotesBPS: min quorum votes bps greater than max' ); uint16 oldMaxQuorumVotesBPS = params.maxQuorumVotesBPS; params.maxQuorumVotesBPS = newMaxQuorumVotesBPS; _writeQuorumParamsCheckpoint(ds, params); emit MaxQuorumVotesBPSSet(oldMaxQuorumVotesBPS, newMaxQuorumVotesBPS); } /** * @notice Admin function for setting the dynamic quorum coefficient * @param newQuorumCoefficient the new coefficient, as a fixed point integer with 6 decimals */ function _setQuorumCoefficient(NounsDAOStorageV3.StorageV3 storage ds, uint32 newQuorumCoefficient) external onlyAdmin(ds) { NounsDAOStorageV3.DynamicQuorumParams memory params = ds.getDynamicQuorumParamsAt(block.number); uint32 oldQuorumCoefficient = params.quorumCoefficient; params.quorumCoefficient = newQuorumCoefficient; _writeQuorumParamsCheckpoint(ds, params); emit QuorumCoefficientSet(oldQuorumCoefficient, newQuorumCoefficient); } /** * @notice Admin function for setting all the dynamic quorum parameters * @param newMinQuorumVotesBPS minimum quorum votes bps * Must be between `MIN_QUORUM_VOTES_BPS_LOWER_BOUND` and `MIN_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be lower than or equal to maxQuorumVotesBPS * @param newMaxQuorumVotesBPS maximum quorum votes bps * Must be lower than `MAX_QUORUM_VOTES_BPS_UPPER_BOUND` * Must be higher than or equal to minQuorumVotesBPS * @param newQuorumCoefficient the new coefficient, as a fixed point integer with 6 decimals */ function _setDynamicQuorumParams( NounsDAOStorageV3.StorageV3 storage ds, uint16 newMinQuorumVotesBPS, uint16 newMaxQuorumVotesBPS, uint32 newQuorumCoefficient ) public onlyAdmin(ds) { if ( newMinQuorumVotesBPS < MIN_QUORUM_VOTES_BPS_LOWER_BOUND || newMinQuorumVotesBPS > MIN_QUORUM_VOTES_BPS_UPPER_BOUND ) { revert InvalidMinQuorumVotesBPS(); } if (newMaxQuorumVotesBPS > MAX_QUORUM_VOTES_BPS_UPPER_BOUND) { revert InvalidMaxQuorumVotesBPS(); } if (newMinQuorumVotesBPS > newMaxQuorumVotesBPS) { revert MinQuorumBPSGreaterThanMaxQuorumBPS(); } NounsDAOStorageV3.DynamicQuorumParams memory oldParams = ds.getDynamicQuorumParamsAt(block.number); NounsDAOStorageV3.DynamicQuorumParams memory params = NounsDAOStorageV3.DynamicQuorumParams({ minQuorumVotesBPS: newMinQuorumVotesBPS, maxQuorumVotesBPS: newMaxQuorumVotesBPS, quorumCoefficient: newQuorumCoefficient }); _writeQuorumParamsCheckpoint(ds, params); emit MinQuorumVotesBPSSet(oldParams.minQuorumVotesBPS, params.minQuorumVotesBPS); emit MaxQuorumVotesBPSSet(oldParams.maxQuorumVotesBPS, params.maxQuorumVotesBPS); emit QuorumCoefficientSet(oldParams.quorumCoefficient, params.quorumCoefficient); } /** * @notice Withdraws all the ETH in the contract. This is callable only by the admin (timelock). */ function _withdraw(NounsDAOStorageV3.StorageV3 storage ds) external onlyAdmin(ds) returns (uint256, bool) { uint256 amount = address(this).balance; (bool sent, ) = msg.sender.call{ value: amount }(''); emit Withdraw(amount, sent); return (amount, sent); } /** * @notice Admin function for setting the proposal id at which vote snapshots start using the voting start block * instead of the proposal creation block. * Sets it to the next proposal id. */ function _setVoteSnapshotBlockSwitchProposalId(NounsDAOStorageV3.StorageV3 storage ds) external onlyAdmin(ds) { uint256 oldVoteSnapshotBlockSwitchProposalId = ds.voteSnapshotBlockSwitchProposalId; if (oldVoteSnapshotBlockSwitchProposalId > 0) { revert VoteSnapshotSwitchAlreadySet(); } uint256 newVoteSnapshotBlockSwitchProposalId = ds.proposalCount + 1; ds.voteSnapshotBlockSwitchProposalId = newVoteSnapshotBlockSwitchProposalId; emit VoteSnapshotBlockSwitchProposalIdSet( oldVoteSnapshotBlockSwitchProposalId, newVoteSnapshotBlockSwitchProposalId ); } /** * @notice Admin function for setting the fork DAO deployer contract */ function _setForkDAODeployer(NounsDAOStorageV3.StorageV3 storage ds, address newForkDAODeployer) external onlyAdmin(ds) { address oldForkDAODeployer = address(ds.forkDAODeployer); ds.forkDAODeployer = IForkDAODeployer(newForkDAODeployer); emit ForkDAODeployerSet(oldForkDAODeployer, newForkDAODeployer); } /** * @notice Admin function for setting the ERC20 tokens that are used when splitting funds to a fork */ function _setErc20TokensToIncludeInFork(NounsDAOStorageV3.StorageV3 storage ds, address[] calldata erc20tokens) external onlyAdmin(ds) { checkForDuplicates(erc20tokens); emit ERC20TokensToIncludeInForkSet(ds.erc20TokensToIncludeInFork, erc20tokens); ds.erc20TokensToIncludeInFork = erc20tokens; } /** * @notice Admin function for setting the fork escrow contract */ function _setForkEscrow(NounsDAOStorageV3.StorageV3 storage ds, address newForkEscrow) external onlyAdmin(ds) { emit ForkEscrowSet(address(ds.forkEscrow), newForkEscrow); ds.forkEscrow = INounsDAOForkEscrow(newForkEscrow); } function _setForkPeriod(NounsDAOStorageV3.StorageV3 storage ds, uint256 newForkPeriod) external onlyAdmin(ds) { if (newForkPeriod > MAX_FORK_PERIOD) { revert ForkPeriodTooLong(); } if (newForkPeriod < MIN_FORK_PERIOD) { revert ForkPeriodTooShort(); } emit ForkPeriodSet(ds.forkPeriod, newForkPeriod); ds.forkPeriod = newForkPeriod; } /** * @notice Admin function for setting the fork threshold * @param newForkThresholdBPS the new fork proposal threshold, in basis points */ function _setForkThresholdBPS(NounsDAOStorageV3.StorageV3 storage ds, uint256 newForkThresholdBPS) external onlyAdmin(ds) { emit ForkThresholdSet(ds.forkThresholdBPS, newForkThresholdBPS); ds.forkThresholdBPS = newForkThresholdBPS; } /** * @notice Admin function for setting the timelocks and admin * @param timelock the new timelock contract * @param timelockV1 the new timelockV1 contract * @param admin the new admin address */ function _setTimelocksAndAdmin( NounsDAOStorageV3.StorageV3 storage ds, address timelock, address timelockV1, address admin ) external onlyAdmin(ds) { ds.timelock = INounsDAOExecutorV2(timelock); ds.timelockV1 = INounsDAOExecutor(timelockV1); ds.admin = admin; emit TimelocksAndAdminSet(timelock, timelockV1, admin); } function _writeQuorumParamsCheckpoint( NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.DynamicQuorumParams memory params ) internal { uint32 blockNumber = safe32(block.number, 'block number exceeds 32 bits'); uint256 pos = ds.quorumParamsCheckpoints.length; if (pos > 0 && ds.quorumParamsCheckpoints[pos - 1].fromBlock == blockNumber) { ds.quorumParamsCheckpoints[pos - 1].params = params; } else { ds.quorumParamsCheckpoints.push( NounsDAOStorageV3.DynamicQuorumParamsCheckpoint({ fromBlock: blockNumber, params: params }) ); } } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n <= type(uint32).max, errorMessage); return uint32(n); } function checkForDuplicates(address[] calldata erc20tokens) internal pure { if (erc20tokens.length == 0) return; for (uint256 i = 0; i < erc20tokens.length - 1; i++) { for (uint256 j = i + 1; j < erc20tokens.length; j++) { if (erc20tokens[i] == erc20tokens[j]) revert DuplicateTokenAddress(); } } } }
// SPDX-License-Identifier: GPL-3.0 /// @title Library for NounsDAOLogicV3 contract containing functions related to quorum calculations /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import './NounsDAOInterfaces.sol'; import { NounsDAOV3Fork } from './fork/NounsDAOV3Fork.sol'; library NounsDAOV3DynamicQuorum { using NounsDAOV3Fork for NounsDAOStorageV3.StorageV3; error UnsafeUint16Cast(); /** * @notice Quorum votes required for a specific proposal to succeed * Differs from `GovernerBravo` which uses fixed amount */ function quorumVotes(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) internal view returns (uint256) { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; if (proposal.totalSupply == 0) { return proposal.quorumVotes; } return dynamicQuorumVotes( proposal.againstVotes, proposal.totalSupply, getDynamicQuorumParamsAt(ds, proposal.creationBlock) ); } /** * @notice Calculates the required quorum of for-votes based on the amount of against-votes * The more against-votes there are for a proposal, the higher the required quorum is. * The quorum BPS is between `params.minQuorumVotesBPS` and params.maxQuorumVotesBPS. * The additional quorum is calculated as: * quorumCoefficient * againstVotesBPS * @dev Note the coefficient is a fixed point integer with 6 decimals * @param againstVotes Number of against-votes in the proposal * @param totalSupply The total supply of Nouns at the time of proposal creation * @param params Configurable parameters for calculating the quorum based on againstVotes. See `DynamicQuorumParams` definition for additional details. * @return quorumVotes The required quorum */ function dynamicQuorumVotes( uint256 againstVotes, uint256 totalSupply, NounsDAOStorageV3.DynamicQuorumParams memory params ) public pure returns (uint256) { uint256 againstVotesBPS = (10000 * againstVotes) / totalSupply; uint256 quorumAdjustmentBPS = (params.quorumCoefficient * againstVotesBPS) / 1e6; uint256 adjustedQuorumBPS = params.minQuorumVotesBPS + quorumAdjustmentBPS; uint256 quorumBPS = min(params.maxQuorumVotesBPS, adjustedQuorumBPS); return bps2Uint(quorumBPS, totalSupply); } /** * @notice returns the dynamic quorum parameters values at a certain block number * @dev The checkpoints array must not be empty, and the block number must be higher than or equal to * the block of the first checkpoint * @param blockNumber_ the block number to get the params at * @return The dynamic quorum parameters that were set at the given block number */ function getDynamicQuorumParamsAt(NounsDAOStorageV3.StorageV3 storage ds, uint256 blockNumber_) internal view returns (NounsDAOStorageV3.DynamicQuorumParams memory) { uint32 blockNumber = safe32(blockNumber_, 'NounsDAO::getDynamicQuorumParamsAt: block number exceeds 32 bits'); uint256 len = ds.quorumParamsCheckpoints.length; if (len == 0) { return NounsDAOStorageV3.DynamicQuorumParams({ minQuorumVotesBPS: safe16(ds.quorumVotesBPS), maxQuorumVotesBPS: safe16(ds.quorumVotesBPS), quorumCoefficient: 0 }); } if (ds.quorumParamsCheckpoints[len - 1].fromBlock <= blockNumber) { return ds.quorumParamsCheckpoints[len - 1].params; } if (ds.quorumParamsCheckpoints[0].fromBlock > blockNumber) { return NounsDAOStorageV3.DynamicQuorumParams({ minQuorumVotesBPS: safe16(ds.quorumVotesBPS), maxQuorumVotesBPS: safe16(ds.quorumVotesBPS), quorumCoefficient: 0 }); } uint256 lower = 0; uint256 upper = len - 1; while (upper > lower) { uint256 center = upper - (upper - lower) / 2; NounsDAOStorageV3.DynamicQuorumParamsCheckpoint memory cp = ds.quorumParamsCheckpoints[center]; if (cp.fromBlock == blockNumber) { return cp.params; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return ds.quorumParamsCheckpoints[lower].params; } /** * @notice Current min quorum votes using Nouns adjusted total supply */ function minQuorumVotes(NounsDAOStorageV3.StorageV3 storage ds, uint256 adjustedTotalSupply) internal view returns (uint256) { return bps2Uint(getDynamicQuorumParamsAt(ds, block.number).minQuorumVotesBPS, adjustedTotalSupply); } /** * @notice Current max quorum votes using Nouns adjusted total supply */ function maxQuorumVotes(NounsDAOStorageV3.StorageV3 storage ds, uint256 adjustedTotalSupply) internal view returns (uint256) { return bps2Uint(getDynamicQuorumParamsAt(ds, block.number).maxQuorumVotesBPS, adjustedTotalSupply); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n <= type(uint32).max, errorMessage); return uint32(n); } function safe16(uint256 n) internal pure returns (uint16) { if (n > type(uint16).max) { revert UnsafeUint16Cast(); } return uint16(n); } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function bps2Uint(uint256 bps, uint256 number) internal pure returns (uint256) { return (number * bps) / 10000; } }
// SPDX-License-Identifier: GPL-3.0 /// @title Library for NounsDAOLogicV3 contract containing all the voting related code /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import './NounsDAOInterfaces.sol'; import { NounsDAOV3Proposals } from './NounsDAOV3Proposals.sol'; import { SafeCast } from '@openzeppelin/contracts/utils/math/SafeCast.sol'; library NounsDAOV3Votes { using NounsDAOV3Proposals for NounsDAOStorageV3.StorageV3; error CanOnlyVoteAgainstDuringObjectionPeriod(); /// @notice An event emitted when a vote has been cast on a proposal /// @param voter The address which casted a vote /// @param proposalId The proposal id which was voted on /// @param support Support value for the vote. 0=against, 1=for, 2=abstain /// @param votes Number of votes which were cast by the voter /// @param reason The reason given for the vote by the voter event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 votes, string reason); /// @notice Emitted when a voter cast a vote requesting a gas refund. event RefundableVote(address indexed voter, uint256 refundAmount, bool refundSent); /// @notice Emitted when a proposal is set to have an objection period event ProposalObjectionPeriodSet(uint256 indexed id, uint256 objectionPeriodEndBlock); /// @notice The name of this contract string public constant name = 'Nouns DAO'; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)'); /// @notice The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256('Ballot(uint256 proposalId,uint8 support)'); /// @notice The maximum priority fee used to cap gas refunds in `castRefundableVote` uint256 public constant MAX_REFUND_PRIORITY_FEE = 2 gwei; /// @notice The vote refund gas overhead, including 7K for ETH transfer and 29K for general transaction overhead uint256 public constant REFUND_BASE_GAS = 36000; /// @notice The maximum gas units the DAO will refund voters on; supports about 9,190 characters uint256 public constant MAX_REFUND_GAS_USED = 200_000; /// @notice The maximum basefee the DAO will refund voters on uint256 public constant MAX_REFUND_BASE_FEE = 200 gwei; /** * @notice Cast a vote for a proposal * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain */ function castVote( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support ) external { emit VoteCast(msg.sender, proposalId, support, castVoteInternal(ds, msg.sender, proposalId, support), ''); } /** * @notice Cast a vote for a proposal, asking the DAO to refund gas costs. * Users with > 0 votes receive refunds. Refunds are partial when using a gas priority fee higher than the DAO's cap. * Refunds are partial when the DAO's balance is insufficient. * No refund is sent when the DAO's balance is empty. No refund is sent to users with no votes. * Voting takes place regardless of refund success. * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @dev Reentrancy is defended against in `castVoteInternal` at the `receipt.hasVoted == false` require statement. */ function castRefundableVote( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support ) external { castRefundableVoteInternal(ds, proposalId, support, ''); } /** * @notice Cast a vote for a proposal, asking the DAO to refund gas costs. * Users with > 0 votes receive refunds. Refunds are partial when using a gas priority fee higher than the DAO's cap. * Refunds are partial when the DAO's balance is insufficient. * No refund is sent when the DAO's balance is empty. No refund is sent to users with no votes. * Voting takes place regardless of refund success. * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @param reason The reason given for the vote by the voter * @dev Reentrancy is defended against in `castVoteInternal` at the `receipt.hasVoted == false` require statement. */ function castRefundableVoteWithReason( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support, string calldata reason ) external { castRefundableVoteInternal(ds, proposalId, support, reason); } /** * @notice Internal function that carries out refundable voting logic * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @param reason The reason given for the vote by the voter * @dev Reentrancy is defended against in `castVoteInternal` at the `receipt.hasVoted == false` require statement. */ function castRefundableVoteInternal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support, string memory reason ) internal { uint256 startGas = gasleft(); uint96 votes = castVoteInternal(ds, msg.sender, proposalId, support); emit VoteCast(msg.sender, proposalId, support, votes, reason); if (votes > 0) { _refundGas(startGas); } } /** * @notice Cast a vote for a proposal with a reason * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @param reason The reason given for the vote by the voter */ function castVoteWithReason( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support, string calldata reason ) external { emit VoteCast(msg.sender, proposalId, support, castVoteInternal(ds, msg.sender, proposalId, support), reason); } /** * @notice Cast a vote for a proposal by signature * @dev External function that accepts EIP-712 signatures for voting on proposals. */ function castVoteBySig( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint8 support, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), block.chainid, address(this)) ); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked('\x19\x01', domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), 'NounsDAO::castVoteBySig: invalid signature'); emit VoteCast(signatory, proposalId, support, castVoteInternal(ds, signatory, proposalId, support), ''); } /** * @notice Internal function that caries out voting logic * In case of a vote during the 'last minute window', which changes the proposal outcome from being defeated to * passing, and objection period is adding to the proposal's voting period. * During the objection period, only votes against a proposal can be cast. * @param voter The voter that is casting their vote * @param proposalId The id of the proposal to vote on * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @return The number of votes cast */ function castVoteInternal( NounsDAOStorageV3.StorageV3 storage ds, address voter, uint256 proposalId, uint8 support ) internal returns (uint96) { NounsDAOStorageV3.ProposalState proposalState = ds.stateInternal(proposalId); if (proposalState == NounsDAOStorageV3.ProposalState.Active) { return castVoteDuringVotingPeriodInternal(ds, proposalId, voter, support); } else if (proposalState == NounsDAOStorageV3.ProposalState.ObjectionPeriod) { if (support != 0) revert CanOnlyVoteAgainstDuringObjectionPeriod(); return castObjectionInternal(ds, proposalId, voter); } revert('NounsDAO::castVoteInternal: voting is closed'); } /** * @notice Internal function that handles voting logic during the voting period. * @dev Assumes it's only called by `castVoteInternal` which ensures the proposal is active. * @param proposalId The id of the proposal being voted on * @param voter The address of the voter * @param support The support value for the vote. 0=against, 1=for, 2=abstain * @return The number of votes cast */ function castVoteDuringVotingPeriodInternal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address voter, uint8 support ) internal returns (uint96) { require(support <= 2, 'NounsDAO::castVoteDuringVotingPeriodInternal: invalid vote type'); NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; NounsDAOStorageV3.Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, 'NounsDAO::castVoteDuringVotingPeriodInternal: voter already voted'); /// @notice: Unlike GovernerBravo, votes are considered from the block the proposal was created in order to normalize quorumVotes and proposalThreshold metrics uint96 votes = ds.nouns.getPriorVotes(voter, proposalVoteSnapshotBlock(ds, proposalId, proposal)); bool isForVoteInLastMinuteWindow = false; if (support == 1) { isForVoteInLastMinuteWindow = (proposal.endBlock - block.number < ds.lastMinuteWindowInBlocks); } bool isDefeatedBefore = false; if (isForVoteInLastMinuteWindow) isDefeatedBefore = ds.isDefeated(proposal); if (support == 0) { proposal.againstVotes = proposal.againstVotes + votes; } else if (support == 1) { proposal.forVotes = proposal.forVotes + votes; } else if (support == 2) { proposal.abstainVotes = proposal.abstainVotes + votes; } if ( // only for votes can trigger an objection period // we're in the last minute window isForVoteInLastMinuteWindow && // first part of the vote flip check // separated from the second part to optimize gas isDefeatedBefore && // haven't turn on objection yet proposal.objectionPeriodEndBlock == 0 && // second part of the vote flip check !ds.isDefeated(proposal) ) { proposal.objectionPeriodEndBlock = SafeCast.toUint64( proposal.endBlock + ds.objectionPeriodDurationInBlocks ); emit ProposalObjectionPeriodSet(proposal.id, proposal.objectionPeriodEndBlock); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; return votes; } /** * @notice Internal function that handles against votes during an objection period. * @dev Assumes it's being called by `castVoteInternal` which ensures: * 1. The proposal is in the objection period state. * 2. The vote is an against vote. * @param proposalId The id of the proposal being voted on * @param voter The address of the voter * @return The number of votes cast */ function castObjectionInternal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address voter ) internal returns (uint96) { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; NounsDAOStorageV3.Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, 'NounsDAO::castVoteInternal: voter already voted'); uint96 votes = receipt.votes = ds.nouns.getPriorVotes( voter, proposalVoteSnapshotBlock(ds, proposalId, proposal) ); receipt.hasVoted = true; receipt.support = 0; proposal.againstVotes = proposal.againstVotes + votes; return votes; } function _refundGas(uint256 startGas) internal { unchecked { uint256 balance = address(this).balance; if (balance == 0) { return; } uint256 basefee = min(block.basefee, MAX_REFUND_BASE_FEE); uint256 gasPrice = min(tx.gasprice, basefee + MAX_REFUND_PRIORITY_FEE); uint256 gasUsed = min(startGas - gasleft() + REFUND_BASE_GAS, MAX_REFUND_GAS_USED); uint256 refundAmount = min(gasPrice * gasUsed, balance); (bool refundSent, ) = tx.origin.call{ value: refundAmount }(''); emit RefundableVote(tx.origin, refundAmount, refundSent); } } /** * @notice Internal function that returns the snapshot block number to use given a proposalId. The choice is * between the proposal's creation block and the proposal's voting start block, to allow a smooth migration from * creation block to start block. * @param proposalId The id of the proposal being voted on * @param proposal The proposal storage reference, used to read `creationBlock` and `startBlock` */ function proposalVoteSnapshotBlock( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, NounsDAOStorageV3.Proposal storage proposal ) internal view returns (uint256) { // The idea is to temporarily use this code that would still use `creationBlock` until all proposals are using // `startBlock`, then we can deploy a quick DAO fix that removes this line and only uses `startBlock`. // In that version upgrade we can also zero-out and remove this storage variable for max cleanup. uint256 voteSnapshotBlockSwitchProposalId = ds.voteSnapshotBlockSwitchProposalId; if (proposalId < voteSnapshotBlockSwitchProposalId || voteSnapshotBlockSwitchProposalId == 0) { return proposal.creationBlock; } return proposal.startBlock; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } }
// SPDX-License-Identifier: GPL-3.0 /// @title Library for NounsDAOLogicV3 contract containing the proposal lifecycle code /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import './NounsDAOInterfaces.sol'; import { NounsDAOV3DynamicQuorum } from './NounsDAOV3DynamicQuorum.sol'; import { NounsDAOV3Fork } from './fork/NounsDAOV3Fork.sol'; import { SignatureChecker } from '../external/openzeppelin/SignatureChecker.sol'; import { ECDSA } from '../external/openzeppelin/ECDSA.sol'; import { SafeCast } from '@openzeppelin/contracts/utils/math/SafeCast.sol'; library NounsDAOV3Proposals { using NounsDAOV3DynamicQuorum for NounsDAOStorageV3.StorageV3; using NounsDAOV3Fork for NounsDAOStorageV3.StorageV3; error CantCancelProposalAtFinalState(); error ProposalInfoArityMismatch(); error MustProvideActions(); error TooManyActions(); error ProposerAlreadyHasALiveProposal(); error InvalidSignature(); error SignatureExpired(); error CanOnlyEditUpdatableProposals(); error OnlyProposerCanEdit(); error SignerCountMismtach(); error ProposerCannotUpdateProposalWithSigners(); error MustProvideSignatures(); error SignatureIsCancelled(); error CannotExecuteDuringForkingPeriod(); error VetoerBurned(); error VetoerOnly(); error CantVetoExecutedProposal(); error VotesBelowProposalThreshold(); /// @notice An event emitted when a proposal has been vetoed by vetoAddress event ProposalVetoed(uint256 id); /// @notice An event emitted when a new proposal is created event ProposalCreated( uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description ); /// @notice An event emitted when a new proposal is created, which includes additional information /// @dev V3 adds `signers`, `updatePeriodEndBlock` compared to the V1/V2 event. event ProposalCreatedWithRequirements( uint256 id, address proposer, address[] signers, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, uint256 updatePeriodEndBlock, uint256 proposalThreshold, uint256 quorumVotes, string description ); /// @notice Emitted when a proposal is created to be executed on timelockV1 event ProposalCreatedOnTimelockV1(uint256 id); /// @notice Emitted when a proposal is updated event ProposalUpdated( uint256 indexed id, address indexed proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string description, string updateMessage ); /// @notice Emitted when a proposal's transactions are updated event ProposalTransactionsUpdated( uint256 indexed id, address indexed proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string updateMessage ); /// @notice Emitted when a proposal's description is updated event ProposalDescriptionUpdated( uint256 indexed id, address indexed proposer, string description, string updateMessage ); /// @notice An event emitted when a proposal has been queued in the NounsDAOExecutor event ProposalQueued(uint256 id, uint256 eta); /// @notice An event emitted when a proposal has been executed in the NounsDAOExecutor event ProposalExecuted(uint256 id); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint256 id); /// @notice Emitted when someone cancels a signature event SignatureCancelled(address indexed signer, bytes sig); // Created to solve stack-too-deep errors struct ProposalTxs { address[] targets; uint256[] values; string[] signatures; bytes[] calldatas; } /// @notice The maximum number of actions that can be included in a proposal uint256 public constant PROPOSAL_MAX_OPERATIONS = 10; // 10 actions bytes32 public constant DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)'); bytes32 public constant PROPOSAL_TYPEHASH = keccak256( 'Proposal(address proposer,address[] targets,uint256[] values,string[] signatures,bytes[] calldatas,string description,uint256 expiry)' ); bytes32 public constant UPDATE_PROPOSAL_TYPEHASH = keccak256( 'UpdateProposal(uint256 proposalId,address proposer,address[] targets,uint256[] values,string[] signatures,bytes[] calldatas,string description,uint256 expiry)' ); /** * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold * @param txs Target addresses, eth values, function signatures and calldatas for proposal calls * @param description String description of the proposal * @return Proposal id of new proposal */ function propose( NounsDAOStorageV3.StorageV3 storage ds, ProposalTxs memory txs, string memory description ) internal returns (uint256) { uint256 adjustedTotalSupply = ds.adjustedTotalSupply(); uint256 proposalThreshold_ = checkPropThreshold( ds, ds.nouns.getPriorVotes(msg.sender, block.number - 1), adjustedTotalSupply ); checkProposalTxs(txs); checkNoActiveProp(ds, msg.sender); uint256 proposalId = ds.proposalCount = ds.proposalCount + 1; NounsDAOStorageV3.Proposal storage newProposal = createNewProposal( ds, proposalId, proposalThreshold_, adjustedTotalSupply, txs ); ds.latestProposalIds[msg.sender] = proposalId; emitNewPropEvents(newProposal, new address[](0), ds.minQuorumVotes(adjustedTotalSupply), txs, description); return proposalId; } /** * @notice Function used to propose a new proposal. Sender must have delegates above the proposal threshold. * This proposal would be executed via the timelockV1 contract. This is meant to be used in case timelockV1 * is still holding funds or has special permissions to execute on certain contracts. * @param txs Target addresses, eth values, function signatures and calldatas for proposal calls * @param description String description of the proposal * @return uint256 Proposal id of new proposal */ function proposeOnTimelockV1( NounsDAOStorageV3.StorageV3 storage ds, ProposalTxs memory txs, string memory description ) internal returns (uint256) { uint256 newProposalId = propose(ds, txs, description); NounsDAOStorageV3.Proposal storage newProposal = ds._proposals[newProposalId]; newProposal.executeOnTimelockV1 = true; emit ProposalCreatedOnTimelockV1(newProposalId); return newProposalId; } /** * @notice Function used to propose a new proposal. Sender and signers must have delegates above the proposal threshold * @param proposerSignatures Array of signers who have signed the proposal and their signatures. * @dev The signatures follow EIP-712. See `PROPOSAL_TYPEHASH` in NounsDAOV3Proposals.sol * @param txs Target addresses, eth values, function signatures and calldatas for proposal calls * @param description String description of the proposal * @return uint256 Proposal id of new proposal */ function proposeBySigs( NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.ProposerSignature[] memory proposerSignatures, ProposalTxs memory txs, string memory description ) external returns (uint256) { if (proposerSignatures.length == 0) revert MustProvideSignatures(); checkProposalTxs(txs); uint256 proposalId = ds.proposalCount = ds.proposalCount + 1; uint256 adjustedTotalSupply = ds.adjustedTotalSupply(); uint256 propThreshold = proposalThreshold(ds, adjustedTotalSupply); NounsDAOStorageV3.Proposal storage newProposal = createNewProposal( ds, proposalId, propThreshold, adjustedTotalSupply, txs ); // important that the proposal is created before the verification call in order to ensure // the same signer is not trying to sign this proposal more than once (uint256 votes, address[] memory signers) = verifySignersCanBackThisProposalAndCountTheirVotes( ds, proposerSignatures, txs, description, proposalId ); if (signers.length == 0) revert MustProvideSignatures(); if (votes <= propThreshold) revert VotesBelowProposalThreshold(); newProposal.signers = signers; emitNewPropEvents(newProposal, signers, ds.minQuorumVotes(adjustedTotalSupply), txs, description); return proposalId; } /** * @notice Invalidates a signature that may be used for signing a proposal. * Once a signature is canceled, the sender can no longer use it again. * If the sender changes their mind and want to sign the proposal, they can change the expiry timestamp * in order to produce a new signature. * The signature will only be invalidated when used by the sender. If used by a different account, it will * not be invalidated. * @param sig The signature to cancel */ function cancelSig(NounsDAOStorageV3.StorageV3 storage ds, bytes calldata sig) external { bytes32 sigHash = keccak256(sig); ds.cancelledSigs[msg.sender][sigHash] = true; emit SignatureCancelled(msg.sender, sig); } /** * @notice Update a proposal transactions and description. * Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param targets Updated target addresses for proposal calls * @param values Updated eth values for proposal calls * @param signatures Updated function signatures for proposal calls * @param calldatas Updated calldatas for proposal calls * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description, string memory updateMessage ) external { updateProposalTransactionsInternal(ds, proposalId, targets, values, signatures, calldatas); emit ProposalUpdated( proposalId, msg.sender, targets, values, signatures, calldatas, description, updateMessage ); } /** * @notice Updates the proposal's transactions. Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param targets Updated target addresses for proposal calls * @param values Updated eth values for proposal calls * @param signatures Updated function signatures for proposal calls * @param calldatas Updated calldatas for proposal calls * @param updateMessage Short message to explain the update */ function updateProposalTransactions( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory updateMessage ) external { updateProposalTransactionsInternal(ds, proposalId, targets, values, signatures, calldatas); emit ProposalTransactionsUpdated(proposalId, msg.sender, targets, values, signatures, calldatas, updateMessage); } function updateProposalTransactionsInternal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas ) internal { checkProposalTxs(ProposalTxs(targets, values, signatures, calldatas)); NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; checkProposalUpdatable(ds, proposalId, proposal); proposal.targets = targets; proposal.values = values; proposal.signatures = signatures; proposal.calldatas = calldatas; } /** * @notice Updates the proposal's description. Only the proposer can update it, and only during the updateable period. * @param proposalId Proposal's id * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposalDescription( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, string calldata description, string calldata updateMessage ) external { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; checkProposalUpdatable(ds, proposalId, proposal); emit ProposalDescriptionUpdated(proposalId, msg.sender, description, updateMessage); } /** * @notice Update a proposal's transactions and description that was created with proposeBySigs. * Only the proposer can update it, during the updateable period. * Requires the original signers to sign the update. * @param proposalId Proposal's id * @param proposerSignatures Array of signers who have signed the proposal and their signatures. * @dev The signatures follow EIP-712. See `UPDATE_PROPOSAL_TYPEHASH` in NounsDAOV3Proposals.sol * @param txs Updated transactions for the proposal * @param description Updated description of the proposal * @param updateMessage Short message to explain the update */ function updateProposalBySigs( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, NounsDAOStorageV3.ProposerSignature[] memory proposerSignatures, ProposalTxs memory txs, string memory description, string memory updateMessage ) external { checkProposalTxs(txs); // without this check it's possible to run through this function and update a proposal without signatures // this problem doesn't exist in the propose function because we check for prop threshold there if (proposerSignatures.length == 0) revert MustProvideSignatures(); NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; if (stateInternal(ds, proposalId) != NounsDAOStorageV3.ProposalState.Updatable) revert CanOnlyEditUpdatableProposals(); if (msg.sender != proposal.proposer) revert OnlyProposerCanEdit(); address[] memory signers = proposal.signers; if (proposerSignatures.length != signers.length) revert SignerCountMismtach(); bytes memory proposalEncodeData = abi.encodePacked( proposalId, calcProposalEncodeData(msg.sender, txs, description) ); for (uint256 i = 0; i < proposerSignatures.length; ++i) { verifyProposalSignature(ds, proposalEncodeData, proposerSignatures[i], UPDATE_PROPOSAL_TYPEHASH); // To avoid the gas cost of having to search signers in proposal.signers, we're assuming the sigs we get // use the same amount of signers and the same order. if (signers[i] != proposerSignatures[i].signer) revert OnlyProposerCanEdit(); } proposal.targets = txs.targets; proposal.values = txs.values; proposal.signatures = txs.signatures; proposal.calldatas = txs.calldatas; emit ProposalUpdated( proposalId, msg.sender, txs.targets, txs.values, txs.signatures, txs.calldatas, description, updateMessage ); } /** * @notice Queues a proposal of state succeeded * @param proposalId The id of the proposal to queue */ function queue(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external { require( stateInternal(ds, proposalId) == NounsDAOStorageV3.ProposalState.Succeeded, 'NounsDAO::queue: proposal can only be queued if it is succeeded' ); NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; INounsDAOExecutor timelock = getProposalTimelock(ds, proposal); uint256 eta = block.timestamp + timelock.delay(); for (uint256 i = 0; i < proposal.targets.length; i++) { queueOrRevertInternal( timelock, proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta ); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function queueOrRevertInternal( INounsDAOExecutor timelock, address target, uint256 value, string memory signature, bytes memory data, uint256 eta ) internal { require( !timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), 'NounsDAO::queueOrRevertInternal: identical proposal action already queued at eta' ); timelock.queueTransaction(target, value, signature, data, eta); } /** * @notice Executes a queued proposal if eta has passed * @param proposalId The id of the proposal to execute */ function execute(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; INounsDAOExecutor timelock = getProposalTimelock(ds, proposal); executeInternal(ds, proposal, timelock); } /** * @notice Executes a queued proposal on timelockV1 if eta has passed * This is only required for proposal that were queued on timelockV1, but before the upgrade to DAO V3. * These proposals will not have the `executeOnTimelockV1` bool turned on. */ function executeOnTimelockV1(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; executeInternal(ds, proposal, ds.timelockV1); } function executeInternal( NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.Proposal storage proposal, INounsDAOExecutor timelock ) internal { require( stateInternal(ds, proposal.id) == NounsDAOStorageV3.ProposalState.Queued, 'NounsDAO::execute: proposal can only be executed if it is queued' ); if (ds.isForkPeriodActive()) revert CannotExecuteDuringForkingPeriod(); proposal.executed = true; for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta ); } emit ProposalExecuted(proposal.id); } function getProposalTimelock(NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.Proposal storage proposal) internal view returns (INounsDAOExecutor) { if (proposal.executeOnTimelockV1) { return ds.timelockV1; } else { return ds.timelock; } } /** * @notice Vetoes a proposal only if sender is the vetoer and the proposal has not been executed. * @param proposalId The id of the proposal to veto */ function veto(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external { if (ds.vetoer == address(0)) { revert VetoerBurned(); } if (msg.sender != ds.vetoer) { revert VetoerOnly(); } if (stateInternal(ds, proposalId) == NounsDAOStorageV3.ProposalState.Executed) { revert CantVetoExecutedProposal(); } NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; proposal.vetoed = true; INounsDAOExecutor timelock = getProposalTimelock(ds, proposal); for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta ); } emit ProposalVetoed(proposalId); } /** * @notice Cancels a proposal only if sender is the proposer or a signer, or proposer & signers voting power * dropped below proposal threshold * @param proposalId The id of the proposal to cancel */ function cancel(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external { NounsDAOStorageV3.ProposalState proposalState = stateInternal(ds, proposalId); if ( proposalState == NounsDAOStorageV3.ProposalState.Canceled || proposalState == NounsDAOStorageV3.ProposalState.Defeated || proposalState == NounsDAOStorageV3.ProposalState.Expired || proposalState == NounsDAOStorageV3.ProposalState.Executed || proposalState == NounsDAOStorageV3.ProposalState.Vetoed ) { revert CantCancelProposalAtFinalState(); } NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; address proposer = proposal.proposer; NounsTokenLike nouns = ds.nouns; uint256 votes = nouns.getPriorVotes(proposer, block.number - 1); bool msgSenderIsProposer = proposer == msg.sender; address[] memory signers = proposal.signers; for (uint256 i = 0; i < signers.length; ++i) { msgSenderIsProposer = msgSenderIsProposer || msg.sender == signers[i]; votes += nouns.getPriorVotes(signers[i], block.number - 1); } require( msgSenderIsProposer || votes <= proposal.proposalThreshold, 'NounsDAO::cancel: proposer above threshold' ); proposal.canceled = true; INounsDAOExecutor timelock = getProposalTimelock(ds, proposal); for (uint256 i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction( proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta ); } emit ProposalCanceled(proposalId); } /** * @notice Gets the state of a proposal * @param ds the DAO's state struct * @param proposalId The id of the proposal * @return Proposal state */ function state(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) public view returns (NounsDAOStorageV3.ProposalState) { return stateInternal(ds, proposalId); } /** * @notice Gets the state of a proposal * @dev This internal function is used by other libraries to embed in compile time and save the runtime gas cost of a delegate call * @param ds the DAO's state struct * @param proposalId The id of the proposal * @return Proposal state */ function stateInternal(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) internal view returns (NounsDAOStorageV3.ProposalState) { require(ds.proposalCount >= proposalId, 'NounsDAO::state: invalid proposal id'); NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; if (proposal.vetoed) { return NounsDAOStorageV3.ProposalState.Vetoed; } else if (proposal.canceled) { return NounsDAOStorageV3.ProposalState.Canceled; } else if (block.number <= proposal.updatePeriodEndBlock) { return NounsDAOStorageV3.ProposalState.Updatable; } else if (block.number <= proposal.startBlock) { return NounsDAOStorageV3.ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return NounsDAOStorageV3.ProposalState.Active; } else if (block.number <= proposal.objectionPeriodEndBlock) { return NounsDAOStorageV3.ProposalState.ObjectionPeriod; } else if (isDefeated(ds, proposal)) { return NounsDAOStorageV3.ProposalState.Defeated; } else if (proposal.eta == 0) { return NounsDAOStorageV3.ProposalState.Succeeded; } else if (proposal.executed) { return NounsDAOStorageV3.ProposalState.Executed; } else if (block.timestamp >= proposal.eta + getProposalTimelock(ds, proposal).GRACE_PERIOD()) { return NounsDAOStorageV3.ProposalState.Expired; } else { return NounsDAOStorageV3.ProposalState.Queued; } } /** * @notice Gets actions of a proposal * @param proposalId the id of the proposal * @return targets * @return values * @return signatures * @return calldatas */ function getActions(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) internal view returns ( address[] memory targets, uint256[] memory values, string[] memory signatures, bytes[] memory calldatas ) { NounsDAOStorageV3.Proposal storage p = ds._proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } /** * @notice Gets the receipt for a voter on a given proposal * @param proposalId the id of proposal * @param voter The address of the voter * @return The voting receipt */ function getReceipt( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, address voter ) internal view returns (NounsDAOStorageV3.Receipt memory) { return ds._proposals[proposalId].receipts[voter]; } /** * @notice Returns the proposal details given a proposal id. * The `quorumVotes` member holds the *current* quorum, given the current votes. * @param proposalId the proposal id to get the data for * @return A `ProposalCondensed` struct with the proposal data */ function proposals(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external view returns (NounsDAOStorageV2.ProposalCondensed memory) { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; return NounsDAOStorageV2.ProposalCondensed({ id: proposal.id, proposer: proposal.proposer, proposalThreshold: proposal.proposalThreshold, quorumVotes: ds.quorumVotes(proposal.id), eta: proposal.eta, startBlock: proposal.startBlock, endBlock: proposal.endBlock, forVotes: proposal.forVotes, againstVotes: proposal.againstVotes, abstainVotes: proposal.abstainVotes, canceled: proposal.canceled, vetoed: proposal.vetoed, executed: proposal.executed, totalSupply: proposal.totalSupply, creationBlock: proposal.creationBlock }); } /** * @notice Returns the proposal details given a proposal id. * The `quorumVotes` member holds the *current* quorum, given the current votes. * @param proposalId the proposal id to get the data for * @return A `ProposalCondensed` struct with the proposal data */ function proposalsV3(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external view returns (NounsDAOStorageV3.ProposalCondensed memory) { NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId]; return NounsDAOStorageV3.ProposalCondensed({ id: proposal.id, proposer: proposal.proposer, proposalThreshold: proposal.proposalThreshold, quorumVotes: ds.quorumVotes(proposal.id), eta: proposal.eta, startBlock: proposal.startBlock, endBlock: proposal.endBlock, forVotes: proposal.forVotes, againstVotes: proposal.againstVotes, abstainVotes: proposal.abstainVotes, canceled: proposal.canceled, vetoed: proposal.vetoed, executed: proposal.executed, totalSupply: proposal.totalSupply, creationBlock: proposal.creationBlock, signers: proposal.signers, updatePeriodEndBlock: proposal.updatePeriodEndBlock, objectionPeriodEndBlock: proposal.objectionPeriodEndBlock, executeOnTimelockV1: proposal.executeOnTimelockV1 }); } /** * @notice Current proposal threshold using Noun Total Supply * Differs from `GovernerBravo` which uses fixed amount */ function proposalThreshold(NounsDAOStorageV3.StorageV3 storage ds, uint256 adjustedTotalSupply) internal view returns (uint256) { return bps2Uint(ds.proposalThresholdBPS, adjustedTotalSupply); } function isDefeated(NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.Proposal storage proposal) internal view returns (bool) { uint256 forVotes = proposal.forVotes; return forVotes <= proposal.againstVotes || forVotes < ds.quorumVotes(proposal.id); } /** * @notice reverts if `proposer` is the proposer or signer of an active proposal. * This is a spam protection mechanism to limit the number of proposals each noun can back. */ function checkNoActiveProp(NounsDAOStorageV3.StorageV3 storage ds, address proposer) internal view { uint256 latestProposalId = ds.latestProposalIds[proposer]; if (latestProposalId != 0) { NounsDAOStorageV3.ProposalState proposersLatestProposalState = stateInternal(ds, latestProposalId); if ( proposersLatestProposalState == NounsDAOStorageV3.ProposalState.ObjectionPeriod || proposersLatestProposalState == NounsDAOStorageV3.ProposalState.Active || proposersLatestProposalState == NounsDAOStorageV3.ProposalState.Pending || proposersLatestProposalState == NounsDAOStorageV3.ProposalState.Updatable ) revert ProposerAlreadyHasALiveProposal(); } } /** * @dev Extracted this function to fix the `Stack too deep` error `proposeBySigs` hit. */ function verifySignersCanBackThisProposalAndCountTheirVotes( NounsDAOStorageV3.StorageV3 storage ds, NounsDAOStorageV3.ProposerSignature[] memory proposerSignatures, ProposalTxs memory txs, string memory description, uint256 proposalId ) internal returns (uint256 votes, address[] memory signers) { NounsTokenLike nouns = ds.nouns; bytes memory proposalEncodeData = calcProposalEncodeData(msg.sender, txs, description); signers = new address[](proposerSignatures.length); uint256 numSigners = 0; for (uint256 i = 0; i < proposerSignatures.length; ++i) { verifyProposalSignature(ds, proposalEncodeData, proposerSignatures[i], PROPOSAL_TYPEHASH); address signer = proposerSignatures[i].signer; checkNoActiveProp(ds, signer); uint256 signerVotes = nouns.getPriorVotes(signer, block.number - 1); if (signerVotes == 0) { continue; } signers[numSigners++] = signer; ds.latestProposalIds[signer] = proposalId; votes += signerVotes; } if (numSigners < proposerSignatures.length) { // this assembly trims the signer array, getting rid of unused cells assembly { mstore(signers, numSigners) } } checkNoActiveProp(ds, msg.sender); ds.latestProposalIds[msg.sender] = proposalId; votes += nouns.getPriorVotes(msg.sender, block.number - 1); } function calcProposalEncodeData( address proposer, ProposalTxs memory txs, string memory description ) internal pure returns (bytes memory) { bytes32[] memory signatureHashes = new bytes32[](txs.signatures.length); for (uint256 i = 0; i < txs.signatures.length; ++i) { signatureHashes[i] = keccak256(bytes(txs.signatures[i])); } bytes32[] memory calldatasHashes = new bytes32[](txs.calldatas.length); for (uint256 i = 0; i < txs.calldatas.length; ++i) { calldatasHashes[i] = keccak256(txs.calldatas[i]); } return abi.encode( proposer, keccak256(abi.encodePacked(txs.targets)), keccak256(abi.encodePacked(txs.values)), keccak256(abi.encodePacked(signatureHashes)), keccak256(abi.encodePacked(calldatasHashes)), keccak256(bytes(description)) ); } function checkProposalUpdatable( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, NounsDAOStorageV3.Proposal storage proposal ) internal view { if (stateInternal(ds, proposalId) != NounsDAOStorageV3.ProposalState.Updatable) revert CanOnlyEditUpdatableProposals(); if (msg.sender != proposal.proposer) revert OnlyProposerCanEdit(); if (proposal.signers.length > 0) revert ProposerCannotUpdateProposalWithSigners(); } function createNewProposal( NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId, uint256 proposalThreshold_, uint256 adjustedTotalSupply, ProposalTxs memory txs ) internal returns (NounsDAOStorageV3.Proposal storage newProposal) { uint64 updatePeriodEndBlock = SafeCast.toUint64(block.number + ds.proposalUpdatablePeriodInBlocks); uint256 startBlock = updatePeriodEndBlock + ds.votingDelay; uint256 endBlock = startBlock + ds.votingPeriod; newProposal = ds._proposals[proposalId]; newProposal.id = proposalId; newProposal.proposer = msg.sender; newProposal.proposalThreshold = proposalThreshold_; newProposal.targets = txs.targets; newProposal.values = txs.values; newProposal.signatures = txs.signatures; newProposal.calldatas = txs.calldatas; newProposal.startBlock = startBlock; newProposal.endBlock = endBlock; newProposal.totalSupply = adjustedTotalSupply; newProposal.creationBlock = SafeCast.toUint64(block.number); newProposal.updatePeriodEndBlock = updatePeriodEndBlock; } function emitNewPropEvents( NounsDAOStorageV3.Proposal storage newProposal, address[] memory signers, uint256 minQuorumVotes, ProposalTxs memory txs, string memory description ) internal { /// @notice Maintains backwards compatibility with GovernorBravo events emit ProposalCreated( newProposal.id, msg.sender, txs.targets, txs.values, txs.signatures, txs.calldatas, newProposal.startBlock, newProposal.endBlock, description ); /// @notice V1: Updated event with `proposalThreshold` and `quorumVotes` `minQuorumVotes` /// @notice V2: `quorumVotes` changed to `minQuorumVotes` /// @notice V3: Added signers and updatePeriodEndBlock emit ProposalCreatedWithRequirements( newProposal.id, msg.sender, signers, txs.targets, txs.values, txs.signatures, txs.calldatas, newProposal.startBlock, newProposal.endBlock, newProposal.updatePeriodEndBlock, newProposal.proposalThreshold, minQuorumVotes, description ); } function checkPropThreshold( NounsDAOStorageV3.StorageV3 storage ds, uint256 votes, uint256 adjustedTotalSupply ) internal view returns (uint256 propThreshold) { propThreshold = proposalThreshold(ds, adjustedTotalSupply); if (votes <= propThreshold) revert VotesBelowProposalThreshold(); } function checkProposalTxs(ProposalTxs memory txs) internal pure { if ( txs.targets.length != txs.values.length || txs.targets.length != txs.signatures.length || txs.targets.length != txs.calldatas.length ) revert ProposalInfoArityMismatch(); if (txs.targets.length == 0) revert MustProvideActions(); if (txs.targets.length > PROPOSAL_MAX_OPERATIONS) revert TooManyActions(); } function verifyProposalSignature( NounsDAOStorageV3.StorageV3 storage ds, bytes memory proposalEncodeData, NounsDAOStorageV3.ProposerSignature memory proposerSignature, bytes32 typehash ) internal view { bytes32 sigHash = keccak256(proposerSignature.sig); if (ds.cancelledSigs[proposerSignature.signer][sigHash]) revert SignatureIsCancelled(); bytes32 digest = sigDigest(typehash, proposalEncodeData, proposerSignature.expirationTimestamp, address(this)); if (!SignatureChecker.isValidSignatureNow(proposerSignature.signer, digest, proposerSignature.sig)) revert InvalidSignature(); if (block.timestamp > proposerSignature.expirationTimestamp) revert SignatureExpired(); } /** * @notice Generate the digest (hash) used to verify proposal signatures. * @param typehash the EIP 712 type hash of the signed message, e.g. `PROPOSAL_TYPEHASH` or `UPDATE_PROPOSAL_TYPEHASH`. * @param proposalEncodeData the abi encoded proposal data, identical to the output of `calcProposalEncodeData`. * @param expirationTimestamp the signature's expiration timestamp. * @param verifyingContract the contract verifying the signature, e.g. the DAO proxy by default. * @return bytes32 the signature's typed data hash. */ function sigDigest( bytes32 typehash, bytes memory proposalEncodeData, uint256 expirationTimestamp, address verifyingContract ) internal view returns (bytes32) { bytes32 structHash = keccak256(abi.encodePacked(typehash, proposalEncodeData, expirationTimestamp)); bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes('Nouns DAO')), block.chainid, verifyingContract) ); return ECDSA.toTypedDataHash(domainSeparator, structHash); } function bps2Uint(uint256 bps, uint256 number) internal pure returns (uint256) { return (number * bps) / 10000; } }
// SPDX-License-Identifier: GPL-3.0 /// @title Library for NounsDAOLogicV3 contract containing the dao fork logic /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import { NounsDAOStorageV3, INounsDAOForkEscrow, INounsDAOExecutorV2 } from '../NounsDAOInterfaces.sol'; import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import { NounsTokenFork } from './newdao/token/NounsTokenFork.sol'; library NounsDAOV3Fork { error ForkThresholdNotMet(); error ForkPeriodNotActive(); error ForkPeriodActive(); error AdminOnly(); error UseAlternativeWithdrawFunction(); /// @notice Emitted when someones adds nouns to the fork escrow event EscrowedToFork( uint32 indexed forkId, address indexed owner, uint256[] tokenIds, uint256[] proposalIds, string reason ); /// @notice Emitted when the owner withdraws their nouns from the fork escrow event WithdrawFromForkEscrow(uint32 indexed forkId, address indexed owner, uint256[] tokenIds); /// @notice Emitted when the fork is executed and the forking period begins event ExecuteFork( uint32 indexed forkId, address forkTreasury, address forkToken, uint256 forkEndTimestamp, uint256 tokensInEscrow ); /// @notice Emitted when someone joins a fork during the forking period event JoinFork( uint32 indexed forkId, address indexed owner, uint256[] tokenIds, uint256[] proposalIds, string reason ); /// @notice Emitted when the DAO withdraws nouns from the fork escrow after a fork has been executed event DAOWithdrawNounsFromEscrow(uint256[] tokenIds, address to); /// @notice Emitted when withdrawing nouns from escrow increases adjusted total supply event DAONounsSupplyIncreasedFromEscrow(uint256 numTokens, address to); /** * @notice Escrow Nouns to contribute to the fork threshold * @dev Requires approving the tokenIds or the entire noun token to the DAO contract * @param tokenIds the tokenIds to escrow. They will be sent to the DAO once the fork threshold is reached and the escrow is closed. * @param proposalIds array of proposal ids which are the reason for wanting to fork. This will only be used to emit event. * @param reason the reason for want to fork. This will only be used to emit event. */ function escrowToFork( NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds, uint256[] calldata proposalIds, string calldata reason ) external { if (isForkPeriodActive(ds)) revert ForkPeriodActive(); INounsDAOForkEscrow forkEscrow = ds.forkEscrow; for (uint256 i = 0; i < tokenIds.length; i++) { ds.nouns.safeTransferFrom(msg.sender, address(forkEscrow), tokenIds[i]); } emit EscrowedToFork(forkEscrow.forkId(), msg.sender, tokenIds, proposalIds, reason); } /** * @notice Withdraw Nouns from the fork escrow. Only possible if the fork has not been executed. * Only allowed to withdraw tokens that the sender has escrowed. * @param tokenIds the tokenIds to withdraw */ function withdrawFromForkEscrow(NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds) external { if (isForkPeriodActive(ds)) revert ForkPeriodActive(); INounsDAOForkEscrow forkEscrow = ds.forkEscrow; forkEscrow.returnTokensToOwner(msg.sender, tokenIds); emit WithdrawFromForkEscrow(forkEscrow.forkId(), msg.sender, tokenIds); } /** * @notice Execute the fork. Only possible if the fork threshold has been exceeded. * This will deploy a new DAO and send the prorated part of the treasury to the new DAO's treasury. * This will also close the active escrow and all nouns in the escrow will belong to the original DAO. * @return forkTreasury The address of the new DAO's treasury * @return forkToken The address of the new DAO's token */ function executeFork(NounsDAOStorageV3.StorageV3 storage ds) external returns (address forkTreasury, address forkToken) { if (isForkPeriodActive(ds)) revert ForkPeriodActive(); INounsDAOForkEscrow forkEscrow = ds.forkEscrow; uint256 tokensInEscrow = forkEscrow.numTokensInEscrow(); if (tokensInEscrow <= forkThreshold(ds)) revert ForkThresholdNotMet(); uint256 forkEndTimestamp = block.timestamp + ds.forkPeriod; (forkTreasury, forkToken) = ds.forkDAODeployer.deployForkDAO(forkEndTimestamp, forkEscrow); sendProRataTreasury(ds, forkTreasury, tokensInEscrow, adjustedTotalSupply(ds)); uint32 forkId = forkEscrow.closeEscrow(); ds.forkDAOTreasury = forkTreasury; ds.forkDAOToken = forkToken; ds.forkEndTimestamp = forkEndTimestamp; emit ExecuteFork(forkId, forkTreasury, forkToken, forkEndTimestamp, tokensInEscrow); } /** * @notice Joins a fork while a fork is active * Sends the tokens to the timelock contract. * Sends a prorated part of the treasury to the new fork DAO's treasury. * Mints new tokens in the new fork DAO with the same token ids. * @param tokenIds the tokenIds to send to the DAO in exchange for joining the fork */ function joinFork( NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds, uint256[] calldata proposalIds, string calldata reason ) external { if (!isForkPeriodActive(ds)) revert ForkPeriodNotActive(); INounsDAOForkEscrow forkEscrow = ds.forkEscrow; address timelock = address(ds.timelock); sendProRataTreasury(ds, ds.forkDAOTreasury, tokenIds.length, adjustedTotalSupply(ds)); for (uint256 i = 0; i < tokenIds.length; i++) { ds.nouns.transferFrom(msg.sender, timelock, tokenIds[i]); } NounsTokenFork(ds.forkDAOToken).claimDuringForkPeriod(msg.sender, tokenIds); emit JoinFork(forkEscrow.forkId() - 1, msg.sender, tokenIds, proposalIds, reason); } /** * @notice Withdraws nouns from the fork escrow to the treasury after the fork has been executed * @dev Only the DAO can call this function * @param tokenIds the tokenIds to withdraw */ function withdrawDAONounsFromEscrowToTreasury(NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds) external { withdrawDAONounsFromEscrow(ds, tokenIds, address(ds.timelock)); } /** * @notice Withdraws nouns from the fork escrow after the fork has been executed to an address other than the treasury * @dev Only the DAO can call this function * @param tokenIds the tokenIds to withdraw * @param to the address to send the nouns to */ function withdrawDAONounsFromEscrowIncreasingTotalSupply( NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds, address to ) external { if (to == address(ds.timelock)) revert UseAlternativeWithdrawFunction(); withdrawDAONounsFromEscrow(ds, tokenIds, to); emit DAONounsSupplyIncreasedFromEscrow(tokenIds.length, to); } function withdrawDAONounsFromEscrow( NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds, address to ) private { if (msg.sender != ds.admin) { revert AdminOnly(); } ds.forkEscrow.withdrawTokens(tokenIds, to); emit DAOWithdrawNounsFromEscrow(tokenIds, to); } /** * @notice Returns the required number of tokens to escrow to trigger a fork */ function forkThreshold(NounsDAOStorageV3.StorageV3 storage ds) public view returns (uint256) { return (adjustedTotalSupply(ds) * ds.forkThresholdBPS) / 10_000; } /** * @notice Returns the number of tokens currently in escrow, contributing to the fork threshold */ function numTokensInForkEscrow(NounsDAOStorageV3.StorageV3 storage ds) public view returns (uint256) { return ds.forkEscrow.numTokensInEscrow(); } /** * @notice Returns the number of nouns in supply minus nouns owned by the DAO, i.e. held in the treasury or in an * escrow after it has closed. * This is used when calculating proposal threshold, quorum, fork threshold & treasury split. */ function adjustedTotalSupply(NounsDAOStorageV3.StorageV3 storage ds) internal view returns (uint256) { return ds.nouns.totalSupply() - ds.nouns.balanceOf(address(ds.timelock)) - ds.forkEscrow.numTokensOwnedByDAO(); } /** * @notice Returns true if noun holders can currently join a fork */ function isForkPeriodActive(NounsDAOStorageV3.StorageV3 storage ds) internal view returns (bool) { return ds.forkEndTimestamp > block.timestamp; } /** * @notice Sends part of the DAO's treasury to the `newDAOTreasury` address. * The amount sent is proportional to the `tokenCount` out of `totalSupply`. * Sends ETH and ERC20 tokens listed in `ds.erc20TokensToIncludeInFork`. */ function sendProRataTreasury( NounsDAOStorageV3.StorageV3 storage ds, address newDAOTreasury, uint256 tokenCount, uint256 totalSupply ) internal { INounsDAOExecutorV2 timelock = ds.timelock; uint256 ethToSend = (address(timelock).balance * tokenCount) / totalSupply; timelock.sendETH(newDAOTreasury, ethToSend); uint256 erc20Count = ds.erc20TokensToIncludeInFork.length; for (uint256 i = 0; i < erc20Count; ++i) { IERC20 erc20token = IERC20(ds.erc20TokensToIncludeInFork[i]); uint256 tokensToSend = (erc20token.balanceOf(address(timelock)) * tokenCount) / totalSupply; if (tokensToSend > 0) { timelock.sendERC20(newDAOTreasury, address(erc20token), tokensToSend); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/math/SafeCast.sol) pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import './ECDSA.sol'; import '@openzeppelin/contracts/interfaces/IERC1271.sol'; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Gnosis Safe. * * _Available since v4.1._ */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); return (error == ECDSA.RecoverError.NoError && recovered == signer) || isValidERC1271SignatureNow(signer, hash, signature); } /** * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated * against the signer smart contract using ERC1271. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidERC1271SignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature) ); return (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import { Strings } from '@openzeppelin/contracts/utils/Strings.sol'; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert('ECDSA: invalid signature'); } else if (error == RecoverError.InvalidSignatureLength) { revert('ECDSA: invalid signature length'); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, '\x19Ethereum Signed Message:\n32') mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked('\x19Ethereum Signed Message:\n', Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, '\x19\x01') mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked('\x19\x00', validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: GPL-3.0 /// @title The Nouns ERC-721 token, adjusted for forks /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import { OwnableUpgradeable } from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import { ERC721CheckpointableUpgradeable } from './base/ERC721CheckpointableUpgradeable.sol'; import { INounsDescriptorMinimal } from '../../../../interfaces/INounsDescriptorMinimal.sol'; import { INounsSeeder } from '../../../../interfaces/INounsSeeder.sol'; import { INounsTokenFork } from './INounsTokenFork.sol'; import { IERC721 } from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import { UUPSUpgradeable } from '@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol'; import { INounsDAOForkEscrow } from '../../../NounsDAOInterfaces.sol'; /** * @dev This contract is a fork of NounsToken, with the following changes: * - Added upgradeablity via UUPSUpgradeable. * - Inheriting from an unmodified ERC721, so that the double Transfer event emission that * NounsToken performs is gone, in favor of the standard single event. * - Added functions to claim tokens from a Nouns Fork escrow, or during the forking period. * - Removed the proxyRegistry feature that whitelisted OpenSea. * - Removed `noundersDAO` and the founder reward every 10 mints. * For additional context see `ERC721CheckpointableUpgradeable`. */ contract NounsTokenFork is INounsTokenFork, OwnableUpgradeable, ERC721CheckpointableUpgradeable, UUPSUpgradeable { error OnlyOwner(); error OnlyTokenOwnerCanClaim(); error OnlyOriginalDAO(); error NoundersCannotBeAddressZero(); error OnlyDuringForkingPeriod(); string public constant NAME = 'NounsTokenFork'; /// @notice An address who has permissions to mint Nouns address public minter; /// @notice The Nouns token URI descriptor INounsDescriptorMinimal public descriptor; /// @notice The Nouns token seeder INounsSeeder public seeder; /// @notice The escrow contract used to verify ownership of the original Nouns in the post-fork claiming process INounsDAOForkEscrow public escrow; /// @notice The fork ID, used when querying the escrow for token ownership uint32 public forkId; /// @notice How many tokens are still available to be claimed by Nouners who put their original Nouns in escrow uint256 public remainingTokensToClaim; /// @notice The forking period expiration timestamp, after which new tokens cannot be claimed by the original DAO uint256 public forkingPeriodEndTimestamp; /// @notice Whether the minter can be updated bool public isMinterLocked; /// @notice Whether the descriptor can be updated bool public isDescriptorLocked; /// @notice Whether the seeder can be updated bool public isSeederLocked; /// @notice The noun seeds mapping(uint256 => INounsSeeder.Seed) public seeds; /// @notice The internal noun ID tracker uint256 private _currentNounId; /// @notice IPFS content hash of contract-level metadata string private _contractURIHash = 'QmZi1n79FqWt2tTLwCqiy6nLM6xLGRsEPQ5JmReJQKNNzX'; /** * @notice Require that the minter has not been locked. */ modifier whenMinterNotLocked() { require(!isMinterLocked, 'Minter is locked'); _; } /** * @notice Require that the descriptor has not been locked. */ modifier whenDescriptorNotLocked() { require(!isDescriptorLocked, 'Descriptor is locked'); _; } /** * @notice Require that the seeder has not been locked. */ modifier whenSeederNotLocked() { require(!isSeederLocked, 'Seeder is locked'); _; } /** * @notice Require that the sender is the minter. */ modifier onlyMinter() { require(msg.sender == minter, 'Sender is not the minter'); _; } constructor() initializer {} function initialize( address _owner, address _minter, INounsDAOForkEscrow _escrow, uint32 _forkId, uint256 startNounId, uint256 tokensToClaim, uint256 _forkingPeriodEndTimestamp ) external initializer { __ERC721_init('Nouns', 'NOUN'); _transferOwnership(_owner); minter = _minter; escrow = _escrow; forkId = _forkId; _currentNounId = startNounId; remainingTokensToClaim = tokensToClaim; forkingPeriodEndTimestamp = _forkingPeriodEndTimestamp; NounsTokenFork originalToken = NounsTokenFork(address(escrow.nounsToken())); descriptor = originalToken.descriptor(); seeder = originalToken.seeder(); } /** * @notice Claim new tokens if you escrowed original Nouns and forked into a new DAO governed by holders of this * token. * @dev Reverts if the sender is not the owner of the escrowed token. * @param tokenIds The token IDs to claim */ function claimFromEscrow(uint256[] calldata tokenIds) external { for (uint256 i = 0; i < tokenIds.length; i++) { uint256 nounId = tokenIds[i]; if (escrow.ownerOfEscrowedToken(forkId, nounId) != msg.sender) revert OnlyTokenOwnerCanClaim(); _mintWithOriginalSeed(msg.sender, nounId); } remainingTokensToClaim -= tokenIds.length; } /** * @notice The original DAO can claim tokens during the forking period, on behalf of Nouners who choose to join * a new fork DAO. Does not allow the original DAO to claim once the forking period has ended. * @dev Assumes the original DAO is honest during the forking period. * @param to The recipient of the tokens * @param tokenIds The token IDs to claim */ function claimDuringForkPeriod(address to, uint256[] calldata tokenIds) external { uint256 currentNounId = _currentNounId; uint256 maxNounId = 0; if (msg.sender != escrow.dao()) revert OnlyOriginalDAO(); if (block.timestamp >= forkingPeriodEndTimestamp) revert OnlyDuringForkingPeriod(); for (uint256 i = 0; i < tokenIds.length; i++) { uint256 nounId = tokenIds[i]; _mintWithOriginalSeed(to, nounId); if (tokenIds[i] > maxNounId) maxNounId = tokenIds[i]; } // This treats an important case: // During a forking period, people can buy new Nouns on auction, with a higher ID than the auction ID at forking // They can then join the fork with those IDs // If we don't increment currentNounId, unpausing the fork auction house would revert // Since it would attempt to mint a noun with an ID that already exists if (maxNounId >= currentNounId) _currentNounId = maxNounId + 1; } /** * @notice The IPFS URI of contract-level metadata. */ function contractURI() public view returns (string memory) { return string(abi.encodePacked('ipfs://', _contractURIHash)); } /** * @notice Set the _contractURIHash. * @dev Only callable by the owner. */ function setContractURIHash(string memory newContractURIHash) external onlyOwner { _contractURIHash = newContractURIHash; } /** * @notice Mint a Noun to the minter * @dev Call _mintTo with the to address(es). */ function mint() public override onlyMinter returns (uint256) { return _mintTo(minter, _currentNounId++); } /** * @notice Burn a noun. */ function burn(uint256 nounId) public override onlyMinter { _burn(nounId); emit NounBurned(nounId); } /** * @notice A distinct Uniform Resource Identifier (URI) for a given asset. * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), 'NounsToken: URI query for nonexistent token'); return descriptor.tokenURI(tokenId, seeds[tokenId]); } /** * @notice Similar to `tokenURI`, but always serves a base64 encoded data URI * with the JSON contents directly inlined. */ function dataURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), 'NounsToken: URI query for nonexistent token'); return descriptor.dataURI(tokenId, seeds[tokenId]); } /** * @notice Set the token minter. * @dev Only callable by the owner when not locked. */ function setMinter(address _minter) external override onlyOwner whenMinterNotLocked { minter = _minter; emit MinterUpdated(_minter); } /** * @notice Lock the minter. * @dev This cannot be reversed and is only callable by the owner when not locked. */ function lockMinter() external override onlyOwner whenMinterNotLocked { isMinterLocked = true; emit MinterLocked(); } /** * @notice Set the token URI descriptor. * @dev Only callable by the owner when not locked. */ function setDescriptor(INounsDescriptorMinimal _descriptor) external override onlyOwner whenDescriptorNotLocked { descriptor = _descriptor; emit DescriptorUpdated(_descriptor); } /** * @notice Lock the descriptor. * @dev This cannot be reversed and is only callable by the owner when not locked. */ function lockDescriptor() external override onlyOwner whenDescriptorNotLocked { isDescriptorLocked = true; emit DescriptorLocked(); } /** * @notice Set the token seeder. * @dev Only callable by the owner when not locked. */ function setSeeder(INounsSeeder _seeder) external override onlyOwner whenSeederNotLocked { seeder = _seeder; emit SeederUpdated(_seeder); } /** * @notice Lock the seeder. * @dev This cannot be reversed and is only callable by the owner when not locked. */ function lockSeeder() external override onlyOwner whenSeederNotLocked { isSeederLocked = true; emit SeederLocked(); } /** * @notice Mint a Noun with `nounId` to the provided `to` address. */ function _mintTo(address to, uint256 nounId) internal returns (uint256) { INounsSeeder.Seed memory seed = seeds[nounId] = seeder.generateSeed(nounId, descriptor); _mint(to, nounId); emit NounCreated(nounId, seed); return nounId; } /** * @notice Mint a new token using the original Nouns seed. */ function _mintWithOriginalSeed(address to, uint256 nounId) internal { (uint48 background, uint48 body, uint48 accessory, uint48 head, uint48 glasses) = NounsTokenFork( address(escrow.nounsToken()) ).seeds(nounId); INounsSeeder.Seed memory seed = INounsSeeder.Seed(background, body, accessory, head, glasses); seeds[nounId] = seed; _mint(to, nounId); emit NounCreated(nounId, seed); } /** * @dev Reverts when `msg.sender` is not the owner of this contract; in the case of Noun DAOs it should be the * DAO's treasury contract. */ function _authorizeUpgrade(address) internal view override onlyOwner {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; }
// SPDX-License-Identifier: BSD-3-Clause /// @title Vote checkpointing for an ERC-721 token /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ // LICENSE // ERC721CheckpointableUpgradeable.sol is a modified version of ERC721Checkpointable.sol in this repository. // ERC721Checkpointable.sol uses and modifies part of Compound Lab's Comp.sol: // https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol // // Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // ERC721CheckpointableUpgradeable.sol MODIFICATIONS: // - Inherits from OpenZeppelin's ERC721EnumerableUpgradeable.sol, removing the original modification Nouns made to // ERC721.sol, where for each mint two Transfer events were emitted; this modified implementation sticks with the // OpenZeppelin standard. // - More importantly, this inheritance change makes the token upgradable, which we deemed important in the context of // forks, in order to give new Nouns forks enough of a chance to modify their contracts to the new DAO's needs. // - Fixes a critical bug in `delegateBySig`, where the previous version allowed delegating to address zero, which then // reverts whenever that owner tries to delegate anew or transfer their tokens. The fix is simply to revert on any // attempt to delegate to address zero. // // ERC721Checkpointable.sol MODIFICATIONS: // Checkpointing logic from Comp.sol has been used with the following modifications: // - `delegates` is renamed to `_delegates` and is set to private // - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike // Comp.sol, returns the delegator's own address if there is no delegate. // This avoids the delegator needing to "delegate to self" with an additional transaction // - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks. pragma solidity ^0.8.19; import { ERC721EnumerableUpgradeable } from '@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol'; abstract contract ERC721CheckpointableUpgradeable is ERC721EnumerableUpgradeable { /// @notice Defines decimals as per ERC-20 convention to make integrations with 3rd party governance platforms easier uint8 public constant decimals = 0; /// @notice A record of each accounts delegate mapping(address => address) private _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)'); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256('Delegation(address delegatee,uint256 nonce,uint256 expiry)'); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @notice The votes a delegator can delegate, which is the current balance of the delegator. * @dev Used when calling `_delegate()` */ function votesToDelegate(address delegator) public view returns (uint96) { return safe96(balanceOf(delegator), 'ERC721Checkpointable::votesToDelegate: amount exceeds 96 bits'); } /** * @notice Overrides the standard `Comp.sol` delegates mapping to return * the delegator's own address if they haven't delegated. * This avoids having to delegate to oneself. */ function delegates(address delegator) public view returns (address) { address current = _delegates[delegator]; return current == address(0) ? delegator : current; } /** * @notice Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes. * @dev hooks into OpenZeppelin's `ERC721._transfer` */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { super._beforeTokenTransfer(from, to, tokenId); /// @notice Differs from `_transferTokens()` to use `delegates` override method to simulate auto-delegation _moveDelegates(delegates(from), delegates(to), 1); } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { if (delegatee == address(0)) delegatee = msg.sender; return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public { require(delegatee != address(0), 'ERC721Checkpointable::delegateBySig: delegatee cannot be zero address'); bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), block.chainid, address(this)) ); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked('\x19\x01', domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), 'ERC721Checkpointable::delegateBySig: invalid signature'); require(nonce == nonces[signatory]++, 'ERC721Checkpointable::delegateBySig: invalid nonce'); require(block.timestamp <= expiry, 'ERC721Checkpointable::delegateBySig: signature expired'); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) { require(blockNumber < block.number, 'ERC721Checkpointable::getPriorVotes: not yet determined'); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation address currentDelegate = delegates(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); uint96 amount = votesToDelegate(delegator); _moveDelegates(currentDelegate, delegatee, amount); } function _moveDelegates( address srcRep, address dstRep, uint96 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, 'ERC721Checkpointable::_moveDelegates: amount underflows'); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, 'ERC721Checkpointable::_moveDelegates: amount overflows'); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes ) internal { uint32 blockNumber = safe32( block.number, 'ERC721Checkpointable::_writeCheckpoint: block number exceeds 32 bits' ); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } }
// SPDX-License-Identifier: GPL-3.0 /// @title Common interface for NounsDescriptor versions, as used by NounsToken and NounsSeeder. /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.6; import { INounsSeeder } from './INounsSeeder.sol'; interface INounsDescriptorMinimal { /// /// USED BY TOKEN /// function tokenURI(uint256 tokenId, INounsSeeder.Seed memory seed) external view returns (string memory); function dataURI(uint256 tokenId, INounsSeeder.Seed memory seed) external view returns (string memory); /// /// USED BY SEEDER /// function backgroundCount() external view returns (uint256); function bodyCount() external view returns (uint256); function accessoryCount() external view returns (uint256); function headCount() external view returns (uint256); function glassesCount() external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0 /// @title Interface for NounsSeeder /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.6; import { INounsDescriptorMinimal } from './INounsDescriptorMinimal.sol'; interface INounsSeeder { struct Seed { uint48 background; uint48 body; uint48 accessory; uint48 head; uint48 glasses; } function generateSeed(uint256 nounId, INounsDescriptorMinimal descriptor) external view returns (Seed memory); }
// SPDX-License-Identifier: GPL-3.0 /// @title Interface for NounsTokenFork /********************************* * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░██░░░████░░██░░░████░░░ * * ░░██████░░░████████░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░██░░██░░░████░░██░░░████░░░ * * ░░░░░░█████████░░█████████░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ * *********************************/ pragma solidity ^0.8.19; import { IERC721Upgradeable } from '@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol'; import { INounsDescriptorMinimal } from '../../../../interfaces/INounsDescriptorMinimal.sol'; import { INounsSeeder } from '../../../../interfaces/INounsSeeder.sol'; interface INounsTokenFork is IERC721Upgradeable { event NounCreated(uint256 indexed tokenId, INounsSeeder.Seed seed); event NounBurned(uint256 indexed tokenId); event MinterUpdated(address minter); event MinterLocked(); event DescriptorUpdated(INounsDescriptorMinimal descriptor); event DescriptorLocked(); event SeederUpdated(INounsSeeder seeder); event SeederLocked(); function mint() external returns (uint256); function burn(uint256 tokenId) external; function dataURI(uint256 tokenId) external returns (string memory); function setMinter(address minter) external; function lockMinter() external; function setDescriptor(INounsDescriptorMinimal descriptor) external; function lockDescriptor() external; function setSeeder(INounsSeeder seeder) external; function lockSeeder() external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is ERC1967Upgrade { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721Enumerable_init_unchained(); } function __ERC721Enumerable_init_unchained() internal initializer { } // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721Upgradeable.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } uint256[46] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "@ensdomains/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/@ensdomains/", "@nouns/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/@nouns/", "@openzeppelin/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/@openzeppelin/", "base64-sol/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/base64-sol/", "eth-gas-reporter/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/eth-gas-reporter/", "hardhat/=/Users/elad/code/nounsDAO/nouns-monorepo/node_modules/hardhat/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": { "contracts/governance/NounsDAOV3Admin.sol": { "NounsDAOV3Admin": "0xcf854bC50Cfb6dbaeD83b04E793F7Ee48B858CA6" }, "contracts/governance/NounsDAOV3DynamicQuorum.sol": { "NounsDAOV3DynamicQuorum": "0xcACc9629a8b283fF0e4EC34B1EB00Da0aEe6D42a" }, "contracts/governance/NounsDAOV3Proposals.sol": { "NounsDAOV3Proposals": "0x6A325F297B4F7A1BDB99918e21656cFE5b181fBc" }, "contracts/governance/NounsDAOV3Votes.sol": { "NounsDAOV3Votes": "0xeF902B590AeF42587DDFEc38C45549dB6C0144ca" }, "contracts/governance/fork/NounsDAOV3Fork.sol": { "NounsDAOV3Fork": "0x88e875e2ADa18245d442500388D701f6E0F4a78D" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AdminOnly","type":"error"},{"inputs":[],"name":"CanOnlyInitializeOnce","type":"error"},{"inputs":[],"name":"InvalidNounsAddress","type":"error"},{"inputs":[],"name":"InvalidTimelockAddress","type":"error"},{"inputs":[],"name":"MustProvideActions","type":"error"},{"inputs":[],"name":"ProposalInfoArityMismatch","type":"error"},{"inputs":[],"name":"ProposerAlreadyHasALiveProposal","type":"error"},{"inputs":[],"name":"TooManyActions","type":"error"},{"inputs":[],"name":"UnsafeUint16Cast","type":"error"},{"inputs":[],"name":"VotesBelowProposalThreshold","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"numTokens","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"DAONounsSupplyIncreasedFromEscrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"DAOWithdrawNounsFromEscrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"oldErc20Tokens","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"newErc20tokens","type":"address[]"}],"name":"ERC20TokensToIncludeInForkSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"forkId","type":"uint32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"proposalIds","type":"uint256[]"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"EscrowedToFork","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"forkId","type":"uint32"},{"indexed":false,"internalType":"address","name":"forkTreasury","type":"address"},{"indexed":false,"internalType":"address","name":"forkToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"forkEndTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensInEscrow","type":"uint256"}],"name":"ExecuteFork","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldForkDAODeployer","type":"address"},{"indexed":false,"internalType":"address","name":"newForkDAODeployer","type":"address"}],"name":"ForkDAODeployerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldForkPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newForkPeriod","type":"uint256"}],"name":"ForkPeriodSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldForkThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newForkThreshold","type":"uint256"}],"name":"ForkThresholdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"forkId","type":"uint32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"proposalIds","type":"uint256[]"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"JoinFork","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"oldLastMinuteWindowInBlocks","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"newLastMinuteWindowInBlocks","type":"uint32"}],"name":"LastMinuteWindowSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldMaxQuorumVotesBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newMaxQuorumVotesBPS","type":"uint16"}],"name":"MaxQuorumVotesBPSSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldMinQuorumVotesBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newMinQuorumVotesBPS","type":"uint16"}],"name":"MinQuorumVotesBPSSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingVetoer","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingVetoer","type":"address"}],"name":"NewPendingVetoer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldVetoer","type":"address"},{"indexed":false,"internalType":"address","name":"newVetoer","type":"address"}],"name":"NewVetoer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"oldObjectionPeriodDurationInBlocks","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"newObjectionPeriodDurationInBlocks","type":"uint32"}],"name":"ObjectionPeriodDurationSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProposalCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"string","name":"description","type":"string"}],"name":"ProposalCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProposalCreatedOnTimelockV1","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"signers","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"updatePeriodEndBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"proposalThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quorumVotes","type":"uint256"},{"indexed":false,"internalType":"string","name":"description","type":"string"}],"name":"ProposalCreatedWithRequirements","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"proposalThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quorumVotes","type":"uint256"},{"indexed":false,"internalType":"string","name":"description","type":"string"}],"name":"ProposalCreatedWithRequirements","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"string","name":"updateMessage","type":"string"}],"name":"ProposalDescriptionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProposalExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"objectionPeriodEndBlock","type":"uint256"}],"name":"ProposalObjectionPeriodSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eta","type":"uint256"}],"name":"ProposalQueued","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldProposalThresholdBPS","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newProposalThresholdBPS","type":"uint256"}],"name":"ProposalThresholdBPSSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"string","name":"updateMessage","type":"string"}],"name":"ProposalTransactionsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"oldProposalUpdatablePeriodInBlocks","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"newProposalUpdatablePeriodInBlocks","type":"uint32"}],"name":"ProposalUpdatablePeriodSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"string","name":"description","type":"string"},{"indexed":false,"internalType":"string","name":"updateMessage","type":"string"}],"name":"ProposalUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProposalVetoed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"oldQuorumCoefficient","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"newQuorumCoefficient","type":"uint32"}],"name":"QuorumCoefficientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldQuorumVotesBPS","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newQuorumVotesBPS","type":"uint256"}],"name":"QuorumVotesBPSSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"voter","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundAmount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"refundSent","type":"bool"}],"name":"RefundableVote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":false,"internalType":"bytes","name":"sig","type":"bytes"}],"name":"SignatureCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"timelock","type":"address"},{"indexed":false,"internalType":"address","name":"timelockV1","type":"address"},{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"TimelocksAndAdminSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"voter","type":"address"},{"indexed":false,"internalType":"uint256","name":"proposalId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"support","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"votes","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"VoteCast","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldVoteSnapshotBlockSwitchProposalId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVoteSnapshotBlockSwitchProposalId","type":"uint256"}],"name":"VoteSnapshotBlockSwitchProposalIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldVotingDelay","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVotingDelay","type":"uint256"}],"name":"VotingDelaySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldVotingPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVotingPeriod","type":"uint256"}],"name":"VotingPeriodSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"sent","type":"bool"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"forkId","type":"uint32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"WithdrawFromForkEscrow","type":"event"},{"inputs":[],"name":"MAX_PROPOSAL_THRESHOLD_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MAX_VOTING_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MAX_VOTING_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MIN_PROPOSAL_THRESHOLD_BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MIN_VOTING_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"MIN_VOTING_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"_acceptAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_acceptVetoer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_burnVetoPower","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMinQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"newMaxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"newQuorumCoefficient","type":"uint32"}],"name":"_setDynamicQuorumParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"erc20tokens","type":"address[]"}],"name":"_setErc20TokensToIncludeInFork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newForkDAODeployer","type":"address"}],"name":"_setForkDAODeployer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newForkEscrow","type":"address"}],"name":"_setForkEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forkEscrow_","type":"address"},{"internalType":"address","name":"forkDAODeployer_","type":"address"},{"internalType":"address[]","name":"erc20TokensToIncludeInFork_","type":"address[]"},{"internalType":"uint256","name":"forkPeriod_","type":"uint256"},{"internalType":"uint256","name":"forkThresholdBPS_","type":"uint256"}],"name":"_setForkParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newForkPeriod","type":"uint256"}],"name":"_setForkPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newForkThresholdBPS","type":"uint256"}],"name":"_setForkThresholdBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newLastMinuteWindowInBlocks","type":"uint32"}],"name":"_setLastMinuteWindowInBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMaxQuorumVotesBPS","type":"uint16"}],"name":"_setMaxQuorumVotesBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMinQuorumVotesBPS","type":"uint16"}],"name":"_setMinQuorumVotesBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newObjectionPeriodDurationInBlocks","type":"uint32"}],"name":"_setObjectionPeriodDurationInBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingVetoer","type":"address"}],"name":"_setPendingVetoer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newProposalThresholdBPS","type":"uint256"}],"name":"_setProposalThresholdBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newProposalUpdatablePeriodInBlocks","type":"uint32"}],"name":"_setProposalUpdatablePeriodInBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newQuorumCoefficient","type":"uint32"}],"name":"_setQuorumCoefficient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTimelock","type":"address"},{"internalType":"address","name":"newTimelockV1","type":"address"},{"internalType":"address","name":"newAdmin","type":"address"}],"name":"_setTimelocksAndAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_setVoteSnapshotBlockSwitchProposalId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newVotingDelay","type":"uint256"}],"name":"_setVotingDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newVotingPeriod","type":"uint256"}],"name":"_setVotingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"adjustedTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"cancelSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint8","name":"support","type":"uint8"}],"name":"castRefundableVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint8","name":"support","type":"uint8"},{"internalType":"string","name":"reason","type":"string"}],"name":"castRefundableVoteWithReason","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint8","name":"support","type":"uint8"}],"name":"castVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint8","name":"support","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"castVoteBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"uint8","name":"support","type":"uint8"},{"internalType":"string","name":"reason","type":"string"}],"name":"castVoteWithReason","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"againstVotes","type":"uint256"},{"internalType":"uint256","name":"adjustedTotalSupply_","type":"uint256"},{"components":[{"internalType":"uint16","name":"minQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"maxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"quorumCoefficient","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParams","name":"params","type":"tuple"}],"name":"dynamicQuorumVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"erc20TokensToIncludeInFork","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"proposalIds","type":"uint256[]"},{"internalType":"string","name":"reason","type":"string"}],"name":"escrowToFork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"executeFork","outputs":[{"internalType":"address","name":"forkTreasury","type":"address"},{"internalType":"address","name":"forkToken","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"executeOnTimelockV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"forkDAODeployer","outputs":[{"internalType":"contract IForkDAODeployer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forkEndTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forkEscrow","outputs":[{"internalType":"contract INounsDAOForkEscrow","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forkPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forkThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forkThresholdBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"getActions","outputs":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber_","type":"uint256"}],"name":"getDynamicQuorumParamsAt","outputs":[{"components":[{"internalType":"uint16","name":"minQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"maxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"quorumCoefficient","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParams","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"address","name":"voter","type":"address"}],"name":"getReceipt","outputs":[{"components":[{"internalType":"bool","name":"hasVoted","type":"bool"},{"internalType":"uint8","name":"support","type":"uint8"},{"internalType":"uint96","name":"votes","type":"uint96"}],"internalType":"struct NounsDAOStorageV3.Receipt","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"timelock_","type":"address"},{"internalType":"address","name":"nouns_","type":"address"},{"internalType":"address","name":"forkEscrow_","type":"address"},{"internalType":"address","name":"forkDAODeployer_","type":"address"},{"internalType":"address","name":"vetoer_","type":"address"},{"components":[{"internalType":"uint256","name":"votingPeriod","type":"uint256"},{"internalType":"uint256","name":"votingDelay","type":"uint256"},{"internalType":"uint256","name":"proposalThresholdBPS","type":"uint256"},{"internalType":"uint32","name":"lastMinuteWindowInBlocks","type":"uint32"},{"internalType":"uint32","name":"objectionPeriodDurationInBlocks","type":"uint32"},{"internalType":"uint32","name":"proposalUpdatablePeriodInBlocks","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.NounsDAOParams","name":"daoParams_","type":"tuple"},{"components":[{"internalType":"uint16","name":"minQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"maxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"quorumCoefficient","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParams","name":"dynamicQuorumParams_","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"proposalIds","type":"uint256[]"},{"internalType":"string","name":"reason","type":"string"}],"name":"joinFork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastMinuteWindowInBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"latestProposalIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxQuorumVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minQuorumVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nouns","outputs":[{"internalType":"contract NounsTokenLike","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTokensInForkEscrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"objectionPeriodDurationInBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingVetoer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposalCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposalMaxOperations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"proposalThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposalThresholdBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposalUpdatablePeriodInBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"proposals","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint256","name":"proposalThreshold","type":"uint256"},{"internalType":"uint256","name":"quorumVotes","type":"uint256"},{"internalType":"uint256","name":"eta","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"uint256","name":"forVotes","type":"uint256"},{"internalType":"uint256","name":"againstVotes","type":"uint256"},{"internalType":"uint256","name":"abstainVotes","type":"uint256"},{"internalType":"bool","name":"canceled","type":"bool"},{"internalType":"bool","name":"vetoed","type":"bool"},{"internalType":"bool","name":"executed","type":"bool"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"creationBlock","type":"uint256"}],"internalType":"struct NounsDAOStorageV2.ProposalCondensed","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"proposalsV3","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint256","name":"proposalThreshold","type":"uint256"},{"internalType":"uint256","name":"quorumVotes","type":"uint256"},{"internalType":"uint256","name":"eta","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"},{"internalType":"uint256","name":"forVotes","type":"uint256"},{"internalType":"uint256","name":"againstVotes","type":"uint256"},{"internalType":"uint256","name":"abstainVotes","type":"uint256"},{"internalType":"bool","name":"canceled","type":"bool"},{"internalType":"bool","name":"vetoed","type":"bool"},{"internalType":"bool","name":"executed","type":"bool"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"creationBlock","type":"uint256"},{"internalType":"address[]","name":"signers","type":"address[]"},{"internalType":"uint256","name":"updatePeriodEndBlock","type":"uint256"},{"internalType":"uint256","name":"objectionPeriodEndBlock","type":"uint256"},{"internalType":"bool","name":"executeOnTimelockV1","type":"bool"}],"internalType":"struct NounsDAOStorageV3.ProposalCondensed","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"description","type":"string"}],"name":"propose","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"uint256","name":"expirationTimestamp","type":"uint256"}],"internalType":"struct NounsDAOStorageV3.ProposerSignature[]","name":"proposerSignatures","type":"tuple[]"},{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"description","type":"string"}],"name":"proposeBySigs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"description","type":"string"}],"name":"proposeOnTimelockV1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"queue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"quorumParamsCheckpoints","outputs":[{"components":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"components":[{"internalType":"uint16","name":"minQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"maxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"quorumCoefficient","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParams","name":"params","type":"tuple"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParamsCheckpoint[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"quorumParamsCheckpoints","outputs":[{"components":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"components":[{"internalType":"uint16","name":"minQuorumVotesBPS","type":"uint16"},{"internalType":"uint16","name":"maxQuorumVotesBPS","type":"uint16"},{"internalType":"uint32","name":"quorumCoefficient","type":"uint32"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParams","name":"params","type":"tuple"}],"internalType":"struct NounsDAOStorageV3.DynamicQuorumParamsCheckpoint","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"quorumVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quorumVotesBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"state","outputs":[{"internalType":"enum NounsDAOStorageV3.ProposalState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelock","outputs":[{"internalType":"contract INounsDAOExecutor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelockV1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"updateMessage","type":"string"}],"name":"updateProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"components":[{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"uint256","name":"expirationTimestamp","type":"uint256"}],"internalType":"struct NounsDAOStorageV3.ProposerSignature[]","name":"proposerSignatures","type":"tuple[]"},{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"updateMessage","type":"string"}],"name":"updateProposalBySigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"updateMessage","type":"string"}],"name":"updateProposalDescription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"},{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"string[]","name":"signatures","type":"string[]"},{"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"internalType":"string","name":"updateMessage","type":"string"}],"name":"updateProposalTransactions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalId","type":"uint256"}],"name":"veto","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vetoer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voteSnapshotBlockSwitchProposalId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"votingDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"votingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawDAONounsFromEscrowIncreasingTotalSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"withdrawDAONounsFromEscrowToTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"withdrawFromForkEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b50615d5680620000216000396000f3fe6080604052600436106105065760003560e01c80637f5ef44511610297578063c3dd69eb11610165578063e23a9a52116100cc578063ea3ecd0f11610085578063ea3ecd0f14610fa6578063ec91deda14610fbb578063f32293d214610fdb578063f4b2a7d614610ff0578063f5f4714c14611005578063fe0d94c11461102557600080fd5b8063e23a9a5214610ed4578063e256077214610f24578063e2742e1814610f44578063e48083fe14610da5578063e5eb5abf14610f71578063e9c714f214610f9157600080fd5b8063d8bff4401161011e578063d8bff44014610e2c578063d93150be14610e4a578063da35c66414610e5f578063da9427c414610e74578063da95691a14610e94578063ddf0b00914610eb457600080fd5b8063c3dd69eb14610d85578063c82fbd0814610da5578063cd0d9eac14610db9578063d27dd11214610dce578063d33219b414610dee578063d3f662e114610e0c57600080fd5b8063a64e024a11610209578063b58131b0116101c2578063b58131b014610ccf578063b5cd5bfa14610ce4578063b71d1a0c14610d04578063bf7a296314610d24578063c10eb14d14610d39578063c37522d414610d6357600080fd5b8063a64e024a14610c2c578063a67d063514610c42578063a78b5f1a14610c60578063a9cf82f014610c80578063abb308b214610ca2578063b112626314610c2c57600080fd5b80638f1314b61161025b5780638f1314b614610b7957806390f8c2f414610b8e5780639547aecb14610bac57806397242b8e14610bcc57806397d048e514610bec5780639a0dfb5314610c0c57600080fd5b80637f5ef44514610aef5780637fa230bd14610b0a57806383cce0e114610b1f578063842e4dae14610b3457806384d1d19914610b5457600080fd5b80633e273334116103d457806355ce73b11161034657806377388b70116102ff57806377388b7014610a265780637757d18d14610a5b5780637a3da69114610a795780637b3c71d314610a995780637bdbe4d014610ab95780637d17aa3a14610acd57600080fd5b806355ce73b1146109635780635678138814610983578063590c1f16146109a357806364c05995146109c3578063705cb335146109e357806374b157b814610a0657600080fd5b806344fac8f61161039857806344fac8f6146108a157806347f4a077146108c157806349e857ea146108ee57806350196db31461090e578063533494131461092e5780635408e7f21461094357600080fd5b80633e273334146107ff5780633e4f49e6146108145780633fde324d1461084157806340e58ee51461086157806344697f981461088157600080fd5b80631e7b5d3a116104785780632df01bdb116104315780632df01bdb14610745578063328dd9821461076557806336a3b5781461079557806338b1c2f6146107aa5780633932abb1146107ca5780633bccf4fd146107df57600080fd5b80631e7b5d3a14610694578063215809ca146106a957806328aa53e4146106be5780632b5ca189146106de5780632cfc81c6146106fe5780632de45f181461071357600080fd5b8063116ce988116104ca578063116ce988146105c957806314a67ea4146105e957806316f1b8cf146105fe57806317977c611461061e5780631d28dec7146106545780631dfb1b5a1461067457600080fd5b8063013cf08b1461051257806302a251a31461054857806306ef9d36146105675780630ea2d98c146105895780630f7b1f08146105a957600080fd5b3661050d57005b600080fd5b34801561051e57600080fd5b5061053261052d366004613efc565b611045565b60405161053f9190613f15565b60405180910390f35b34801561055457600080fd5b506005545b60405190815260200161053f565b34801561057357600080fd5b50610587610582366004613efc565b61114f565b005b34801561059557600080fd5b506105876105a4366004613efc565b6111bd565b3480156105b557600080fd5b506105596105c4366004613efc565b6111fc565b3480156105d557600080fd5b506105876105e4366004613efc565b611208565b3480156105f557600080fd5b50600654610559565b34801561060a57600080fd5b506105596106193660046143ca565b611247565b34801561062a57600080fd5b506105596106393660046144be565b6001600160a01b03166000908152600c602052604090205490565b34801561066057600080fd5b5061058761066f366004613efc565b6112f1565b34801561068057600080fd5b5061058761068f366004613efc565b611330565b3480156106a057600080fd5b506103e8610559565b3480156106b557600080fd5b50611c20610559565b3480156106ca57600080fd5b506105876106d93660046144db565b61136f565b3480156106ea57600080fd5b506105876106f936600461459d565b61178c565b34801561070a57600080fd5b506105876117d0565b34801561071f57600080fd5b50600a546001600160a01b03165b6040516001600160a01b03909116815260200161053f565b34801561075157600080fd5b506105876107603660046144be565b611836565b34801561077157600080fd5b50610785610780366004613efc565b61187d565b60405161053f94939291906146c4565b3480156107a157600080fd5b5061055961189c565b3480156107b657600080fd5b506105596107c5366004614711565b611919565b3480156107d657600080fd5b50600454610559565b3480156107eb57600080fd5b506105876107fa3660046147f3565b61195b565b34801561080b57600080fd5b506105596119ec565b34801561082057600080fd5b5061083461082f366004613efc565b611a03565b60405161053f9190614857565b34801561084d57600080fd5b5061058761085c3660046148c7565b611a81565b34801561086d57600080fd5b5061058761087c366004613efc565b611af1565b34801561088d57600080fd5b5061058761089c366004614908565b611b30565b3480156108ad57600080fd5b506105876108bc366004614953565b611bb8565b3480156108cd57600080fd5b506108e16108dc366004613efc565b611c00565b60405161053f919061497f565b3480156108fa57600080fd5b506105876109093660046149f3565b611c28565b34801561091a57600080fd5b50610587610929366004614a3a565b611c64565b34801561093a57600080fd5b50601654610559565b34801561094f57600080fd5b5061058761095e366004614a55565b611ca6565b34801561096f57600080fd5b5061058761097e366004614a8c565b611d22565b34801561098f57600080fd5b5061058761099e366004614953565b611d60565b3480156109af57600080fd5b506105876109be366004614ad7565b611da8565b3480156109cf57600080fd5b506105876109de366004614b70565b611dec565b3480156109ef57600080fd5b50601054640100000000900463ffffffff16610559565b348015610a1257600080fd5b50610587610a2136600461459d565b611e62565b348015610a3257600080fd5b50610a3b611ea6565b604080516001600160a01b0393841681529290911660208301520161053f565b348015610a6757600080fd5b506011546001600160a01b031661072d565b348015610a8557600080fd5b50610587610a94366004614a3a565b611f26565b348015610aa557600080fd5b50610587610ab4366004614b70565b611f68565b348015610ac557600080fd5b50600a610559565b348015610ad957600080fd5b50601054600160401b900463ffffffff16610559565b348015610afb57600080fd5b5060105463ffffffff16610559565b348015610b1657600080fd5b50610559611fa8565b348015610b2b57600080fd5b50600754610559565b348015610b4057600080fd5b50610587610b4f366004613efc565b611fbf565b348015610b6057600080fd5b50601054600160601b90046001600160a01b031661072d565b348015610b8557600080fd5b50610559611ffe565b348015610b9a57600080fd5b506018546001600160a01b031661072d565b348015610bb857600080fd5b50610587610bc7366004614bc9565b61200a565b348015610bd857600080fd5b50610587610be7366004614c3f565b612203565b348015610bf857600080fd5b50610587610c07366004613efc565b61229d565b348015610c1857600080fd5b50610559610c27366004614d63565b6122dc565b348015610c3857600080fd5b50620189c0610559565b348015610c4e57600080fd5b50600e546001600160a01b031661072d565b348015610c6c57600080fd5b50610587610c7b3660046149f3565b61238c565b348015610c8c57600080fd5b50610c956123c8565b60405161053f9190614e1b565b348015610cae57600080fd5b50610cc2610cbd366004613efc565b61246e565b60405161053f9190614e69565b348015610cdb57600080fd5b5061055961251b565b348015610cf057600080fd5b50610587610cff366004614ad7565b612532565b348015610d1057600080fd5b50610587610d1f3660046144be565b612576565b348015610d3057600080fd5b506105876125bd565b348015610d4557600080fd5b50610d4e6125f5565b6040805192835290151560208301520161053f565b348015610d6f57600080fd5b50610d7861266d565b60405161053f9190614e77565b348015610d9157600080fd5b50610587610da0366004614e8a565b6126d2565b348015610db157600080fd5b506001610559565b348015610dc557600080fd5b50610559612714565b348015610dda57600080fd5b50610587610de93660046149f3565b61274f565b348015610dfa57600080fd5b506009546001600160a01b031661072d565b348015610e1857600080fd5b50610587610e273660046144be565b61278b565b348015610e3857600080fd5b506003546001600160a01b031661072d565b348015610e5657600080fd5b50601554610559565b348015610e6b57600080fd5b50600854610559565b348015610e8057600080fd5b50610587610e8f366004614f03565b6127d2565b348015610ea057600080fd5b50610559610eaf366004614711565b612818565b348015610ec057600080fd5b50610587610ecf366004613efc565b612850565b348015610ee057600080fd5b50610ef4610eef366004615002565b61288f565b6040805182511515815260208084015160ff1690820152918101516001600160601b03169082015260600161053f565b348015610f3057600080fd5b50610587610f3f36600461459d565b61291b565b348015610f5057600080fd5b50610f64610f5f366004613efc565b61295f565b60405161053f9190615032565b348015610f7d57600080fd5b50610587610f8c36600461459d565b612a84565b348015610f9d57600080fd5b50610587612ac8565b348015610fb257600080fd5b50601954610559565b348015610fc757600080fd5b50610587610fd6366004615161565b612b00565b348015610fe757600080fd5b50601754610559565b348015610ffc57600080fd5b50610587612b56565b34801561101157600080fd5b506105876110203660046144be565b612b8e565b34801561103157600080fd5b50610587611040366004613efc565b612bd5565b6110cd604051806101e001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160001515815260200160008152602001600081525090565b6040516310549af960e21b81526000600482015260248101839052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906341526be4906044016101e060405180830381865af4158015611125573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114991906151bf565b92915050565b6040516349e2f96f60e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906393c5f2de906044015b60006040518083038186803b1580156111a257600080fd5b505af41580156111b6573d6000803e3d6000fd5b5050505050565b60405163adb8355760e01b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063adb835579060440161118a565b60006111498183612c14565b6040516311b5760360e31b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc90638dabb0189060440161118a565b6040805160808101825286815260208101869052808201859052606081018490529051630c2d20bb60e21b8152600091736a325f297b4f7a1bdb99918e21656cfe5b181fbc916330b482ec916112a59185918c9188906004016153bc565b602060405180830381865af41580156112c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e691906153fb565b979650505050505050565b604051636c1578c760e01b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc90636c1578c79060440161118a565b60405163a79aaf2760e01b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a79aaf279060440161118a565b6009546001600160a01b03161561139957604051630205737f60e61b815260040160405180910390fd5b6000546001600160a01b031633146113c457604051633057182d60e21b815260040160405180910390fd5b6001600160a01b0387166113eb57604051637330d04160e11b815260040160405180910390fd5b6001600160a01b0386166114125760405163d2ef0d7160e01b815260040160405180910390fd5b60405163adb8355760e01b8152600060048201528235602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063adb835579060440160006040518083038186803b15801561146457600080fd5b505af4158015611478573d6000803e3d6000fd5b505060405163a79aaf2760e01b8152600060048201526020850135602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063a79aaf27915060440160006040518083038186803b1580156114d157600080fd5b505af41580156114e5573d6000803e3d6000fd5b50506040805163796871d560e11b81526000600482015290850135602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063f2d0e3aa915060440160006040518083038186803b15801561153e57600080fd5b505af4158015611552573d6000803e3d6000fd5b5050600980546001600160a01b03199081166001600160a01b038c811691909117909255600a805482168b8416179055601080546001600160601b0316600160601b8b85160217905560118054821689841617905560038054909116918716919091179055506115ea90506115ca6020830183614a3a565b6115da6040840160208501614a3a565b610fd6606085016040860161459d565b73cf854bc50cfb6dbaed83b04e793f7ee48b858ca66385a38d346000611616608086016060870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff16602482015260440160006040518083038186803b15801561165857600080fd5b505af415801561166c573d6000803e3d6000fd5b5073cf854bc50cfb6dbaed83b04e793f7ee48b858ca69250638474893a91506000905061169f60a086016080870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff16602482015260440160006040518083038186803b1580156116e157600080fd5b505af41580156116f5573d6000803e3d6000fd5b5073cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063931938d991506000905061172860c0860160a0870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff1660248201526044015b60006040518083038186803b15801561176b57600080fd5b505af415801561177f573d6000803e3d6000fd5b5050505050505050505050565b60405163bd43440760e01b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063bd4344079060440161118a565b60405163a1ef30a160e01b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a1ef30a1906024015b60006040518083038186803b15801561181c57600080fd5b505af4158015611830573d6000803e3d6000fd5b50505050565b60405163a77238a560e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a77238a59060440161118a565b606080808061188d600086612c70565b93509350935093509193509193565b604051631fb0a1ab60e11b8152600060048201819052907388e875e2ada18245d442500388d701f6e0f4a78d90633f614356906024015b602060405180830381865af41580156118f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191491906153fb565b905090565b6000611951604051806080016040528088815260200187815260200186815260200185815250836000612f059092919063ffffffff16565b9695505050505050565b604051637b784a4960e01b8152600060048201526024810186905260ff8086166044830152841660648201526084810183905260a4810182905273ef902b590aef42587ddfec38c45549db6c0144ca90637b784a499060c4015b60006040518083038186803b1580156119cd57600080fd5b505af41580156119e1573d6000803e3d6000fd5b505050505050505050565b60006119146119fb6000612f7a565b6000906130f6565b604051630390952560e11b81526000600482018190526024820183905290736a325f297b4f7a1bdb99918e21656cfe5b181fbc906307212a4a90604401602060405180830381865af4158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111499190615414565b6040516333fb311b60e21b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063cfecc46c90611abd906000908690869060040161545e565b60006040518083038186803b158015611ad557600080fd5b505af4158015611ae9573d6000803e3d6000fd5b505050505050565b60405163121069ef60e31b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906390834f789060440161118a565b604051635c97764960e01b8152600060048201526001600160a01b03808516602483015280841660448301528216606482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690635c977649906084015b60006040518083038186803b158015611b9b57600080fd5b505af4158015611baf573d6000803e3d6000fd5b50505050505050565b60405163473501b760e11b8152600060048201526024810183905260ff8216604482015273ef902b590aef42587ddfec38c45549db6c0144ca90638e6a036e90606401611abd565b6040805160608101825260008082526020820181905291810191909152611149600083613110565b604051633fcfd14760e01b81527388e875e2ada18245d442500388d701f6e0f4a78d90633fcfd14790611abd90600090869086906004016154aa565b604051632a38c7b160e01b81526000600482015261ffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690632a38c7b19060440161118a565b604051631167d67160e21b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063459f59c490611cea906000908a908a908a908a908a908a906004016154c4565b60006040518083038186803b158015611d0257600080fd5b505af4158015611d16573d6000803e3d6000fd5b50505050505050505050565b60405163e6b8f0af60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063e6b8f0af90611b839060009087908790879060040161553f565b60405163233a163f60e11b8152600060048201526024810183905260ff8216604482015273ef902b590aef42587ddfec38c45549db6c0144ca906346742c7e90606401611abd565b60405163bcac609f60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063bcac609f90611cea906000908a908a908a908a908a908a90600401615572565b6040516346aec09d60e01b815273ef902b590aef42587ddfec38c45549db6c0144ca906346aec09d90611e2c9060009088908890889088906004016155b4565b60006040518083038186803b158015611e4457600080fd5b505af4158015611e58573d6000803e3d6000fd5b5050505050505050565b60405163931938d960e01b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063931938d99060440161118a565b6040516305a15c8360e21b81526000600482018190529081907388e875e2ada18245d442500388d701f6e0f4a78d90631685720c906024016040805180830381865af4158015611efa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1e91906155dd565b915091509091565b6040516380ffd06b60e01b81526000600482015261ffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906380ffd06b9060440161118a565b6040516392a364c960e01b815273ef902b590aef42587ddfec38c45549db6c0144ca906392a364c990611e2c9060009088908890889088906004016155b4565b6000611914611fb76000612f7a565b600090613425565b604051635752203b60e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063aea440769060440161118a565b60006119146000612f7a565b60405163a77238a560e01b8152600060048201526001600160a01b038716602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a77238a59060440160006040518083038186803b15801561206457600080fd5b505af4158015612078573d6000803e3d6000fd5b50506040516302d548bf60e01b8152600060048201526001600160a01b038816602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca692506302d548bf915060440160006040518083038186803b1580156120d657600080fd5b505af41580156120ea573d6000803e3d6000fd5b5050604051634762cea160e01b815273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69250634762cea1915061212a906000908890889060040161560c565b60006040518083038186803b15801561214257600080fd5b505af4158015612156573d6000803e3d6000fd5b5050604051635752203b60e11b8152600060048201526024810185905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063aea44076915060440160006040518083038186803b1580156121ac57600080fd5b505af41580156121c0573d6000803e3d6000fd5b50506040516349e2f96f60e11b8152600060048201526024810184905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca692506393c5f2de9150604401611cea565b604080516080810182528781526020810187905280820186905260608101859052905163e473627360e01b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9163e473627391612263916000918d918d9189908990600401615664565b60006040518083038186803b15801561227b57600080fd5b505af415801561228f573d6000803e3d6000fd5b505050505050505050505050565b60405163796871d560e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063f2d0e3aa9060440161118a565b6040805163af7d88eb60e01b81526004810185905260248101849052825161ffff908116604483015260208401511660648201529082015163ffffffff16608482015260009073cacc9629a8b283ff0e4ec34b1eb00da0aee6d42a9063af7d88eb9060a401602060405180830381865af415801561235e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238291906153fb565b90505b9392505050565b604051634762cea160e01b815273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690634762cea190611abd906000908690869060040161560c565b60606000600d01805480602002602001604051908101604052809291908181526020016000905b8282101561246557600084815260209081902060408051808201825260028602909201805463ffffffff9081168452825160608101845260019283015461ffff808216835262010000820416828801526401000000009004909116928101929092528284019190915290835290920191016123ef565b50505050905090565b6124a160408051808201825260008082528251606081018452818152602081810183905293810191909152909182015290565b600d8054839081106124b5576124b56156ca565b60009182526020918290206040805180820182526002909302909101805463ffffffff9081168452825160608101845260019092015461ffff80821684526201000082041683870152640100000000900416918101919091529181019190915292915050565b600061191461252a6000612f7a565b600090613442565b60405163fe5cebdb60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063fe5cebdb90611cea906000908a908a908a908a908a908a90600401615572565b6040516354afee2160e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906354afee219060440161118a565b60405163117f658d60e01b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063117f658d90602401611804565b604051633fba359560e01b815260006004820181905290819073cf854bc50cfb6dbaed83b04e793f7ee48b858ca690633fba3595906024016040805180830381865af4158015612649573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1e91906156e0565b606060006012018054806020026020016040519081016040528092919081815260200182805480156126c857602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126aa575b5050505050905090565b60405163e54ab2b960e01b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063e54ab2b9906119b59060009089908990899089908990600401615703565b604051633840c95f60e01b8152600060048201819052907388e875e2ada18245d442500388d701f6e0f4a78d90633840c95f906024016118d3565b60405163e46aa49560e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063e46aa49590611abd90600090869086906004016154aa565b60405163850da8bf60e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063850da8bf9060440161118a565b604051630d2f400360e31b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063697a001890611753906000908b908b908b908b908b908b908b90600401615736565b60006119516040518060800160405280888152602001878152602001868152602001858152508360006134529092919063ffffffff16565b604051634215da8560e11b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063842bb50a9060440161118a565b604080516060808201835260008083526020808401829052838501829052845180840186528281528082018390528501829052868252600b81528482206001600160a01b0387168352600f01815290849020845192830185525460ff80821615158452610100820416918301919091526201000090046001600160601b03169281019290925290612385565b604051632168e34d60e21b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906385a38d349060440161118a565b612a056040518061026001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160001515815260200160008152602001600081526020016060815260200160008152602001600081526020016000151581525090565b60405163100e0d6d60e01b81526000600482015260248101839052736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063100e0d6d90604401600060405180830381865af4158015612a5c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611149919081019061582d565b60405163423a449d60e11b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690638474893a9060440161118a565b60405163096d03f360e21b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906325b40fcc90602401611804565b6040516327b5eff560e01b81526000600482015261ffff80851660248301528316604482015263ffffffff8216606482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906327b5eff590608401611b83565b604051630712073760e51b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063e240e6e090602401611804565b6040516302d548bf60e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906302d548bf9060440161118a565b6040516377aaa1bb60e01b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906377aaa1bb9060440161118a565b6000818152600b83016020526040812060108101548203612c3a57600301549050611149565b600c81015460108201546011830154612c68929190612c639088906001600160401b0316613110565b61358b565b949350505050565b606080606080600086600b01600087815260200190815260200160002090508060050181600601826007018360080183805480602002602001604051908101604052809291908181526020018280548015612cf457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612cd6575b5050505050935082805480602002602001604051908101604052809291908181526020018280548015612d4657602002820191906000526020600020905b815481526020019060010190808311612d32575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b82821015612e1a578382906000526020600020018054612d8d90615985565b80601f0160208091040260200160405190810160405280929190818152602001828054612db990615985565b8015612e065780601f10612ddb57610100808354040283529160200191612e06565b820191906000526020600020905b815481529060010190602001808311612de957829003601f168201915b505050505081526020019060010190612d6e565b50505050915080805480602002602001604051908101604052809291908181526020016000905b82821015612eed578382906000526020600020018054612e6090615985565b80601f0160208091040260200160405190810160405280929190818152602001828054612e8c90615985565b8015612ed95780601f10612eae57610100808354040283529160200191612ed9565b820191906000526020600020905b815481529060010190602001808311612ebc57829003601f168201915b505050505081526020019060010190612e41565b50505050905094509450945094505092959194509250565b600080612f13858585613452565b6000818152600b870160205260409081902060138101805460ff191660011790559051919250907f9fb4e5204ac554428e5c744568b78732c229c76c0b5eaebdca7171c41366f6af90612f699084815260200190565b60405180910390a150949350505050565b600081601001600c9054906101000a90046001600160a01b03166001600160a01b0316639b3c1e226040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ff591906153fb565b600a83015460098401546040516370a0823160e01b81526001600160a01b0391821660048201529116906370a0823190602401602060405180830381865afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306991906153fb565b83600a0160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e291906153fb565b6130ec91906159d5565b61114991906159d5565b60006123856131058443613110565b5161ffff1683613613565b6040805160608101825260008082526020820181905291810191909152600061315183604051806060016040528060408152602001615ce16040913961362c565b600d85015490915060008190036131a857604051806060016040528061317a8760070154613665565b61ffff1681526020016131908760070154613665565b61ffff16815260006020909101529250611149915050565b63ffffffff8216600d86016131be6001846159d5565b815481106131ce576131ce6156ca565b600091825260209091206002909102015463ffffffff161161326157600d85016131f96001836159d5565b81548110613209576132096156ca565b6000918252602091829020604080516060810182526002939093029091016001015461ffff8082168452620100008204169383019390935264010000000090920463ffffffff16918101919091529250611149915050565b8163ffffffff1685600d0160008154811061327e5761327e6156ca565b600091825260209091206002909102015463ffffffff1611156132b357604051806060016040528061317a8760070154613665565b6000806132c16001846159d5565b90505b818111156133b757600060026132da84846159d5565b6132e491906159e8565b6132ee90836159d5565b9050600088600d018281548110613307576133076156ca565b60009182526020918290206040805180820182526002909302909101805463ffffffff9081168452825160608101845260019092015461ffff80821684526201000082041683870152640100000000900481169282019290925292820192909252805190925087821691160361338857602001519550611149945050505050565b805163ffffffff808816911610156133a2578193506133b0565b6133ad6001836159d5565b92505b50506132c4565b86600d0182815481106133cc576133cc6156ca565b6000918252602091829020604080516060810182526002939093029091016001015461ffff8082168452620100008204169383019390935264010000000090920463ffffffff1691810191909152979650505050505050565b60006123856134348443613110565b6020015161ffff1683613613565b6000612385836006015483613613565b60008061345e85612f7a565b600a8601549091506000906135059087906001600160a01b031663782d6fe1336134896001436159d5565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa1580156134d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134f69190615a0a565b6001600160601b03168461368e565b9050613510856136bc565b61351a8633613753565b60008660080154600161352d9190615a33565b8760080181905590506000613545888385878b61380e565b336000908152600c8a0160209081526040808320869055805192835290820190529091506135809082906135798b886130f6565b8a8a613968565b509695505050505050565b6000808361359b86612710615a46565b6135a591906159e8565b90506000620f424082856040015163ffffffff166135c39190615a46565b6135cd91906159e8565b9050600081856000015161ffff166135e59190615a33565b905060006135fb866020015161ffff1683613a58565b90506136078188613613565b98975050505050505050565b60006127106136228484615a46565b61238591906159e8565b60008163ffffffff84111561365d5760405162461bcd60e51b81526004016136549190615a5d565b60405180910390fd5b509192915050565b600061ffff82111561368a5760405163555abf0160e11b815260040160405180910390fd5b5090565b600061369a8483613442565b90508083116123855760405163ead8241560e01b815260040160405180910390fd5b6020810151518151511415806136d9575060408101515181515114155b806136eb575060608101515181515114155b156137095760405163ccb0ce3f60e01b815260040160405180910390fd5b80515160000361372c57604051630f24cd7360e01b815260040160405180910390fd5b805151600a1015613750576040516308e3b1eb60e11b815260040160405180910390fd5b50565b6001600160a01b0381166000908152600c8301602052604090205480156138095760006137808483613a6e565b9050600981600a81111561379657613796614841565b14806137b35750600181600a8111156137b1576137b1614841565b145b806137cf5750600081600a8111156137cd576137cd614841565b145b806137eb5750600a81600a8111156137e9576137e9614841565b145b15611830576040516306bee79560e01b815260040160405180910390fd5b505050565b601085015460009081906138389061383390600160401b900463ffffffff1643615a33565b613c67565b905060008760040154826001600160401b03166138559190615a33565b905060008860050154826138699190615a33565b6000898152600b8b01602090815260409091208a81556001810180546001600160a01b03191633179055600281018a9055875180519197509293506138b49260058801920190613d33565b5060208086015180516138cd9260068801920190613d94565b50604085015180516138e9916007870191602090910190613dcf565b5060608501518051613905916008870191602090910190613e21565b5060098401829055600a84018190556010840186905561392443613c67565b6011850180546001600160401b039283166fffffffffffffffffffffffffffffffff1990911617600160401b95909216949094021790925550909695505050505050565b7f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e085600001543384600001518560200151866040015187606001518b600901548c600a0154896040516139c399989796959493929190615a70565b60405180910390a17f0cc4b35cbed68ce6ca5b3e6560894c6ccc309603ed423fa45554c837dd9a06aa8560000154338685600001518660200151876040015188606001518c600901548d600a01548e60110160089054906101000a90046001600160401b03168f600201548e8d604051613a499d9c9b9a99989796959493929190615b08565b60405180910390a15050505050565b6000818310613a675781612385565b5090919050565b60008183600801541015613ad05760405162461bcd60e51b8152602060048201526024808201527f4e6f756e7344414f3a3a73746174653a20696e76616c69642070726f706f73616044820152631b081a5960e21b6064820152608401613654565b6000828152600b840160205260409020600e810154610100900460ff1615613afc576008915050611149565b600e81015460ff1615613b13576002915050611149565b6011810154600160401b90046001600160401b03164311613b3857600a915050611149565b80600901544311613b4d576000915050611149565b80600a01544311613b62576001915050611149565b6011810154600160801b90046001600160401b03164311613b87576009915050611149565b613b918482613ccf565b15613ba0576003915050611149565b8060040154600003613bb6576004915050611149565b600e81015462010000900460ff1615613bd3576007915050611149565b613bdd8482613cfb565b6001600160a01b031663c1a287e26040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c3e91906153fb565b8160040154613c4d9190615a33565b4210613c5d576006915050611149565b6005915050611149565b60006001600160401b0382111561368a5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401613654565b600b810154600c8201546000919081111580612c6857508254613cf3908590612c14565b119392505050565b601381015460009060ff1615613d1f575060188201546001600160a01b0316611149565b5060098201546001600160a01b0316611149565b828054828255906000526020600020908101928215613d88579160200282015b82811115613d8857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613d53565b5061368a929150613e73565b828054828255906000526020600020908101928215613d88579160200282015b82811115613d88578251825591602001919060010190613db4565b828054828255906000526020600020908101928215613e15579160200282015b82811115613e155782518290613e059082615c21565b5091602001919060010190613def565b5061368a929150613e88565b828054828255906000526020600020908101928215613e67579160200282015b82811115613e675782518290613e579082615c21565b5091602001919060010190613e41565b5061368a929150613ea5565b5b8082111561368a5760008155600101613e74565b8082111561368a576000613e9c8282613ec2565b50600101613e88565b8082111561368a576000613eb98282613ec2565b50600101613ea5565b508054613ece90615985565b6000825580601f10613ede575050565b601f0160209004906000526020600020908101906137509190613e73565b600060208284031215613f0e57600080fd5b5035919050565b815181526020808301516101e0830191613f39908401826001600160a01b03169052565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525061014080840151613fa28285018215159052565b505061016083810151151590830152610180808401511515908301526101a080840151908301526101c092830151929091019190915290565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561401357614013613fdb565b60405290565b6040516101e081016001600160401b038111828210171561401357614013613fdb565b60405161026081016001600160401b038111828210171561401357614013613fdb565b604051601f8201601f191681016001600160401b038111828210171561408757614087613fdb565b604052919050565b60006001600160401b038211156140a8576140a8613fdb565b5060051b60200190565b600082601f8301126140c357600080fd5b81356001600160401b038111156140dc576140dc613fdb565b6140ef601f8201601f191660200161405f565b81815284602083860101111561410457600080fd5b816020850160208301376000918101602001919091529392505050565b6001600160a01b038116811461375057600080fd5b600082601f83011261414757600080fd5b8135602061415c6141578361408f565b61405f565b82815260059290921b8401810191818101908684111561417b57600080fd5b8286015b848110156135805780356001600160401b038082111561419f5760008081fd5b908801906060828b03601f19018113156141b95760008081fd5b6141c1613ff1565b87840135838111156141d35760008081fd5b6141e18d8a838801016140b2565b82525060409250828401356141f581614121565b8189015292013590820152835291830191830161417f565b600082601f83011261421e57600080fd5b8135602061422e6141578361408f565b82815260059290921b8401810191818101908684111561424d57600080fd5b8286015b8481101561358057803561426481614121565b8352918301918301614251565b600082601f83011261428257600080fd5b813560206142926141578361408f565b82815260059290921b840181019181810190868411156142b157600080fd5b8286015b8481101561358057803583529183019183016142b5565b600082601f8301126142dd57600080fd5b813560206142ed6141578361408f565b82815260059290921b8401810191818101908684111561430c57600080fd5b8286015b848110156135805780356001600160401b0381111561432f5760008081fd5b61433d8986838b01016140b2565b845250918301918301614310565b600082601f83011261435c57600080fd5b8135602061436c6141578361408f565b82815260059290921b8401810191818101908684111561438b57600080fd5b8286015b848110156135805780356001600160401b038111156143ae5760008081fd5b6143bc8986838b01016140b2565b84525091830191830161438f565b60008060008060008060c087890312156143e357600080fd5b86356001600160401b03808211156143fa57600080fd5b6144068a838b01614136565b9750602089013591508082111561441c57600080fd5b6144288a838b0161420d565b9650604089013591508082111561443e57600080fd5b61444a8a838b01614271565b9550606089013591508082111561446057600080fd5b61446c8a838b016142cc565b9450608089013591508082111561448257600080fd5b61448e8a838b0161434b565b935060a08901359150808211156144a457600080fd5b506144b189828a016140b2565b9150509295509295509295565b6000602082840312156144d057600080fd5b813561238581614121565b60008060008060008060008789036101c08112156144f857600080fd5b883561450381614121565b9750602089013561451381614121565b9650604089013561452381614121565b9550606089013561453381614121565b9450608089013561454381614121565b935060c0609f198201121561455757600080fd5b60a089019250606061015f198201121561457057600080fd5b506101608801905092959891949750929550565b803563ffffffff8116811461459857600080fd5b919050565b6000602082840312156145af57600080fd5b61238582614584565b600081518084526020808501945080840160005b838110156145f15781516001600160a01b0316875295820195908201906001016145cc565b509495945050505050565b600081518084526020808501945080840160005b838110156145f157815187529582019590820190600101614610565b6000815180845260005b8181101561465257602081850181015186830182015201614636565b506000602082860101526020601f19601f83011685010191505092915050565b6000815180845260208085019450848260051b860182860160005b858110156146b75783830389526146a583835161462c565b9885019892509084019060010161468d565b5090979650505050505050565b6080815260006146d760808301876145b8565b82810360208401526146e981876145fc565b905082810360408401526146fd8186614672565b905082810360608401526112e68185614672565b600080600080600060a0868803121561472957600080fd5b85356001600160401b038082111561474057600080fd5b61474c89838a0161420d565b9650602088013591508082111561476257600080fd5b61476e89838a01614271565b9550604088013591508082111561478457600080fd5b61479089838a016142cc565b945060608801359150808211156147a657600080fd5b6147b289838a0161434b565b935060808801359150808211156147c857600080fd5b506147d5888289016140b2565b9150509295509295909350565b803560ff8116811461459857600080fd5b600080600080600060a0868803121561480b57600080fd5b8535945061481b602087016147e2565b9350614829604087016147e2565b94979396509394606081013594506080013592915050565b634e487b7160e01b600052602160045260246000fd5b60208101600b831061487957634e487b7160e01b600052602160045260246000fd5b91905290565b60008083601f84011261489157600080fd5b5081356001600160401b038111156148a857600080fd5b6020830191508360208285010111156148c057600080fd5b9250929050565b600080602083850312156148da57600080fd5b82356001600160401b038111156148f057600080fd5b6148fc8582860161487f565b90969095509350505050565b60008060006060848603121561491d57600080fd5b833561492881614121565b9250602084013561493881614121565b9150604084013561494881614121565b809150509250925092565b6000806040838503121561496657600080fd5b82359150614976602084016147e2565b90509250929050565b815161ffff90811682526020808401519091169082015260408083015163ffffffff169082015260608101611149565b60008083601f8401126149c157600080fd5b5081356001600160401b038111156149d857600080fd5b6020830191508360208260051b85010111156148c057600080fd5b60008060208385031215614a0657600080fd5b82356001600160401b03811115614a1c57600080fd5b6148fc858286016149af565b803561ffff8116811461459857600080fd5b600060208284031215614a4c57600080fd5b61238582614a28565b60008060008060008060c08789031215614a6e57600080fd5b8635955060208701356001600160401b038082111561441c57600080fd5b600080600060408486031215614aa157600080fd5b83356001600160401b03811115614ab757600080fd5b614ac3868287016149af565b909450925050602084013561494881614121565b60008060008060008060608789031215614af057600080fd5b86356001600160401b0380821115614b0757600080fd5b614b138a838b016149af565b90985096506020890135915080821115614b2c57600080fd5b614b388a838b016149af565b90965094506040890135915080821115614b5157600080fd5b50614b5e89828a0161487f565b979a9699509497509295939492505050565b60008060008060608587031215614b8657600080fd5b84359350614b96602086016147e2565b925060408501356001600160401b03811115614bb157600080fd5b614bbd8782880161487f565b95989497509550505050565b60008060008060008060a08789031215614be257600080fd5b8635614bed81614121565b95506020870135614bfd81614121565b945060408701356001600160401b03811115614c1857600080fd5b614c2489828a016149af565b979a9699509760608101359660809091013595509350505050565b600080600080600080600080610100898b031215614c5c57600080fd5b8835975060208901356001600160401b0380821115614c7a57600080fd5b614c868c838d01614136565b985060408b0135915080821115614c9c57600080fd5b614ca88c838d0161420d565b975060608b0135915080821115614cbe57600080fd5b614cca8c838d01614271565b965060808b0135915080821115614ce057600080fd5b614cec8c838d016142cc565b955060a08b0135915080821115614d0257600080fd5b614d0e8c838d0161434b565b945060c08b0135915080821115614d2457600080fd5b614d308c838d016140b2565b935060e08b0135915080821115614d4657600080fd5b50614d538b828c016140b2565b9150509295985092959890939650565b600080600083850360a0811215614d7957600080fd5b84359350602085013592506060603f1982011215614d9657600080fd5b50614d9f613ff1565b614dab60408601614a28565b8152614db960608601614a28565b6020820152614dca60808601614584565b6040820152809150509250925092565b63ffffffff81511682526020810151613809602084018261ffff8082511683528060208301511660208401525063ffffffff60408201511660408301525050565b6020808252825182820181905260009190848201906040850190845b81811015614e5d57614e4a838551614dda565b9284019260809290920191600101614e37565b50909695505050505050565b608081016111498284614dda565b60208152600061238560208301846145b8565b600080600080600060608688031215614ea257600080fd5b8535945060208601356001600160401b0380821115614ec057600080fd5b614ecc89838a0161487f565b90965094506040880135915080821115614ee557600080fd5b50614ef28882890161487f565b969995985093965092949392505050565b600080600080600080600060e0888a031215614f1e57600080fd5b8735965060208801356001600160401b0380821115614f3c57600080fd5b614f488b838c0161420d565b975060408a0135915080821115614f5e57600080fd5b614f6a8b838c01614271565b965060608a0135915080821115614f8057600080fd5b614f8c8b838c016142cc565b955060808a0135915080821115614fa257600080fd5b614fae8b838c0161434b565b945060a08a0135915080821115614fc457600080fd5b614fd08b838c016140b2565b935060c08a0135915080821115614fe657600080fd5b50614ff38a828b016140b2565b91505092959891949750929550565b6000806040838503121561501557600080fd5b82359150602083013561502781614121565b809150509250929050565b60208152815160208201526000602083015161505960408401826001600160a01b03169052565b506040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c083015160e083015260e08301516101008181850152808501519150506101208181850152808501519150506101408181850152808501519150506101606150ce8185018315159052565b84015190506101806150e38482018315159052565b84015190506101a06150f88482018315159052565b8401516101c0848101919091528401516101e080850191909152840151610260610200808601829052919250906151336102808601846145b8565b9086015161022086810191909152860151610240808701919091529095015115159301929092525090919050565b60008060006060848603121561517657600080fd5b61517f84614a28565b925061518d60208501614a28565b915061519b60408501614584565b90509250925092565b805161459881614121565b8051801515811461459857600080fd5b60006101e082840312156151d257600080fd5b6151da614019565b825181526151ea602084016151a4565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406152518185016151af565b908201526101606152638482016151af565b908201526101806152758482016151af565b908201526101a083810151908201526101c0928301519281019290925250919050565b6000815180845260208085019450848260051b860182860160005b858110156146b75783830389528151606081518186526152d58287018261462c565b838901516001600160a01b0316878a01526040938401519390960192909252505097840197908401906001016152b3565b600082825180855260208086019550808260051b84010181860160005b848110156146b757601f1986840301895261533f83835161462c565b98840198925090830190600101615323565b600081516080845261536660808501826145b8565b90506020830151848203602086015261537f82826145fc565b915050604083015184820360408601526153998282615306565b915050606083015184820360608601526153b38282614672565b95945050505050565b8481526080602082015260006153d56080830186615298565b82810360408401526153e78186615351565b905082810360608401526112e6818561462c565b60006020828403121561540d57600080fd5b5051919050565b60006020828403121561542657600080fd5b8151600b811061238557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006153b3604083018486615435565b81835260006001600160fb1b0383111561549157600080fd5b8260051b80836020870137939093016020019392505050565b8381526040602082015260006153b3604083018486615478565b87815286602082015260e0604082015260006154e360e08301886145b8565b82810360608401526154f581886145fc565b905082810360808401526155098187615306565b905082810360a084015261551d8186614672565b905082810360c0840152615531818561462c565b9a9950505050505050505050565b848152606060208201526000615559606083018587615478565b905060018060a01b038316604083015295945050505050565b87815260806020820152600061558c60808301888a615478565b828103604084015261559f818789615478565b90508281036060840152615531818587615435565b85815284602082015260ff841660408201526080606082015260006112e6608083018486615435565b600080604083850312156155f057600080fd5b82516155fb81614121565b602084015190925061502781614121565b83815260406020808301829052908201839052600090849060608401835b8681101561565857833561563d81614121565b6001600160a01b03168252928201929082019060010161562a565b50979650505050505050565b86815285602082015260c06040820152600061568360c0830187615298565b82810360608401526156958187615351565b905082810360808401526156a9818661462c565b905082810360a08401526156bd818561462c565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b600080604083850312156156f357600080fd5b82519150614976602084016151af565b868152856020820152608060408201526000615723608083018688615435565b82810360608401526156bd818587615435565b60006101008a83528960208401528060408401526157568184018a6145b8565b9050828103606084015261576a81896145fc565b9050828103608084015261577e8188615306565b905082810360a08401526157928187614672565b905082810360c08401526157a6818661462c565b905082810360e08401526157ba818561462c565b9b9a5050505050505050505050565b600082601f8301126157da57600080fd5b815160206157ea6141578361408f565b82815260059290921b8401810191818101908684111561580957600080fd5b8286015b8481101561358057805161582081614121565b835291830191830161580d565b60006020828403121561583f57600080fd5b81516001600160401b038082111561585657600080fd5b90830190610260828603121561586b57600080fd5b61587361403c565b82518152615883602084016151a4565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406158ea8185016151af565b908201526101606158fc8482016151af565b9082015261018061590e8482016151af565b908201526101a083810151908201526101c080840151908201526101e0808401518381111561593c57600080fd5b615948888287016157c9565b91830191909152506102008381015190820152610220808401519082015261024091506159768284016151af565b91810191909152949350505050565b600181811c9082168061599957607f821691505b6020821081036159b957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611149576111496159bf565b600082615a0557634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215615a1c57600080fd5b81516001600160601b038116811461238557600080fd5b80820180821115611149576111496159bf565b8082028115828204841417611149576111496159bf565b602081526000612385602083018461462c565b8981526001600160a01b038916602082015261012060408201819052600090615a9b8382018b6145b8565b90508281036060840152615aaf818a6145fc565b90508281036080840152615ac38189614672565b905082810360a0840152615ad78188614672565b90508560c08401528460e0840152828103610100840152615af8818561462c565b9c9b505050505050505050505050565b8d81526001600160a01b038d1660208201526101a060408201526000615b326101a083018e6145b8565b8281036060840152615b44818e6145b8565b90508281036080840152615b58818d6145fc565b905082810360a0840152615b6c818c614672565b905082810360c0840152615b80818b614672565b90508860e084015287610100840152615ba56101208401886001600160401b03169052565b8561014084015284610160840152828103610180840152615bc6818561462c565b9150509e9d5050505050505050505050505050565b601f82111561380957600081815260208120601f850160051c81016020861015615c025750805b601f850160051c820191505b81811015611ae957828155600101615c0e565b81516001600160401b03811115615c3a57615c3a613fdb565b615c4e81615c488454615985565b84615bdb565b602080601f831160018114615c835760008415615c6b5750858301515b600019600386901b1c1916600185901b178555611ae9565b600085815260208120601f198616915b82811015615cb257888601518255948401946001909101908401615c93565b5085821015615cd05787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe4e6f756e7344414f3a3a67657444796e616d696351756f72756d506172616d7341743a20626c6f636b206e756d62657220657863656564732033322062697473a2646970667358221220f2491533bce39ba61a365bfc63f8b086fe9c0ae725b29e960d5b36bc221d741664736f6c63430008130033
Deployed Bytecode
0x6080604052600436106105065760003560e01c80637f5ef44511610297578063c3dd69eb11610165578063e23a9a52116100cc578063ea3ecd0f11610085578063ea3ecd0f14610fa6578063ec91deda14610fbb578063f32293d214610fdb578063f4b2a7d614610ff0578063f5f4714c14611005578063fe0d94c11461102557600080fd5b8063e23a9a5214610ed4578063e256077214610f24578063e2742e1814610f44578063e48083fe14610da5578063e5eb5abf14610f71578063e9c714f214610f9157600080fd5b8063d8bff4401161011e578063d8bff44014610e2c578063d93150be14610e4a578063da35c66414610e5f578063da9427c414610e74578063da95691a14610e94578063ddf0b00914610eb457600080fd5b8063c3dd69eb14610d85578063c82fbd0814610da5578063cd0d9eac14610db9578063d27dd11214610dce578063d33219b414610dee578063d3f662e114610e0c57600080fd5b8063a64e024a11610209578063b58131b0116101c2578063b58131b014610ccf578063b5cd5bfa14610ce4578063b71d1a0c14610d04578063bf7a296314610d24578063c10eb14d14610d39578063c37522d414610d6357600080fd5b8063a64e024a14610c2c578063a67d063514610c42578063a78b5f1a14610c60578063a9cf82f014610c80578063abb308b214610ca2578063b112626314610c2c57600080fd5b80638f1314b61161025b5780638f1314b614610b7957806390f8c2f414610b8e5780639547aecb14610bac57806397242b8e14610bcc57806397d048e514610bec5780639a0dfb5314610c0c57600080fd5b80637f5ef44514610aef5780637fa230bd14610b0a57806383cce0e114610b1f578063842e4dae14610b3457806384d1d19914610b5457600080fd5b80633e273334116103d457806355ce73b11161034657806377388b70116102ff57806377388b7014610a265780637757d18d14610a5b5780637a3da69114610a795780637b3c71d314610a995780637bdbe4d014610ab95780637d17aa3a14610acd57600080fd5b806355ce73b1146109635780635678138814610983578063590c1f16146109a357806364c05995146109c3578063705cb335146109e357806374b157b814610a0657600080fd5b806344fac8f61161039857806344fac8f6146108a157806347f4a077146108c157806349e857ea146108ee57806350196db31461090e578063533494131461092e5780635408e7f21461094357600080fd5b80633e273334146107ff5780633e4f49e6146108145780633fde324d1461084157806340e58ee51461086157806344697f981461088157600080fd5b80631e7b5d3a116104785780632df01bdb116104315780632df01bdb14610745578063328dd9821461076557806336a3b5781461079557806338b1c2f6146107aa5780633932abb1146107ca5780633bccf4fd146107df57600080fd5b80631e7b5d3a14610694578063215809ca146106a957806328aa53e4146106be5780632b5ca189146106de5780632cfc81c6146106fe5780632de45f181461071357600080fd5b8063116ce988116104ca578063116ce988146105c957806314a67ea4146105e957806316f1b8cf146105fe57806317977c611461061e5780631d28dec7146106545780631dfb1b5a1461067457600080fd5b8063013cf08b1461051257806302a251a31461054857806306ef9d36146105675780630ea2d98c146105895780630f7b1f08146105a957600080fd5b3661050d57005b600080fd5b34801561051e57600080fd5b5061053261052d366004613efc565b611045565b60405161053f9190613f15565b60405180910390f35b34801561055457600080fd5b506005545b60405190815260200161053f565b34801561057357600080fd5b50610587610582366004613efc565b61114f565b005b34801561059557600080fd5b506105876105a4366004613efc565b6111bd565b3480156105b557600080fd5b506105596105c4366004613efc565b6111fc565b3480156105d557600080fd5b506105876105e4366004613efc565b611208565b3480156105f557600080fd5b50600654610559565b34801561060a57600080fd5b506105596106193660046143ca565b611247565b34801561062a57600080fd5b506105596106393660046144be565b6001600160a01b03166000908152600c602052604090205490565b34801561066057600080fd5b5061058761066f366004613efc565b6112f1565b34801561068057600080fd5b5061058761068f366004613efc565b611330565b3480156106a057600080fd5b506103e8610559565b3480156106b557600080fd5b50611c20610559565b3480156106ca57600080fd5b506105876106d93660046144db565b61136f565b3480156106ea57600080fd5b506105876106f936600461459d565b61178c565b34801561070a57600080fd5b506105876117d0565b34801561071f57600080fd5b50600a546001600160a01b03165b6040516001600160a01b03909116815260200161053f565b34801561075157600080fd5b506105876107603660046144be565b611836565b34801561077157600080fd5b50610785610780366004613efc565b61187d565b60405161053f94939291906146c4565b3480156107a157600080fd5b5061055961189c565b3480156107b657600080fd5b506105596107c5366004614711565b611919565b3480156107d657600080fd5b50600454610559565b3480156107eb57600080fd5b506105876107fa3660046147f3565b61195b565b34801561080b57600080fd5b506105596119ec565b34801561082057600080fd5b5061083461082f366004613efc565b611a03565b60405161053f9190614857565b34801561084d57600080fd5b5061058761085c3660046148c7565b611a81565b34801561086d57600080fd5b5061058761087c366004613efc565b611af1565b34801561088d57600080fd5b5061058761089c366004614908565b611b30565b3480156108ad57600080fd5b506105876108bc366004614953565b611bb8565b3480156108cd57600080fd5b506108e16108dc366004613efc565b611c00565b60405161053f919061497f565b3480156108fa57600080fd5b506105876109093660046149f3565b611c28565b34801561091a57600080fd5b50610587610929366004614a3a565b611c64565b34801561093a57600080fd5b50601654610559565b34801561094f57600080fd5b5061058761095e366004614a55565b611ca6565b34801561096f57600080fd5b5061058761097e366004614a8c565b611d22565b34801561098f57600080fd5b5061058761099e366004614953565b611d60565b3480156109af57600080fd5b506105876109be366004614ad7565b611da8565b3480156109cf57600080fd5b506105876109de366004614b70565b611dec565b3480156109ef57600080fd5b50601054640100000000900463ffffffff16610559565b348015610a1257600080fd5b50610587610a2136600461459d565b611e62565b348015610a3257600080fd5b50610a3b611ea6565b604080516001600160a01b0393841681529290911660208301520161053f565b348015610a6757600080fd5b506011546001600160a01b031661072d565b348015610a8557600080fd5b50610587610a94366004614a3a565b611f26565b348015610aa557600080fd5b50610587610ab4366004614b70565b611f68565b348015610ac557600080fd5b50600a610559565b348015610ad957600080fd5b50601054600160401b900463ffffffff16610559565b348015610afb57600080fd5b5060105463ffffffff16610559565b348015610b1657600080fd5b50610559611fa8565b348015610b2b57600080fd5b50600754610559565b348015610b4057600080fd5b50610587610b4f366004613efc565b611fbf565b348015610b6057600080fd5b50601054600160601b90046001600160a01b031661072d565b348015610b8557600080fd5b50610559611ffe565b348015610b9a57600080fd5b506018546001600160a01b031661072d565b348015610bb857600080fd5b50610587610bc7366004614bc9565b61200a565b348015610bd857600080fd5b50610587610be7366004614c3f565b612203565b348015610bf857600080fd5b50610587610c07366004613efc565b61229d565b348015610c1857600080fd5b50610559610c27366004614d63565b6122dc565b348015610c3857600080fd5b50620189c0610559565b348015610c4e57600080fd5b50600e546001600160a01b031661072d565b348015610c6c57600080fd5b50610587610c7b3660046149f3565b61238c565b348015610c8c57600080fd5b50610c956123c8565b60405161053f9190614e1b565b348015610cae57600080fd5b50610cc2610cbd366004613efc565b61246e565b60405161053f9190614e69565b348015610cdb57600080fd5b5061055961251b565b348015610cf057600080fd5b50610587610cff366004614ad7565b612532565b348015610d1057600080fd5b50610587610d1f3660046144be565b612576565b348015610d3057600080fd5b506105876125bd565b348015610d4557600080fd5b50610d4e6125f5565b6040805192835290151560208301520161053f565b348015610d6f57600080fd5b50610d7861266d565b60405161053f9190614e77565b348015610d9157600080fd5b50610587610da0366004614e8a565b6126d2565b348015610db157600080fd5b506001610559565b348015610dc557600080fd5b50610559612714565b348015610dda57600080fd5b50610587610de93660046149f3565b61274f565b348015610dfa57600080fd5b506009546001600160a01b031661072d565b348015610e1857600080fd5b50610587610e273660046144be565b61278b565b348015610e3857600080fd5b506003546001600160a01b031661072d565b348015610e5657600080fd5b50601554610559565b348015610e6b57600080fd5b50600854610559565b348015610e8057600080fd5b50610587610e8f366004614f03565b6127d2565b348015610ea057600080fd5b50610559610eaf366004614711565b612818565b348015610ec057600080fd5b50610587610ecf366004613efc565b612850565b348015610ee057600080fd5b50610ef4610eef366004615002565b61288f565b6040805182511515815260208084015160ff1690820152918101516001600160601b03169082015260600161053f565b348015610f3057600080fd5b50610587610f3f36600461459d565b61291b565b348015610f5057600080fd5b50610f64610f5f366004613efc565b61295f565b60405161053f9190615032565b348015610f7d57600080fd5b50610587610f8c36600461459d565b612a84565b348015610f9d57600080fd5b50610587612ac8565b348015610fb257600080fd5b50601954610559565b348015610fc757600080fd5b50610587610fd6366004615161565b612b00565b348015610fe757600080fd5b50601754610559565b348015610ffc57600080fd5b50610587612b56565b34801561101157600080fd5b506105876110203660046144be565b612b8e565b34801561103157600080fd5b50610587611040366004613efc565b612bd5565b6110cd604051806101e001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160001515815260200160008152602001600081525090565b6040516310549af960e21b81526000600482015260248101839052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906341526be4906044016101e060405180830381865af4158015611125573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114991906151bf565b92915050565b6040516349e2f96f60e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906393c5f2de906044015b60006040518083038186803b1580156111a257600080fd5b505af41580156111b6573d6000803e3d6000fd5b5050505050565b60405163adb8355760e01b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063adb835579060440161118a565b60006111498183612c14565b6040516311b5760360e31b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc90638dabb0189060440161118a565b6040805160808101825286815260208101869052808201859052606081018490529051630c2d20bb60e21b8152600091736a325f297b4f7a1bdb99918e21656cfe5b181fbc916330b482ec916112a59185918c9188906004016153bc565b602060405180830381865af41580156112c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e691906153fb565b979650505050505050565b604051636c1578c760e01b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc90636c1578c79060440161118a565b60405163a79aaf2760e01b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a79aaf279060440161118a565b6009546001600160a01b03161561139957604051630205737f60e61b815260040160405180910390fd5b6000546001600160a01b031633146113c457604051633057182d60e21b815260040160405180910390fd5b6001600160a01b0387166113eb57604051637330d04160e11b815260040160405180910390fd5b6001600160a01b0386166114125760405163d2ef0d7160e01b815260040160405180910390fd5b60405163adb8355760e01b8152600060048201528235602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063adb835579060440160006040518083038186803b15801561146457600080fd5b505af4158015611478573d6000803e3d6000fd5b505060405163a79aaf2760e01b8152600060048201526020850135602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063a79aaf27915060440160006040518083038186803b1580156114d157600080fd5b505af41580156114e5573d6000803e3d6000fd5b50506040805163796871d560e11b81526000600482015290850135602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063f2d0e3aa915060440160006040518083038186803b15801561153e57600080fd5b505af4158015611552573d6000803e3d6000fd5b5050600980546001600160a01b03199081166001600160a01b038c811691909117909255600a805482168b8416179055601080546001600160601b0316600160601b8b85160217905560118054821689841617905560038054909116918716919091179055506115ea90506115ca6020830183614a3a565b6115da6040840160208501614a3a565b610fd6606085016040860161459d565b73cf854bc50cfb6dbaed83b04e793f7ee48b858ca66385a38d346000611616608086016060870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff16602482015260440160006040518083038186803b15801561165857600080fd5b505af415801561166c573d6000803e3d6000fd5b5073cf854bc50cfb6dbaed83b04e793f7ee48b858ca69250638474893a91506000905061169f60a086016080870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff16602482015260440160006040518083038186803b1580156116e157600080fd5b505af41580156116f5573d6000803e3d6000fd5b5073cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063931938d991506000905061172860c0860160a0870161459d565b6040516001600160e01b031960e085901b168152600481019290925263ffffffff1660248201526044015b60006040518083038186803b15801561176b57600080fd5b505af415801561177f573d6000803e3d6000fd5b5050505050505050505050565b60405163bd43440760e01b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063bd4344079060440161118a565b60405163a1ef30a160e01b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a1ef30a1906024015b60006040518083038186803b15801561181c57600080fd5b505af4158015611830573d6000803e3d6000fd5b50505050565b60405163a77238a560e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a77238a59060440161118a565b606080808061188d600086612c70565b93509350935093509193509193565b604051631fb0a1ab60e11b8152600060048201819052907388e875e2ada18245d442500388d701f6e0f4a78d90633f614356906024015b602060405180830381865af41580156118f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191491906153fb565b905090565b6000611951604051806080016040528088815260200187815260200186815260200185815250836000612f059092919063ffffffff16565b9695505050505050565b604051637b784a4960e01b8152600060048201526024810186905260ff8086166044830152841660648201526084810183905260a4810182905273ef902b590aef42587ddfec38c45549db6c0144ca90637b784a499060c4015b60006040518083038186803b1580156119cd57600080fd5b505af41580156119e1573d6000803e3d6000fd5b505050505050505050565b60006119146119fb6000612f7a565b6000906130f6565b604051630390952560e11b81526000600482018190526024820183905290736a325f297b4f7a1bdb99918e21656cfe5b181fbc906307212a4a90604401602060405180830381865af4158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111499190615414565b6040516333fb311b60e21b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063cfecc46c90611abd906000908690869060040161545e565b60006040518083038186803b158015611ad557600080fd5b505af4158015611ae9573d6000803e3d6000fd5b505050505050565b60405163121069ef60e31b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906390834f789060440161118a565b604051635c97764960e01b8152600060048201526001600160a01b03808516602483015280841660448301528216606482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690635c977649906084015b60006040518083038186803b158015611b9b57600080fd5b505af4158015611baf573d6000803e3d6000fd5b50505050505050565b60405163473501b760e11b8152600060048201526024810183905260ff8216604482015273ef902b590aef42587ddfec38c45549db6c0144ca90638e6a036e90606401611abd565b6040805160608101825260008082526020820181905291810191909152611149600083613110565b604051633fcfd14760e01b81527388e875e2ada18245d442500388d701f6e0f4a78d90633fcfd14790611abd90600090869086906004016154aa565b604051632a38c7b160e01b81526000600482015261ffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690632a38c7b19060440161118a565b604051631167d67160e21b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063459f59c490611cea906000908a908a908a908a908a908a906004016154c4565b60006040518083038186803b158015611d0257600080fd5b505af4158015611d16573d6000803e3d6000fd5b50505050505050505050565b60405163e6b8f0af60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063e6b8f0af90611b839060009087908790879060040161553f565b60405163233a163f60e11b8152600060048201526024810183905260ff8216604482015273ef902b590aef42587ddfec38c45549db6c0144ca906346742c7e90606401611abd565b60405163bcac609f60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063bcac609f90611cea906000908a908a908a908a908a908a90600401615572565b6040516346aec09d60e01b815273ef902b590aef42587ddfec38c45549db6c0144ca906346aec09d90611e2c9060009088908890889088906004016155b4565b60006040518083038186803b158015611e4457600080fd5b505af4158015611e58573d6000803e3d6000fd5b5050505050505050565b60405163931938d960e01b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063931938d99060440161118a565b6040516305a15c8360e21b81526000600482018190529081907388e875e2ada18245d442500388d701f6e0f4a78d90631685720c906024016040805180830381865af4158015611efa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1e91906155dd565b915091509091565b6040516380ffd06b60e01b81526000600482015261ffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906380ffd06b9060440161118a565b6040516392a364c960e01b815273ef902b590aef42587ddfec38c45549db6c0144ca906392a364c990611e2c9060009088908890889088906004016155b4565b6000611914611fb76000612f7a565b600090613425565b604051635752203b60e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063aea440769060440161118a565b60006119146000612f7a565b60405163a77238a560e01b8152600060048201526001600160a01b038716602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063a77238a59060440160006040518083038186803b15801561206457600080fd5b505af4158015612078573d6000803e3d6000fd5b50506040516302d548bf60e01b8152600060048201526001600160a01b038816602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca692506302d548bf915060440160006040518083038186803b1580156120d657600080fd5b505af41580156120ea573d6000803e3d6000fd5b5050604051634762cea160e01b815273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69250634762cea1915061212a906000908890889060040161560c565b60006040518083038186803b15801561214257600080fd5b505af4158015612156573d6000803e3d6000fd5b5050604051635752203b60e11b8152600060048201526024810185905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6925063aea44076915060440160006040518083038186803b1580156121ac57600080fd5b505af41580156121c0573d6000803e3d6000fd5b50506040516349e2f96f60e11b8152600060048201526024810184905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca692506393c5f2de9150604401611cea565b604080516080810182528781526020810187905280820186905260608101859052905163e473627360e01b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9163e473627391612263916000918d918d9189908990600401615664565b60006040518083038186803b15801561227b57600080fd5b505af415801561228f573d6000803e3d6000fd5b505050505050505050505050565b60405163796871d560e11b8152600060048201526024810182905273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063f2d0e3aa9060440161118a565b6040805163af7d88eb60e01b81526004810185905260248101849052825161ffff908116604483015260208401511660648201529082015163ffffffff16608482015260009073cacc9629a8b283ff0e4ec34b1eb00da0aee6d42a9063af7d88eb9060a401602060405180830381865af415801561235e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238291906153fb565b90505b9392505050565b604051634762cea160e01b815273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690634762cea190611abd906000908690869060040161560c565b60606000600d01805480602002602001604051908101604052809291908181526020016000905b8282101561246557600084815260209081902060408051808201825260028602909201805463ffffffff9081168452825160608101845260019283015461ffff808216835262010000820416828801526401000000009004909116928101929092528284019190915290835290920191016123ef565b50505050905090565b6124a160408051808201825260008082528251606081018452818152602081810183905293810191909152909182015290565b600d8054839081106124b5576124b56156ca565b60009182526020918290206040805180820182526002909302909101805463ffffffff9081168452825160608101845260019092015461ffff80821684526201000082041683870152640100000000900416918101919091529181019190915292915050565b600061191461252a6000612f7a565b600090613442565b60405163fe5cebdb60e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063fe5cebdb90611cea906000908a908a908a908a908a908a90600401615572565b6040516354afee2160e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906354afee219060440161118a565b60405163117f658d60e01b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063117f658d90602401611804565b604051633fba359560e01b815260006004820181905290819073cf854bc50cfb6dbaed83b04e793f7ee48b858ca690633fba3595906024016040805180830381865af4158015612649573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f1e91906156e0565b606060006012018054806020026020016040519081016040528092919081815260200182805480156126c857602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126aa575b5050505050905090565b60405163e54ab2b960e01b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063e54ab2b9906119b59060009089908990899089908990600401615703565b604051633840c95f60e01b8152600060048201819052907388e875e2ada18245d442500388d701f6e0f4a78d90633840c95f906024016118d3565b60405163e46aa49560e01b81527388e875e2ada18245d442500388d701f6e0f4a78d9063e46aa49590611abd90600090869086906004016154aa565b60405163850da8bf60e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063850da8bf9060440161118a565b604051630d2f400360e31b8152736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063697a001890611753906000908b908b908b908b908b908b908b90600401615736565b60006119516040518060800160405280888152602001878152602001868152602001858152508360006134529092919063ffffffff16565b604051634215da8560e11b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063842bb50a9060440161118a565b604080516060808201835260008083526020808401829052838501829052845180840186528281528082018390528501829052868252600b81528482206001600160a01b0387168352600f01815290849020845192830185525460ff80821615158452610100820416918301919091526201000090046001600160601b03169281019290925290612385565b604051632168e34d60e21b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906385a38d349060440161118a565b612a056040518061026001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160001515815260200160008152602001600081526020016060815260200160008152602001600081526020016000151581525090565b60405163100e0d6d60e01b81526000600482015260248101839052736a325f297b4f7a1bdb99918e21656cfe5b181fbc9063100e0d6d90604401600060405180830381865af4158015612a5c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611149919081019061582d565b60405163423a449d60e11b81526000600482015263ffffffff8216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca690638474893a9060440161118a565b60405163096d03f360e21b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906325b40fcc90602401611804565b6040516327b5eff560e01b81526000600482015261ffff80851660248301528316604482015263ffffffff8216606482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906327b5eff590608401611b83565b604051630712073760e51b81526000600482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca69063e240e6e090602401611804565b6040516302d548bf60e01b8152600060048201526001600160a01b038216602482015273cf854bc50cfb6dbaed83b04e793f7ee48b858ca6906302d548bf9060440161118a565b6040516377aaa1bb60e01b81526000600482015260248101829052736a325f297b4f7a1bdb99918e21656cfe5b181fbc906377aaa1bb9060440161118a565b6000818152600b83016020526040812060108101548203612c3a57600301549050611149565b600c81015460108201546011830154612c68929190612c639088906001600160401b0316613110565b61358b565b949350505050565b606080606080600086600b01600087815260200190815260200160002090508060050181600601826007018360080183805480602002602001604051908101604052809291908181526020018280548015612cf457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612cd6575b5050505050935082805480602002602001604051908101604052809291908181526020018280548015612d4657602002820191906000526020600020905b815481526020019060010190808311612d32575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b82821015612e1a578382906000526020600020018054612d8d90615985565b80601f0160208091040260200160405190810160405280929190818152602001828054612db990615985565b8015612e065780601f10612ddb57610100808354040283529160200191612e06565b820191906000526020600020905b815481529060010190602001808311612de957829003601f168201915b505050505081526020019060010190612d6e565b50505050915080805480602002602001604051908101604052809291908181526020016000905b82821015612eed578382906000526020600020018054612e6090615985565b80601f0160208091040260200160405190810160405280929190818152602001828054612e8c90615985565b8015612ed95780601f10612eae57610100808354040283529160200191612ed9565b820191906000526020600020905b815481529060010190602001808311612ebc57829003601f168201915b505050505081526020019060010190612e41565b50505050905094509450945094505092959194509250565b600080612f13858585613452565b6000818152600b870160205260409081902060138101805460ff191660011790559051919250907f9fb4e5204ac554428e5c744568b78732c229c76c0b5eaebdca7171c41366f6af90612f699084815260200190565b60405180910390a150949350505050565b600081601001600c9054906101000a90046001600160a01b03166001600160a01b0316639b3c1e226040518163ffffffff1660e01b8152600401602060405180830381865afa158015612fd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ff591906153fb565b600a83015460098401546040516370a0823160e01b81526001600160a01b0391821660048201529116906370a0823190602401602060405180830381865afa158015613045573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306991906153fb565b83600a0160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e291906153fb565b6130ec91906159d5565b61114991906159d5565b60006123856131058443613110565b5161ffff1683613613565b6040805160608101825260008082526020820181905291810191909152600061315183604051806060016040528060408152602001615ce16040913961362c565b600d85015490915060008190036131a857604051806060016040528061317a8760070154613665565b61ffff1681526020016131908760070154613665565b61ffff16815260006020909101529250611149915050565b63ffffffff8216600d86016131be6001846159d5565b815481106131ce576131ce6156ca565b600091825260209091206002909102015463ffffffff161161326157600d85016131f96001836159d5565b81548110613209576132096156ca565b6000918252602091829020604080516060810182526002939093029091016001015461ffff8082168452620100008204169383019390935264010000000090920463ffffffff16918101919091529250611149915050565b8163ffffffff1685600d0160008154811061327e5761327e6156ca565b600091825260209091206002909102015463ffffffff1611156132b357604051806060016040528061317a8760070154613665565b6000806132c16001846159d5565b90505b818111156133b757600060026132da84846159d5565b6132e491906159e8565b6132ee90836159d5565b9050600088600d018281548110613307576133076156ca565b60009182526020918290206040805180820182526002909302909101805463ffffffff9081168452825160608101845260019092015461ffff80821684526201000082041683870152640100000000900481169282019290925292820192909252805190925087821691160361338857602001519550611149945050505050565b805163ffffffff808816911610156133a2578193506133b0565b6133ad6001836159d5565b92505b50506132c4565b86600d0182815481106133cc576133cc6156ca565b6000918252602091829020604080516060810182526002939093029091016001015461ffff8082168452620100008204169383019390935264010000000090920463ffffffff1691810191909152979650505050505050565b60006123856134348443613110565b6020015161ffff1683613613565b6000612385836006015483613613565b60008061345e85612f7a565b600a8601549091506000906135059087906001600160a01b031663782d6fe1336134896001436159d5565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa1580156134d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134f69190615a0a565b6001600160601b03168461368e565b9050613510856136bc565b61351a8633613753565b60008660080154600161352d9190615a33565b8760080181905590506000613545888385878b61380e565b336000908152600c8a0160209081526040808320869055805192835290820190529091506135809082906135798b886130f6565b8a8a613968565b509695505050505050565b6000808361359b86612710615a46565b6135a591906159e8565b90506000620f424082856040015163ffffffff166135c39190615a46565b6135cd91906159e8565b9050600081856000015161ffff166135e59190615a33565b905060006135fb866020015161ffff1683613a58565b90506136078188613613565b98975050505050505050565b60006127106136228484615a46565b61238591906159e8565b60008163ffffffff84111561365d5760405162461bcd60e51b81526004016136549190615a5d565b60405180910390fd5b509192915050565b600061ffff82111561368a5760405163555abf0160e11b815260040160405180910390fd5b5090565b600061369a8483613442565b90508083116123855760405163ead8241560e01b815260040160405180910390fd5b6020810151518151511415806136d9575060408101515181515114155b806136eb575060608101515181515114155b156137095760405163ccb0ce3f60e01b815260040160405180910390fd5b80515160000361372c57604051630f24cd7360e01b815260040160405180910390fd5b805151600a1015613750576040516308e3b1eb60e11b815260040160405180910390fd5b50565b6001600160a01b0381166000908152600c8301602052604090205480156138095760006137808483613a6e565b9050600981600a81111561379657613796614841565b14806137b35750600181600a8111156137b1576137b1614841565b145b806137cf5750600081600a8111156137cd576137cd614841565b145b806137eb5750600a81600a8111156137e9576137e9614841565b145b15611830576040516306bee79560e01b815260040160405180910390fd5b505050565b601085015460009081906138389061383390600160401b900463ffffffff1643615a33565b613c67565b905060008760040154826001600160401b03166138559190615a33565b905060008860050154826138699190615a33565b6000898152600b8b01602090815260409091208a81556001810180546001600160a01b03191633179055600281018a9055875180519197509293506138b49260058801920190613d33565b5060208086015180516138cd9260068801920190613d94565b50604085015180516138e9916007870191602090910190613dcf565b5060608501518051613905916008870191602090910190613e21565b5060098401829055600a84018190556010840186905561392443613c67565b6011850180546001600160401b039283166fffffffffffffffffffffffffffffffff1990911617600160401b95909216949094021790925550909695505050505050565b7f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e085600001543384600001518560200151866040015187606001518b600901548c600a0154896040516139c399989796959493929190615a70565b60405180910390a17f0cc4b35cbed68ce6ca5b3e6560894c6ccc309603ed423fa45554c837dd9a06aa8560000154338685600001518660200151876040015188606001518c600901548d600a01548e60110160089054906101000a90046001600160401b03168f600201548e8d604051613a499d9c9b9a99989796959493929190615b08565b60405180910390a15050505050565b6000818310613a675781612385565b5090919050565b60008183600801541015613ad05760405162461bcd60e51b8152602060048201526024808201527f4e6f756e7344414f3a3a73746174653a20696e76616c69642070726f706f73616044820152631b081a5960e21b6064820152608401613654565b6000828152600b840160205260409020600e810154610100900460ff1615613afc576008915050611149565b600e81015460ff1615613b13576002915050611149565b6011810154600160401b90046001600160401b03164311613b3857600a915050611149565b80600901544311613b4d576000915050611149565b80600a01544311613b62576001915050611149565b6011810154600160801b90046001600160401b03164311613b87576009915050611149565b613b918482613ccf565b15613ba0576003915050611149565b8060040154600003613bb6576004915050611149565b600e81015462010000900460ff1615613bd3576007915050611149565b613bdd8482613cfb565b6001600160a01b031663c1a287e26040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c3e91906153fb565b8160040154613c4d9190615a33565b4210613c5d576006915050611149565b6005915050611149565b60006001600160401b0382111561368a5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b6064820152608401613654565b600b810154600c8201546000919081111580612c6857508254613cf3908590612c14565b119392505050565b601381015460009060ff1615613d1f575060188201546001600160a01b0316611149565b5060098201546001600160a01b0316611149565b828054828255906000526020600020908101928215613d88579160200282015b82811115613d8857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613d53565b5061368a929150613e73565b828054828255906000526020600020908101928215613d88579160200282015b82811115613d88578251825591602001919060010190613db4565b828054828255906000526020600020908101928215613e15579160200282015b82811115613e155782518290613e059082615c21565b5091602001919060010190613def565b5061368a929150613e88565b828054828255906000526020600020908101928215613e67579160200282015b82811115613e675782518290613e579082615c21565b5091602001919060010190613e41565b5061368a929150613ea5565b5b8082111561368a5760008155600101613e74565b8082111561368a576000613e9c8282613ec2565b50600101613e88565b8082111561368a576000613eb98282613ec2565b50600101613ea5565b508054613ece90615985565b6000825580601f10613ede575050565b601f0160209004906000526020600020908101906137509190613e73565b600060208284031215613f0e57600080fd5b5035919050565b815181526020808301516101e0830191613f39908401826001600160a01b03169052565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525061014080840151613fa28285018215159052565b505061016083810151151590830152610180808401511515908301526101a080840151908301526101c092830151929091019190915290565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b038111828210171561401357614013613fdb565b60405290565b6040516101e081016001600160401b038111828210171561401357614013613fdb565b60405161026081016001600160401b038111828210171561401357614013613fdb565b604051601f8201601f191681016001600160401b038111828210171561408757614087613fdb565b604052919050565b60006001600160401b038211156140a8576140a8613fdb565b5060051b60200190565b600082601f8301126140c357600080fd5b81356001600160401b038111156140dc576140dc613fdb565b6140ef601f8201601f191660200161405f565b81815284602083860101111561410457600080fd5b816020850160208301376000918101602001919091529392505050565b6001600160a01b038116811461375057600080fd5b600082601f83011261414757600080fd5b8135602061415c6141578361408f565b61405f565b82815260059290921b8401810191818101908684111561417b57600080fd5b8286015b848110156135805780356001600160401b038082111561419f5760008081fd5b908801906060828b03601f19018113156141b95760008081fd5b6141c1613ff1565b87840135838111156141d35760008081fd5b6141e18d8a838801016140b2565b82525060409250828401356141f581614121565b8189015292013590820152835291830191830161417f565b600082601f83011261421e57600080fd5b8135602061422e6141578361408f565b82815260059290921b8401810191818101908684111561424d57600080fd5b8286015b8481101561358057803561426481614121565b8352918301918301614251565b600082601f83011261428257600080fd5b813560206142926141578361408f565b82815260059290921b840181019181810190868411156142b157600080fd5b8286015b8481101561358057803583529183019183016142b5565b600082601f8301126142dd57600080fd5b813560206142ed6141578361408f565b82815260059290921b8401810191818101908684111561430c57600080fd5b8286015b848110156135805780356001600160401b0381111561432f5760008081fd5b61433d8986838b01016140b2565b845250918301918301614310565b600082601f83011261435c57600080fd5b8135602061436c6141578361408f565b82815260059290921b8401810191818101908684111561438b57600080fd5b8286015b848110156135805780356001600160401b038111156143ae5760008081fd5b6143bc8986838b01016140b2565b84525091830191830161438f565b60008060008060008060c087890312156143e357600080fd5b86356001600160401b03808211156143fa57600080fd5b6144068a838b01614136565b9750602089013591508082111561441c57600080fd5b6144288a838b0161420d565b9650604089013591508082111561443e57600080fd5b61444a8a838b01614271565b9550606089013591508082111561446057600080fd5b61446c8a838b016142cc565b9450608089013591508082111561448257600080fd5b61448e8a838b0161434b565b935060a08901359150808211156144a457600080fd5b506144b189828a016140b2565b9150509295509295509295565b6000602082840312156144d057600080fd5b813561238581614121565b60008060008060008060008789036101c08112156144f857600080fd5b883561450381614121565b9750602089013561451381614121565b9650604089013561452381614121565b9550606089013561453381614121565b9450608089013561454381614121565b935060c0609f198201121561455757600080fd5b60a089019250606061015f198201121561457057600080fd5b506101608801905092959891949750929550565b803563ffffffff8116811461459857600080fd5b919050565b6000602082840312156145af57600080fd5b61238582614584565b600081518084526020808501945080840160005b838110156145f15781516001600160a01b0316875295820195908201906001016145cc565b509495945050505050565b600081518084526020808501945080840160005b838110156145f157815187529582019590820190600101614610565b6000815180845260005b8181101561465257602081850181015186830182015201614636565b506000602082860101526020601f19601f83011685010191505092915050565b6000815180845260208085019450848260051b860182860160005b858110156146b75783830389526146a583835161462c565b9885019892509084019060010161468d565b5090979650505050505050565b6080815260006146d760808301876145b8565b82810360208401526146e981876145fc565b905082810360408401526146fd8186614672565b905082810360608401526112e68185614672565b600080600080600060a0868803121561472957600080fd5b85356001600160401b038082111561474057600080fd5b61474c89838a0161420d565b9650602088013591508082111561476257600080fd5b61476e89838a01614271565b9550604088013591508082111561478457600080fd5b61479089838a016142cc565b945060608801359150808211156147a657600080fd5b6147b289838a0161434b565b935060808801359150808211156147c857600080fd5b506147d5888289016140b2565b9150509295509295909350565b803560ff8116811461459857600080fd5b600080600080600060a0868803121561480b57600080fd5b8535945061481b602087016147e2565b9350614829604087016147e2565b94979396509394606081013594506080013592915050565b634e487b7160e01b600052602160045260246000fd5b60208101600b831061487957634e487b7160e01b600052602160045260246000fd5b91905290565b60008083601f84011261489157600080fd5b5081356001600160401b038111156148a857600080fd5b6020830191508360208285010111156148c057600080fd5b9250929050565b600080602083850312156148da57600080fd5b82356001600160401b038111156148f057600080fd5b6148fc8582860161487f565b90969095509350505050565b60008060006060848603121561491d57600080fd5b833561492881614121565b9250602084013561493881614121565b9150604084013561494881614121565b809150509250925092565b6000806040838503121561496657600080fd5b82359150614976602084016147e2565b90509250929050565b815161ffff90811682526020808401519091169082015260408083015163ffffffff169082015260608101611149565b60008083601f8401126149c157600080fd5b5081356001600160401b038111156149d857600080fd5b6020830191508360208260051b85010111156148c057600080fd5b60008060208385031215614a0657600080fd5b82356001600160401b03811115614a1c57600080fd5b6148fc858286016149af565b803561ffff8116811461459857600080fd5b600060208284031215614a4c57600080fd5b61238582614a28565b60008060008060008060c08789031215614a6e57600080fd5b8635955060208701356001600160401b038082111561441c57600080fd5b600080600060408486031215614aa157600080fd5b83356001600160401b03811115614ab757600080fd5b614ac3868287016149af565b909450925050602084013561494881614121565b60008060008060008060608789031215614af057600080fd5b86356001600160401b0380821115614b0757600080fd5b614b138a838b016149af565b90985096506020890135915080821115614b2c57600080fd5b614b388a838b016149af565b90965094506040890135915080821115614b5157600080fd5b50614b5e89828a0161487f565b979a9699509497509295939492505050565b60008060008060608587031215614b8657600080fd5b84359350614b96602086016147e2565b925060408501356001600160401b03811115614bb157600080fd5b614bbd8782880161487f565b95989497509550505050565b60008060008060008060a08789031215614be257600080fd5b8635614bed81614121565b95506020870135614bfd81614121565b945060408701356001600160401b03811115614c1857600080fd5b614c2489828a016149af565b979a9699509760608101359660809091013595509350505050565b600080600080600080600080610100898b031215614c5c57600080fd5b8835975060208901356001600160401b0380821115614c7a57600080fd5b614c868c838d01614136565b985060408b0135915080821115614c9c57600080fd5b614ca88c838d0161420d565b975060608b0135915080821115614cbe57600080fd5b614cca8c838d01614271565b965060808b0135915080821115614ce057600080fd5b614cec8c838d016142cc565b955060a08b0135915080821115614d0257600080fd5b614d0e8c838d0161434b565b945060c08b0135915080821115614d2457600080fd5b614d308c838d016140b2565b935060e08b0135915080821115614d4657600080fd5b50614d538b828c016140b2565b9150509295985092959890939650565b600080600083850360a0811215614d7957600080fd5b84359350602085013592506060603f1982011215614d9657600080fd5b50614d9f613ff1565b614dab60408601614a28565b8152614db960608601614a28565b6020820152614dca60808601614584565b6040820152809150509250925092565b63ffffffff81511682526020810151613809602084018261ffff8082511683528060208301511660208401525063ffffffff60408201511660408301525050565b6020808252825182820181905260009190848201906040850190845b81811015614e5d57614e4a838551614dda565b9284019260809290920191600101614e37565b50909695505050505050565b608081016111498284614dda565b60208152600061238560208301846145b8565b600080600080600060608688031215614ea257600080fd5b8535945060208601356001600160401b0380821115614ec057600080fd5b614ecc89838a0161487f565b90965094506040880135915080821115614ee557600080fd5b50614ef28882890161487f565b969995985093965092949392505050565b600080600080600080600060e0888a031215614f1e57600080fd5b8735965060208801356001600160401b0380821115614f3c57600080fd5b614f488b838c0161420d565b975060408a0135915080821115614f5e57600080fd5b614f6a8b838c01614271565b965060608a0135915080821115614f8057600080fd5b614f8c8b838c016142cc565b955060808a0135915080821115614fa257600080fd5b614fae8b838c0161434b565b945060a08a0135915080821115614fc457600080fd5b614fd08b838c016140b2565b935060c08a0135915080821115614fe657600080fd5b50614ff38a828b016140b2565b91505092959891949750929550565b6000806040838503121561501557600080fd5b82359150602083013561502781614121565b809150509250929050565b60208152815160208201526000602083015161505960408401826001600160a01b03169052565b506040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c083015160e083015260e08301516101008181850152808501519150506101208181850152808501519150506101408181850152808501519150506101606150ce8185018315159052565b84015190506101806150e38482018315159052565b84015190506101a06150f88482018315159052565b8401516101c0848101919091528401516101e080850191909152840151610260610200808601829052919250906151336102808601846145b8565b9086015161022086810191909152860151610240808701919091529095015115159301929092525090919050565b60008060006060848603121561517657600080fd5b61517f84614a28565b925061518d60208501614a28565b915061519b60408501614584565b90509250925092565b805161459881614121565b8051801515811461459857600080fd5b60006101e082840312156151d257600080fd5b6151da614019565b825181526151ea602084016151a4565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406152518185016151af565b908201526101606152638482016151af565b908201526101806152758482016151af565b908201526101a083810151908201526101c0928301519281019290925250919050565b6000815180845260208085019450848260051b860182860160005b858110156146b75783830389528151606081518186526152d58287018261462c565b838901516001600160a01b0316878a01526040938401519390960192909252505097840197908401906001016152b3565b600082825180855260208086019550808260051b84010181860160005b848110156146b757601f1986840301895261533f83835161462c565b98840198925090830190600101615323565b600081516080845261536660808501826145b8565b90506020830151848203602086015261537f82826145fc565b915050604083015184820360408601526153998282615306565b915050606083015184820360608601526153b38282614672565b95945050505050565b8481526080602082015260006153d56080830186615298565b82810360408401526153e78186615351565b905082810360608401526112e6818561462c565b60006020828403121561540d57600080fd5b5051919050565b60006020828403121561542657600080fd5b8151600b811061238557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006153b3604083018486615435565b81835260006001600160fb1b0383111561549157600080fd5b8260051b80836020870137939093016020019392505050565b8381526040602082015260006153b3604083018486615478565b87815286602082015260e0604082015260006154e360e08301886145b8565b82810360608401526154f581886145fc565b905082810360808401526155098187615306565b905082810360a084015261551d8186614672565b905082810360c0840152615531818561462c565b9a9950505050505050505050565b848152606060208201526000615559606083018587615478565b905060018060a01b038316604083015295945050505050565b87815260806020820152600061558c60808301888a615478565b828103604084015261559f818789615478565b90508281036060840152615531818587615435565b85815284602082015260ff841660408201526080606082015260006112e6608083018486615435565b600080604083850312156155f057600080fd5b82516155fb81614121565b602084015190925061502781614121565b83815260406020808301829052908201839052600090849060608401835b8681101561565857833561563d81614121565b6001600160a01b03168252928201929082019060010161562a565b50979650505050505050565b86815285602082015260c06040820152600061568360c0830187615298565b82810360608401526156958187615351565b905082810360808401526156a9818661462c565b905082810360a08401526156bd818561462c565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b600080604083850312156156f357600080fd5b82519150614976602084016151af565b868152856020820152608060408201526000615723608083018688615435565b82810360608401526156bd818587615435565b60006101008a83528960208401528060408401526157568184018a6145b8565b9050828103606084015261576a81896145fc565b9050828103608084015261577e8188615306565b905082810360a08401526157928187614672565b905082810360c08401526157a6818661462c565b905082810360e08401526157ba818561462c565b9b9a5050505050505050505050565b600082601f8301126157da57600080fd5b815160206157ea6141578361408f565b82815260059290921b8401810191818101908684111561580957600080fd5b8286015b8481101561358057805161582081614121565b835291830191830161580d565b60006020828403121561583f57600080fd5b81516001600160401b038082111561585657600080fd5b90830190610260828603121561586b57600080fd5b61587361403c565b82518152615883602084016151a4565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406158ea8185016151af565b908201526101606158fc8482016151af565b9082015261018061590e8482016151af565b908201526101a083810151908201526101c080840151908201526101e0808401518381111561593c57600080fd5b615948888287016157c9565b91830191909152506102008381015190820152610220808401519082015261024091506159768284016151af565b91810191909152949350505050565b600181811c9082168061599957607f821691505b6020821081036159b957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611149576111496159bf565b600082615a0557634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215615a1c57600080fd5b81516001600160601b038116811461238557600080fd5b80820180821115611149576111496159bf565b8082028115828204841417611149576111496159bf565b602081526000612385602083018461462c565b8981526001600160a01b038916602082015261012060408201819052600090615a9b8382018b6145b8565b90508281036060840152615aaf818a6145fc565b90508281036080840152615ac38189614672565b905082810360a0840152615ad78188614672565b90508560c08401528460e0840152828103610100840152615af8818561462c565b9c9b505050505050505050505050565b8d81526001600160a01b038d1660208201526101a060408201526000615b326101a083018e6145b8565b8281036060840152615b44818e6145b8565b90508281036080840152615b58818d6145fc565b905082810360a0840152615b6c818c614672565b905082810360c0840152615b80818b614672565b90508860e084015287610100840152615ba56101208401886001600160401b03169052565b8561014084015284610160840152828103610180840152615bc6818561462c565b9150509e9d5050505050505050505050505050565b601f82111561380957600081815260208120601f850160051c81016020861015615c025750805b601f850160051c820191505b81811015611ae957828155600101615c0e565b81516001600160401b03811115615c3a57615c3a613fdb565b615c4e81615c488454615985565b84615bdb565b602080601f831160018114615c835760008415615c6b5750858301515b600019600386901b1c1916600185901b178555611ae9565b600085815260208120601f198616915b82811015615cb257888601518255948401946001909101908401615c93565b5085821015615cd05787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe4e6f756e7344414f3a3a67657444796e616d696351756f72756d506172616d7341743a20626c6f636b206e756d62657220657863656564732033322062697473a2646970667358221220f2491533bce39ba61a365bfc63f8b086fe9c0ae725b29e960d5b36bc221d741664736f6c63430008130033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.