|
{
|
|
"language": "Solidity",
|
|
"sources": {
|
|
"src/manager/Manager.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { UUPS } from \"../lib/proxy/UUPS.sol\";\nimport { Ownable } from \"../lib/utils/Ownable.sol\";\nimport { ERC1967Proxy } from \"../lib/proxy/ERC1967Proxy.sol\";\n\nimport { ManagerStorageV1 } from \"./storage/ManagerStorageV1.sol\";\nimport { IManager } from \"./IManager.sol\";\nimport { IToken } from \"../token/IToken.sol\";\nimport { IBaseMetadata } from \"../token/metadata/interfaces/IBaseMetadata.sol\";\nimport { IAuction } from \"../auction/IAuction.sol\";\nimport { ITreasury } from \"../governance/treasury/ITreasury.sol\";\nimport { IGovernor } from \"../governance/governor/IGovernor.sol\";\n\n/// @title Manager\n/// @author Rohan Kulkarni\n/// @notice The DAO deployer and upgrade manager\ncontract Manager is IManager, UUPS, Ownable, ManagerStorageV1 {\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @notice The token implementation address\n address public immutable tokenImpl;\n\n /// @notice The metadata renderer implementation address\n address public immutable metadataImpl;\n\n /// @notice The auction house implementation address\n address public immutable auctionImpl;\n\n /// @notice The treasury implementation address\n address public immutable treasuryImpl;\n\n /// @notice The governor implementation address\n address public immutable governorImpl;\n\n /// ///\n /// CONSTRUCTOR ///\n /// ///\n\n constructor(\n address _tokenImpl,\n address _metadataImpl,\n address _auctionImpl,\n address _treasuryImpl,\n address _governorImpl\n ) payable initializer {\n tokenImpl = _tokenImpl;\n metadataImpl = _metadataImpl;\n auctionImpl = _auctionImpl;\n treasuryImpl = _treasuryImpl;\n governorImpl = _governorImpl;\n }\n\n /// ///\n /// INITIALIZER ///\n /// ///\n\n /// @notice Initializes ownership of the manager contract\n /// @param _newOwner The owner address to set (will be transferred to the Builder DAO once its deployed)\n function initialize(address _newOwner) external initializer {\n // Ensure an owner is specified\n if (_newOwner == address(0)) revert ADDRESS_ZERO();\n\n // Set the contract owner\n __Ownable_init(_newOwner);\n }\n\n /// ///\n /// DAO DEPLOY ///\n /// ///\n\n /// @notice Deploys a DAO with custom token, auction, and governance settings\n /// @param _founderParams The DAO founders\n /// @param _tokenParams The ERC-721 token settings\n /// @param _auctionParams The auction settings\n /// @param _govParams The governance settings\n function deploy(\n FounderParams[] calldata _founderParams,\n TokenParams calldata _tokenParams,\n AuctionParams calldata _auctionParams,\n GovParams calldata _govParams\n )\n external\n returns (\n address token,\n address metadata,\n address auction,\n address treasury,\n address governor\n )\n {\n // Used to store the address of the first (or only) founder\n // This founder is responsible for adding token artwork and launching the first auction -- they're also free to transfer this responsiblity\n address founder;\n\n // Ensure at least one founder is provided\n if ((founder = _founderParams[0].wallet) == address(0)) revert FOUNDER_REQUIRED();\n\n // Deploy the DAO's ERC-721 governance token\n token = address(new ERC1967Proxy(tokenImpl, \"\"));\n\n // Use the token address to precompute the DAO's remaining addresses\n bytes32 salt = bytes32(uint256(uint160(token)) << 96);\n\n // Deploy the remaining DAO contracts\n metadata = address(new ERC1967Proxy{ salt: salt }(metadataImpl, \"\"));\n auction = address(new ERC1967Proxy{ salt: salt }(auctionImpl, \"\"));\n treasury = address(new ERC1967Proxy{ salt: salt }(treasuryImpl, \"\"));\n governor = address(new ERC1967Proxy{ salt: salt }(governorImpl, \"\"));\n\n daoAddressesByToken[token] = DAOAddresses({ metadata: metadata, auction: auction, treasury: treasury, governor: governor });\n\n // Initialize each instance with the provided settings\n IToken(token).initialize({\n founders: _founderParams,\n initStrings: _tokenParams.initStrings,\n metadataRenderer: metadata,\n auction: auction,\n initialOwner: founder\n });\n IBaseMetadata(metadata).initialize({ initStrings: _tokenParams.initStrings, token: token });\n IAuction(auction).initialize({\n token: token,\n founder: founder,\n treasury: treasury,\n duration: _auctionParams.duration,\n reservePrice: _auctionParams.reservePrice\n });\n ITreasury(treasury).initialize({ governor: governor, timelockDelay: _govParams.timelockDelay });\n IGovernor(governor).initialize({\n treasury: treasury,\n token: token,\n vetoer: _govParams.vetoer,\n votingDelay: _govParams.votingDelay,\n votingPeriod: _govParams.votingPeriod,\n proposalThresholdBps: _govParams.proposalThresholdBps,\n quorumThresholdBps: _govParams.quorumThresholdBps\n });\n\n emit DAODeployed({ token: token, metadata: metadata, auction: auction, treasury: treasury, governor: governor });\n }\n\n /// ///\n /// DAO ADDRESSES ///\n /// ///\n\n /// @notice A DAO's contract addresses from its token\n /// @param _token The ERC-721 token address\n /// @return metadata Metadata deployed address\n /// @return auction Auction deployed address\n /// @return treasury Treasury deployed address\n /// @return governor Governor deployed address\n function getAddresses(address _token)\n external\n view\n returns (\n address metadata,\n address auction,\n address treasury,\n address governor\n )\n {\n DAOAddresses storage addresses = daoAddressesByToken[_token];\n\n metadata = addresses.metadata;\n auction = addresses.auction;\n treasury = addresses.treasury;\n governor = addresses.governor;\n }\n\n /// ///\n /// DAO UPGRADES ///\n /// ///\n\n /// @notice If an implementation is registered by the Builder DAO as an optional upgrade\n /// @param _baseImpl The base implementation address\n /// @param _upgradeImpl The upgrade implementation address\n function isRegisteredUpgrade(address _baseImpl, address _upgradeImpl) external view returns (bool) {\n return isUpgrade[_baseImpl][_upgradeImpl];\n }\n\n /// @notice Called by the Builder DAO to offer implementation upgrades for created DAOs\n /// @param _baseImpl The base implementation address\n /// @param _upgradeImpl The upgrade implementation address\n function registerUpgrade(address _baseImpl, address _upgradeImpl) external onlyOwner {\n isUpgrade[_baseImpl][_upgradeImpl] = true;\n\n emit UpgradeRegistered(_baseImpl, _upgradeImpl);\n }\n\n /// @notice Called by the Builder DAO to remove an upgrade\n /// @param _baseImpl The base implementation address\n /// @param _upgradeImpl The upgrade implementation address\n function removeUpgrade(address _baseImpl, address _upgradeImpl) external onlyOwner {\n delete isUpgrade[_baseImpl][_upgradeImpl];\n\n emit UpgradeRemoved(_baseImpl, _upgradeImpl);\n }\n\n /// ///\n /// MANAGER UPGRADE ///\n /// ///\n\n /// @notice Ensures the caller is authorized to upgrade the contract\n /// @dev This function is called in `upgradeTo` & `upgradeToAndCall`\n /// @param _newImpl The new implementation address\n function _authorizeUpgrade(address _newImpl) internal override onlyOwner {}\n}\n"
|
|
},
|
|
"src/lib/proxy/UUPS.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../interfaces/IUUPS.sol\";\nimport { ERC1967Upgrade } from \"./ERC1967Upgrade.sol\";\n\n/// @title UUPS\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/utils/UUPSUpgradeable.sol)\n/// - Uses custom errors declared in IUUPS\n/// - Inherits a modern, minimal ERC1967Upgrade\nabstract contract UUPS is IUUPS, ERC1967Upgrade {\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @dev The address of the implementation\n address private immutable __self = address(this);\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @dev Ensures that execution is via proxy delegatecall with the correct implementation\n modifier onlyProxy() {\n if (address(this) == __self) revert ONLY_DELEGATECALL();\n if (_getImplementation() != __self) revert ONLY_PROXY();\n _;\n }\n\n /// @dev Ensures that execution is via direct call\n modifier notDelegated() {\n if (address(this) != __self) revert ONLY_CALL();\n _;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Hook to authorize an implementation upgrade\n /// @param _newImpl The new implementation address\n function _authorizeUpgrade(address _newImpl) internal virtual;\n\n /// @notice Upgrades to an implementation\n /// @param _newImpl The new implementation address\n function upgradeTo(address _newImpl) external onlyProxy {\n _authorizeUpgrade(_newImpl);\n _upgradeToAndCallUUPS(_newImpl, \"\", false);\n }\n\n /// @notice Upgrades to an implementation with an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function upgradeToAndCall(address _newImpl, bytes memory _data) external payable onlyProxy {\n _authorizeUpgrade(_newImpl);\n _upgradeToAndCallUUPS(_newImpl, _data, true);\n }\n\n /// @notice The storage slot of the implementation address\n function proxiableUUID() external view notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n}\n"
|
|
},
|
|
"src/lib/utils/Ownable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IOwnable } from \"../interfaces/IOwnable.sol\";\nimport { Initializable } from \"../utils/Initializable.sol\";\n\n/// @title Ownable\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (access/OwnableUpgradeable.sol)\n/// - Uses custom errors declared in IOwnable\n/// - Adds optional two-step ownership transfer (`safeTransferOwnership` + `acceptOwnership`)\nabstract contract Ownable is IOwnable, Initializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @dev The address of the owner\n address internal _owner;\n\n /// @dev The address of the pending owner\n address internal _pendingOwner;\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @dev Ensures the caller is the owner\n modifier onlyOwner() {\n if (msg.sender != _owner) revert ONLY_OWNER();\n _;\n }\n\n /// @dev Ensures the caller is the pending owner\n modifier onlyPendingOwner() {\n if (msg.sender != _pendingOwner) revert ONLY_PENDING_OWNER();\n _;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Initializes contract ownership\n /// @param _initialOwner The initial owner address\n function __Ownable_init(address _initialOwner) internal onlyInitializing {\n _owner = _initialOwner;\n\n emit OwnerUpdated(address(0), _initialOwner);\n }\n\n /// @notice The address of the owner\n function owner() public virtual view returns (address) {\n return _owner;\n }\n\n /// @notice The address of the pending owner\n function pendingOwner() public view returns (address) {\n return _pendingOwner;\n }\n\n /// @notice Forces an ownership transfer from the last owner\n /// @param _newOwner The new owner address\n function transferOwnership(address _newOwner) public onlyOwner {\n _transferOwnership(_newOwner);\n }\n\n /// @notice Forces an ownership transfer from any sender\n /// @param _newOwner New owner to transfer contract to\n /// @dev Ensure is called only from trusted internal code, no access control checks.\n function _transferOwnership(address _newOwner) internal {\n emit OwnerUpdated(_owner, _newOwner);\n\n _owner = _newOwner;\n\n if (_pendingOwner != address(0)) delete _pendingOwner;\n }\n\n /// @notice Initiates a two-step ownership transfer\n /// @param _newOwner The new owner address\n function safeTransferOwnership(address _newOwner) public onlyOwner {\n _pendingOwner = _newOwner;\n\n emit OwnerPending(_owner, _newOwner);\n }\n\n /// @notice Accepts an ownership transfer\n function acceptOwnership() public onlyPendingOwner {\n emit OwnerUpdated(_owner, msg.sender);\n\n _owner = _pendingOwner;\n\n delete _pendingOwner;\n }\n\n /// @notice Cancels a pending ownership transfer\n function cancelOwnershipTransfer() public onlyOwner {\n emit OwnerCanceled(_owner, _pendingOwner);\n\n delete _pendingOwner;\n }\n}\n"
|
|
},
|
|
"src/lib/proxy/ERC1967Proxy.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { Proxy } from \"@openzeppelin/contracts/proxy/Proxy.sol\";\n\nimport { IERC1967Upgrade } from \"../interfaces/IERC1967Upgrade.sol\";\nimport { ERC1967Upgrade } from \"./ERC1967Upgrade.sol\";\n\n/// @title ERC1967Proxy\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/ERC1967/ERC1967Proxy.sol)\n/// - Inherits a modern, minimal ERC1967Upgrade\ncontract ERC1967Proxy is IERC1967Upgrade, Proxy, ERC1967Upgrade {\n /// ///\n /// CONSTRUCTOR ///\n /// ///\n\n /// @dev Initializes the proxy with an implementation contract and encoded function call\n /// @param _logic The implementation address\n /// @param _data The encoded function call\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev The address of the current implementation\n function _implementation() internal view virtual override returns (address) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n"
|
|
},
|
|
"src/manager/storage/ManagerStorageV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { ManagerTypesV1 } from \"../types/ManagerTypesV1.sol\";\n\n/// @notice Manager Storage V1\n/// @author Rohan Kulkarni\n/// @notice The Manager storage contract\ncontract ManagerStorageV1 is ManagerTypesV1 {\n /// @notice If a contract has been registered as an upgrade\n /// @dev Base impl => Upgrade impl\n mapping(address => mapping(address => bool)) internal isUpgrade;\n\n /// @notice Registers deployed addresses\n /// @dev Token deployed address => Struct of all other DAO addresses\n mapping(address => DAOAddresses) internal daoAddressesByToken;\n}\n"
|
|
},
|
|
"src/manager/IManager.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../lib/interfaces/IUUPS.sol\";\nimport { IOwnable } from \"../lib/interfaces/IOwnable.sol\";\n\n/// @title IManager\n/// @author Rohan Kulkarni\n/// @notice The external Manager events, errors, structs and functions\ninterface IManager is IUUPS, IOwnable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a DAO is deployed\n /// @param token The ERC-721 token address\n /// @param metadata The metadata renderer address\n /// @param auction The auction address\n /// @param treasury The treasury address\n /// @param governor The governor address\n event DAODeployed(address token, address metadata, address auction, address treasury, address governor);\n\n /// @notice Emitted when an upgrade is registered by the Builder DAO\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n event UpgradeRegistered(address baseImpl, address upgradeImpl);\n\n /// @notice Emitted when an upgrade is unregistered by the Builder DAO\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n event UpgradeRemoved(address baseImpl, address upgradeImpl);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if at least one founder is not provided upon deploy\n error FOUNDER_REQUIRED();\n\n /// ///\n /// STRUCTS ///\n /// ///\n\n /// @notice The founder parameters\n /// @param wallet The wallet address\n /// @param ownershipPct The percent ownership of the token\n /// @param vestExpiry The timestamp that vesting expires\n struct FounderParams {\n address wallet;\n uint256 ownershipPct;\n uint256 vestExpiry;\n }\n\n /// @notice The ERC-721 token parameters\n /// @param initStrings The encoded token name, symbol, collection description, collection image uri, renderer base uri\n struct TokenParams {\n bytes initStrings;\n }\n\n /// @notice The auction parameters\n /// @param reservePrice The reserve price of each auction\n /// @param duration The duration of each auction\n struct AuctionParams {\n uint256 reservePrice;\n uint256 duration;\n }\n\n /// @notice The governance parameters\n /// @param timelockDelay The time delay to execute a queued transaction\n /// @param votingDelay The time delay to vote on a created proposal\n /// @param votingPeriod The time period to vote on a proposal\n /// @param proposalThresholdBps The basis points of the token supply required to create a proposal\n /// @param quorumThresholdBps The basis points of the token supply required to reach quorum\n /// @param vetoer The address authorized to veto proposals (address(0) if none desired)\n struct GovParams {\n uint256 timelockDelay;\n uint256 votingDelay;\n uint256 votingPeriod;\n uint256 proposalThresholdBps;\n uint256 quorumThresholdBps;\n address vetoer;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The token implementation address\n function tokenImpl() external view returns (address);\n\n /// @notice The metadata renderer implementation address\n function metadataImpl() external view returns (address);\n\n /// @notice The auction house implementation address\n function auctionImpl() external view returns (address);\n\n /// @notice The treasury implementation address\n function treasuryImpl() external view returns (address);\n\n /// @notice The governor implementation address\n function governorImpl() external view returns (address);\n\n /// @notice Deploys a DAO with custom token, auction, and governance settings\n /// @param founderParams The DAO founder(s)\n /// @param tokenParams The ERC-721 token settings\n /// @param auctionParams The auction settings\n /// @param govParams The governance settings\n function deploy(\n FounderParams[] calldata founderParams,\n TokenParams calldata tokenParams,\n AuctionParams calldata auctionParams,\n GovParams calldata govParams\n )\n external\n returns (\n address token,\n address metadataRenderer,\n address auction,\n address treasury,\n address governor\n );\n\n /// @notice A DAO's remaining contract addresses from its token address\n /// @param token The ERC-721 token address\n function getAddresses(address token)\n external\n returns (\n address metadataRenderer,\n address auction,\n address treasury,\n address governor\n );\n\n /// @notice If an implementation is registered by the Builder DAO as an optional upgrade\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function isRegisteredUpgrade(address baseImpl, address upgradeImpl) external view returns (bool);\n\n /// @notice Called by the Builder DAO to offer opt-in implementation upgrades for all other DAOs\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function registerUpgrade(address baseImpl, address upgradeImpl) external;\n\n /// @notice Called by the Builder DAO to remove an upgrade\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function removeUpgrade(address baseImpl, address upgradeImpl) external;\n}\n"
|
|
},
|
|
"src/token/IToken.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../lib/interfaces/IUUPS.sol\";\nimport { IERC721Votes } from \"../lib/interfaces/IERC721Votes.sol\";\nimport { IManager } from \"../manager/IManager.sol\";\nimport { TokenTypesV1 } from \"./types/TokenTypesV1.sol\";\n\n/// @title IToken\n/// @author Rohan Kulkarni\n/// @notice The external Token events, errors and functions\ninterface IToken is IUUPS, IERC721Votes, TokenTypesV1 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a token is scheduled to be allocated\n /// @param baseTokenId The\n /// @param founderId The founder's id\n /// @param founder The founder's vesting details\n event MintScheduled(uint256 baseTokenId, uint256 founderId, Founder founder);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the founder ownership exceeds 100 percent\n error INVALID_FOUNDER_OWNERSHIP();\n\n /// @dev Reverts if the caller was not the auction contract\n error ONLY_AUCTION();\n\n /// @dev Reverts if no metadata was generated upon mint\n error NO_METADATA_GENERATED();\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's ERC-721 token\n /// @param founders The founding members to receive vesting allocations\n /// @param initStrings The encoded token and metadata initialization strings\n /// @param metadataRenderer The token's metadata renderer\n /// @param auction The token's auction house\n function initialize(\n IManager.FounderParams[] calldata founders,\n bytes calldata initStrings,\n address metadataRenderer,\n address auction,\n address initialOwner\n ) external;\n\n /// @notice Mints tokens to the auction house for bidding and handles founder vesting\n function mint() external returns (uint256 tokenId);\n\n /// @notice Burns a token that did not see any bids\n /// @param tokenId The ERC-721 token id\n function burn(uint256 tokenId) external;\n\n /// @notice The URI for a token\n /// @param tokenId The ERC-721 token id\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n /// @notice The URI for the contract\n function contractURI() external view returns (string memory);\n\n /// @notice The number of founders\n function totalFounders() external view returns (uint256);\n\n /// @notice The founders total percent ownership\n function totalFounderOwnership() external view returns (uint256);\n\n /// @notice The vesting details of a founder\n /// @param founderId The founder id\n function getFounder(uint256 founderId) external view returns (Founder memory);\n\n /// @notice The vesting details of all founders\n function getFounders() external view returns (Founder[] memory);\n\n /// @notice The founder scheduled to receive the given token id\n /// NOTE: If a founder is returned, there's no guarantee they'll receive the token as vesting expiration is not considered\n /// @param tokenId The ERC-721 token id\n function getScheduledRecipient(uint256 tokenId) external view returns (Founder memory);\n\n /// @notice The total supply of tokens\n function totalSupply() external view returns (uint256);\n\n /// @notice The token's auction house\n function auction() external view returns (address);\n\n /// @notice The token's metadata renderer\n function metadataRenderer() external view returns (address);\n\n /// @notice The owner of the token and metadata renderer\n function owner() external view returns (address);\n\n /// @notice Callback called by auction on first auction started to transfer ownership to treasury from founder\n function onFirstAuctionStarted() external;\n}\n"
|
|
},
|
|
"src/token/metadata/interfaces/IBaseMetadata.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../../../lib/interfaces/IUUPS.sol\";\n\n\n/// @title IBaseMetadata\n/// @author Rohan Kulkarni\n/// @notice The external Base Metadata errors and functions\ninterface IBaseMetadata is IUUPS {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's token metadata renderer\n /// @param initStrings The encoded token and metadata initialization strings\n /// @param token The associated ERC-721 token address\n function initialize(\n bytes calldata initStrings,\n address token\n ) external;\n\n /// @notice Generates attributes for a token upon mint\n /// @param tokenId The ERC-721 token id\n function onMinted(uint256 tokenId) external returns (bool);\n\n /// @notice The token URI\n /// @param tokenId The ERC-721 token id\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n /// @notice The contract URI\n function contractURI() external view returns (string memory);\n\n /// @notice The associated ERC-721 token\n function token() external view returns (address);\n\n /// @notice Get metadata owner address\n function owner() external view returns (address);\n}\n"
|
|
},
|
|
"src/auction/IAuction.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../lib/interfaces/IUUPS.sol\";\nimport { IOwnable } from \"../lib/interfaces/IOwnable.sol\";\nimport { IPausable } from \"../lib/interfaces/IPausable.sol\";\n\n/// @title IAuction\n/// @author Rohan Kulkarni\n/// @notice The external Auction events, errors, and functions\ninterface IAuction is IUUPS, IOwnable, IPausable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a bid is placed\n /// @param tokenId The ERC-721 token id\n /// @param bidder The address of the bidder\n /// @param amount The amount of ETH\n /// @param extended If the bid extended the auction\n /// @param endTime The end time of the auction\n event AuctionBid(uint256 tokenId, address bidder, uint256 amount, bool extended, uint256 endTime);\n\n /// @notice Emitted when an auction is settled\n /// @param tokenId The ERC-721 token id of the settled auction\n /// @param winner The address of the winning bidder\n /// @param amount The amount of ETH raised from the winning bid\n event AuctionSettled(uint256 tokenId, address winner, uint256 amount);\n\n /// @notice Emitted when an auction is created\n /// @param tokenId The ERC-721 token id of the created auction\n /// @param startTime The start time of the created auction\n /// @param endTime The end time of the created auction\n event AuctionCreated(uint256 tokenId, uint256 startTime, uint256 endTime);\n\n /// @notice Emitted when the auction duration is updated\n /// @param duration The new auction duration\n event DurationUpdated(uint256 duration);\n\n /// @notice Emitted when the reserve price is updated\n /// @param reservePrice The new reserve price\n event ReservePriceUpdated(uint256 reservePrice);\n\n /// @notice Emitted when the min bid increment percentage is updated\n /// @param minBidIncrementPercentage The new min bid increment percentage\n event MinBidIncrementPercentageUpdated(uint256 minBidIncrementPercentage);\n\n /// @notice Emitted when the time buffer is updated\n /// @param timeBuffer The new time buffer\n event TimeBufferUpdated(uint256 timeBuffer);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if a bid is placed for the wrong token\n error INVALID_TOKEN_ID();\n\n /// @dev Reverts if a bid is placed for an auction thats over\n error AUCTION_OVER();\n\n /// @dev Reverts if a bid is placed for an auction that hasn't started\n error AUCTION_NOT_STARTED();\n\n /// @dev Reverts if attempting to settle an active auction\n error AUCTION_ACTIVE();\n\n /// @dev Reverts if attempting to settle an auction that was already settled\n error AUCTION_SETTLED();\n\n /// @dev Reverts if a bid does not meet the reserve price\n error RESERVE_PRICE_NOT_MET();\n\n /// @dev Reverts if a bid does not meet the minimum bid\n error MINIMUM_BID_NOT_MET();\n\n /// @dev Reverts if the contract does not have enough ETH\n error INSOLVENT();\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// @dev Thrown if the WETH contract throws a failure on transfer\n error FAILING_WETH_TRANSFER();\n\n /// @dev Thrown if the auction creation failed\n error AUCTION_CREATE_FAILED_TO_LAUNCH();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's auction house\n /// @param token The ERC-721 token address\n /// @param founder The founder responsible for starting the first auction\n /// @param treasury The treasury address where ETH will be sent\n /// @param duration The duration of each auction\n /// @param reservePrice The reserve price of each auction\n function initialize(\n address token,\n address founder,\n address treasury,\n uint256 duration,\n uint256 reservePrice\n ) external;\n\n /// @notice Creates a bid for the current token\n /// @param tokenId The ERC-721 token id\n function createBid(uint256 tokenId) external payable;\n\n /// @notice Settles the current auction and creates the next one\n function settleCurrentAndCreateNewAuction() external;\n\n /// @notice Settles the latest auction when the contract is paused\n function settleAuction() external;\n\n /// @notice Pauses the auction house\n function pause() external;\n\n /// @notice Unpauses the auction house\n function unpause() external;\n\n /// @notice The time duration of each auction\n function duration() external view returns (uint256);\n\n /// @notice The reserve price of each auction\n function reservePrice() external view returns (uint256);\n\n /// @notice The minimum amount of time to place a bid during an active auction\n function timeBuffer() external view returns (uint256);\n\n /// @notice The minimum percentage an incoming bid must raise the highest bid\n function minBidIncrement() external view returns (uint256);\n\n /// @notice Updates the time duration of each auction\n /// @param duration The new time duration\n function setDuration(uint256 duration) external;\n\n /// @notice Updates the reserve price of each auction\n /// @param reservePrice The new reserve price\n function setReservePrice(uint256 reservePrice) external;\n\n /// @notice Updates the time buffer of each auction\n /// @param timeBuffer The new time buffer\n function setTimeBuffer(uint256 timeBuffer) external;\n\n /// @notice Updates the minimum bid increment of each subsequent bid\n /// @param percentage The new percentage\n function setMinimumBidIncrement(uint256 percentage) external;\n\n /// @notice Get the address of the treasury\n function treasury() external returns (address);\n}\n"
|
|
},
|
|
"src/governance/treasury/ITreasury.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IOwnable } from \"../../lib/utils/Ownable.sol\";\nimport { IUUPS } from \"../../lib/interfaces/IUUPS.sol\";\n\n/// @title ITreasury\n/// @author Rohan Kulkarni\n/// @notice The external Treasury events, errors and functions\ninterface ITreasury is IUUPS, IOwnable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a transaction is scheduled\n event TransactionScheduled(bytes32 proposalId, uint256 timestamp);\n\n /// @notice Emitted when a transaction is canceled\n event TransactionCanceled(bytes32 proposalId);\n\n /// @notice Emitted when a transaction is executed\n event TransactionExecuted(bytes32 proposalId, address[] targets, uint256[] values, bytes[] payloads);\n\n /// @notice Emitted when the transaction delay is updated\n event DelayUpdated(uint256 prevDelay, uint256 newDelay);\n\n /// @notice Emitted when the grace period is updated\n event GracePeriodUpdated(uint256 prevGracePeriod, uint256 newGracePeriod);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if tx was already queued\n error PROPOSAL_ALREADY_QUEUED();\n\n /// @dev Reverts if tx was not queued\n error PROPOSAL_NOT_QUEUED();\n\n /// @dev Reverts if a tx isn't ready to execute\n /// @param proposalId The proposal id\n error EXECUTION_NOT_READY(bytes32 proposalId);\n\n /// @dev Reverts if a tx failed\n /// @param txIndex The index of the tx\n error EXECUTION_FAILED(uint256 txIndex);\n\n /// @dev Reverts if execution was attempted after the grace period\n error EXECUTION_EXPIRED();\n\n /// @dev Reverts if the caller was not the treasury itself\n error ONLY_TREASURY();\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's treasury\n /// @param governor The governor address\n /// @param timelockDelay The time delay to execute a queued transaction\n function initialize(address governor, uint256 timelockDelay) external;\n\n /// @notice The timestamp that a proposal is valid to execute\n /// @param proposalId The proposal id\n function timestamp(bytes32 proposalId) external view returns (uint256);\n\n /// @notice If a proposal has been queued\n /// @param proposalId The proposal ids\n function isQueued(bytes32 proposalId) external view returns (bool);\n\n /// @notice If a proposal is ready to execute (does not consider if a proposal has expired)\n /// @param proposalId The proposal id\n function isReady(bytes32 proposalId) external view returns (bool);\n\n /// @notice If a proposal has expired to execute\n /// @param proposalId The proposal id\n function isExpired(bytes32 proposalId) external view returns (bool);\n\n /// @notice Schedules a proposal for execution\n /// @param proposalId The proposal id\n function queue(bytes32 proposalId) external returns (uint256 eta);\n\n /// @notice Removes a queued proposal\n /// @param proposalId The proposal id\n function cancel(bytes32 proposalId) external;\n\n /// @notice Executes a queued proposal\n /// @param targets The target addresses to call\n /// @param values The ETH values of each call\n /// @param calldatas The calldata of each call\n /// @param descriptionHash The hash of the description\n /// @param proposer The proposal creator\n function execute(\n address[] calldata targets,\n uint256[] calldata values,\n bytes[] calldata calldatas,\n bytes32 descriptionHash,\n address proposer\n ) external payable;\n\n /// @notice The time delay to execute a queued transaction\n function delay() external view returns (uint256);\n\n /// @notice The time period to execute a transaction\n function gracePeriod() external view returns (uint256);\n\n /// @notice Updates the time delay\n /// @param newDelay The new time delay\n function updateDelay(uint256 newDelay) external;\n\n /// @notice Updates the grace period\n /// @param newGracePeriod The grace period\n function updateGracePeriod(uint256 newGracePeriod) external;\n}\n"
|
|
},
|
|
"src/governance/governor/IGovernor.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../../lib/interfaces/IUUPS.sol\";\nimport { IOwnable } from \"../../lib/utils/Ownable.sol\";\nimport { IEIP712 } from \"../../lib/utils/EIP712.sol\";\nimport { GovernorTypesV1 } from \"./types/GovernorTypesV1.sol\";\n\n/// @title IGovernor\n/// @author Rohan Kulkarni\n/// @notice The external Governor events, errors and functions\ninterface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a proposal is created\n event ProposalCreated(\n bytes32 proposalId,\n address[] targets,\n uint256[] values,\n bytes[] calldatas,\n string description,\n bytes32 descriptionHash,\n Proposal proposal\n );\n\n /// @notice Emitted when a proposal is queued\n event ProposalQueued(bytes32 proposalId, uint256 eta);\n\n /// @notice Emitted when a proposal is executed\n /// @param proposalId The proposal id\n event ProposalExecuted(bytes32 proposalId);\n\n /// @notice Emitted when a proposal is canceled\n event ProposalCanceled(bytes32 proposalId);\n\n /// @notice Emitted when a proposal is vetoed\n event ProposalVetoed(bytes32 proposalId);\n\n /// @notice Emitted when a vote is casted for a proposal\n event VoteCast(address voter, bytes32 proposalId, uint256 support, uint256 weight, string reason);\n\n /// @notice Emitted when the governor's voting delay is updated\n event VotingDelayUpdated(uint256 prevVotingDelay, uint256 newVotingDelay);\n\n /// @notice Emitted when the governor's voting period is updated\n event VotingPeriodUpdated(uint256 prevVotingPeriod, uint256 newVotingPeriod);\n\n /// @notice Emitted when the basis points of the governor's proposal threshold is updated\n event ProposalThresholdBpsUpdated(uint256 prevBps, uint256 newBps);\n\n /// @notice Emitted when the basis points of the governor's quorum votes is updated\n event QuorumVotesBpsUpdated(uint256 prevBps, uint256 newBps);\n\n //// @notice Emitted when the governor's vetoer is updated\n event VetoerUpdated(address prevVetoer, address newVetoer);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n error INVALID_PROPOSAL_THRESHOLD_BPS();\n\n error INVALID_QUORUM_THRESHOLD_BPS();\n\n error INVALID_VOTING_DELAY();\n\n error INVALID_VOTING_PERIOD();\n\n /// @dev Reverts if a proposal already exists\n /// @param proposalId The proposal id\n error PROPOSAL_EXISTS(bytes32 proposalId);\n\n /// @dev Reverts if a proposal isn't queued\n /// @param proposalId The proposal id\n error PROPOSAL_NOT_QUEUED(bytes32 proposalId);\n\n /// @dev Reverts if the proposer didn't specify a target address\n error PROPOSAL_TARGET_MISSING();\n\n /// @dev Reverts if the number of targets, values, and calldatas does not match\n error PROPOSAL_LENGTH_MISMATCH();\n\n /// @dev Reverts if a proposal didn't succeed\n error PROPOSAL_UNSUCCESSFUL();\n\n /// @dev Reverts if a proposal was already executed\n error PROPOSAL_ALREADY_EXECUTED();\n\n /// @dev Reverts if a specified proposal doesn't exist\n error PROPOSAL_DOES_NOT_EXIST();\n\n /// @dev Reverts if the proposer's voting weight is below the proposal threshold\n error BELOW_PROPOSAL_THRESHOLD();\n\n /// @dev Reverts if a vote was prematurely casted\n error VOTING_NOT_STARTED();\n\n /// @dev Reverts if the caller wasn't the vetoer\n error ONLY_VETOER();\n\n /// @dev Reverts if the caller already voted\n error ALREADY_VOTED();\n\n /// @dev Reverts if a proposal was attempted to be canceled incorrectly\n error INVALID_CANCEL();\n\n /// @dev Reverts if a vote was attempted to be casted incorrectly\n error INVALID_VOTE();\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's governor\n /// @param treasury The DAO's treasury address\n /// @param token The DAO's governance token address\n /// @param vetoer The address eligible to veto proposals\n /// @param votingDelay The voting delay\n /// @param votingPeriod The voting period\n /// @param proposalThresholdBps The proposal threshold basis points\n /// @param quorumThresholdBps The quorum threshold basis points\n function initialize(\n address treasury,\n address token,\n address vetoer,\n uint256 votingDelay,\n uint256 votingPeriod,\n uint256 proposalThresholdBps,\n uint256 quorumThresholdBps\n ) external;\n\n /// @notice Creates a proposal\n /// @param targets The target addresses to call\n /// @param values The ETH values of each call\n /// @param calldatas The calldata of each call\n /// @param description The proposal description\n function propose(\n address[] memory targets,\n uint256[] memory values,\n bytes[] memory calldatas,\n string memory description\n ) external returns (bytes32);\n\n /// @notice Casts a vote\n /// @param proposalId The proposal id\n /// @param support The support value (0 = Against, 1 = For, 2 = Abstain)\n function castVote(bytes32 proposalId, uint256 support) external returns (uint256);\n\n /// @notice Casts a vote with a reason\n /// @param proposalId The proposal id\n /// @param support The support value (0 = Against, 1 = For, 2 = Abstain)\n /// @param reason The vote reason\n function castVoteWithReason(\n bytes32 proposalId,\n uint256 support,\n string memory reason\n ) external returns (uint256);\n\n /// @notice Casts a signed vote\n /// @param voter The voter address\n /// @param proposalId The proposal id\n /// @param support The support value (0 = Against, 1 = For, 2 = Abstain)\n /// @param deadline The signature deadline\n /// @param v The 129th byte and chain id of the signature\n /// @param r The first 64 bytes of the signature\n /// @param s Bytes 64-128 of the signature\n function castVoteBySig(\n address voter,\n bytes32 proposalId,\n uint256 support,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256);\n\n /// @notice Queues a proposal\n /// @param proposalId The proposal id\n function queue(bytes32 proposalId) external returns (uint256 eta);\n\n /// @notice Executes a proposal\n /// @param targets The target addresses to call\n /// @param values The ETH values of each call\n /// @param calldatas The calldata of each call\n /// @param descriptionHash The hash of the description\n /// @param proposer The proposal creator\n function execute(\n address[] memory targets,\n uint256[] memory values,\n bytes[] memory calldatas,\n bytes32 descriptionHash,\n address proposer\n ) external payable returns (bytes32);\n\n /// @notice Cancels a proposal\n /// @param proposalId The proposal id\n function cancel(bytes32 proposalId) external;\n\n /// @notice Vetoes a proposal\n /// @param proposalId The proposal id\n function veto(bytes32 proposalId) external;\n\n /// @notice The state of a proposal\n /// @param proposalId The proposal id\n function state(bytes32 proposalId) external view returns (ProposalState);\n\n /// @notice The voting weight of an account at a timestamp\n /// @param account The account address\n /// @param timestamp The specific timestamp\n function getVotes(address account, uint256 timestamp) external view returns (uint256);\n\n /// @notice The current number of votes required to submit a proposal\n function proposalThreshold() external view returns (uint256);\n\n /// @notice The current number of votes required to be in favor of a proposal in order to reach quorum\n function quorum() external view returns (uint256);\n\n /// @notice The details of a proposal\n /// @param proposalId The proposal id\n function getProposal(bytes32 proposalId) external view returns (Proposal memory);\n\n /// @notice The timestamp when voting starts for a proposal\n /// @param proposalId The proposal id\n function proposalSnapshot(bytes32 proposalId) external view returns (uint256);\n\n /// @notice The timestamp when voting ends for a proposal\n /// @param proposalId The proposal id\n function proposalDeadline(bytes32 proposalId) external view returns (uint256);\n\n /// @notice The vote counts for a proposal\n /// @param proposalId The proposal id\n function proposalVotes(bytes32 proposalId)\n external\n view\n returns (\n uint256 againstVotes,\n uint256 forVotes,\n uint256 abstainVotes\n );\n\n /// @notice The timestamp valid to execute a proposal\n /// @param proposalId The proposal id\n function proposalEta(bytes32 proposalId) external view returns (uint256);\n\n /// @notice The minimum basis points of the total token supply required to submit a proposal\n function proposalThresholdBps() external view returns (uint256);\n\n /// @notice The minimum basis points of the total token supply required to reach quorum\n function quorumThresholdBps() external view returns (uint256);\n\n /// @notice The amount of time until voting begins after a proposal is created\n function votingDelay() external view returns (uint256);\n\n /// @notice The amount of time to vote on a proposal\n function votingPeriod() external view returns (uint256);\n\n /// @notice The address eligible to veto any proposal (address(0) if burned)\n function vetoer() external view returns (address);\n\n /// @notice The address of the governance token\n function token() external view returns (address);\n\n /// @notice The address of the DAO treasury\n function treasury() external view returns (address);\n\n /// @notice Updates the voting delay\n /// @param newVotingDelay The new voting delay\n function updateVotingDelay(uint256 newVotingDelay) external;\n\n /// @notice Updates the voting period\n /// @param newVotingPeriod The new voting period\n function updateVotingPeriod(uint256 newVotingPeriod) external;\n\n /// @notice Updates the minimum proposal threshold\n /// @param newProposalThresholdBps The new proposal threshold basis points\n function updateProposalThresholdBps(uint256 newProposalThresholdBps) external;\n\n /// @notice Updates the minimum quorum threshold\n /// @param newQuorumVotesBps The new quorum votes basis points\n function updateQuorumThresholdBps(uint256 newQuorumVotesBps) external;\n\n /// @notice Updates the vetoer\n /// @param newVetoer The new vetoer addresss\n function updateVetoer(address newVetoer) external;\n\n /// @notice Burns the vetoer\n function burnVetoer() external;\n\n /// @notice The EIP-712 typehash to vote with a signature\n function VOTE_TYPEHASH() external view returns (bytes32);\n}\n"
|
|
},
|
|
"src/lib/interfaces/IUUPS.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport { IERC1822Proxiable } from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport { IERC1967Upgrade } from \"./IERC1967Upgrade.sol\";\n\n/// @title IUUPS\n/// @author Rohan Kulkarni\n/// @notice The external UUPS errors and functions\ninterface IUUPS is IERC1967Upgrade, IERC1822Proxiable {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if not called directly\n error ONLY_CALL();\n\n /// @dev Reverts if not called via delegatecall\n error ONLY_DELEGATECALL();\n\n /// @dev Reverts if not called via proxy\n error ONLY_PROXY();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Upgrades to an implementation\n /// @param newImpl The new implementation address\n function upgradeTo(address newImpl) external;\n\n /// @notice Upgrades to an implementation with an additional function call\n /// @param newImpl The new implementation address\n /// @param data The encoded function call\n function upgradeToAndCall(address newImpl, bytes memory data) external payable;\n}\n"
|
|
},
|
|
"src/lib/proxy/ERC1967Upgrade.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC1822Proxiable } from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport { StorageSlot } from \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\nimport { IERC1967Upgrade } from \"../interfaces/IERC1967Upgrade.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title ERC1967Upgrade\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/ERC1967/ERC1967Upgrade.sol)\n/// - Uses custom errors declared in IERC1967Upgrade\n/// - Removes ERC1967 admin and beacon support\nabstract contract ERC1967Upgrade is IERC1967Upgrade {\n /// ///\n /// CONSTANTS ///\n /// ///\n\n /// @dev bytes32(uint256(keccak256('eip1967.proxy.rollback')) - 1)\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /// @dev bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Upgrades to an implementation with security checks for UUPS proxies and an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function _upgradeToAndCallUUPS(\n address _newImpl,\n bytes memory _data,\n bool _forceCall\n ) internal {\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(_newImpl);\n } else {\n try IERC1822Proxiable(_newImpl).proxiableUUID() returns (bytes32 slot) {\n if (slot != _IMPLEMENTATION_SLOT) revert UNSUPPORTED_UUID();\n } catch {\n revert ONLY_UUPS();\n }\n\n _upgradeToAndCall(_newImpl, _data, _forceCall);\n }\n }\n\n /// @dev Upgrades to an implementation with an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function _upgradeToAndCall(\n address _newImpl,\n bytes memory _data,\n bool _forceCall\n ) internal {\n _upgradeTo(_newImpl);\n\n if (_data.length > 0 || _forceCall) {\n Address.functionDelegateCall(_newImpl, _data);\n }\n }\n\n /// @dev Performs an implementation upgrade\n /// @param _newImpl The new implementation address\n function _upgradeTo(address _newImpl) internal {\n _setImplementation(_newImpl);\n\n emit Upgraded(_newImpl);\n }\n\n /// @dev Stores the address of an implementation\n /// @param _impl The implementation address\n function _setImplementation(address _impl) private {\n if (!Address.isContract(_impl)) revert INVALID_UPGRADE(_impl);\n\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = _impl;\n }\n\n /// @dev The address of the current implementation\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n}\n"
|
|
},
|
|
"src/lib/interfaces/IOwnable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IOwnable\n/// @author Rohan Kulkarni\n/// @notice The external Ownable events, errors, and functions\ninterface IOwnable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when ownership has been updated\n /// @param prevOwner The previous owner address\n /// @param newOwner The new owner address\n event OwnerUpdated(address indexed prevOwner, address indexed newOwner);\n\n /// @notice Emitted when an ownership transfer is pending\n /// @param owner The current owner address\n /// @param pendingOwner The pending new owner address\n event OwnerPending(address indexed owner, address indexed pendingOwner);\n\n /// @notice Emitted when a pending ownership transfer has been canceled\n /// @param owner The current owner address\n /// @param canceledOwner The canceled owner address\n event OwnerCanceled(address indexed owner, address indexed canceledOwner);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if an unauthorized user calls an owner function\n error ONLY_OWNER();\n\n /// @dev Reverts if an unauthorized user calls a pending owner function\n error ONLY_PENDING_OWNER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The address of the owner\n function owner() external view returns (address);\n\n /// @notice The address of the pending owner\n function pendingOwner() external view returns (address);\n\n /// @notice Forces an ownership transfer\n /// @param newOwner The new owner address\n function transferOwnership(address newOwner) external;\n\n /// @notice Initiates a two-step ownership transfer\n /// @param newOwner The new owner address\n function safeTransferOwnership(address newOwner) external;\n\n /// @notice Accepts an ownership transfer\n function acceptOwnership() external;\n\n /// @notice Cancels a pending ownership transfer\n function cancelOwnershipTransfer() external;\n}\n"
|
|
},
|
|
"src/lib/utils/Initializable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IInitializable } from \"../interfaces/IInitializable.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title Initializable\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/utils/Initializable.sol)\n/// - Uses custom errors declared in IInitializable\nabstract contract Initializable is IInitializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @dev Indicates the contract has been initialized\n uint8 internal _initialized;\n\n /// @dev Indicates the contract is being initialized\n bool internal _initializing;\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @dev Ensures an initialization function is only called within an `initializer` or `reinitializer` function\n modifier onlyInitializing() {\n if (!_initializing) revert NOT_INITIALIZING();\n _;\n }\n\n /// @dev Enables initializing upgradeable contracts\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n\n if ((!isTopLevelCall || _initialized != 0) && (Address.isContract(address(this)) || _initialized != 1)) revert ALREADY_INITIALIZED();\n\n _initialized = 1;\n\n if (isTopLevelCall) {\n _initializing = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n\n emit Initialized(1);\n }\n }\n\n /// @dev Enables initializer versioning\n /// @param _version The version to set\n modifier reinitializer(uint8 _version) {\n if (_initializing || _initialized >= _version) revert ALREADY_INITIALIZED();\n\n _initialized = _version;\n\n _initializing = true;\n\n _;\n\n _initializing = false;\n\n emit Initialized(_version);\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Prevents future initialization\n function _disableInitializers() internal virtual {\n if (_initializing) revert INITIALIZING();\n\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n\n emit Initialized(type(uint8).max);\n }\n }\n}\n"
|
|
},
|
|
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n"
|
|
},
|
|
"src/lib/interfaces/IERC1967Upgrade.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IERC1967Upgrade\n/// @author Rohan Kulkarni\n/// @notice The external ERC1967Upgrade events and errors\ninterface IERC1967Upgrade {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when the implementation is upgraded\n /// @param impl The address of the implementation\n event Upgraded(address impl);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if an implementation is an invalid upgrade\n /// @param impl The address of the invalid implementation\n error INVALID_UPGRADE(address impl);\n\n /// @dev Reverts if an implementation upgrade is not stored at the storage slot of the original\n error UNSUPPORTED_UUID();\n\n /// @dev Reverts if an implementation does not support ERC1822 proxiableUUID()\n error ONLY_UUPS();\n}\n"
|
|
},
|
|
"src/manager/types/ManagerTypesV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title ManagerTypesV1\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The external Base Metadata errors and functions\ninterface ManagerTypesV1 {\n /// @notice Stores deployed addresses for a given token's DAO\n struct DAOAddresses {\n /// @notice Address for deployed metadata contract\n address metadata;\n /// @notice Address for deployed auction contract\n address auction;\n /// @notice Address for deployed treasury contract\n address treasury;\n /// @notice Address for deployed governor contract\n address governor;\n }\n}"
|
|
},
|
|
"src/lib/interfaces/IERC721Votes.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC721 } from \"./IERC721.sol\";\nimport { IEIP712 } from \"./IEIP712.sol\";\n\n/// @title IERC721Votes\n/// @author Rohan Kulkarni\n/// @notice The external ERC721Votes events, errors, and functions\ninterface IERC721Votes is IERC721, IEIP712 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when an account changes their delegate\n event DelegateChanged(address indexed delegator, address indexed from, address indexed to);\n\n /// @notice Emitted when a delegate's number of votes is updated\n event DelegateVotesChanged(address indexed delegate, uint256 prevTotalVotes, uint256 newTotalVotes);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the timestamp provided isn't in the past\n error INVALID_TIMESTAMP();\n\n /// ///\n /// STRUCTS ///\n /// ///\n\n /// @notice The checkpoint data type\n /// @param timestamp The recorded timestamp\n /// @param votes The voting weight\n struct Checkpoint {\n uint64 timestamp;\n uint192 votes;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The current number of votes for an account\n /// @param account The account address\n function getVotes(address account) external view returns (uint256);\n\n /// @notice The number of votes for an account at a past timestamp\n /// @param account The account address\n /// @param timestamp The past timestamp\n function getPastVotes(address account, uint256 timestamp) external view returns (uint256);\n\n /// @notice The delegate for an account\n /// @param account The account address\n function delegates(address account) external view returns (address);\n\n /// @notice Delegates votes to an account\n /// @param to The address delegating votes to\n function delegate(address to) external;\n\n /// @notice Delegates votes from a signer to an account\n /// @param from The address delegating votes from\n /// @param to The address delegating votes to\n /// @param deadline The signature deadline\n /// @param v The 129th byte and chain id of the signature\n /// @param r The first 64 bytes of the signature\n /// @param s Bytes 64-128 of the signature\n function delegateBySig(\n address from,\n address to,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n"
|
|
},
|
|
"src/token/types/TokenTypesV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IBaseMetadata } from \"../metadata/interfaces/IBaseMetadata.sol\";\n\n/// @title TokenTypesV1\n/// @author Rohan Kulkarni\n/// @notice The Token custom data types\ninterface TokenTypesV1 {\n /// @notice The settings type\n /// @param auction The DAO auction house\n /// @param totalSupply The number of active tokens\n /// @param numFounders The number of vesting recipients\n /// @param metadatarenderer The token metadata renderer\n /// @param mintCount The number of minted tokens\n /// @param totalPercentage The total percentage owned by founders\n struct Settings {\n address auction;\n uint88 totalSupply;\n uint8 numFounders;\n IBaseMetadata metadataRenderer;\n uint88 mintCount;\n uint8 totalOwnership;\n }\n\n /// @notice The founder type\n /// @param wallet The address where tokens are sent\n /// @param ownershipPct The percentage of token ownership\n /// @param vestExpiry The timestamp when vesting ends\n struct Founder {\n address wallet;\n uint8 ownershipPct;\n uint32 vestExpiry;\n }\n}\n"
|
|
},
|
|
"src/lib/interfaces/IPausable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IPausable\n/// @author Rohan Kulkarni\n/// @notice The external Pausable events, errors, and functions\ninterface IPausable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when the contract is paused\n /// @param user The address that paused the contract\n event Paused(address user);\n\n /// @notice Emitted when the contract is unpaused\n /// @param user The address that unpaused the contract\n event Unpaused(address user);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if called when the contract is paused\n error PAUSED();\n\n /// @dev Reverts if called when the contract is unpaused\n error UNPAUSED();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice If the contract is paused\n function paused() external view returns (bool);\n}\n"
|
|
},
|
|
"src/lib/utils/EIP712.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IEIP712 } from \"../interfaces/IEIP712.sol\";\nimport { Initializable } from \"../utils/Initializable.sol\";\n\n/// @title EIP712\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (utils/cryptography/draft-EIP712Upgradeable.sol)\n/// - Uses custom errors declared in IEIP712\n/// - Caches `INITIAL_CHAIN_ID` and `INITIAL_DOMAIN_SEPARATOR` upon initialization\n/// - Adds mapping for account nonces\nabstract contract EIP712 is IEIP712, Initializable {\n /// ///\n /// CONSTANTS ///\n /// ///\n\n /// @dev The EIP-712 domain typehash\n bytes32 internal constant DOMAIN_TYPEHASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @notice The hash of the EIP-712 domain name\n bytes32 internal HASHED_NAME;\n\n /// @notice The hash of the EIP-712 domain version\n bytes32 internal HASHED_VERSION;\n\n /// @notice The domain separator computed upon initialization\n bytes32 internal INITIAL_DOMAIN_SEPARATOR;\n\n /// @notice The chain id upon initialization\n uint256 internal INITIAL_CHAIN_ID;\n\n /// @notice The account nonces\n /// @dev Account => Nonce\n mapping(address => uint256) internal nonces;\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Initializes EIP-712 support\n /// @param _name The EIP-712 domain name\n /// @param _version The EIP-712 domain version\n function __EIP712_init(string memory _name, string memory _version) internal onlyInitializing {\n HASHED_NAME = keccak256(bytes(_name));\n HASHED_VERSION = keccak256(bytes(_version));\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = _computeDomainSeparator();\n }\n\n /// @notice The current nonce for an account\n /// @param _account The account address\n function nonce(address _account) external view returns (uint256) {\n return nonces[_account];\n }\n\n /// @notice The EIP-712 domain separator\n function DOMAIN_SEPARATOR() public view returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : _computeDomainSeparator();\n }\n\n /// @dev Computes the EIP-712 domain separator\n function _computeDomainSeparator() private view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_TYPEHASH, HASHED_NAME, HASHED_VERSION, block.chainid, address(this)));\n }\n}\n"
|
|
},
|
|
"src/governance/governor/types/GovernorTypesV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { Token } from \"../../../token/Token.sol\";\nimport { Treasury } from \"../../treasury/Treasury.sol\";\n\n/// @title GovernorTypesV1\n/// @author Rohan Kulkarni\n/// @notice The Governor custom data types\ninterface GovernorTypesV1 {\n /// @notice The governor settings\n /// @param token The DAO governance token\n /// @param proposalThresholdBps The basis points of the token supply required to create a proposal\n /// @param quorumThresholdBps The basis points of the token supply required to reach quorum\n /// @param treasury The DAO treasury\n /// @param votingDelay The time delay to vote on a created proposal\n /// @param votingPeriod The time period to vote on a proposal\n /// @param vetoer The address with the ability to veto proposals\n struct Settings {\n Token token;\n uint16 proposalThresholdBps;\n uint16 quorumThresholdBps;\n Treasury treasury;\n uint48 votingDelay;\n uint48 votingPeriod;\n address vetoer;\n }\n\n /// @notice A governance proposal\n /// @param proposer The proposal creator\n /// @param timeCreated The timestamp that the proposal was created\n /// @param againstVotes The number of votes against\n /// @param forVotes The number of votes in favor\n /// @param abstainVotes The number of votes abstained\n /// @param voteStart The timestamp that voting starts\n /// @param voteEnd The timestamp that voting ends\n /// @param proposalThreshold The proposal threshold when the proposal was created\n /// @param quorumVotes The quorum threshold when the proposal was created\n /// @param executed If the proposal was executed\n /// @param canceled If the proposal was canceled\n /// @param vetoed If the proposal was vetoed\n struct Proposal {\n address proposer;\n uint32 timeCreated;\n uint32 againstVotes;\n uint32 forVotes;\n uint32 abstainVotes;\n uint32 voteStart;\n uint32 voteEnd;\n uint32 proposalThreshold;\n uint32 quorumVotes;\n bool executed;\n bool canceled;\n bool vetoed;\n }\n\n /// @notice The proposal state type\n enum ProposalState {\n Pending,\n Active,\n Canceled,\n Defeated,\n Succeeded,\n Queued,\n Expired,\n Executed,\n Vetoed\n }\n}\n"
|
|
},
|
|
"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n"
|
|
},
|
|
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
|
},
|
|
"src/lib/utils/Address.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title EIP712\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (utils/Address.sol)\n/// - Uses custom errors `INVALID_TARGET()` & `DELEGATE_CALL_FAILED()`\n/// - Adds util converting address to bytes32\nlibrary Address {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the target of a delegatecall is not a contract\n error INVALID_TARGET();\n\n /// @dev Reverts if a delegatecall has failed\n error DELEGATE_CALL_FAILED();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Utility to convert an address to bytes32\n function toBytes32(address _account) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(_account)) << 96);\n }\n\n /// @dev If an address is a contract\n function isContract(address _account) internal view returns (bool rv) {\n assembly {\n rv := gt(extcodesize(_account), 0)\n }\n }\n\n /// @dev Performs a delegatecall on an address\n function functionDelegateCall(address _target, bytes memory _data) internal returns (bytes memory) {\n if (!isContract(_target)) revert INVALID_TARGET();\n\n (bool success, bytes memory returndata) = _target.delegatecall(_data);\n\n return verifyCallResult(success, returndata);\n }\n\n /// @dev Verifies a delegatecall was successful\n function verifyCallResult(bool _success, bytes memory _returndata) internal pure returns (bytes memory) {\n if (_success) {\n return _returndata;\n } else {\n if (_returndata.length > 0) {\n assembly {\n let returndata_size := mload(_returndata)\n\n revert(add(32, _returndata), returndata_size)\n }\n } else {\n revert DELEGATE_CALL_FAILED();\n }\n }\n }\n}\n"
|
|
},
|
|
"src/lib/interfaces/IInitializable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IInitializable\n/// @author Rohan Kulkarni\n/// @notice The external Initializable events and errors\ninterface IInitializable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when the contract has been initialized or reinitialized\n event Initialized(uint256 version);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if incorrectly initialized with address(0)\n error ADDRESS_ZERO();\n\n /// @dev Reverts if disabling initializers during initialization\n error INITIALIZING();\n\n /// @dev Reverts if calling an initialization function outside of initialization\n error NOT_INITIALIZING();\n\n /// @dev Reverts if reinitializing incorrectly\n error ALREADY_INITIALIZED();\n}\n"
|
|
},
|
|
"src/lib/interfaces/IERC721.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IERC721\n/// @author Rohan Kulkarni\n/// @notice The external ERC721 events, errors, and functions\ninterface IERC721 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a token is transferred from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /// @notice Emitted when an owner approves an account to manage a token\n /// @param owner The owner address\n /// @param approved The account address\n /// @param tokenId The ERC-721 token id\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /// @notice Emitted when an owner sets an approval for a spender to manage all tokens\n /// @param owner The owner address\n /// @param operator The spender address\n /// @param approved If the approval is being set or removed\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if a caller is not authorized to approve or transfer a token\n error INVALID_APPROVAL();\n\n /// @dev Reverts if a transfer is called with the incorrect token owner\n error INVALID_OWNER();\n\n /// @dev Reverts if a transfer is attempted to address(0)\n error INVALID_RECIPIENT();\n\n /// @dev Reverts if an existing token is called to be minted\n error ALREADY_MINTED();\n\n /// @dev Reverts if a non-existent token is called to be burned\n error NOT_MINTED();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The number of tokens owned\n /// @param owner The owner address\n function balanceOf(address owner) external view returns (uint256);\n\n /// @notice The owner of a token\n /// @param tokenId The ERC-721 token id\n function ownerOf(uint256 tokenId) external view returns (address);\n\n /// @notice The account approved to manage a token\n /// @param tokenId The ERC-721 token id\n function getApproved(uint256 tokenId) external view returns (address);\n\n /// @notice If an operator is authorized to manage all of an owner's tokens\n /// @param owner The owner address\n /// @param operator The operator address\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /// @notice Authorizes an account to manage a token\n /// @param to The account address\n /// @param tokenId The ERC-721 token id\n function approve(address to, uint256 tokenId) external;\n\n /// @notice Authorizes an account to manage all tokens\n /// @param operator The account address\n /// @param approved If permission is being given or removed\n function setApprovalForAll(address operator, bool approved) external;\n\n /// @notice Safe transfers a token from sender to recipient with additional data\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n /// @param data The additional data sent in the call to the recipient\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /// @notice Safe transfers a token from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /// @notice Transfers a token from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n}\n"
|
|
},
|
|
"src/lib/interfaces/IEIP712.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IEIP712\n/// @author Rohan Kulkarni\n/// @notice The external EIP712 errors and functions\ninterface IEIP712 {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the deadline has passed to submit a signature\n error EXPIRED_SIGNATURE();\n\n /// @dev Reverts if the recovered signature is invalid\n error INVALID_SIGNATURE();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The sig nonce for an account\n /// @param account The account address\n function nonce(address account) external view returns (uint256);\n\n /// @notice The EIP-712 domain separator\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
|
|
},
|
|
"src/token/Token.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { UUPS } from \"../lib/proxy/UUPS.sol\";\nimport { ReentrancyGuard } from \"../lib/utils/ReentrancyGuard.sol\";\nimport { ERC721Votes } from \"../lib/token/ERC721Votes.sol\";\nimport { ERC721 } from \"../lib/token/ERC721.sol\";\nimport { Ownable } from \"../lib/utils/Ownable.sol\";\n\nimport { TokenStorageV1 } from \"./storage/TokenStorageV1.sol\";\nimport { IBaseMetadata } from \"./metadata/interfaces/IBaseMetadata.sol\";\nimport { IManager } from \"../manager/IManager.sol\";\nimport { IAuction } from \"../auction/IAuction.sol\";\nimport { IToken } from \"./IToken.sol\";\n\n/// @title Token\n/// @author Rohan Kulkarni\n/// @notice A DAO's ERC-721 governance token\ncontract Token is IToken, UUPS, Ownable, ReentrancyGuard, ERC721Votes, TokenStorageV1 {\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @notice The contract upgrade manager\n IManager private immutable manager;\n\n /// ///\n /// CONSTRUCTOR ///\n /// ///\n\n /// @param _manager The contract upgrade manager address\n constructor(address _manager) payable initializer {\n manager = IManager(_manager);\n }\n\n /// ///\n /// INITIALIZER ///\n /// ///\n\n /// @notice Initializes a DAO's ERC-721 token contract\n /// @param _founders The DAO founders\n /// @param _initStrings The encoded token and metadata initialization strings\n /// @param _metadataRenderer The token's metadata renderer\n /// @param _auction The token's auction house\n /// @param _initialOwner The initial owner of the token\n function initialize(\n IManager.FounderParams[] calldata _founders,\n bytes calldata _initStrings,\n address _metadataRenderer,\n address _auction,\n address _initialOwner\n ) external initializer {\n // Ensure the caller is the contract manager\n if (msg.sender != address(manager)) {\n revert ONLY_MANAGER();\n }\n\n // Initialize the reentrancy guard\n __ReentrancyGuard_init();\n\n // Setup ownable\n __Ownable_init(_initialOwner);\n\n // Store the founders and compute their allocations\n _addFounders(_founders);\n\n // Decode the token name and symbol\n (string memory _name, string memory _symbol, , , , ) = abi.decode(_initStrings, (string, string, string, string, string, string));\n\n // Initialize the ERC-721 token\n __ERC721_init(_name, _symbol);\n\n // Store the metadata renderer and auction house\n settings.metadataRenderer = IBaseMetadata(_metadataRenderer);\n settings.auction = _auction;\n }\n\n /// @notice Called by the auction upon the first unpause / token mint to transfer ownership from founder to treasury\n /// @dev Only callable by the auction contract\n function onFirstAuctionStarted() external override {\n if (msg.sender != settings.auction) {\n revert ONLY_AUCTION();\n }\n\n // Force transfer ownership to the treasury\n _transferOwnership(IAuction(settings.auction).treasury());\n }\n\n /// @notice Called upon initialization to add founders and compute their vesting allocations\n /// @dev We do this by reserving an mapping of [0-100] token indices, such that if a new token mint ID % 100 is reserved, it's sent to the appropriate founder.\n /// @param _founders The list of DAO founders\n function _addFounders(IManager.FounderParams[] calldata _founders) internal {\n // Cache the number of founders\n uint256 numFounders = _founders.length;\n\n // Used to store the total percent ownership among the founders\n uint256 totalOwnership;\n\n unchecked {\n // For each founder:\n for (uint256 i; i < numFounders; ++i) {\n // Cache the percent ownership\n uint256 founderPct = _founders[i].ownershipPct;\n\n // Continue if no ownership is specified\n if (founderPct == 0) {\n continue;\n }\n\n // Update the total ownership and ensure it's valid\n totalOwnership += founderPct;\n\n // Check that founders own less than 100% of tokens\n if (totalOwnership > 99) {\n revert INVALID_FOUNDER_OWNERSHIP();\n }\n\n // Compute the founder's id\n uint256 founderId = settings.numFounders++;\n\n // Get the pointer to store the founder\n Founder storage newFounder = founder[founderId];\n\n // Store the founder's vesting details\n newFounder.wallet = _founders[i].wallet;\n newFounder.vestExpiry = uint32(_founders[i].vestExpiry);\n // Total ownership cannot be above 100 so this fits safely in uint8\n newFounder.ownershipPct = uint8(founderPct);\n\n // Compute the vesting schedule\n uint256 schedule = 100 / founderPct;\n\n // Used to store the base token id the founder will recieve\n uint256 baseTokenId;\n\n // For each token to vest:\n for (uint256 j; j < founderPct; ++j) {\n // Get the available token id\n baseTokenId = _getNextTokenId(baseTokenId);\n\n // Store the founder as the recipient\n tokenRecipient[baseTokenId] = newFounder;\n\n emit MintScheduled(baseTokenId, founderId, newFounder);\n\n // Update the base token id\n baseTokenId = (baseTokenId + schedule) % 100;\n }\n }\n\n // Store the founders' details\n settings.totalOwnership = uint8(totalOwnership);\n settings.numFounders = uint8(numFounders);\n }\n }\n\n /// @dev Finds the next available base token id for a founder\n /// @param _tokenId The ERC-721 token id\n function _getNextTokenId(uint256 _tokenId) internal view returns (uint256) {\n unchecked {\n while (tokenRecipient[_tokenId].wallet != address(0)) {\n _tokenId = (++_tokenId) % 100;\n }\n\n return _tokenId;\n }\n }\n\n /// ///\n /// MINT ///\n /// ///\n\n /// @notice Mints tokens to the auction house for bidding and handles founder vesting\n function mint() external nonReentrant returns (uint256 tokenId) {\n // Cache the auction address\n address minter = settings.auction;\n\n // Ensure the caller is the auction\n if (msg.sender != minter) {\n revert ONLY_AUCTION();\n }\n\n // Cannot realistically overflow\n unchecked {\n do {\n // Get the next token to mint\n tokenId = settings.mintCount++;\n\n // Lookup whether the token is for a founder, and mint accordingly if so\n } while (_isForFounder(tokenId));\n }\n\n // Mint the next available token to the auction house for bidding\n _mint(minter, tokenId);\n }\n\n /// @dev Overrides _mint to include attribute generation\n /// @param _to The token recipient\n /// @param _tokenId The ERC-721 token id\n function _mint(address _to, uint256 _tokenId) internal override {\n // Mint the token\n super._mint(_to, _tokenId);\n\n // Increment the total supply\n unchecked {\n ++settings.totalSupply;\n }\n\n // Generate the token attributes\n if (!settings.metadataRenderer.onMinted(_tokenId)) revert NO_METADATA_GENERATED();\n }\n\n /// @dev Checks if a given token is for a founder and mints accordingly\n /// @param _tokenId The ERC-721 token id\n function _isForFounder(uint256 _tokenId) private returns (bool) {\n // Get the base token id\n uint256 baseTokenId = _tokenId % 100;\n\n // If there is no scheduled recipient:\n if (tokenRecipient[baseTokenId].wallet == address(0)) {\n return false;\n\n // Else if the founder is still vesting:\n } else if (block.timestamp < tokenRecipient[baseTokenId].vestExpiry) {\n // Mint the token to the founder\n _mint(tokenRecipient[baseTokenId].wallet, _tokenId);\n\n return true;\n\n // Else the founder has finished vesting:\n } else {\n // Remove them from future lookups\n delete tokenRecipient[baseTokenId];\n\n return false;\n }\n }\n\n /// ///\n /// BURN ///\n /// ///\n\n /// @notice Burns a token that did not see any bids\n /// @param _tokenId The ERC-721 token id\n function burn(uint256 _tokenId) external {\n // Ensure the caller is the auction house\n if (msg.sender != settings.auction) {\n revert ONLY_AUCTION();\n }\n\n // Burn the token\n _burn(_tokenId);\n }\n\n function _burn(uint256 _tokenId) internal override {\n super._burn(_tokenId);\n\n unchecked {\n --settings.totalSupply;\n }\n }\n\n /// ///\n /// METADATA ///\n /// ///\n\n /// @notice The URI for a token\n /// @param _tokenId The ERC-721 token id\n function tokenURI(uint256 _tokenId) public view override(IToken, ERC721) returns (string memory) {\n return settings.metadataRenderer.tokenURI(_tokenId);\n }\n\n /// @notice The URI for the contract\n function contractURI() public view override(IToken, ERC721) returns (string memory) {\n return settings.metadataRenderer.contractURI();\n }\n\n /// ///\n /// FOUNDERS ///\n /// ///\n\n /// @notice The number of founders\n function totalFounders() external view returns (uint256) {\n return settings.numFounders;\n }\n\n /// @notice The founders total percent ownership\n function totalFounderOwnership() external view returns (uint256) {\n return settings.totalOwnership;\n }\n\n /// @notice The vesting details of a founder\n /// @param _founderId The founder id\n function getFounder(uint256 _founderId) external view returns (Founder memory) {\n return founder[_founderId];\n }\n\n /// @notice The vesting details of all founders\n function getFounders() external view returns (Founder[] memory) {\n // Cache the number of founders\n uint256 numFounders = settings.numFounders;\n\n // Get a temporary array to hold all founders\n Founder[] memory founders = new Founder[](numFounders);\n\n // Cannot realistically overflow\n unchecked {\n // Add each founder to the array\n for (uint256 i; i < numFounders; ++i) {\n founders[i] = founder[i];\n }\n }\n\n return founders;\n }\n\n /// @notice The founder scheduled to receive the given token id\n /// NOTE: If a founder is returned, there's no guarantee they'll receive the token as vesting expiration is not considered\n /// @param _tokenId The ERC-721 token id\n function getScheduledRecipient(uint256 _tokenId) external view returns (Founder memory) {\n return tokenRecipient[_tokenId % 100];\n }\n\n /// ///\n /// SETTINGS ///\n /// ///\n\n /// @notice The total supply of tokens\n function totalSupply() external view returns (uint256) {\n return settings.totalSupply;\n }\n\n /// @notice The address of the auction house\n function auction() external view returns (address) {\n return settings.auction;\n }\n\n /// @notice The address of the metadata renderer\n function metadataRenderer() external view returns (address) {\n return address(settings.metadataRenderer);\n }\n\n function owner() public view override(IToken, Ownable) returns (address) {\n return super.owner();\n }\n\n /// ///\n /// TOKEN UPGRADE ///\n /// ///\n\n /// @notice Ensures the caller is authorized to upgrade the contract and that the new implementation is valid\n /// @dev This function is called in `upgradeTo` & `upgradeToAndCall`\n /// @param _newImpl The new implementation address\n function _authorizeUpgrade(address _newImpl) internal view override {\n // Ensure the caller is the shared owner of the token and metadata renderer\n if (msg.sender != owner()) revert ONLY_OWNER();\n\n // Ensure the implementation is valid\n if (!manager.isRegisteredUpgrade(_getImplementation(), _newImpl)) revert INVALID_UPGRADE(_newImpl);\n }\n}\n"
|
|
},
|
|
"src/governance/treasury/Treasury.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { UUPS } from \"../../lib/proxy/UUPS.sol\";\nimport { Ownable } from \"../../lib/utils/Ownable.sol\";\nimport { ERC721TokenReceiver, ERC1155TokenReceiver } from \"../../lib/utils/TokenReceiver.sol\";\nimport { SafeCast } from \"../../lib/utils/SafeCast.sol\";\n\nimport { TreasuryStorageV1 } from \"./storage/TreasuryStorageV1.sol\";\nimport { ITreasury } from \"./ITreasury.sol\";\nimport { ProposalHasher } from \"../governor/ProposalHasher.sol\";\nimport { IManager } from \"../../manager/IManager.sol\";\n\n/// @title Treasury\n/// @author Rohan Kulkarni\n/// @notice A DAO's treasury and transaction executor\n/// Modified from:\n/// - OpenZeppelin Contracts v4.7.3 (governance/TimelockController.sol)\n/// - NounsDAOExecutor.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.\ncontract Treasury is ITreasury, UUPS, Ownable, ProposalHasher, TreasuryStorageV1 {\n /// ///\n /// CONSTANTS ///\n /// ///\n\n /// @notice The default grace period setting\n uint128 private constant INITIAL_GRACE_PERIOD = 2 weeks;\n\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @notice The contract upgrade manager\n IManager private immutable manager;\n\n /// ///\n /// CONSTRUCTOR ///\n /// ///\n\n /// @param _manager The contract upgrade manager address\n constructor(address _manager) payable initializer {\n manager = IManager(_manager);\n }\n\n /// ///\n /// INITIALIZER ///\n /// ///\n\n /// @notice Initializes an instance of a DAO's treasury\n /// @param _governor The DAO's governor address\n /// @param _delay The time delay to execute a queued transaction\n function initialize(address _governor, uint256 _delay) external initializer {\n // Ensure the caller is the contract manager\n if (msg.sender != address(manager)) revert ONLY_MANAGER();\n\n // Ensure a governor address was provided\n if (_governor == address(0)) revert ADDRESS_ZERO();\n\n // Grant ownership to the governor\n __Ownable_init(_governor);\n\n // Store the time delay\n settings.delay = SafeCast.toUint128(_delay);\n\n // Set the default grace period\n settings.gracePeriod = INITIAL_GRACE_PERIOD;\n\n emit DelayUpdated(0, _delay);\n }\n\n /// ///\n /// TRANSACTION STATE ///\n /// ///\n\n /// @notice The timestamp that a proposal is valid to execute\n /// @param _proposalId The proposal id\n function timestamp(bytes32 _proposalId) external view returns (uint256) {\n return timestamps[_proposalId];\n }\n\n /// @notice If a queued proposal can no longer be executed\n /// @param _proposalId The proposal id\n function isExpired(bytes32 _proposalId) external view returns (bool) {\n unchecked {\n return block.timestamp > (timestamps[_proposalId] + settings.gracePeriod);\n }\n }\n\n /// @notice If a proposal is queued\n /// @param _proposalId The proposal id\n function isQueued(bytes32 _proposalId) public view returns (bool) {\n return timestamps[_proposalId] != 0;\n }\n\n /// @notice If a proposal is ready to execute (does not consider expiration)\n /// @param _proposalId The proposal id\n function isReady(bytes32 _proposalId) public view returns (bool) {\n return timestamps[_proposalId] != 0 && block.timestamp >= timestamps[_proposalId];\n }\n\n /// ///\n /// QUEUE PROPOSAL ///\n /// ///\n\n /// @notice Schedules a proposal for execution\n /// @param _proposalId The proposal id\n function queue(bytes32 _proposalId) external onlyOwner returns (uint256 eta) {\n // Ensure the proposal was not already queued\n if (isQueued(_proposalId)) revert PROPOSAL_ALREADY_QUEUED();\n\n // Cannot realistically overflow\n unchecked {\n // Compute the timestamp that the proposal will be valid to execute\n eta = block.timestamp + settings.delay;\n }\n\n // Store the timestamp\n timestamps[_proposalId] = eta;\n\n emit TransactionScheduled(_proposalId, eta);\n }\n\n /// ///\n /// EXECUTE PROPOSAL ///\n /// ///\n\n /// @notice Executes a queued proposal\n /// @param _targets The target addresses to call\n /// @param _values The ETH values of each call\n /// @param _calldatas The calldata of each call\n /// @param _descriptionHash The hash of the description\n /// @param _proposer The proposal creator\n function execute(\n address[] calldata _targets,\n uint256[] calldata _values,\n bytes[] calldata _calldatas,\n bytes32 _descriptionHash,\n address _proposer\n ) external payable onlyOwner {\n // Get the proposal id\n bytes32 proposalId = hashProposal(_targets, _values, _calldatas, _descriptionHash, _proposer);\n\n // Ensure the proposal is ready to execute\n if (!isReady(proposalId)) revert EXECUTION_NOT_READY(proposalId);\n\n // Remove the proposal from the queue\n delete timestamps[proposalId];\n\n // Cache the number of targets\n uint256 numTargets = _targets.length;\n\n // Cannot realistically overflow\n unchecked {\n // For each target:\n for (uint256 i = 0; i < numTargets; ++i) {\n // Execute the transaction\n (bool success, ) = _targets[i].call{ value: _values[i] }(_calldatas[i]);\n\n // Ensure the transaction succeeded\n if (!success) revert EXECUTION_FAILED(i);\n }\n }\n\n emit TransactionExecuted(proposalId, _targets, _values, _calldatas);\n }\n\n /// ///\n /// CANCEL PROPOSAL ///\n /// ///\n\n /// @notice Removes a queued proposal\n /// @param _proposalId The proposal id\n function cancel(bytes32 _proposalId) external onlyOwner {\n // Ensure the proposal is queued\n if (!isQueued(_proposalId)) revert PROPOSAL_NOT_QUEUED();\n\n // Remove the proposal from the queue\n delete timestamps[_proposalId];\n\n emit TransactionCanceled(_proposalId);\n }\n\n /// ///\n /// TREASURY SETTINGS ///\n /// ///\n\n /// @notice The time delay to execute a queued transaction\n function delay() external view returns (uint256) {\n return settings.delay;\n }\n\n /// @notice The time period to execute a proposal\n function gracePeriod() external view returns (uint256) {\n return settings.gracePeriod;\n }\n\n /// ///\n /// UPDATE SETTINGS ///\n /// ///\n\n /// @notice Updates the transaction delay\n /// @param _newDelay The new time delay\n function updateDelay(uint256 _newDelay) external {\n // Ensure the caller is the treasury itself\n if (msg.sender != address(this)) revert ONLY_TREASURY();\n\n emit DelayUpdated(settings.delay, _newDelay);\n\n // Update the delay\n settings.delay = SafeCast.toUint128(_newDelay);\n }\n\n /// @notice Updates the execution grace period\n /// @param _newGracePeriod The new grace period\n function updateGracePeriod(uint256 _newGracePeriod) external {\n // Ensure the caller is the treasury itself\n if (msg.sender != address(this)) revert ONLY_TREASURY();\n\n emit GracePeriodUpdated(settings.gracePeriod, _newGracePeriod);\n\n // Update the grace period\n settings.gracePeriod = SafeCast.toUint128(_newGracePeriod);\n }\n\n /// ///\n /// RECEIVE TOKENS ///\n /// ///\n\n /// @dev Accepts all ERC-721 transfers\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public pure returns (bytes4) {\n return ERC721TokenReceiver.onERC721Received.selector;\n }\n\n /// @dev Accepts all ERC-1155 single id transfers\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes memory\n ) public pure returns (bytes4) {\n return ERC1155TokenReceiver.onERC1155Received.selector;\n }\n\n /// @dev Accept all ERC-1155 batch id transfers\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] memory,\n uint256[] memory,\n bytes memory\n ) public pure returns (bytes4) {\n return ERC1155TokenReceiver.onERC1155BatchReceived.selector;\n }\n\n /// @dev Accepts ETH transfers\n receive() external payable {}\n\n /// ///\n /// TREASURY UPGRADE ///\n /// ///\n\n /// @notice Ensures the caller is authorized to upgrade the contract and that the new implementation is valid\n /// @dev This function is called in `upgradeTo` & `upgradeToAndCall`\n /// @param _newImpl The new implementation address\n function _authorizeUpgrade(address _newImpl) internal view override {\n // Ensure the caller is the treasury itself\n if (msg.sender != address(this)) revert ONLY_TREASURY();\n\n // Ensure the new implementation is a registered upgrade\n if (!manager.isRegisteredUpgrade(_getImplementation(), _newImpl)) revert INVALID_UPGRADE(_newImpl);\n }\n}\n"
|
|
},
|
|
"src/lib/utils/ReentrancyGuard.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { Initializable } from \"../utils/Initializable.sol\";\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (security/ReentrancyGuardUpgradeable.sol)\n/// - Uses custom error `REENTRANCY()`\nabstract contract ReentrancyGuard is Initializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @dev Indicates a function has not been entered\n uint256 internal constant _NOT_ENTERED = 1;\n\n /// @dev Indicates a function has been entered\n uint256 internal constant _ENTERED = 2;\n\n /// @notice The reentrancy status of a function\n uint256 internal _status;\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if attempted reentrancy\n error REENTRANCY();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Initializes the reentrancy guard\n function __ReentrancyGuard_init() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /// @dev Ensures a function cannot be reentered\n modifier nonReentrant() {\n if (_status == _ENTERED) revert REENTRANCY();\n\n _status = _ENTERED;\n\n _;\n\n _status = _NOT_ENTERED;\n }\n}\n"
|
|
},
|
|
"src/lib/token/ERC721Votes.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC721Votes } from \"../interfaces/IERC721Votes.sol\";\nimport { ERC721 } from \"../token/ERC721.sol\";\nimport { EIP712 } from \"../utils/EIP712.sol\";\n\n/// @title ERC721Votes\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/extensions/draft-ERC721Votes.sol) & Nouns DAO ERC721Checkpointable.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.\n/// - Uses custom errors defined in IERC721Votes\n/// - Checkpoints are based on timestamps instead of block numbers\n/// - Tokens are self-delegated by default\n/// - The total number of votes is the token supply itself\nabstract contract ERC721Votes is IERC721Votes, EIP712, ERC721 {\n /// ///\n /// CONSTANTS ///\n /// ///\n\n /// @dev The EIP-712 typehash to delegate with a signature\n bytes32 internal constant DELEGATION_TYPEHASH = keccak256(\"Delegation(address from,address to,uint256 nonce,uint256 deadline)\");\n\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @notice The delegate for an account\n /// @notice Account => Delegate\n mapping(address => address) internal delegation;\n\n /// @notice The number of checkpoints for an account\n /// @dev Account => Num Checkpoints\n mapping(address => uint256) internal numCheckpoints;\n\n /// @notice The checkpoint for an account\n /// @dev Account => Checkpoint Id => Checkpoint\n mapping(address => mapping(uint256 => Checkpoint)) internal checkpoints;\n\n /// ///\n /// VOTING WEIGHT ///\n /// ///\n\n /// @notice The current number of votes for an account\n /// @param _account The account address\n function getVotes(address _account) public view returns (uint256) {\n // Get the account's number of checkpoints\n uint256 nCheckpoints = numCheckpoints[_account];\n\n // Cannot underflow as `nCheckpoints` is ensured to be greater than 0 if reached\n unchecked {\n // Return the number of votes at the latest checkpoint if applicable\n return nCheckpoints != 0 ? checkpoints[_account][nCheckpoints - 1].votes : 0;\n }\n }\n\n /// @notice The number of votes for an account at a past timestamp\n /// @param _account The account address\n /// @param _timestamp The past timestamp\n function getPastVotes(address _account, uint256 _timestamp) public view returns (uint256) {\n // Ensure the given timestamp is in the past\n if (_timestamp >= block.timestamp) revert INVALID_TIMESTAMP();\n\n // Get the account's number of checkpoints\n uint256 nCheckpoints = numCheckpoints[_account];\n\n // If there are none return 0\n if (nCheckpoints == 0) return 0;\n\n // Get the account's checkpoints\n mapping(uint256 => Checkpoint) storage accountCheckpoints = checkpoints[_account];\n\n unchecked {\n // Get the latest checkpoint id\n // Cannot underflow as `nCheckpoints` is ensured to be greater than 0\n uint256 lastCheckpoint = nCheckpoints - 1;\n\n // If the latest checkpoint has a valid timestamp, return its number of votes\n if (accountCheckpoints[lastCheckpoint].timestamp <= _timestamp) return accountCheckpoints[lastCheckpoint].votes;\n\n // If the first checkpoint doesn't have a valid timestamp, return 0\n if (accountCheckpoints[0].timestamp > _timestamp) return 0;\n\n // Otherwise, find a checkpoint with a valid timestamp\n // Use the latest id as the initial upper bound\n uint256 high = lastCheckpoint;\n uint256 low;\n uint256 middle;\n\n // Used to temporarily hold a checkpoint\n Checkpoint memory cp;\n\n // While a valid checkpoint is to be found:\n while (high > low) {\n // Find the id of the middle checkpoint\n middle = high - (high - low) / 2;\n\n // Get the middle checkpoint\n cp = accountCheckpoints[middle];\n\n // If the timestamp is a match:\n if (cp.timestamp == _timestamp) {\n // Return the voting weight\n return cp.votes;\n\n // Else if the timestamp is before the one looking for:\n } else if (cp.timestamp < _timestamp) {\n // Update the lower bound\n low = middle;\n\n // Else update the upper bound\n } else {\n high = middle - 1;\n }\n }\n\n return accountCheckpoints[low].votes;\n }\n }\n\n /// ///\n /// DELEGATION ///\n /// ///\n\n /// @notice The delegate for an account\n /// @param _account The account address\n function delegates(address _account) public view returns (address) {\n address current = delegation[_account];\n return current == address(0) ? _account : current;\n }\n\n /// @notice Delegates votes to an account\n /// @param _to The address delegating votes to\n function delegate(address _to) external {\n _delegate(msg.sender, _to);\n }\n\n /// @notice Delegates votes from a signer to an account\n /// @param _from The address delegating votes from\n /// @param _to The address delegating votes to\n /// @param _deadline The signature deadline\n /// @param _v The 129th byte and chain id of the signature\n /// @param _r The first 64 bytes of the signature\n /// @param _s Bytes 64-128 of the signature\n function delegateBySig(\n address _from,\n address _to,\n uint256 _deadline,\n uint8 _v,\n bytes32 _r,\n bytes32 _s\n ) external {\n // Ensure the signature has not expired\n if (block.timestamp > _deadline) revert EXPIRED_SIGNATURE();\n\n // Used to store the digest\n bytes32 digest;\n\n // Cannot realistically overflow\n unchecked {\n // Compute the hash of the domain seperator with the typed delegation data\n digest = keccak256(\n abi.encodePacked(\"\\x19\\x01\", DOMAIN_SEPARATOR(), keccak256(abi.encode(DELEGATION_TYPEHASH, _from, _to, nonces[_from]++, _deadline)))\n );\n }\n\n // Recover the message signer\n address recoveredAddress = ecrecover(digest, _v, _r, _s);\n\n // Ensure the recovered signer is the voter\n if (recoveredAddress == address(0) || recoveredAddress != _from) revert INVALID_SIGNATURE();\n\n // Update the delegate\n _delegate(_from, _to);\n }\n\n /// @dev Updates delegate addresses\n /// @param _from The address delegating votes from\n /// @param _to The address delegating votes to\n function _delegate(address _from, address _to) internal {\n // If address(0) is being delegated to, update the op as a self-delegate\n if (_to == address(0)) _to = _from;\n\n // Get the previous delegate\n address prevDelegate = delegates(_from);\n\n // Store the new delegate\n delegation[_from] = _to;\n\n emit DelegateChanged(_from, prevDelegate, _to);\n\n // Transfer voting weight from the previous delegate to the new delegate\n _moveDelegateVotes(prevDelegate, _to, balanceOf(_from));\n }\n\n /// @dev Transfers voting weight\n /// @param _from The address delegating votes from\n /// @param _to The address delegating votes to\n /// @param _amount The number of votes delegating\n function _moveDelegateVotes(\n address _from,\n address _to,\n uint256 _amount\n ) internal {\n unchecked {\n // If voting weight is being transferred:\n if (_from != _to && _amount > 0) {\n // If this isn't a token mint:\n if (_from != address(0)) {\n // Get the sender's number of checkpoints\n uint256 newCheckpointId = numCheckpoints[_from];\n\n // Used to store their previous checkpoint id\n uint256 prevCheckpointId;\n\n // Used to store their previous checkpoint's voting weight\n uint256 prevTotalVotes;\n\n // Used to store their previous checkpoint's timestamp\n uint256 prevTimestamp;\n\n // If this isn't the sender's first checkpoint:\n if (newCheckpointId != 0) {\n // Get their previous checkpoint's id\n prevCheckpointId = newCheckpointId - 1;\n\n // Get their previous checkpoint's voting weight\n prevTotalVotes = checkpoints[_from][prevCheckpointId].votes;\n\n // Get their previous checkpoint's timestamp\n prevTimestamp = checkpoints[_from][prevCheckpointId].timestamp;\n }\n\n // Update their voting weight\n _writeCheckpoint(_from, newCheckpointId, prevCheckpointId, prevTimestamp, prevTotalVotes, prevTotalVotes - _amount);\n }\n\n // If this isn't a token burn:\n if (_to != address(0)) {\n // Get the recipients's number of checkpoints\n uint256 nCheckpoints = numCheckpoints[_to];\n\n // Used to store their previous checkpoint id\n uint256 prevCheckpointId;\n\n // Used to store their previous checkpoint's voting weight\n uint256 prevTotalVotes;\n\n // Used to store their previous checkpoint's timestamp\n uint256 prevTimestamp;\n\n // If this isn't the recipient's first checkpoint:\n if (nCheckpoints != 0) {\n // Get their previous checkpoint's id\n prevCheckpointId = nCheckpoints - 1;\n\n // Get their previous checkpoint's voting weight\n prevTotalVotes = checkpoints[_to][prevCheckpointId].votes;\n\n // Get their previous checkpoint's timestamp\n prevTimestamp = checkpoints[_to][prevCheckpointId].timestamp;\n }\n\n // Update their voting weight\n _writeCheckpoint(_to, nCheckpoints, prevCheckpointId, prevTimestamp, prevTotalVotes, prevTotalVotes + _amount);\n }\n }\n }\n }\n\n /// @dev Records a checkpoint\n /// @param _account The account address\n /// @param _newId The new checkpoint id\n /// @param _prevId The previous checkpoint id\n /// @param _prevTimestamp The previous checkpoint timestamp\n /// @param _prevTotalVotes The previous checkpoint voting weight\n /// @param _newTotalVotes The new checkpoint voting weight\n function _writeCheckpoint(\n address _account,\n uint256 _newId,\n uint256 _prevId,\n uint256 _prevTimestamp,\n uint256 _prevTotalVotes,\n uint256 _newTotalVotes\n ) private {\n unchecked {\n // If the new checkpoint is not the user's first AND has the timestamp of the previous checkpoint:\n if (_newId > 0 && _prevTimestamp == block.timestamp) {\n // Just update the previous checkpoint's votes\n checkpoints[_account][_prevId].votes = uint192(_newTotalVotes);\n\n // Else write a new checkpoint:\n } else {\n // Get the pointer to store the checkpoint\n Checkpoint storage checkpoint = checkpoints[_account][_newId];\n\n // Store the new voting weight and the current time\n checkpoint.votes = uint192(_newTotalVotes);\n checkpoint.timestamp = uint64(block.timestamp);\n\n // Increment the account's number of checkpoints\n ++numCheckpoints[_account];\n }\n\n emit DelegateVotesChanged(_account, _prevTotalVotes, _newTotalVotes);\n }\n }\n\n /// @dev Enables each NFT to equal 1 vote\n /// @param _from The token sender\n /// @param _to The token recipient\n /// @param _tokenId The ERC-721 token id\n function _afterTokenTransfer(\n address _from,\n address _to,\n uint256 _tokenId\n ) internal override {\n // Transfer 1 vote from the sender to the recipient\n _moveDelegateVotes(delegates(_from), delegates(_to), 1);\n\n super._afterTokenTransfer(_from, _to, _tokenId);\n }\n}\n"
|
|
},
|
|
"src/lib/token/ERC721.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC721 } from \"../interfaces/IERC721.sol\";\nimport { Initializable } from \"../utils/Initializable.sol\";\nimport { ERC721TokenReceiver } from \"../utils/TokenReceiver.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title ERC721\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/ERC721Upgradeable.sol)\n/// - Uses custom errors declared in IERC721\nabstract contract ERC721 is IERC721, Initializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @notice The token name\n string public name;\n\n /// @notice The token symbol\n string public symbol;\n\n /// @notice The token owners\n /// @dev ERC-721 token id => Owner\n mapping(uint256 => address) internal owners;\n\n /// @notice The owner balances\n /// @dev Owner => Balance\n mapping(address => uint256) internal balances;\n\n /// @notice The token approvals\n /// @dev ERC-721 token id => Manager\n mapping(uint256 => address) internal tokenApprovals;\n\n /// @notice The balance approvals\n /// @dev Owner => Operator => Approved\n mapping(address => mapping(address => bool)) internal operatorApprovals;\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Initializes an ERC-721 token\n /// @param _name The ERC-721 token name\n /// @param _symbol The ERC-721 token symbol\n function __ERC721_init(string memory _name, string memory _symbol) internal onlyInitializing {\n name = _name;\n symbol = _symbol;\n }\n\n /// @notice The token URI\n /// @param _tokenId The ERC-721 token id\n function tokenURI(uint256 _tokenId) public view virtual returns (string memory) {}\n\n /// @notice The contract URI\n function contractURI() public view virtual returns (string memory) {}\n\n /// @notice If the contract implements an interface\n /// @param _interfaceId The interface id\n function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {\n return\n _interfaceId == 0x01ffc9a7 || // ERC165 Interface ID\n _interfaceId == 0x80ac58cd || // ERC721 Interface ID\n _interfaceId == 0x5b5e139f; // ERC721Metadata Interface ID\n }\n\n /// @notice The account approved to manage a token\n /// @param _tokenId The ERC-721 token id\n function getApproved(uint256 _tokenId) external view returns (address) {\n return tokenApprovals[_tokenId];\n }\n\n /// @notice If an operator is authorized to manage all of an owner's tokens\n /// @param _owner The owner address\n /// @param _operator The operator address\n function isApprovedForAll(address _owner, address _operator) external view returns (bool) {\n return operatorApprovals[_owner][_operator];\n }\n\n /// @notice The number of tokens owned\n /// @param _owner The owner address\n function balanceOf(address _owner) public view returns (uint256) {\n if (_owner == address(0)) revert ADDRESS_ZERO();\n\n return balances[_owner];\n }\n\n /// @notice The owner of a token\n /// @param _tokenId The ERC-721 token id\n function ownerOf(uint256 _tokenId) public view returns (address) {\n address owner = owners[_tokenId];\n\n if (owner == address(0)) revert INVALID_OWNER();\n\n return owner;\n }\n\n /// @notice Authorizes an account to manage a token\n /// @param _to The account address\n /// @param _tokenId The ERC-721 token id\n function approve(address _to, uint256 _tokenId) external {\n address owner = owners[_tokenId];\n\n if (msg.sender != owner && !operatorApprovals[owner][msg.sender]) revert INVALID_APPROVAL();\n\n tokenApprovals[_tokenId] = _to;\n\n emit Approval(owner, _to, _tokenId);\n }\n\n /// @notice Authorizes an account to manage all tokens\n /// @param _operator The account address\n /// @param _approved If permission is being given or removed\n function setApprovalForAll(address _operator, bool _approved) external {\n operatorApprovals[msg.sender][_operator] = _approved;\n\n emit ApprovalForAll(msg.sender, _operator, _approved);\n }\n\n /// @notice Transfers a token from sender to recipient\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function transferFrom(\n address _from,\n address _to,\n uint256 _tokenId\n ) public {\n if (_from != owners[_tokenId]) revert INVALID_OWNER();\n\n if (_to == address(0)) revert ADDRESS_ZERO();\n\n if (msg.sender != _from && !operatorApprovals[_from][msg.sender] && msg.sender != tokenApprovals[_tokenId]) revert INVALID_APPROVAL();\n\n _beforeTokenTransfer(_from, _to, _tokenId);\n\n unchecked {\n --balances[_from];\n\n ++balances[_to];\n }\n\n owners[_tokenId] = _to;\n\n delete tokenApprovals[_tokenId];\n\n emit Transfer(_from, _to, _tokenId);\n\n _afterTokenTransfer(_from, _to, _tokenId);\n }\n\n /// @notice Safe transfers a token from sender to recipient\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function safeTransferFrom(\n address _from,\n address _to,\n uint256 _tokenId\n ) external {\n transferFrom(_from, _to, _tokenId);\n\n if (\n Address.isContract(_to) &&\n ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, \"\") != ERC721TokenReceiver.onERC721Received.selector\n ) revert INVALID_RECIPIENT();\n }\n\n /// @notice Safe transfers a token from sender to recipient with additional data\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function safeTransferFrom(\n address _from,\n address _to,\n uint256 _tokenId,\n bytes calldata _data\n ) external {\n transferFrom(_from, _to, _tokenId);\n\n if (\n Address.isContract(_to) &&\n ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) != ERC721TokenReceiver.onERC721Received.selector\n ) revert INVALID_RECIPIENT();\n }\n\n /// @dev Mints a token to a recipient\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _mint(address _to, uint256 _tokenId) internal virtual {\n if (_to == address(0)) revert ADDRESS_ZERO();\n\n if (owners[_tokenId] != address(0)) revert ALREADY_MINTED();\n\n _beforeTokenTransfer(address(0), _to, _tokenId);\n\n unchecked {\n ++balances[_to];\n }\n\n owners[_tokenId] = _to;\n\n emit Transfer(address(0), _to, _tokenId);\n\n _afterTokenTransfer(address(0), _to, _tokenId);\n }\n\n /// @dev Burns a token to a recipient\n /// @param _tokenId The ERC-721 token id\n function _burn(uint256 _tokenId) internal virtual {\n address owner = owners[_tokenId];\n\n if (owner == address(0)) revert NOT_MINTED();\n\n _beforeTokenTransfer(owner, address(0), _tokenId);\n\n unchecked {\n --balances[owner];\n }\n\n delete owners[_tokenId];\n\n delete tokenApprovals[_tokenId];\n\n emit Transfer(owner, address(0), _tokenId);\n\n _afterTokenTransfer(owner, address(0), _tokenId);\n }\n\n /// @dev Hook called before a token transfer\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _beforeTokenTransfer(\n address _from,\n address _to,\n uint256 _tokenId\n ) internal virtual {}\n\n /// @dev Hook called after a token transfer\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _afterTokenTransfer(\n address _from,\n address _to,\n uint256 _tokenId\n ) internal virtual {}\n}\n"
|
|
},
|
|
"src/token/storage/TokenStorageV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { TokenTypesV1 } from \"../types/TokenTypesV1.sol\";\n\n/// @title TokenStorageV1\n/// @author Rohan Kulkarni\n/// @notice The Token storage contract\ncontract TokenStorageV1 is TokenTypesV1 {\n /// @notice The token settings\n Settings internal settings;\n\n /// @notice The vesting details of a founder\n /// @dev Founder id => Founder\n mapping(uint256 => Founder) internal founder;\n\n /// @notice The recipient of a token\n /// @dev ERC-721 token id => Founder\n mapping(uint256 => Founder) internal tokenRecipient;\n}\n"
|
|
},
|
|
"src/lib/utils/TokenReceiver.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/utils/ERC721Holder.sol)\nabstract contract ERC721TokenReceiver {\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC721Received.selector;\n }\n}\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC1155/utils/ERC1155Holder.sol)\nabstract contract ERC1155TokenReceiver {\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata,\n uint256[] calldata,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n"
|
|
},
|
|
"src/lib/utils/SafeCast.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (utils/math/SafeCast.sol)\n/// - Uses custom error `UNSAFE_CAST()`\nlibrary SafeCast {\n error UNSAFE_CAST();\n\n function toUint128(uint256 x) internal pure returns (uint128) {\n if (x > type(uint128).max) revert UNSAFE_CAST();\n\n return uint128(x);\n }\n\n function toUint64(uint256 x) internal pure returns (uint64) {\n if (x > type(uint64).max) revert UNSAFE_CAST();\n\n return uint64(x);\n }\n\n function toUint48(uint256 x) internal pure returns (uint48) {\n if (x > type(uint48).max) revert UNSAFE_CAST();\n\n return uint48(x);\n }\n\n function toUint40(uint256 x) internal pure returns (uint40) {\n if (x > type(uint40).max) revert UNSAFE_CAST();\n\n return uint40(x);\n }\n\n function toUint32(uint256 x) internal pure returns (uint32) {\n if (x > type(uint32).max) revert UNSAFE_CAST();\n\n return uint32(x);\n }\n\n function toUint16(uint256 x) internal pure returns (uint16) {\n if (x > type(uint16).max) revert UNSAFE_CAST();\n\n return uint16(x);\n }\n\n function toUint8(uint256 x) internal pure returns (uint8) {\n if (x > type(uint8).max) revert UNSAFE_CAST();\n\n return uint8(x);\n }\n}\n"
|
|
},
|
|
"src/governance/treasury/storage/TreasuryStorageV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { TreasuryTypesV1 } from \"../types/TreasuryTypesV1.sol\";\n\n/// @notice TreasuryStorageV1\n/// @author Rohan Kulkarni\n/// @notice The Treasury storage contract\ncontract TreasuryStorageV1 is TreasuryTypesV1 {\n /// @notice The treasury settings\n Settings internal settings;\n\n /// @notice The timestamp that a queued proposal is ready to execute\n /// @dev Proposal Id => Timestamp\n mapping(bytes32 => uint256) internal timestamps;\n}\n"
|
|
},
|
|
"src/governance/governor/ProposalHasher.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title ProposalHasher\n/// @author tbtstl\n/// @notice Helper contract to ensure proposal hashing functions are unified\nabstract contract ProposalHasher {\n /// ///\n /// HASH PROPOSAL ///\n /// ///\n\n /// @notice Hashes a proposal's details into a proposal id\n /// @param _targets The target addresses to call\n /// @param _values The ETH values of each call\n /// @param _calldatas The calldata of each call\n /// @param _descriptionHash The hash of the description\n /// @param _proposer The original proposer of the transaction\n function hashProposal(\n address[] memory _targets,\n uint256[] memory _values,\n bytes[] memory _calldatas,\n bytes32 _descriptionHash,\n address _proposer\n ) public pure returns (bytes32) {\n return keccak256(abi.encode(_targets, _values, _calldatas, _descriptionHash, _proposer));\n }\n}\n"
|
|
},
|
|
"src/governance/treasury/types/TreasuryTypesV1.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @notice TreasuryTypesV1\n/// @author Rohan Kulkarni\n/// @notice The treasury's custom data types\ncontract TreasuryTypesV1 {\n /// @notice The settings type\n /// @param gracePeriod The time period to execute a proposal\n /// @param delay The time delay to execute a queued transaction\n struct Settings {\n uint128 gracePeriod;\n uint128 delay;\n }\n}\n"
|
|
}
|
|
},
|
|
"settings": {
|
|
"remappings": [
|
|
"@openzeppelin/=node_modules/@openzeppelin/",
|
|
"ds-test/=lib/forge-std/lib/ds-test/src/",
|
|
"forge-std/=lib/forge-std/src/",
|
|
"micro-onchain-metadata-utils/=node_modules/micro-onchain-metadata-utils/src/",
|
|
"sol-uriencode/=node_modules/sol-uriencode/",
|
|
"sol2string/=node_modules/sol2string/"
|
|
],
|
|
"optimizer": {
|
|
"enabled": true,
|
|
"runs": 500000
|
|
},
|
|
"metadata": {
|
|
"bytecodeHash": "ipfs"
|
|
},
|
|
"outputSelection": {
|
|
"*": {
|
|
"*": [
|
|
"evm.bytecode",
|
|
"evm.deployedBytecode",
|
|
"devdoc",
|
|
"userdoc",
|
|
"metadata",
|
|
"abi"
|
|
]
|
|
}
|
|
},
|
|
"evmVersion": "london",
|
|
"libraries": {}
|
|
}
|
|
} |