Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60808060 | 18891634 | 314 days ago | IN | 0 ETH | 0.07834372 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
ERC721DAO
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 5 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/common/ERC2981.sol"; import "./erc20dao.sol"; import "./emitter.sol"; import "./helper.sol"; import "./factory.sol"; contract ERC721DAO is IERC721Receiver, ERC721Upgradeable, AccessControl, ERC2981, Helper { using SafeERC20 for IERC20; uint256 public _tokenIdTracker; mapping(uint256 => string) private _tokenURIs; address public factoryAddress; address public emitterAddress; ERC721DAOdetails public erc721DaoDetails; /// @dev initialize Function to initialize NFT Token contract /// @param _DaoName name of DAO /// @param _DaoSymbol symbol of DAO function initializeERC721( string calldata _DaoName, string calldata _DaoSymbol, address _factoryAddress, address _emitterAddress, uint256 _quorum, uint256 _threshold, uint256 _maxTokensPerUser, bool _isTransferable, bool _isNftTotalSupplyUnlimited, bool _isGovernanceActive, bool _onlyAllowWhitelist, address _ownerAddress ) external initializer { factoryAddress = _factoryAddress; emitterAddress = _emitterAddress; ERC721DAOdetails memory _erc721DaoDetails = ERC721DAOdetails( _DaoName, _DaoSymbol, _quorum, _threshold, _maxTokensPerUser, _isTransferable, _isNftTotalSupplyUnlimited, _isGovernanceActive, _onlyAllowWhitelist, _ownerAddress ); erc721DaoDetails = _erc721DaoDetails; __ERC721_init(_DaoName, _DaoSymbol); } /// @dev This function returns details of a particular dao function getERC721DAOdetails() external view returns (ERC721DAOdetails memory) { return erc721DaoDetails; } /// @dev Function to mint Governance Token and assign delegate /// @param _to Address to which tokens will be minted /// @param _tokenURI token URI of nft function mintNft( address _to, string memory _tokenURI, bytes32[] calldata _merkleProof ) public onlyFactory(factoryAddress) { if (balanceOf(_to) == erc721DaoDetails.maxTokensPerUser) revert MaxTokensMintedForUser(_to); if (erc721DaoDetails.onlyAllowWhitelist) { require( MerkleProof.verify( _merkleProof, Factory(factoryAddress) .getDAOdetails(address(this)) .merkleRoot, keccak256(abi.encodePacked(_to)) ), "Incorrect proof" ); } _tokenIdTracker += 1; if (!erc721DaoDetails.isNftTotalSupplyUnlimited) { require( Factory(factoryAddress) .getDAOdetails(address(this)) .distributionAmount >= _tokenIdTracker, "Max supply reached" ); } _safeMint(_to, _tokenIdTracker); _setTokenURI(_tokenIdTracker, _tokenURI); Emitter(emitterAddress).mintNft( _to, address(this), _tokenURI, _tokenIdTracker ); } /// @dev Function execute proposals called by gnosis safe /// @param _data function signature data encoded along with parameters function updateProposalAndExecution( address _contract, bytes memory _data ) external onlyGnosis(factoryAddress, address(this)) { if (_contract == address(0)) revert AddressInvalid("_contract", _contract); (bool success, ) = _contract.call(_data); require(success); } /// @dev Function to transfer NFT from this contract /// @param _nft address of nft to transfer /// @param _to address of receiver /// @param _tokenId tokenId of nft to transfer function transferNft( address _nft, address _to, uint256 _tokenId ) external onlyCurrentContract { if (_nft == address(0)) revert AddressInvalid("_nft", _nft); if (_to == address(0)) revert AddressInvalid("_to", _to); IERC721(_nft).safeTransferFrom(address(this), _to, _tokenId); } /// @dev Function to change governance active /// @param _isGovernanceActive New governance active status function updateGovernanceActive( bool _isGovernanceActive ) external payable onlyCurrentContract { erc721DaoDetails.isGovernanceActive = _isGovernanceActive; } /// @param _amountArray array of amount to be transferred /// @param _tokenURI array of token uri for each nft /// @param _userAddress array of address where the amount should be transferred function mintGTToAddress( uint256[] memory _amountArray, string[] memory _tokenURI, address[] memory _userAddress ) external onlyCurrentContract { if (_tokenURI.length != _userAddress.length) revert ArrayLengthMismatch(_tokenURI.length, _userAddress.length); if (_amountArray.length != _userAddress.length) revert ArrayLengthMismatch( _amountArray.length, _userAddress.length ); uint256 length = _userAddress.length; for (uint256 i; i < length; ) { for (uint j; j < _amountArray[i]; ) { if ( balanceOf(_userAddress[i]) == erc721DaoDetails.maxTokensPerUser ) revert MaxTokensMintedForUser(_userAddress[i]); _tokenIdTracker += 1; if (!erc721DaoDetails.isNftTotalSupplyUnlimited) { require( Factory(factoryAddress) .getDAOdetails(address(this)) .distributionAmount >= _tokenIdTracker, "Max supply reached" ); } _safeMint(_userAddress[i], _tokenIdTracker); _setTokenURI(_tokenIdTracker, _tokenURI[i]); unchecked { ++j; } } Emitter(emitterAddress).newUser( address(this), _userAddress[i], Factory(factoryAddress) .getDAOdetails(address(this)) .depositTokenAddress, 0, block.timestamp, _amountArray[i], Safe( Factory(factoryAddress) .getDAOdetails(address(this)) .gnosisAddress ).isOwner(_userAddress[i]) ); unchecked { ++i; } } Emitter(emitterAddress).mintGTToAddress( address(this), _amountArray, _userAddress ); } /// @dev function to update governance settings /// @param _quorum update quorum into the contract /// @param _threshold update threshold into the contract function updateGovernanceSettings( uint256 _quorum, uint256 _threshold ) external onlyCurrentContract { if (_quorum == 0) revert AmountInvalid("_quorum", _quorum); if (_threshold == 0) revert AmountInvalid("_threshold", _threshold); if (!(_quorum <= FLOAT_HANDLER_TEN_4)) revert AmountInvalid("_quorum", _quorum); if (!(_threshold <= FLOAT_HANDLER_TEN_4)) revert AmountInvalid("_threshold", _threshold); erc721DaoDetails.quorum = _quorum; erc721DaoDetails.threshold = _threshold; Emitter(emitterAddress).updateGovernanceSettings( address(this), _quorum, _threshold ); } /// @dev Function to set whitelist to true for a particular token contract function toggleOnlyAllowWhitelist() external payable onlyCurrentContract { erc721DaoDetails.onlyAllowWhitelist = !erc721DaoDetails .onlyAllowWhitelist; } /// @dev Function to update nft transferability for a particular token contract /// @param _isNftTransferable New nft transferability function updateTokenTransferability( bool _isNftTransferable ) external payable onlyCurrentContract { erc721DaoDetails.isTransferable = _isNftTransferable; Emitter(emitterAddress).updateTokenTransferability( address(this), _isNftTransferable ); } function updateMaxTokensPerUser( uint256 _maxTokensPerUser ) external payable onlyCurrentContract { erc721DaoDetails.maxTokensPerUser = _maxTokensPerUser; Emitter(emitterAddress).updateMaxTokensPerUser( address(this), _maxTokensPerUser ); } function _setTokenURI( uint256 tokenId, string memory _tokenURI ) internal virtual { require( _exists(tokenId), "ERC721URIStorage: URI set of nonexistent token" ); _tokenURIs[tokenId] = _tokenURI; } function tokenURI( uint256 tokenId ) public view override returns (string memory) { _requireMinted(tokenId); return _tokenURIs[tokenId]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override(ERC721Upgradeable) { require(balanceOf(to) <= erc721DaoDetails.maxTokensPerUser); require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved" ); require(erc721DaoDetails.isTransferable, "NFT Non Transferable"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override(ERC721Upgradeable) { require(balanceOf(to) <= erc721DaoDetails.maxTokensPerUser); require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved" ); require(erc721DaoDetails.isTransferable, "NFT Non Transferable"); _safeTransfer(from, to, tokenId, data); } function _msgSender() internal view virtual override(Context, ContextUpgradeable) returns (address) { return msg.sender; } function _msgData() internal view virtual override(Context, ContextUpgradeable) returns (bytes calldata) { return msg.data; } function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC721Upgradeable, ERC2981, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } function onERC721Received( address, address, uint256, bytes calldata ) external pure returns (bytes4) { return IERC721Receiver.onERC721Received.selector; } receive() external payable {} function setRoyalty( address _receiver, uint96 _royaltyFeesInBips ) public onlyCurrentContract { _setDefaultRoyalty(_receiver, _royaltyFeesInBips); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721Upgradeable.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializing the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overridden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol) pragma solidity ^0.8.0; import "../../interfaces/IERC2981.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC2981 is IERC2981, ERC165 { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: invalid receiver"); _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { delete _defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty( uint256 tokenId, address receiver, uint96 feeNumerator ) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; /// @title StationXFactory Emitter Contract /// @dev Contract Emits events for Factory and Proxy contract Emitter is Initializable, AccessControl { bytes32 constant ADMIN = keccak256("ADMIN"); bytes32 public constant EMITTER = keccak256("EMITTER"); bytes32 public constant FACTORY = keccak256("FACTORY"); //FACTORY EVENTS event DefineContracts( address indexed factory, address ERC20ImplementationAddress, address ERC721ImplementationAddress, address emitterImplementationAddress ); event ChangeMerkleRoot( address indexed factory, address indexed daoAddress, bytes32 newMerkleRoot ); event CreateDaoErc20( address indexed deployerAddress, address indexed proxy, string name, string symbol, uint256 distributionAmount, uint256 pricePerToken, uint256 minDeposit, uint256 maxDeposit, uint256 ownerFee, uint256 _days, uint256 quorum, uint256 threshold, address depositTokenAddress, address emitter, address gnosisAddress, bool isGovernanceActive, bool isTransferable, bool assetsStoredOnGnosis ); event CreateDaoErc721( address indexed deployerAddress, address indexed proxy, string name, string symbol, string tokenURI, uint256 pricePerToken, uint256 distributionAmount, uint256 maxTokensPerUser, uint256 ownerFee, uint256 _days, uint256 quorum, uint256 threshold, address depositTokenAddress, address emitter, address gnosisAddress, bool isGovernanceActive, bool isTransferable, bool assetsStoredOnGnosis ); event FactoryCreated( address indexed _ERC20Implementation, address indexed _ERC721Implementation, address _wrappedTokenAddress, address indexed _factory, address _emitter ); //PROXY EVENTS event Deposited( address indexed _daoAddress, address indexed _depositor, address indexed _depositTokenAddress, uint256 _amount, uint256 _timeStamp, uint256 _ownerFee, uint256 _adminShare ); event StartDeposit( address indexed _proxy, uint256 startTime, uint256 closeTime ); event CloseDeposit(address indexed _proxy, uint256 closeTime); event UpdateMinMaxDeposit( address indexed _proxy, uint256 _minDeposit, uint256 _maxDeposit ); event UpdateOwnerFee(address indexed _proxy, uint256 _ownerFee); event AirDropToken( address indexed _daoAddress, address _token, address _to, uint256 _amount ); event MintGTToAddress( address indexed _daoAddress, uint256[] _amount, address[] _userAddress ); event UpdateGovernanceSettings( address indexed _daoAddress, uint256 _quorum, uint256 _threshold ); event UpdateDistributionAmount( address indexed _daoAddress, uint256 _amount ); event UpdatePricePerToken(address indexed _daoAddress, uint256 _amount); event SendCustomToken( address indexed _daoAddress, address _token, uint256[] _amount, address[] _addresses ); event NewUser( address indexed _daoAddress, address indexed _depositor, address indexed _depositTokenAddress, uint256 _depositTokenAmount, uint256 _timeStamp, uint256 _gtToken, bool _isAdmin ); //nft events event MintNft( address indexed _to, address indexed _daoAddress, string _tokenURI, uint256 _tokenId ); event UpdateMaxTokensPerUser( address indexed _daoAddress, uint256 _maxTokensPerUser ); event UpdateTotalSupplyOfToken( address indexed _daoAddress, uint256 _totalSupplyOfToken ); event UpdateTokenTransferability( address indexed _daoAddress, bool _isTokenTransferable ); event WhitelistAddress( address indexed _daoAddress, address indexed _address ); event RemoveWhitelistAddress( address indexed _daoAddress, address indexed _address ); address public factoryAddress; function initialize( address _ERC20Implementation, address _ERC721Implementation, address _wrappedTokenAddress, address _factory ) external initializer { _grantRole(ADMIN, msg.sender); _grantRole(FACTORY, _factory); factoryAddress = _factory; emit FactoryCreated( _ERC20Implementation, _ERC721Implementation, _wrappedTokenAddress, _factory, address(this) ); } function changeFactory(address _newFactory) external onlyRole(ADMIN) { _revokeRole(FACTORY, factoryAddress); _grantRole(FACTORY, _newFactory); factoryAddress = _newFactory; } function allowActionContract( address _actionContract ) external onlyRole(ADMIN) { _grantRole(EMITTER, _actionContract); } function defineContracts( address ERC20ImplementationAddress, address ERC721ImplementationAddress, address emitterImplementationAddress ) external payable onlyRole(FACTORY) { emit DefineContracts( msg.sender, ERC20ImplementationAddress, ERC721ImplementationAddress, emitterImplementationAddress ); } function changeMerkleRoot( address factory, address daoAddress, bytes32 newMerkleRoot ) external payable onlyRole(FACTORY) { emit ChangeMerkleRoot(factory, daoAddress, newMerkleRoot); } function createDaoErc20( address _deployerAddress, address _proxy, string memory _name, string memory _symbol, uint256 _distributionAmount, uint256 _pricePerToken, uint256 _minDeposit, uint256 _maxDeposit, uint256 _ownerFee, uint256 _totalDays, uint256 _quorum, uint256 _threshold, address _emitter, address _depositTokenAddress, address _gnosisAddress, bool _isGovernanceActive, bool isTransferable, bool assetsStoredOnGnosis ) external payable onlyRole(FACTORY) { _grantRole(EMITTER, _proxy); _grantRole(EMITTER, msg.sender); emit CreateDaoErc20( _deployerAddress, _proxy, _name, _symbol, _distributionAmount, _pricePerToken, _minDeposit, _maxDeposit, _ownerFee, _totalDays, _quorum, _threshold, _depositTokenAddress, _emitter, _gnosisAddress, _isGovernanceActive, isTransferable, assetsStoredOnGnosis ); } function createDaoErc721( address _deployerAddress, address _proxy, string memory _name, string memory _symbol, string memory _tokenURI, uint256 _pricePerToken, uint256 _distributionAmount, uint256 _maxTokensPerUser, uint256 _ownerFee, uint256 _totalDays, uint256 _quorum, uint256 _threshold, address _depositTokenAddress, address _emitter, address _gnosisAddress, bool _isGovernanceActive, bool isTransferable, bool assetsStoredOnGnosis ) external payable onlyRole(FACTORY) { _grantRole(EMITTER, _proxy); _grantRole(EMITTER, msg.sender); emit CreateDaoErc721( _deployerAddress, _proxy, _name, _symbol, _tokenURI, _pricePerToken, _distributionAmount, _maxTokensPerUser, _ownerFee, _totalDays, _quorum, _threshold, _depositTokenAddress, _emitter, _gnosisAddress, _isGovernanceActive, isTransferable, assetsStoredOnGnosis ); } function deposited( address _daoAddress, address _depositor, address _depositTokenAddress, uint256 _amount, uint256 _timestamp, uint256 _ownerFee, uint256 _adminShare ) external onlyRole(EMITTER) { emit Deposited( _daoAddress, _depositor, _depositTokenAddress, _amount, _timestamp, _ownerFee, _adminShare ); } function newUser( address _daoAddress, address _depositor, address _depositTokenAddress, uint256 _depositTokenAmount, uint256 _timeStamp, uint256 _gtToken, bool _isAdmin ) external onlyRole(EMITTER) { emit NewUser( _daoAddress, _depositor, _depositTokenAddress, _depositTokenAmount, _timeStamp, _gtToken, _isAdmin ); } function startDeposit( address _proxy, uint256 _startTime, uint256 _closeTime ) external onlyRole(EMITTER) { emit StartDeposit(_proxy, _startTime, _closeTime); } function closeDeposit( address _proxy, uint256 _closeTime ) external onlyRole(EMITTER) { emit CloseDeposit(_proxy, _closeTime); } function updateMinMaxDeposit( address _proxy, uint256 _minDeposit, uint256 _maxDeposit ) external onlyRole(EMITTER) { emit UpdateMinMaxDeposit(_proxy, _minDeposit, _maxDeposit); } function updateOwnerFee( address _proxy, uint256 _ownerFee ) external onlyRole(EMITTER) { emit UpdateOwnerFee(_proxy, _ownerFee); } function airDropToken( address _proxy, address _token, address _to, uint256 _amount ) external onlyRole(EMITTER) { emit AirDropToken(_proxy, _token, _to, _amount); } function mintGTToAddress( address _proxy, uint256[] memory _amount, address[] memory _userAddress ) external onlyRole(EMITTER) { emit MintGTToAddress(_proxy, _amount, _userAddress); } function updateGovernanceSettings( address _proxy, uint256 _quorum, uint256 _threshold ) external onlyRole(EMITTER) { emit UpdateGovernanceSettings(_proxy, _quorum, _threshold); } function updateDistributionAmount( address _daoAddress, uint256 _distributionAmount ) external onlyRole(EMITTER) { emit UpdateDistributionAmount(_daoAddress, _distributionAmount); } function updatePricePerToken( address _daoAddress, uint256 _pricePerToken ) external onlyRole(EMITTER) { emit UpdatePricePerToken(_daoAddress, _pricePerToken); } function sendCustomToken( address _daoAddress, address _token, uint256[] memory _amount, address[] memory _addresses ) external onlyRole(EMITTER) { emit SendCustomToken(_daoAddress, _token, _amount, _addresses); } function mintNft( address _to, address _implementation, string memory _tokenURI, uint256 _tokenId ) external onlyRole(EMITTER) { emit MintNft(_to, _implementation, _tokenURI, _tokenId); } function updateMaxTokensPerUser( address _nftAddress, uint256 _maxTokensPerUser ) external onlyRole(EMITTER) { emit UpdateMaxTokensPerUser(_nftAddress, _maxTokensPerUser); } function updateTotalSupplyOfToken( address _nftAddress, uint256 _totalSupplyOfToken ) external onlyRole(EMITTER) { emit UpdateTotalSupplyOfToken(_nftAddress, _totalSupplyOfToken); } function updateTokenTransferability( address _nftAddress, bool _isTokenTransferable ) external onlyRole(EMITTER) { emit UpdateTokenTransferability(_nftAddress, _isTokenTransferable); } function whitelistAddress( address _nftAddress, address _address ) external onlyRole(EMITTER) { emit WhitelistAddress(_nftAddress, _address); } function removeWhitelistAddress( address _nftAddress, address _address ) external onlyRole(EMITTER) { emit RemoveWhitelistAddress(_nftAddress, _address); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "./factory.sol"; import "./emitter.sol"; import "./helper.sol"; interface IERC20Extented is IERC20 { function decimals() external view returns (uint8); } /// @title StationX Governance Token Contract /// @dev Base Contract as a reference for DAO Governance Token contract proxies contract ERC20DAO is ERC20Upgradeable, AccessControl, IERC721Receiver, ReentrancyGuard, Helper { using SafeERC20 for IERC20; ///@dev address of the emitter contract address public emitterContractAddress; address public factoryAddress; ERC20DAOdetails public erc20DaoDetails; /// @dev initialize Function to initialize Token contract function initializeERC20( address _factory, address _emitter, string memory _DaoName, string memory _DaoSymbol, uint256 _quorum, uint256 _threshold, bool _isGovernanceActive, bool _isTransferable, address _ownerAddress, bool onlyAllowWhitelist ) external initializer { factoryAddress = _factory; emitterContractAddress = _emitter; ERC20DAOdetails memory _erc20DaoDetails = ERC20DAOdetails( _DaoName, _DaoSymbol, _quorum, _threshold, _isGovernanceActive, _isTransferable, onlyAllowWhitelist, _ownerAddress ); erc20DaoDetails = _erc20DaoDetails; __ERC20_init(_DaoName, _DaoSymbol); } /// @dev This function returns details of a particular dao function getERC20DAOdetails() external view returns (ERC20DAOdetails memory) { return erc20DaoDetails; } /// @dev Function execute proposals called by gnosis safe /// @param _data function signature data encoded along with parameters function updateProposalAndExecution( address _contract, bytes memory _data ) external onlyGnosis(factoryAddress, address(this)) nonReentrant { if (_contract == address(0)) revert AddressInvalid("_contract", _contract); (bool success, ) = _contract.call(_data); require(success); } /// @dev Function to transfer NFT from this contract /// @param _nft address of nft to transfer /// @param _to address of receiver /// @param _tokenId tokenId of nft to transfer function transferNft( address _nft, address _to, uint256 _tokenId ) external onlyCurrentContract { if (_nft == address(0)) revert AddressInvalid("_nft", _nft); if (_to == address(0)) revert AddressInvalid("_to", _to); IERC721(_nft).safeTransferFrom(address(this), _to, _tokenId); } /// @dev function to mint GT token to a addresses /// @param _amountArray array of amount to be transferred /// @param _userAddress array of address where the amount should be transferred function mintGTToAddress( uint256[] memory _amountArray, address[] memory _userAddress ) external onlyCurrentContract { if (_amountArray.length != _userAddress.length) revert ArrayLengthMismatch( _amountArray.length, _userAddress.length ); uint256 leng = _amountArray.length; for (uint256 i; i < leng; ) { _mint(_userAddress[i], _amountArray[i]); Emitter(emitterContractAddress).newUser( address(this), _userAddress[i], Factory(factoryAddress) .getDAOdetails(address(this)) .depositTokenAddress, 0, block.timestamp, _amountArray[i], Safe( Factory(factoryAddress) .getDAOdetails(address(this)) .gnosisAddress ).isOwner(_userAddress[i]) ); unchecked { ++i; } } Emitter(emitterContractAddress).mintGTToAddress( address(this), _amountArray, _userAddress ); } /// @dev function to update governance settings /// @param _quorum update quorum into the contract /// @param _threshold update threshold into the contract function updateGovernanceSettings( uint256 _quorum, uint256 _threshold ) external onlyCurrentContract { if (_quorum == 0) revert AmountInvalid("_quorum", _quorum); if (_threshold == 0) revert AmountInvalid("_threshold", _threshold); if (!(_quorum <= FLOAT_HANDLER_TEN_4)) revert AmountInvalid("_quorum", _quorum); if (!(_threshold <= FLOAT_HANDLER_TEN_4)) revert AmountInvalid("_threshold", _threshold); erc20DaoDetails.quorum = _quorum; erc20DaoDetails.threshold = _threshold; Emitter(emitterContractAddress).updateGovernanceSettings( address(this), _quorum, _threshold ); } /// @dev Function to set whitelist to true for a particular token contract function toggleOnlyAllowWhitelist() external payable onlyCurrentContract { erc20DaoDetails.onlyAllowWhitelist = !erc20DaoDetails .onlyAllowWhitelist; } /// @dev Function to change governance active /// @param _isGovernanceActive New governance active status function updateGovernanceActive( bool _isGovernanceActive ) external payable onlyCurrentContract { erc20DaoDetails.isGovernanceActive = _isGovernanceActive; } /// @dev Function to update token transferability for a particular token contract /// @param _isTokenTransferable New token transferability function updateTokenTransferability( bool _isTokenTransferable ) external payable onlyCurrentContract { erc20DaoDetails.isTransferable = _isTokenTransferable; Emitter(emitterContractAddress).updateTokenTransferability( address(this), _isTokenTransferable ); } /// @dev Function to override transfer to restrict token transfers function transfer( address to, uint256 amount ) public virtual override(ERC20Upgradeable) returns (bool) { require(erc20DaoDetails.isTransferable, "Token Non Transferable"); address owner = _msgSender(); _transfer(owner, to, amount); return true; } /// @dev Function to override transferFrom to restrict token transfers function transferFrom( address from, address to, uint256 amount ) public virtual override(ERC20Upgradeable) returns (bool) { require(erc20DaoDetails.isTransferable, "Token Non Transferable"); address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /// @dev Function to mint Governance Token and assign delegate /// @param to Address to which tokens will be minted /// @param amount Value of tokens to be minted based on deposit by DAO member function mintToken( address to, uint256 amount, bytes32[] calldata _merkleProof ) public { if (erc20DaoDetails.onlyAllowWhitelist) { require( MerkleProof.verify( _merkleProof, Factory(factoryAddress) .getDAOdetails(address(this)) .merkleRoot, keccak256(abi.encodePacked(to)) ), "Incorrect proof" ); } require(msg.sender == factoryAddress || msg.sender == address(this)); _mint(to, amount); } // -- Who will have access control for burning tokens? /// @dev Function to burn Governance Token /// @param account Address from where token will be burned /// @param amount Value of tokens to be burned function burnToken(address account, uint256 amount) internal { _burn(account, amount); } /// @dev Internal function that needs to be override function _msgSender() internal view virtual override(Context, ContextUpgradeable) returns (address) { return msg.sender; } function _msgData() internal view virtual override(Context, ContextUpgradeable) returns (bytes calldata) { return msg.data; } function onERC721Received( address, address, uint256, bytes calldata ) external pure returns (bytes4) { return IERC721Receiver.onERC721Received.selector; } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "./proxy.sol"; import "./emitter.sol"; import "./erc20dao.sol"; import "./erc721dao.sol"; import "./helper.sol"; interface IWrappedToken { function deposit() external payable; } interface Safe { function createProxyWithNonce( address _singleton, bytes memory initializer, uint256 saltNonce ) external returns (address proxy); function isOwner(address owner) external view returns (bool); } /// @title StationXFactory Cloning Contract /// @dev Contract create proxies of DAO Token and Governor contract contract Factory is Helper { using SafeERC20 for IERC20; address private ERC20Implementation; address private ERC721Implementation; address private emitterAddress; address private constant wrappedTokenAddress = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; address private safe; address private singleton; address private _owner; //Mapping to get details of a particular dao mapping(address => DAODetails) private daoDetails; //Mapping to store total deposit by a user in a particular dao mapping(address => mapping(address => uint256)) private totalDeposit; //Mapping to get details of token gating for a particular dao mapping(address => TokenGatingCondition[]) private tokenGatingDetails; bool private _initialized; function initialize() external { require(!_initialized); _owner = msg.sender; _initialized = true; } modifier onlyOwner() { require(msg.sender == _owner, "caller is not the owner"); _; } function changeOwner(address _newOwner) external onlyOwner { _owner = _newOwner; } function defineTokenContracts( address ERC20ImplementationAddress, address ERC721ImplementationAddress, address emitterImplementationAddress, address _safe, address _singleton ) external onlyOwner { //Setting ERC20 implementation contract for the reference ERC20Implementation = ERC20ImplementationAddress; //Setting ERC721 implementation contract for the reference ERC721Implementation = ERC721ImplementationAddress; //Setting Emitter proxy contract emitterAddress = emitterImplementationAddress; safe = _safe; singleton = _singleton; } /// @dev This function returns details of a particular dao /// @param _daoAddress address of token contract function getDAOdetails( address _daoAddress ) public view returns (DAODetails memory) { return daoDetails[_daoAddress]; } /// @dev This function returns token gating details of a particular dao /// @param _daoAddress address of token contract function getTokenGatingDetails( address _daoAddress ) external view returns (TokenGatingCondition[] memory) { return tokenGatingDetails[_daoAddress]; } /// @dev Function to change merkle root of particular token contract /// @param _daoAddress address token contract function changeMerkleRoot( address _daoAddress, bytes32 _newMerkleRoot ) external payable onlyGnosisOrDao(address(this), _daoAddress) { if (!daoDetails[_daoAddress].isDeployedByFactory) revert AddressInvalid("_daoAddress", _daoAddress); daoDetails[_daoAddress].merkleRoot = _newMerkleRoot; Emitter(emitterAddress).changeMerkleRoot( address(this), _daoAddress, _newMerkleRoot ); } /// @dev Function to create proxies and initialization of Token and Governor contract function createERC20DAO( string memory _DaoName, string memory _DaoSymbol, uint256 _distributionAmount, uint256 _pricePerToken, uint256 _minDepositPerUser, uint256 _maxDepositPerUser, uint256 _ownerFeePerDepositPercent, uint256 _depositTime, uint256 _quorumPercent, uint256 _thresholdPercent, uint256 _safeThreshold, address _depositTokenAddress, address _gnosisAddress, address[] memory _admins, bool _isGovernanceActive, bool _isTransferable, bool _onlyAllowWhitelist, bool _assetsStoredOnGnosis, bytes32 _merkleRoot ) external { if (_quorumPercent == 0 || _quorumPercent > FLOAT_HANDLER_TEN_4) revert AmountInvalid("_quorumPercent", _quorumPercent); if (_thresholdPercent == 0 || _thresholdPercent > FLOAT_HANDLER_TEN_4) revert AmountInvalid("_thresholdPercent", _thresholdPercent); if (_depositTime == 0) revert AmountInvalid("_depositFunctioningDays", _depositTime); if (!(_ownerFeePerDepositPercent < FLOAT_HANDLER_TEN_4)) revert AmountInvalid( "_ownerFeePerDeposit", _ownerFeePerDepositPercent ); if (_maxDepositPerUser == 0) revert AmountInvalid("_maxDepositPerUser", _maxDepositPerUser); if (_maxDepositPerUser <= _minDepositPerUser) revert DepositAmountInvalid(_maxDepositPerUser, _minDepositPerUser); if ( ((_distributionAmount * _pricePerToken) / 1e18) < _maxDepositPerUser ) revert RaiseAmountInvalid( ((_distributionAmount * _pricePerToken) / 1e18), _maxDepositPerUser ); address _safe; if (_gnosisAddress == address(0)) { bytes memory _initializer = abi.encodeWithSignature( "setup(address[],uint256,address,bytes,address,address,uint256,address)", _admins, _safeThreshold, 0x0000000000000000000000000000000000000000, "0x", 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4, 0x0000000000000000000000000000000000000000, 0, 0x0000000000000000000000000000000000000000 ); _safe = Safe(safe).createProxyWithNonce( singleton, _initializer, block.timestamp ); } else { _safe = _gnosisAddress; } bytes memory data = abi.encodeWithSignature( "initializeERC20(address,address,string,string,uint256,uint256,bool,bool,address,bool)", address(this), emitterAddress, _DaoName, _DaoSymbol, _quorumPercent, _thresholdPercent, _isGovernanceActive, _isTransferable, msg.sender, _onlyAllowWhitelist ); address _daoAddress = address( new ProxyContract(ERC20Implementation, _owner, data) ); daoDetails[_daoAddress] = DAODetails( _pricePerToken, _distributionAmount, _minDepositPerUser, _maxDepositPerUser, _ownerFeePerDepositPercent, _depositTime, _depositTokenAddress, _safe, _merkleRoot, true, false, _assetsStoredOnGnosis ); Emitter(emitterAddress).createDaoErc20( msg.sender, _daoAddress, _DaoName, _DaoSymbol, _distributionAmount, _pricePerToken, _minDepositPerUser, _maxDepositPerUser, _ownerFeePerDepositPercent, _depositTime, _quorumPercent, _thresholdPercent, _depositTokenAddress, emitterAddress, _safe, _isGovernanceActive, _isTransferable, _assetsStoredOnGnosis ); for (uint i; i < _admins.length; ) { Emitter(emitterAddress).newUser( _daoAddress, _admins[i], _depositTokenAddress, 0, block.timestamp, 0, true ); unchecked { ++i; } } } /// @dev Function to create proxies and initialization of Token and Governor contract function createERC721DAO( string memory _DaoName, string memory _DaoSymbol, string memory _tokenURI, uint256 _ownerFeePerDepositPercent, uint256 _depositTime, uint256 _quorumPercent, uint256 _thresholdPercent, uint256 _safeThreshold, address _depositTokenAddress, address _gnosisAddress, address[] memory _admins, uint256 _maxTokensPerUser, uint256 _distributionAmount, uint256 _pricePerToken, bool _isNftTransferable, bool _isNftTotalSupplyUnlimited, bool _isGovernanceActive, bool _onlyAllowWhitelist, bool _assetsStoredOnGnosis, bytes32 _merkleRoot ) external { if (_quorumPercent == 0 || _quorumPercent > FLOAT_HANDLER_TEN_4) revert AmountInvalid("_quorumPercent", _quorumPercent); if (_thresholdPercent == 0 || _thresholdPercent > FLOAT_HANDLER_TEN_4) revert AmountInvalid("_thresholdPercent", _thresholdPercent); if (_depositTime == 0) revert AmountInvalid("_depositFunctioningDays", _depositTime); if (!(_ownerFeePerDepositPercent < FLOAT_HANDLER_TEN_4)) revert AmountInvalid( "_ownerFeePerDeposit", _ownerFeePerDepositPercent ); if (_maxTokensPerUser == 0) revert AmountInvalid("_maxTokensPerUser", _maxTokensPerUser); address _safe; if (_gnosisAddress == address(0)) { bytes memory _initializer = abi.encodeWithSignature( "setup(address[],uint256,address,bytes,address,address,uint256,address)", _admins, _safeThreshold, 0x0000000000000000000000000000000000000000, "0x", 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4, 0x0000000000000000000000000000000000000000, 0, 0x0000000000000000000000000000000000000000 ); _safe = Safe(safe).createProxyWithNonce( singleton, _initializer, block.timestamp ); } else { _safe = _gnosisAddress; } bytes memory data = abi.encodeWithSignature( "initializeERC721(string,string,address,address,uint256,uint256,uint256,bool,bool,bool,bool,address)", _DaoName, _DaoSymbol, address(this), emitterAddress, _quorumPercent, _thresholdPercent, _maxTokensPerUser, _isNftTransferable, _isNftTotalSupplyUnlimited, _isGovernanceActive, _onlyAllowWhitelist, msg.sender ); address _daoAddress = address( new ProxyContract(ERC721Implementation, _owner, data) ); daoDetails[_daoAddress] = DAODetails( _pricePerToken, _distributionAmount, 0, 0, _ownerFeePerDepositPercent, _depositTime, _depositTokenAddress, _safe, _merkleRoot, true, false, _assetsStoredOnGnosis ); Emitter(emitterAddress).createDaoErc721( msg.sender, _daoAddress, _DaoName, _DaoSymbol, _tokenURI, _pricePerToken, _distributionAmount, _maxTokensPerUser, _ownerFeePerDepositPercent, _depositTime, _quorumPercent, _thresholdPercent, _depositTokenAddress, emitterAddress, _safe, _isGovernanceActive, _isNftTransferable, _assetsStoredOnGnosis ); for (uint i; i < _admins.length; ) { Emitter(emitterAddress).newUser( _daoAddress, _admins[i], _depositTokenAddress, 0, block.timestamp, 0, true ); unchecked { ++i; } } } /// @dev Function to update Minimum and Maximum deposits allowed by DAO members /// @param _minDepositPerUser New minimum deposit requirement amount in wei /// @param _maxDepositPerUser New maximum deposit limit amount in wei /// @param _daoAddress address of the token contract function updateMinMaxDeposit( uint256 _minDepositPerUser, uint256 _maxDepositPerUser, address _daoAddress ) external payable onlyGnosisOrDao(address(this), _daoAddress) { if (!daoDetails[_daoAddress].isDeployedByFactory) revert AddressInvalid("_daoAddress", _daoAddress); if (_minDepositPerUser == 0) revert AmountInvalid("_minDepositPerUser", _minDepositPerUser); if (_minDepositPerUser > _maxDepositPerUser) revert DepositAmountInvalid(_minDepositPerUser, _maxDepositPerUser); daoDetails[_daoAddress].minDepositPerUser = _minDepositPerUser; daoDetails[_daoAddress].maxDepositPerUser = _maxDepositPerUser; Emitter(emitterAddress).updateMinMaxDeposit( _daoAddress, _minDepositPerUser, _maxDepositPerUser ); } /// @dev Function to update DAO Owner Fee /// @param _ownerFeePerDeposit New Owner fee /// @param _daoAddress address of the token contract function updateOwnerFee( uint256 _ownerFeePerDeposit, address _daoAddress ) external payable onlyAdmins(daoDetails[_daoAddress].gnosisAddress) { if (!daoDetails[_daoAddress].isDeployedByFactory) revert AddressInvalid("_daoAddress", _daoAddress); if (!(_ownerFeePerDeposit < FLOAT_HANDLER_TEN_4)) revert AmountInvalid("_ownerFeePerDeposit", _ownerFeePerDeposit); daoDetails[_daoAddress].ownerFeePerDepositPercent = _ownerFeePerDeposit; Emitter(emitterAddress).updateOwnerFee( _daoAddress, _ownerFeePerDeposit ); } /// @dev Function to update total raise amount /// @param _newDistributionAmount New distribution amount /// @param _newPricePerToken New price per token /// @param _daoAddress address of the token contract function updateTotalRaiseAmount( uint256 _newDistributionAmount, uint256 _newPricePerToken, address _daoAddress ) external payable onlyGnosisOrDao(address(this), _daoAddress) { if (!daoDetails[_daoAddress].isDeployedByFactory) revert AddressInvalid("_daoAddress", _daoAddress); uint _distributionAmount = daoDetails[_daoAddress].distributionAmount; if (_distributionAmount != _newDistributionAmount) { if (_distributionAmount > _newDistributionAmount) revert AmountInvalid( "_newDistributionAmount", _newDistributionAmount ); daoDetails[_daoAddress].distributionAmount = _newDistributionAmount; Emitter(emitterAddress).updateDistributionAmount( _daoAddress, _newDistributionAmount ); } if (daoDetails[_daoAddress].pricePerToken != _newPricePerToken) { daoDetails[_daoAddress].pricePerToken = _newPricePerToken; Emitter(emitterAddress).updatePricePerToken( _daoAddress, _newPricePerToken ); } } /// @dev Function to update deposit time /// @param _depositTime New start time /// @param _daoAddress address of the token contract function updateDepositTime( uint256 _depositTime, address _daoAddress ) external payable onlyAdmins(daoDetails[_daoAddress].gnosisAddress) { if (!daoDetails[_daoAddress].isDeployedByFactory) revert AddressInvalid("_daoAddress", _daoAddress); if (_depositTime == 0) revert AmountInvalid("_days", _depositTime); daoDetails[_daoAddress].depositCloseTime = _depositTime; Emitter(emitterAddress).startDeposit( _daoAddress, block.timestamp, daoDetails[_daoAddress].depositCloseTime ); } /// @dev Function to setup multiple token checks to gate community /// @param _tokenA Address of token A /// @param _tokenB Address of token B /// @param _operator Operator for token checks (0 for AND and 1 for OR) /// @param _comparator Operator for comparing token balances (0 for GREATER, 1 for BELOW and 2 for EQUAL) /// @param _value Minimum user balance amount /// @param _daoAddress Address to DAO function setupTokenGating( address _tokenA, address _tokenB, Operator _operator, Comparator _comparator, uint256[] memory _value, address payable _daoAddress ) external payable onlyAdmins(daoDetails[_daoAddress].gnosisAddress) { require(_value.length == 2, "Length mismatch"); TokenGatingCondition memory _tokenGatingCondition = TokenGatingCondition( _tokenA, _tokenB, _operator, _comparator, _value ); if (_tokenA == address(0) || _tokenB == address(0)) { require(uint8(_operator) == 1, "Operator cannot be AND"); } tokenGatingDetails[_daoAddress].push(_tokenGatingCondition); daoDetails[_daoAddress].isTokenGatingApplied = true; } /// @dev Function to disable token gating /// @param _daoAddress address of the token contract function disableTokenGating( address _daoAddress ) external payable onlyAdmins(daoDetails[_daoAddress].gnosisAddress) { delete tokenGatingDetails[_daoAddress]; daoDetails[_daoAddress].isTokenGatingApplied = false; } function buyGovernanceTokenWithNative( address payable _daoAddress, uint256 _numOfTokensToBuy, string memory _tokenURI, bool isNFTGovernance, bytes32[] calldata _proof ) external payable { require( daoDetails[_daoAddress].depositTokenAddress == wrappedTokenAddress, "Token not supported" ); IWrappedToken(wrappedTokenAddress).deposit{value: msg.value}(); if (isNFTGovernance) { buyGovernanceTokenERC721DAO( address(this), _daoAddress, _tokenURI, _numOfTokensToBuy, _proof ); } else { buyGovernanceTokenERC20DAO( address(this), _daoAddress, _numOfTokensToBuy, _proof ); } } /// @dev function to deposit tokens and receive dao tokens in return /// @param _daoAddress address of the token contract /// @param _numOfTokensToBuy amount of tokens to buy function buyGovernanceTokenERC20DAO( address _user, address payable _daoAddress, uint256 _numOfTokensToBuy, bytes32[] calldata _merkleProof ) public { if (daoDetails[_daoAddress].depositCloseTime < block.timestamp) revert DepositClosed(); uint _totalDeposit = totalDeposit[msg.sender][_daoAddress]; uint256 _totalAmount = (_numOfTokensToBuy * daoDetails[_daoAddress].pricePerToken) / 1e18; if (_totalDeposit == 0) { if (_totalAmount < daoDetails[_daoAddress].minDepositPerUser) revert AmountInvalid("_numOfTokensToBuy", _numOfTokensToBuy); if (_totalAmount > daoDetails[_daoAddress].maxDepositPerUser) revert AmountInvalid("_numOfTokensToBuy", _numOfTokensToBuy); } else { if ( _totalDeposit + _totalAmount > daoDetails[_daoAddress].maxDepositPerUser ) revert AmountInvalid("_numOfTokensToBuy", _numOfTokensToBuy); } if (daoDetails[_daoAddress].isTokenGatingApplied) { ifTokenGatingApplied(_daoAddress); } uint256 daoBalance = IERC20(daoDetails[_daoAddress].depositTokenAddress) .balanceOf(_daoAddress); daoBalance += _totalAmount; totalDeposit[msg.sender][_daoAddress] += _totalAmount; if ( daoBalance > (daoDetails[_daoAddress].pricePerToken * daoDetails[_daoAddress].distributionAmount) / 1e18 ) revert AmountInvalid("daoBalance", daoBalance); uint256 ownerShare = (_totalAmount * daoDetails[_daoAddress].ownerFeePerDepositPercent) / (FLOAT_HANDLER_TEN_4); uint256 userShare = _totalAmount - ownerShare; checkFeeAndMintTokens( _user, _daoAddress, daoDetails[_daoAddress].depositTokenAddress, userShare, ownerShare, _numOfTokensToBuy, _totalAmount, _merkleProof ); } /// @dev This internal function performs required operations if token gating is applied function ifTokenGatingApplied(address _daoAddress) private view { TokenGatingCondition[] memory conditions = tokenGatingDetails[ _daoAddress ]; for (uint i; i < conditions.length; ) { address _tokenA = conditions[i].tokenA; address _tokenB = conditions[i].tokenB; uint _valueA = conditions[i].value[0]; uint _valueB = conditions[i].value[1]; uint _balanceA = IERC20(_tokenA).balanceOf(msg.sender); uint _balanceB = IERC20(_tokenB).balanceOf(msg.sender); if (conditions[i].operator == Operator.AND) { if (conditions[i].comparator == Comparator.GREATER) { if (_balanceA < _valueA) revert InsufficientBalance(); if (_balanceB < _valueB) revert InsufficientBalance(); } else if (conditions[i].comparator == Comparator.BELOW) { if (_balanceA > _valueA) revert InsufficientBalance(); if (_balanceB > _valueB) revert InsufficientBalance(); } else { if (_balanceA != _valueA) revert InsufficientBalance(); if (_balanceB != _valueB) revert InsufficientBalance(); } } else { if (conditions[i].comparator == Comparator.GREATER) { if (_balanceA < _valueA && _balanceB < _valueB) revert InsufficientBalance(); } else if (conditions[i].comparator == Comparator.BELOW) { if (_balanceA > _valueA && _balanceB > _valueB) revert InsufficientBalance(); } else { if (_balanceA != _valueA && _balanceB != _valueB) revert InsufficientBalance(); } } unchecked { ++i; } } } /// @dev function to deposit tokens and receive dao tokens in return /// @param _daoAddress address of the token contract /// @param _tokenURI token URI of nft /// @param _numOfTokensToBuy amount of nfts to mint function buyGovernanceTokenERC721DAO( address _user, address payable _daoAddress, string memory _tokenURI, uint256 _numOfTokensToBuy, bytes32[] calldata _merkleProof ) public { if (daoDetails[_daoAddress].depositCloseTime < block.timestamp) revert DepositClosed(); if (_numOfTokensToBuy == 0) revert AmountInvalid("_numOfTokensToBuy", _numOfTokensToBuy); uint _totalAmount = daoDetails[_daoAddress].pricePerToken * (_numOfTokensToBuy); if (daoDetails[_daoAddress].isTokenGatingApplied) { ifTokenGatingApplied(_daoAddress); } uint256 daoBalance = IERC20(daoDetails[_daoAddress].depositTokenAddress) .balanceOf(_daoAddress); daoBalance += _totalAmount; uint256 ownerShare = (_totalAmount * daoDetails[_daoAddress].ownerFeePerDepositPercent) / (FLOAT_HANDLER_TEN_4); uint256 userShare = _totalAmount - ownerShare; IERC20(daoDetails[_daoAddress].depositTokenAddress).safeTransferFrom( _user, daoDetails[_daoAddress].assetsStoredOnGnosis ? daoDetails[_daoAddress].gnosisAddress : _daoAddress, userShare ); IERC20(daoDetails[_daoAddress].depositTokenAddress).safeTransferFrom( _user, ERC721DAO(_daoAddress).getERC721DAOdetails().ownerAddress, ownerShare ); for (uint256 i; i < _numOfTokensToBuy; ) { ERC721DAO(_daoAddress).mintNft(msg.sender, _tokenURI, _merkleProof); unchecked { ++i; } } Emitter(emitterAddress).deposited( _daoAddress, msg.sender, daoDetails[_daoAddress].depositTokenAddress, _totalAmount, block.timestamp, daoDetails[_daoAddress].ownerFeePerDepositPercent, ownerShare ); Emitter(emitterAddress).newUser( _daoAddress, msg.sender, daoDetails[_daoAddress].depositTokenAddress, _totalAmount, block.timestamp, _numOfTokensToBuy, false ); } /// @dev This internal function checks if Fee is true and mints tokens accordingly function checkFeeAndMintTokens( address _user, address payable _daoAddress, address _depositTokenAddress, uint256 userShare, uint256 ownerShare, uint256 userGtTokens, uint256 _totalAmount, bytes32[] calldata _merkleProof ) internal { ERC20DAOdetails memory _details = ERC20DAO(_daoAddress) .getERC20DAOdetails(); if (daoDetails[_daoAddress].ownerFeePerDepositPercent > 0) { IERC20(_depositTokenAddress).safeTransferFrom( _user, daoDetails[_daoAddress].assetsStoredOnGnosis ? daoDetails[_daoAddress].gnosisAddress : _daoAddress, userShare ); IERC20(_depositTokenAddress).safeTransferFrom( _user, _details.ownerAddress, ownerShare ); ERC20DAO(_daoAddress).mintToken( msg.sender, userGtTokens, _merkleProof ); Emitter(emitterAddress).deposited( _daoAddress, msg.sender, _depositTokenAddress, _totalAmount, block.timestamp, daoDetails[_daoAddress].ownerFeePerDepositPercent, ownerShare ); Emitter(emitterAddress).newUser( _daoAddress, msg.sender, _depositTokenAddress, _totalAmount, block.timestamp, userGtTokens, false ); } else { IERC20(_depositTokenAddress).safeTransferFrom( _user, daoDetails[_daoAddress].assetsStoredOnGnosis ? daoDetails[_daoAddress].gnosisAddress : _daoAddress, _totalAmount ); ERC20DAO(_daoAddress).mintToken( msg.sender, userGtTokens, _merkleProof ); Emitter(emitterAddress).deposited( _daoAddress, msg.sender, _depositTokenAddress, _totalAmount, block.timestamp, daoDetails[_daoAddress].ownerFeePerDepositPercent, userGtTokens ); Emitter(emitterAddress).newUser( _daoAddress, msg.sender, _depositTokenAddress, _totalAmount, block.timestamp, userGtTokens, false ); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "@openzeppelin/contracts/access/IAccessControl.sol"; import "./factory.sol"; interface IERC20Extended { function decimals() external view returns (uint8); } contract Helper { ///@dev Admin role bytes32 constant ADMIN = keccak256("ADMIN"); uint8 constant UNIFORM_DECIMALS = 18; bytes32 constant operationNameAND = keccak256(abi.encodePacked(("AND"))); bytes32 constant operationNameOR = keccak256(abi.encodePacked(("OR"))); uint256 constant EIGHTEEN_DECIMALS = 1e18; uint256 constant FLOAT_HANDLER_TEN_4 = 10000; struct DAODetails { uint256 pricePerToken; uint256 distributionAmount; uint256 minDepositPerUser; uint256 maxDepositPerUser; uint256 ownerFeePerDepositPercent; uint256 depositCloseTime; address depositTokenAddress; address gnosisAddress; bytes32 merkleRoot; bool isDeployedByFactory; bool isTokenGatingApplied; bool assetsStoredOnGnosis; } struct ERC20DAOdetails { string DaoName; string DaoSymbol; uint256 quorum; uint256 threshold; bool isGovernanceActive; bool isTransferable; bool onlyAllowWhitelist; address ownerAddress; } struct ERC721DAOdetails { string DaoName; string DaoSymbol; uint256 quorum; uint256 threshold; uint256 maxTokensPerUser; bool isTransferable; bool isNftTotalSupplyUnlimited; bool isGovernanceActive; bool onlyAllowWhitelist; address ownerAddress; } enum Operator { AND, OR } enum Comparator { GREATER, BELOW, EQUAL } struct TokenGatingCondition { address tokenA; address tokenB; Operator operator; Comparator comparator; uint256[] value; } //implementation contract errors error AmountInvalid(string _param, uint256 _amount); error NotERC20Template(); error DepositAmountInvalid( uint256 _maxDepositPerUser, uint256 _minDepositPerUser ); error DepositClosed(); error DepositStarted(); error Max4TokensAllowed(uint256 _length); error ArrayLengthMismatch(uint256 _length1, uint256 _length2); error AddressInvalid(string _param, address _address); error InsufficientFunds(); error InvalidData(); error InsufficientAllowance(uint256 required, uint256 current); //nft contract errors error NotWhitelisted(); error MaxTokensMinted(); error NoAccess(address _user); error MintingNotOpen(); error MaxTokensMintedForUser(address _user); error RaiseAmountInvalid( uint256 _totalRaiseAmount, uint256 _maxDepositPerUser ); error InsufficientBalance(); /// @dev onlyOwner modifier to allow only Owner access to functions modifier onlyGnosis(address _factory, address _daoAddress) { require( Factory(_factory).getDAOdetails(_daoAddress).gnosisAddress == msg.sender, "Only Gnosis" ); _; } modifier onlyGnosisOrDao(address _factory, address _daoAddress) { require( Factory(_factory).getDAOdetails(_daoAddress).gnosisAddress == msg.sender || _daoAddress == msg.sender, "Only Gnosis or Dao" ); _; } modifier onlyFactory(address _factory) { require(msg.sender == _factory); _; } modifier onlyFactoryDeployed(address _factory) { require( Factory(_factory).getDAOdetails(address(this)).isDeployedByFactory ); _; } modifier onlyCurrentContract() { require(msg.sender == address(this)); _; } modifier onlyAdmins(address _safe) { require(Safe(_safe).isOwner(msg.sender), "Only owner access"); _; } /// @dev Change decimal places to `UNIFORM_DECIMALS`. function toUniform( uint256 amount, address token ) internal view returns (uint256) { return changeDecimals( amount, IERC20Extended(token).decimals(), UNIFORM_DECIMALS ); } /// @dev Convert decimal places from `UNIFORM_DECIMALS` to token decimals. function fromUniform( uint256 amount, address token ) internal view returns (uint256) { return changeDecimals( amount, UNIFORM_DECIMALS, IERC20Extended(token).decimals() ); } /// @dev Change decimal places of number from `oldDecimals` to `newDecimals`. function changeDecimals( uint256 amount, uint8 oldDecimals, uint8 newDecimals ) internal pure returns (uint256) { if (amount == 0) { return amount; } if (oldDecimals < newDecimals) { return amount * (10 ** (newDecimals - oldDecimals)); } else if (oldDecimals > newDecimals) { return amount / (10 ** (oldDecimals - newDecimals)); } return amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.16; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract ProxyContract is TransparentUpgradeableProxy { constructor (address _implementation, address _admin, bytes memory _data) TransparentUpgradeableProxy(_implementation, _admin, _data) { } function getAdmin() external view returns (address adm) { bytes32 slot = _ADMIN_SLOT; assembly { adm := sload(slot) } } function getImplementation() external view returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 5 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_param","type":"string"},{"internalType":"address","name":"_address","type":"address"}],"name":"AddressInvalid","type":"error"},{"inputs":[{"internalType":"string","name":"_param","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AmountInvalid","type":"error"},{"inputs":[{"internalType":"uint256","name":"_length1","type":"uint256"},{"internalType":"uint256","name":"_length2","type":"uint256"}],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"_maxDepositPerUser","type":"uint256"},{"internalType":"uint256","name":"_minDepositPerUser","type":"uint256"}],"name":"DepositAmountInvalid","type":"error"},{"inputs":[],"name":"DepositClosed","type":"error"},{"inputs":[],"name":"DepositStarted","type":"error"},{"inputs":[{"internalType":"uint256","name":"required","type":"uint256"},{"internalType":"uint256","name":"current","type":"uint256"}],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InsufficientFunds","type":"error"},{"inputs":[],"name":"InvalidData","type":"error"},{"inputs":[{"internalType":"uint256","name":"_length","type":"uint256"}],"name":"Max4TokensAllowed","type":"error"},{"inputs":[],"name":"MaxTokensMinted","type":"error"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"MaxTokensMintedForUser","type":"error"},{"inputs":[],"name":"MintingNotOpen","type":"error"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"NoAccess","type":"error"},{"inputs":[],"name":"NotERC20Template","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[{"internalType":"uint256","name":"_totalRaiseAmount","type":"uint256"},{"internalType":"uint256","name":"_maxDepositPerUser","type":"uint256"}],"name":"RaiseAmountInvalid","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_tokenIdTracker","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emitterAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc721DaoDetails","outputs":[{"internalType":"string","name":"DaoName","type":"string"},{"internalType":"string","name":"DaoSymbol","type":"string"},{"internalType":"uint256","name":"quorum","type":"uint256"},{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"uint256","name":"maxTokensPerUser","type":"uint256"},{"internalType":"bool","name":"isTransferable","type":"bool"},{"internalType":"bool","name":"isNftTotalSupplyUnlimited","type":"bool"},{"internalType":"bool","name":"isGovernanceActive","type":"bool"},{"internalType":"bool","name":"onlyAllowWhitelist","type":"bool"},{"internalType":"address","name":"ownerAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getERC721DAOdetails","outputs":[{"components":[{"internalType":"string","name":"DaoName","type":"string"},{"internalType":"string","name":"DaoSymbol","type":"string"},{"internalType":"uint256","name":"quorum","type":"uint256"},{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"uint256","name":"maxTokensPerUser","type":"uint256"},{"internalType":"bool","name":"isTransferable","type":"bool"},{"internalType":"bool","name":"isNftTotalSupplyUnlimited","type":"bool"},{"internalType":"bool","name":"isGovernanceActive","type":"bool"},{"internalType":"bool","name":"onlyAllowWhitelist","type":"bool"},{"internalType":"address","name":"ownerAddress","type":"address"}],"internalType":"struct Helper.ERC721DAOdetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_DaoName","type":"string"},{"internalType":"string","name":"_DaoSymbol","type":"string"},{"internalType":"address","name":"_factoryAddress","type":"address"},{"internalType":"address","name":"_emitterAddress","type":"address"},{"internalType":"uint256","name":"_quorum","type":"uint256"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"uint256","name":"_maxTokensPerUser","type":"uint256"},{"internalType":"bool","name":"_isTransferable","type":"bool"},{"internalType":"bool","name":"_isNftTotalSupplyUnlimited","type":"bool"},{"internalType":"bool","name":"_isGovernanceActive","type":"bool"},{"internalType":"bool","name":"_onlyAllowWhitelist","type":"bool"},{"internalType":"address","name":"_ownerAddress","type":"address"}],"name":"initializeERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_amountArray","type":"uint256[]"},{"internalType":"string[]","name":"_tokenURI","type":"string[]"},{"internalType":"address[]","name":"_userAddress","type":"address[]"}],"name":"mintGTToAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"string","name":"_tokenURI","type":"string"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"}],"name":"mintNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint96","name":"_royaltyFeesInBips","type":"uint96"}],"name":"setRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleOnlyAllowWhitelist","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isGovernanceActive","type":"bool"}],"name":"updateGovernanceActive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_quorum","type":"uint256"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"updateGovernanceSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxTokensPerUser","type":"uint256"}],"name":"updateMaxTokensPerUser","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"updateProposalAndExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isNftTransferable","type":"bool"}],"name":"updateTokenTransferability","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60808060405234610016576138d5908161001c8239f35b600080fdfe608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c90816301ffc9a7146126415750806306fdde0314612587578063081812fc14612568578063095ea7b3146123f0578063150b7a021461239957806323b872dd1461234f578063248a9ca3146123225780632a55205a146122695780632f2ff15d146121b457806336568abe146121215780633d8d927014611efc57806342842e0e14611ed45780634a7345b414611e5d5780635bfc74d114611d095780636352211e14611cd8578063668132c914611bd157806370a0823114611ba55780637aa4488f146113eb5780638728c87d146113b15780638f2fc60b146112a057806391d148541461125457806395d89b4114611184578063966dae0e1461115b57806398542ae21461113257806398bcede9146111145780639f090dce14610b01578063a217fddf14610ae5578063a22cb46514610a10578063a718b21a146106a1578063b3cda50d1461054b578063b88d4fde146104f8578063b8cd71f91461047b578063c87b56dd14610391578063d11eccd61461028e578063d547741f1461024b578063e6f002a8146102135763e985e9c50361000f5734610210576040366003190112610210576101d66126f8565b60406101e061270e565b9260018060a01b038093168152606a602052209116600052602052602060ff604060002054166040519015158152f35b80fd5b5080600319360112610210573033036102105760a35463ff00000060ff8260181c161560181b169063ff00000019161760a355604051f35b50346102105760403660031901126102105761028960043561026b61270e565b9080845260976020526102846001604086200154612af5565b612dfc565b604051f35b50346102105761029d36612751565b929130330361038d576001600160a01b0390811691821561035a571692831561032857928293823b156103235760648492836040519586948593632142170760e11b8552306004860152602485015260448401525af1801561031857610304575b50604051f35b61030d90612823565b6102105780386102fe565b6040513d84823e3d90fd5b505050fd5b6084846040519063045a4b3160e01b82526040600483015260036044830152625f746f60e81b60648301526024820152fd5b6084836040519063045a4b3160e01b825260406004830152600460448301526317db999d60e21b60648301526024820152fd5b8280fd5b50346102105760209081600319360112610210576040906004356103bc6103b782612ad8565b612a47565b8152609b835220906040519182600082546103d6816127b7565b9384845260019186838216918260001461045957505060011461041a575b50506104029250038361286c565b6104166040519282849384528301906126d3565b0390f35b85925060005281600020906000915b858310610441575050610402935082010138806103f4565b80548389018501528794508693909201918101610429565b925093505061040294915060ff191682840152151560051b82010138806103f4565b506020366003190112610210578061049161293a565b3033036104f557151560ff1960a3541660ff82161760a35560018060a01b03609d541690813b156104f157829160448392604051948593849263089a084f60e21b845230600485015260248401525af18015610318576103045750604051f35b5050fd5b50fd5b5034610210576080366003190112610210576105126126f8565b61051a61270e565b606435916001600160401b0383116105475761053d6102899336906004016129b2565b9160443591613797565b8380fd5b5034610210576040366003190112610210576105656126f8565b6024356001600160401b03811161038d576105849036906004016129b2565b609c54604051633b188ab560e01b81523060048201529192916001600160a01b03916101809081908390602490829087165afa801561069657839260e0928892610669575b5050015116330361063657811680156105fe57838080858582602083519301915af16105f36131ba565b501561021057604051f35b6084906040519063045a4b3160e01b825260406004830152600960448301526817d8dbdb9d1c9858dd60ba1b60648301526024820152fd5b60405162461bcd60e51b815260206004820152600b60248201526a4f6e6c7920476e6f73697360a81b6044820152606490fd5b6106889250803d1061068f575b610680818361286c565b810190612f1c565b38806105c9565b503d610676565b6040513d88823e3d90fd5b5034610210576060366003190112610210576106bb6126f8565b6001600160401b0391906024908135848111610547576106df9036906004016129b2565b91604435858111610a0c5736602382011215610a0c578060040135958611610a0c57818660051b820101368111610a0857609c546001600160a01b03929083169133839003610a0457610731866129d0565b60a254146109eb5760a3549860ff8a60181c1661086c575b505050609a54600181018091116108595760ff879882609a5560081c16156107e8575b610777915084613022565b61078384609a54613395565b80609d541690609a54823b156107e457869485916107ca60405198899788968795637cdb30bd60e01b875216600486015230908501526080604485015260848401906126d3565b90606483015203925af18015610318576103045750604051f35b8680fd5b6040518092633b188ab560e01b825230600483015281866101809586935afa90811561084e57602061082c928492610777968c92610831575b505001511015612fe1565b61076c565b6108479250803d1061068f57610680818361286c565b3880610821565b6040513d8a823e3d90fd5b634e487b7160e01b875260116004528387fd5b9360409993969195999897929851633b188ab560e01b81523060048201526101809081818d818c5afa9182156109e0579061010092918b926109c3575b50500151604051606084901b6001600160601b031916602080830191825260148352929b9298916108d981612836565b519020916108e688612949565b976108f4604051998a61286c565b88528c01888089015b8383106109b357505050509688975b86518910156109665761091f8988613359565b519081811015610958578a528752604089205b976000198114610945576001019761090c565b634e487b7160e01b8a5260116004528b8afd5b908a52875260408920610932565b9195509399959297989196500361097e578080610749565b606490600f856040519262461bcd60e51b845260048401528201526e24b731b7b93932b1ba10383937b7b360891b6044820152fd5b82358152918101918a91016108fd565b6109d99250803d1061068f57610680818361286c565b38806108a9565b6040513d8c823e3d90fd5b60405163357ea64b60e11b815284871660048201528590fd5b8780fd5b8580fd5b8480fd5b503461021057604036600319011261021057610a2a6126f8565b60243590811515809203610ae0576001600160a01b031690338214610a9f57338352606a6020526040832082600052602052604060002060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3604051f35b60405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606490fd5b600080fd5b5034610210578060031936011261021057602090604051908152f35b5034610210576060366003190112610210576001600160401b0390600435828111611110573660238201121561111057806004013592610b4084612949565b91610b4e604051938461286c565b848352602083016024819660051b83010191368311610a0857602401905b82821061110057505050602435818111610547573660238201121561054757806004013590610b9a82612949565b91610ba8604051938461286c565b80835260051b8101602401602083013682116107e45760248301905b8282106110d45750505050604435918211610547573660238301121561054757816004013590610bf382612949565b92610c01604051948561286c565b82845260208401906024829460051b82010190368211610a0457602401915b8183106110b457505050303303610a0c578051835180820361109657505083518351808203611096575050825185905b808210610d27575050609d546001600160a01b039690871693909150833b15610a085760405163b9d3970560e01b815230600482015260606024820152945160648601819052608486019290875b818110610d11575050506020906003198684030160448701525191828152019190855b818110610cf957868087818180890381838c5af1801561031857610ce55750604051f35b610cee90612823565b6102105780826102fe565b82518816845260209384019390920191600101610cc1565b8251855260209485019490920191600101610c9e565b91949596909392875b610d3a8689613359565b51811015610e9a57610d5e6001600160a01b03610d578888613359565b51166129d0565b60a25414610e6f57609a5490600182018211610e5b5760018201609a558960ff60a35460081c1615610dcb575b50600191610dae9083016001600160a01b03610da78a8a613359565b5116613022565b610dc5609a54610dbe898b613359565b5190613395565b01610d30565b609c54604051633b188ab560e01b81523060048201529193919061018090829060249082906001600160a01b03165afa918215610e5057610e25610dae9360019693879491610e2f575b5060208484019101511015612fe1565b9350505089610d8b565b610e4a91506101803d6101801161068f57610680818361286c565b38610e15565b6040513d86823e3d90fd5b634e487b7160e01b8a52601160045260248afd5b60246001600160a01b03610e838888613359565b5160405163357ea64b60e11b815291166004820152fd5b50609d54919796959394909392916001600160a01b0390811690610ebe8388613359565b51169060018060a01b03609c541691604051633b188ab560e01b815230600482015261018081602481875afa90811561108b578b9161106a575b5060c001516001600160a01b0316916024610180610f16878d613359565b519560405192838092633b188ab560e01b82523060048301525afa90811561103e578c91611049575b5060e001516001600160a01b0390811690602090610f5d888d613359565b51166024604051809481936317aa5fb760e11b835260048301525afa90811561103e578c91611004575b50813b1561100057918b60e4928195946040519788968795637c28875f60e01b87523060048801526024870152604486015283606486015242608486015260a4850152151560c48401525af1801561084e57908891610fec575b505060010190610c50565b610ff590612823565b6107e4578638610fe1565b8b80fd5b90506020813d602011611036575b8161101f6020938361286c565b810103126110005761103090612f0f565b38610f87565b3d9150611012565b6040513d8e823e3d90fd5b61106491506101803d6101801161068f57610680818361286c565b38610f3f565b61108591506101803d6101801161068f57610680818361286c565b38610ef8565b6040513d8d823e3d90fd5b6044925060405191631f4bb7c160e31b835260048301526024820152fd5b82356001600160a01b0381168103610ae057815260209283019201610c20565b81358681116110fc576020916110f18392602436918901016129b2565b815201910190610bc4565b8880fd5b8135815260209182019101610b6c565b5080fd5b50346102105780600319360112610210576020609a54604051908152f35b5034610210578060031936011261021057609d546040516001600160a01b039091168152602090f35b5034610210578060031936011261021057609c546040516001600160a01b039091168152602090f35b50346102105780600319360112610210576040516000906066546111a7816127b7565b80835260019180831690811561122c57506001146111e4575b610416836111d08187038261286c565b6040519182916020835260208301906126d3565b6066600090815260209450916000805160206137e08339815191525b828410611219575050508101909101906111d0816111c0565b8054858501870152928501928101611200565b61041695506111d093506020915091849260ff191682840152151560051b82010193506111c0565b503461021057604036600319011261021057604061127061270e565b9160043581526097602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b5034610210576040366003190112610210576112ba6126f8565b6024356001600160601b0381169182820361054757303303610547576127108311611359576001600160a01b03169182156113185760206040516112fd81612836565b848152015260a01b6001600160a01b03191617609855604051f35b60405162461bcd60e51b815260206004820152601960248201527822a921991c9c189d1034b73b30b634b2103932b1b2b4bb32b960391b6044820152606490fd5b60405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b6064820152608490fd5b506020366003190112610210576113c661293a565b3033036111105762ff000060a35491151560101b169062ff000019161760a355604051f35b503461021057610180366003190112610210576004356001600160401b0381116111105761141d903690600401612724565b90916024356001600160401b0381116111105761143e903690600401612724565b936001600160a01b03936044358581168103610ae057606435958087168703610ae05760e435918215158303610ae057610104358015158103610ae057610124358015158103610ae05761014435918215158303610ae05761016435938585168503610ae0578a5460ff8160081c16159c8d809e611b98575b8015611b81575b15611b255760ff1982166001178d5587918e611b14575b508160018060a01b0319931683609c541617609c551690609d541617609d5560405195611501876127f1565b61150c36898b61297b565b8752611519368e8c61297b565b6020880152608435604088015260a435606088015260c4356080880152151560a0870152151560c0860152151560e085015215156101008401521661012082015280518051906001600160401b038211611a2657819061157a609e546127b7565b601f8111611abb575b50602090601f8311600114611a45578892611a3a575b50508160011b916000199060031b1c191617609e555b60208101518051906001600160401b038211611a26576115d0609f546127b7565b601f81116119d9575b50602090601f831160011461195b5791806116a09796949261169896948a92611950575b50508160011b916000199060031b1c191617609f555b604081015160a055606081015160a155608081015160a25560a081015115159060a35461ff0060c0830151151560081b1662ff000060e0840151151560101b169160ff63ff000000610100860151151560181b1694610120600160201b600160c01b0391015160201b1695169060018060c01b031916171717171760a355369161297b565b94369161297b565b916116ba60ff835460081c166116b581612e9b565b612e9b565b83516001600160401b038111611870576116d56065546127b7565b601f81116118ff575b50602094601f821160011461188f579483949582939492611884575b50508160011b916000199060031b1c1916176065555b82516001600160401b0381116118705761172b6066546127b7565b601f811161181f575b506020601f82116001146117b0578394829394926117a5575b50508160011b916000199060031b1c1916176066555b61176c57604051f35b61ff001981541681557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1604051f35b01519050388061174d565b606684526000805160206137e083398151915290601f198316855b818110611807575095836001959697106117ee575b505050811b01606655611763565b015160001960f88460031b161c191690553880806117e0565b9192602060018192868b0151815501940192016117cb565b606684526000805160206137e0833981519152601f830160051c81019160208410611866575b601f0160051c01905b81811061185b5750611734565b84815560010161184e565b9091508190611845565b634e487b7160e01b83526041600452602483fd5b0151905038806116fa565b60658452601f1982169560008051602061382083398151915291855b8881106118e7575083600195969798106118ce575b505050811b01606555611710565b015160001960f88460031b161c191690553880806118c0565b919260206001819286850151815501940192016118ab565b60658452600080516020613820833981519152601f830160051c81019160208410611946575b601f0160051c01905b81811061193b57506116de565b84815560010161192e565b9091508190611925565b0151905038806115fd565b609f88526000805160206138408339815191529190885b601f19851681106119c15750926116a097969492600192611698979583601f198116106119a8575b505050811b01609f55611613565b015160001960f88460031b161c1916905538808061199a565b91926020600181928685015181550194019201611972565b609f8852600080516020613840833981519152601f840160051c810160208510611a1f575b601f830160051c82018110611a145750506115d9565b8981556001016119fe565b50806119fe565b634e487b7160e01b87526041600452602487fd5b015190503880611599565b609e895288935060008051602061386083398151915291905b601f1984168510611aa0576001945083601f19811610611a87575b505050811b01609e556115af565b015160001960f88460031b161c19169055388080611a79565b81810151835560209485019460019093019290910190611a5e565b609e8952909150600080516020613860833981519152601f840160051c810160208510611b0d575b90849392915b601f830160051c82018110611aff575050611583565b8a8155859450600101611ae9565b5080611ae3565b61ffff1916610101178d55386114d5565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156114be5750600160ff8316146114be565b50600160ff8316106114b7565b5034610210576020366003190112610210576020611bc9611bc46126f8565b6129d0565b604051908152f35b503461021057611be036612786565b9030330361038d578015611cbb578115611c5b57612710808211611ca0578211611c5b579081839260a0558160a15560018060a01b03609d541691823b156103235760648492836040519586948593630dff04f760e31b8552306004860152602485015260448401525af18015610318576103045750604051f35b604051631aac77f760e31b815280611c9c8460048301919060408352600a60408401526917dd1a1c995cda1bdb1960b21b6060840152602060808401930152565b0390fd5b604051631aac77f760e31b815280611c9c846004830161336d565b604051631aac77f760e31b8152908190611c9c906004830161336d565b5034610210576020366003190112610210576020611cf7600435612a8e565b6040516001600160a01b039091168152f35b5034610210578060031936011261021057604051600090609e54611d2c816127b7565b808352600191808316908115611e355750600114611ded575b611d8383611d558187038261286c565b611d5d61288f565b60a0549060a15460a25490611d9160a35493604051978897610140808a528901906126d3565b9087820360208901526126d3565b9360408601526060850152608084015260ff8116151560a084015260ff8160081c16151560c084015260ff8160101c16151560e084015260ff8160181c16151561010084015260018060a01b039060201c166101208301520390f35b609e600090815260209450916000805160206138608339815191525b828410611e2257505050810190910190611d5581611d45565b8054858501870152928501928101611e09565b611d839550611d5593506020915091849260ff191682840152151560051b8201019350611d45565b50602036600319011261021057806004353033036104f55760a2819055609d546001600160a01b031690813b156104f1578291611eb19160405194858094819363d1d3d4f160e01b8352306004840161279c565b03925af1801561031857611ec55750604051f35b611ece90612823565b386102fe565b503461021057610289611ee636612751565b9060405192611ef484612851565b858452613797565b503461021057806003193601126102105780610120604051611f1d816127f1565b60608152606060208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152015260405190611f62826127f1565b604051908181609e54611f74816127b7565b808452936001918083169081156120fd57506001146120b2575b5050611f9c9250038261286c565b8152611fa661288f565b602082015260a054604082015260a154606082015260a254608082015260a35460ff8116151560a083015260ff8160081c16151560c083015260ff8160101c16151560e083015260ff8160181c16151561010083015260018060a01b039060201c16610120820152604051809160208252612048612032825161014060208601526101608501906126d3565b6020830151848203601f190160408601526126d3565b906040810151606084015260608101516080840152608081015160a084015260a0810151151560c084015260c0810151151560e084015260e08101511515610100840152610100810151151561012084015261012060018060a01b03910151166101408301520390f35b609e815291506000805160206138608339815191525b8483106120e25750611f9c93505081016020013880611f8e565b819350908160209254838589010152019101909184926120c8565b91505060209250611f9c94915060ff191682840152151560051b8201013880611f8e565b50346102105760403660031901126102105761213b61270e565b336001600160a01b038216036121575761028990600435612dfc565b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b5034610210576040366003190112610210576004356121d161270e565b81835260976020526121e96001604085200154612af5565b8183526097602052604083209060018060a01b03169081845260205260ff60408420541615612219575b82604051f35b81835260976020526040832081845260205260408320600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d84604051a43880612213565b50346102105761227836612786565b9082526099602052604082206040519061229182612836565b546001600160a01b0380821680845260a09290921c6020840152919015612300575b60208101516001600160601b0316938315156000198590048611166122ec5750906104169151166127106040519485940204908361279c565b634e487b7160e01b81526011600452602490fd5b5060405161230d81612836565b609854828116825260a01c60208201526122b3565b50346102105760203660031901126102105760016040602092600435815260978452200154604051908152f35b50346102105761235e36612751565b90612368816129d0565b60a25410610547576102899261238661238184336135d1565b61352c565b61239460ff60a3541661358e565b613699565b5034610210576080366003190112610210576123b36126f8565b506123bc61270e565b506064356001600160401b038111611110576123dc903690600401612724565b5050604051630a85bd0160e11b8152602090f35b50346102105760403660031901126102105761240a6126f8565b6024356001600160a01b03808061242084612a8e565b16931692808414612519578033149081156124f8575b501561248d5781845260696020526040842080546001600160a01b0319168417905561246182612a8e565b1691604051927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258585a4f35b60405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608490fd5b90508452606a6020526040842033855260205260ff60408520541638612436565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b5034610210576020366003190112610210576020611cf7600435612ab1565b5034610210578060031936011261021057604051816065546125a8816127b7565b8084529060019081811690811561261957506001146125d2575b610416846111d08188038261286c565b60658352602094506000805160206138208339815191525b8284106126065750505081610416936111d092820101936125c2565b80548585018701529285019281016125ea565b61041696506111d09450602092508593915060ff191682840152151560051b820101936125c2565b9050346111105760203660031901126111105760043563ffffffff60e01b811680910361038d576020925063152a902d60e11b8114908115612685575b5015158152f35b637965db0b60e01b81149150811561269f575b503861267e565b6301ffc9a760e01b14905038612698565b60005b8381106126c35750506000910152565b81810151838201526020016126b3565b906020916126ec815180928185528580860191016126b0565b601f01601f1916010190565b600435906001600160a01b0382168203610ae057565b602435906001600160a01b0382168203610ae057565b9181601f84011215610ae0578235916001600160401b038311610ae05760208381860195010111610ae057565b6060906003190112610ae0576001600160a01b03906004358281168103610ae057916024359081168103610ae0579060443590565b6040906003190112610ae0576004359060243590565b6001600160a01b039091168152602081019190915260400190565b90600182811c921680156127e7575b60208310146127d157565b634e487b7160e01b600052602260045260246000fd5b91607f16916127c6565b61014081019081106001600160401b0382111761280d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161280d57604052565b604081019081106001600160401b0382111761280d57604052565b602081019081106001600160401b0382111761280d57604052565b601f909101601f19168101906001600160401b0382119082101761280d57604052565b60405190600082609f54916128a3836127b7565b80835260019380851690811561291957506001146128cb575b506128c99250038361286c565b565b609f600090815260008051602061384083398151915294602093509091905b8183106129015750506128c99350820101386128bc565b855488840185015294850194879450918301916128ea565b90506128c994506020925060ff191682840152151560051b820101386128bc565b600435908115158203610ae057565b6001600160401b03811161280d5760051b60200190565b6001600160401b03811161280d57601f01601f191660200190565b92919261298782612960565b91612995604051938461286c565b829481845281830111610ae0578281602093846000960137010152565b9080601f83011215610ae0578160206129cd9335910161297b565b90565b6001600160a01b031680156129f057600052606860205260406000205490565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608490fd5b15612a4e57565b60405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606490fd5b6000908152606760205260409020546001600160a01b03166129cd811515612a47565b612abd6103b782612ad8565b6000908152606960205260409020546001600160a01b031690565b6000908152606760205260409020546001600160a01b0316151590565b60009080825260209060978252604092838120338252835260ff848220541615612b1f5750505050565b8351916001600160401b0390336060850183811186821017612de8578752602a85528585019187368437855115612dd45760308353855191600192831015612dc0576078602188015360295b838111612d565750612d265790875193608085019085821090821117612d1257885260428452868401946060368737845115612cfe57603086538451821015612cfe5790607860218601536041915b818311612c9057505050612c6057611c9c938693612c4493612c35604894612c0c9a519a8b9576020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8c88015251809260378801906126b0565b8401917001034b99036b4b9b9b4b733903937b6329607d1b6037840152518093868401906126b0565b0103602881018752018561286c565b5192839262461bcd60e51b8452600484015260248301906126d3565b60648587519062461bcd60e51b825280600483015260248201526000805160206138008339815191526044820152fd5b909192600f81166010811015612cea576f181899199a1a9b1b9c1cb0b131b232b360811b901a612cc08588612e74565b5360041c928015612cd657600019019190612bba565b634e487b7160e01b82526011600452602482fd5b634e487b7160e01b83526032600452602483fd5b634e487b7160e01b81526032600452602490fd5b634e487b7160e01b86526041600452602486fd5b60648789519062461bcd60e51b825280600483015260248201526000805160206138008339815191526044820152fd5b90600f81166010811015612dac576f181899199a1a9b1b9c1cb0b131b232b360811b901a612d84838a612e74565b5360041c908015612d985760001901612b6b565b634e487b7160e01b87526011600452602487fd5b634e487b7160e01b88526032600452602488fd5b634e487b7160e01b86526032600452602486fd5b634e487b7160e01b85526032600452602485fd5b634e487b7160e01b85526041600452602485fd5b906000918083526097602052604083209160018060a01b03169182845260205260ff604084205416612e2d57505050565b8083526097602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b3393604051a4565b908151811015612e85570160200190565b634e487b7160e01b600052603260045260246000fd5b15612ea257565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b51906001600160a01b0382168203610ae057565b51908115158203610ae057565b80916101809283910312610ae0576040519182016001600160401b0381118382101761280d57604052805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a0830152612f8760c08201612efb565b60c0830152612f9860e08201612efb565b60e08301526101008082015190830152610120612fb6818301612f0f565b90830152610140612fc8818301612f0f565b90830152612fda610160809201612f0f565b9082015290565b15612fe857565b60405162461bcd60e51b815260206004820152601260248201527113585e081cdd5c1c1b1e481c995858da195960721b6044820152606490fd5b60405161302e81612851565b6000808252926001600160a01b0383169283156130b857816130b3946128c99661306061305a84612ad8565b1561316f565b61306c61305a84612ad8565b818152606860205260408120600181540190558281526067602052604081208260018060a01b031982541617905560008051602061388083398151915281604051a46131ea565b61314f565b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b1561315657565b60405162461bcd60e51b815280611c9c600482016130fc565b1561317657565b60405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b6044820152606490fd5b3d156131e5573d906131cb82612960565b916131d9604051938461286c565b82523d6000602084013e565b606090565b9091600091803b156132d5576132356020918493604051948580948193630a85bd0160e11b9a8b845233600485015284602485015260448401526080606484015260848301906126d3565b03926001600160a01b03165af19082908261328d575b505061327f576132596131ba565b8051908161327a5760405162461bcd60e51b815280611c9c600482016130fc565b602001fd5b6001600160e01b0319161490565b909192506020813d82116132cd575b816132a96020938361286c565b810103126111105751906001600160e01b031982168203610210575090388061324b565b3d915061329c565b50505050600190565b91926000929190813b1561334f576020916133349185604051958680958194630a85bd0160e11b9b8c845233600485015260018060a01b03809516602485015260448401526080606484015260848301906126d3565b0393165af19082908261328d57505061327f576132596131ba565b5050505050600190565b8051821015612e855760209160051b010190565b91906040835260076040840152665f71756f72756d60c81b6060840152602060808401930152565b9190916133a181612ad8565b156134d0576000908152609b602090815260408220845191949092906001600160401b0383116134bc576133d584546127b7565b601f8111613479575b508591601f84116001146134185783949596509261340d575b50508160011b916000199060031b1c1916179055565b0151905038806133f7565b9190601f1984169685845280842093905b88821061346157505083600195969710613448575b505050811b019055565b015160001960f88460031b161c1916905538808061343e565b80600185968294968601518155019501930190613429565b848352868320601f850160051c8101918886106134b2575b601f0160051c01905b8181106134a757506133de565b83815560010161349a565b9091508190613491565b634e487b7160e01b82526041600452602482fd5b60405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608490fd5b1561353357565b60405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608490fd5b1561359557565b60405162461bcd60e51b81526020600482015260146024820152734e4654204e6f6e205472616e7366657261626c6560601b6044820152606490fd5b906001600160a01b0380806135e584612a8e565b16931691838314938415613618575b508315613602575b50505090565b61360e91929350612ab1565b16143880806135fc565b909350600052606a60205260406000208260005260205260ff6040600020541692386135f4565b1561364657565b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b906136c1916136a784612a8e565b6001600160a01b039391841692849290918316841461363f565b1691821561374657816136de916136d786612a8e565b161461363f565b600080516020613880833981519152600084815260696020526040812060018060a01b031990818154169055838252606860205260408220600019815401905584825260408220600181540190558582526067602052846040832091825416179055604051a4565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b919290926137a4846129d0565b60a25410610ae0576128c9936130b3936137c161238184336135d1565b6137cf60ff60a3541661358e565b6137da838383613699565b6132de56fe46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e94354537472696e67733a20686578206c656e67746820696e73756666696369656e748ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c70bc14066c33013fe88f66e314e4cf150b0b2d4d6451a1a51dbbd1c27cd11de28cfe2a20ff701a1f3e14f63bd70d6c6bc6fba8172ec6d5a505cdab3927c0a9de6ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220bcd7ed56c0c28d8d514a65196a6a97abd0c7b5c3016aaa10f1c60b68dab6b97f64736f6c63430008100033
Deployed Bytecode
0x608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c90816301ffc9a7146126415750806306fdde0314612587578063081812fc14612568578063095ea7b3146123f0578063150b7a021461239957806323b872dd1461234f578063248a9ca3146123225780632a55205a146122695780632f2ff15d146121b457806336568abe146121215780633d8d927014611efc57806342842e0e14611ed45780634a7345b414611e5d5780635bfc74d114611d095780636352211e14611cd8578063668132c914611bd157806370a0823114611ba55780637aa4488f146113eb5780638728c87d146113b15780638f2fc60b146112a057806391d148541461125457806395d89b4114611184578063966dae0e1461115b57806398542ae21461113257806398bcede9146111145780639f090dce14610b01578063a217fddf14610ae5578063a22cb46514610a10578063a718b21a146106a1578063b3cda50d1461054b578063b88d4fde146104f8578063b8cd71f91461047b578063c87b56dd14610391578063d11eccd61461028e578063d547741f1461024b578063e6f002a8146102135763e985e9c50361000f5734610210576040366003190112610210576101d66126f8565b60406101e061270e565b9260018060a01b038093168152606a602052209116600052602052602060ff604060002054166040519015158152f35b80fd5b5080600319360112610210573033036102105760a35463ff00000060ff8260181c161560181b169063ff00000019161760a355604051f35b50346102105760403660031901126102105761028960043561026b61270e565b9080845260976020526102846001604086200154612af5565b612dfc565b604051f35b50346102105761029d36612751565b929130330361038d576001600160a01b0390811691821561035a571692831561032857928293823b156103235760648492836040519586948593632142170760e11b8552306004860152602485015260448401525af1801561031857610304575b50604051f35b61030d90612823565b6102105780386102fe565b6040513d84823e3d90fd5b505050fd5b6084846040519063045a4b3160e01b82526040600483015260036044830152625f746f60e81b60648301526024820152fd5b6084836040519063045a4b3160e01b825260406004830152600460448301526317db999d60e21b60648301526024820152fd5b8280fd5b50346102105760209081600319360112610210576040906004356103bc6103b782612ad8565b612a47565b8152609b835220906040519182600082546103d6816127b7565b9384845260019186838216918260001461045957505060011461041a575b50506104029250038361286c565b6104166040519282849384528301906126d3565b0390f35b85925060005281600020906000915b858310610441575050610402935082010138806103f4565b80548389018501528794508693909201918101610429565b925093505061040294915060ff191682840152151560051b82010138806103f4565b506020366003190112610210578061049161293a565b3033036104f557151560ff1960a3541660ff82161760a35560018060a01b03609d541690813b156104f157829160448392604051948593849263089a084f60e21b845230600485015260248401525af18015610318576103045750604051f35b5050fd5b50fd5b5034610210576080366003190112610210576105126126f8565b61051a61270e565b606435916001600160401b0383116105475761053d6102899336906004016129b2565b9160443591613797565b8380fd5b5034610210576040366003190112610210576105656126f8565b6024356001600160401b03811161038d576105849036906004016129b2565b609c54604051633b188ab560e01b81523060048201529192916001600160a01b03916101809081908390602490829087165afa801561069657839260e0928892610669575b5050015116330361063657811680156105fe57838080858582602083519301915af16105f36131ba565b501561021057604051f35b6084906040519063045a4b3160e01b825260406004830152600960448301526817d8dbdb9d1c9858dd60ba1b60648301526024820152fd5b60405162461bcd60e51b815260206004820152600b60248201526a4f6e6c7920476e6f73697360a81b6044820152606490fd5b6106889250803d1061068f575b610680818361286c565b810190612f1c565b38806105c9565b503d610676565b6040513d88823e3d90fd5b5034610210576060366003190112610210576106bb6126f8565b6001600160401b0391906024908135848111610547576106df9036906004016129b2565b91604435858111610a0c5736602382011215610a0c578060040135958611610a0c57818660051b820101368111610a0857609c546001600160a01b03929083169133839003610a0457610731866129d0565b60a254146109eb5760a3549860ff8a60181c1661086c575b505050609a54600181018091116108595760ff879882609a5560081c16156107e8575b610777915084613022565b61078384609a54613395565b80609d541690609a54823b156107e457869485916107ca60405198899788968795637cdb30bd60e01b875216600486015230908501526080604485015260848401906126d3565b90606483015203925af18015610318576103045750604051f35b8680fd5b6040518092633b188ab560e01b825230600483015281866101809586935afa90811561084e57602061082c928492610777968c92610831575b505001511015612fe1565b61076c565b6108479250803d1061068f57610680818361286c565b3880610821565b6040513d8a823e3d90fd5b634e487b7160e01b875260116004528387fd5b9360409993969195999897929851633b188ab560e01b81523060048201526101809081818d818c5afa9182156109e0579061010092918b926109c3575b50500151604051606084901b6001600160601b031916602080830191825260148352929b9298916108d981612836565b519020916108e688612949565b976108f4604051998a61286c565b88528c01888089015b8383106109b357505050509688975b86518910156109665761091f8988613359565b519081811015610958578a528752604089205b976000198114610945576001019761090c565b634e487b7160e01b8a5260116004528b8afd5b908a52875260408920610932565b9195509399959297989196500361097e578080610749565b606490600f856040519262461bcd60e51b845260048401528201526e24b731b7b93932b1ba10383937b7b360891b6044820152fd5b82358152918101918a91016108fd565b6109d99250803d1061068f57610680818361286c565b38806108a9565b6040513d8c823e3d90fd5b60405163357ea64b60e11b815284871660048201528590fd5b8780fd5b8580fd5b8480fd5b503461021057604036600319011261021057610a2a6126f8565b60243590811515809203610ae0576001600160a01b031690338214610a9f57338352606a6020526040832082600052602052604060002060ff1981541660ff83161790556040519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3604051f35b60405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606490fd5b600080fd5b5034610210578060031936011261021057602090604051908152f35b5034610210576060366003190112610210576001600160401b0390600435828111611110573660238201121561111057806004013592610b4084612949565b91610b4e604051938461286c565b848352602083016024819660051b83010191368311610a0857602401905b82821061110057505050602435818111610547573660238201121561054757806004013590610b9a82612949565b91610ba8604051938461286c565b80835260051b8101602401602083013682116107e45760248301905b8282106110d45750505050604435918211610547573660238301121561054757816004013590610bf382612949565b92610c01604051948561286c565b82845260208401906024829460051b82010190368211610a0457602401915b8183106110b457505050303303610a0c578051835180820361109657505083518351808203611096575050825185905b808210610d27575050609d546001600160a01b039690871693909150833b15610a085760405163b9d3970560e01b815230600482015260606024820152945160648601819052608486019290875b818110610d11575050506020906003198684030160448701525191828152019190855b818110610cf957868087818180890381838c5af1801561031857610ce55750604051f35b610cee90612823565b6102105780826102fe565b82518816845260209384019390920191600101610cc1565b8251855260209485019490920191600101610c9e565b91949596909392875b610d3a8689613359565b51811015610e9a57610d5e6001600160a01b03610d578888613359565b51166129d0565b60a25414610e6f57609a5490600182018211610e5b5760018201609a558960ff60a35460081c1615610dcb575b50600191610dae9083016001600160a01b03610da78a8a613359565b5116613022565b610dc5609a54610dbe898b613359565b5190613395565b01610d30565b609c54604051633b188ab560e01b81523060048201529193919061018090829060249082906001600160a01b03165afa918215610e5057610e25610dae9360019693879491610e2f575b5060208484019101511015612fe1565b9350505089610d8b565b610e4a91506101803d6101801161068f57610680818361286c565b38610e15565b6040513d86823e3d90fd5b634e487b7160e01b8a52601160045260248afd5b60246001600160a01b03610e838888613359565b5160405163357ea64b60e11b815291166004820152fd5b50609d54919796959394909392916001600160a01b0390811690610ebe8388613359565b51169060018060a01b03609c541691604051633b188ab560e01b815230600482015261018081602481875afa90811561108b578b9161106a575b5060c001516001600160a01b0316916024610180610f16878d613359565b519560405192838092633b188ab560e01b82523060048301525afa90811561103e578c91611049575b5060e001516001600160a01b0390811690602090610f5d888d613359565b51166024604051809481936317aa5fb760e11b835260048301525afa90811561103e578c91611004575b50813b1561100057918b60e4928195946040519788968795637c28875f60e01b87523060048801526024870152604486015283606486015242608486015260a4850152151560c48401525af1801561084e57908891610fec575b505060010190610c50565b610ff590612823565b6107e4578638610fe1565b8b80fd5b90506020813d602011611036575b8161101f6020938361286c565b810103126110005761103090612f0f565b38610f87565b3d9150611012565b6040513d8e823e3d90fd5b61106491506101803d6101801161068f57610680818361286c565b38610f3f565b61108591506101803d6101801161068f57610680818361286c565b38610ef8565b6040513d8d823e3d90fd5b6044925060405191631f4bb7c160e31b835260048301526024820152fd5b82356001600160a01b0381168103610ae057815260209283019201610c20565b81358681116110fc576020916110f18392602436918901016129b2565b815201910190610bc4565b8880fd5b8135815260209182019101610b6c565b5080fd5b50346102105780600319360112610210576020609a54604051908152f35b5034610210578060031936011261021057609d546040516001600160a01b039091168152602090f35b5034610210578060031936011261021057609c546040516001600160a01b039091168152602090f35b50346102105780600319360112610210576040516000906066546111a7816127b7565b80835260019180831690811561122c57506001146111e4575b610416836111d08187038261286c565b6040519182916020835260208301906126d3565b6066600090815260209450916000805160206137e08339815191525b828410611219575050508101909101906111d0816111c0565b8054858501870152928501928101611200565b61041695506111d093506020915091849260ff191682840152151560051b82010193506111c0565b503461021057604036600319011261021057604061127061270e565b9160043581526097602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b5034610210576040366003190112610210576112ba6126f8565b6024356001600160601b0381169182820361054757303303610547576127108311611359576001600160a01b03169182156113185760206040516112fd81612836565b848152015260a01b6001600160a01b03191617609855604051f35b60405162461bcd60e51b815260206004820152601960248201527822a921991c9c189d1034b73b30b634b2103932b1b2b4bb32b960391b6044820152606490fd5b60405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b6064820152608490fd5b506020366003190112610210576113c661293a565b3033036111105762ff000060a35491151560101b169062ff000019161760a355604051f35b503461021057610180366003190112610210576004356001600160401b0381116111105761141d903690600401612724565b90916024356001600160401b0381116111105761143e903690600401612724565b936001600160a01b03936044358581168103610ae057606435958087168703610ae05760e435918215158303610ae057610104358015158103610ae057610124358015158103610ae05761014435918215158303610ae05761016435938585168503610ae0578a5460ff8160081c16159c8d809e611b98575b8015611b81575b15611b255760ff1982166001178d5587918e611b14575b508160018060a01b0319931683609c541617609c551690609d541617609d5560405195611501876127f1565b61150c36898b61297b565b8752611519368e8c61297b565b6020880152608435604088015260a435606088015260c4356080880152151560a0870152151560c0860152151560e085015215156101008401521661012082015280518051906001600160401b038211611a2657819061157a609e546127b7565b601f8111611abb575b50602090601f8311600114611a45578892611a3a575b50508160011b916000199060031b1c191617609e555b60208101518051906001600160401b038211611a26576115d0609f546127b7565b601f81116119d9575b50602090601f831160011461195b5791806116a09796949261169896948a92611950575b50508160011b916000199060031b1c191617609f555b604081015160a055606081015160a155608081015160a25560a081015115159060a35461ff0060c0830151151560081b1662ff000060e0840151151560101b169160ff63ff000000610100860151151560181b1694610120600160201b600160c01b0391015160201b1695169060018060c01b031916171717171760a355369161297b565b94369161297b565b916116ba60ff835460081c166116b581612e9b565b612e9b565b83516001600160401b038111611870576116d56065546127b7565b601f81116118ff575b50602094601f821160011461188f579483949582939492611884575b50508160011b916000199060031b1c1916176065555b82516001600160401b0381116118705761172b6066546127b7565b601f811161181f575b506020601f82116001146117b0578394829394926117a5575b50508160011b916000199060031b1c1916176066555b61176c57604051f35b61ff001981541681557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1604051f35b01519050388061174d565b606684526000805160206137e083398151915290601f198316855b818110611807575095836001959697106117ee575b505050811b01606655611763565b015160001960f88460031b161c191690553880806117e0565b9192602060018192868b0151815501940192016117cb565b606684526000805160206137e0833981519152601f830160051c81019160208410611866575b601f0160051c01905b81811061185b5750611734565b84815560010161184e565b9091508190611845565b634e487b7160e01b83526041600452602483fd5b0151905038806116fa565b60658452601f1982169560008051602061382083398151915291855b8881106118e7575083600195969798106118ce575b505050811b01606555611710565b015160001960f88460031b161c191690553880806118c0565b919260206001819286850151815501940192016118ab565b60658452600080516020613820833981519152601f830160051c81019160208410611946575b601f0160051c01905b81811061193b57506116de565b84815560010161192e565b9091508190611925565b0151905038806115fd565b609f88526000805160206138408339815191529190885b601f19851681106119c15750926116a097969492600192611698979583601f198116106119a8575b505050811b01609f55611613565b015160001960f88460031b161c1916905538808061199a565b91926020600181928685015181550194019201611972565b609f8852600080516020613840833981519152601f840160051c810160208510611a1f575b601f830160051c82018110611a145750506115d9565b8981556001016119fe565b50806119fe565b634e487b7160e01b87526041600452602487fd5b015190503880611599565b609e895288935060008051602061386083398151915291905b601f1984168510611aa0576001945083601f19811610611a87575b505050811b01609e556115af565b015160001960f88460031b161c19169055388080611a79565b81810151835560209485019460019093019290910190611a5e565b609e8952909150600080516020613860833981519152601f840160051c810160208510611b0d575b90849392915b601f830160051c82018110611aff575050611583565b8a8155859450600101611ae9565b5080611ae3565b61ffff1916610101178d55386114d5565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156114be5750600160ff8316146114be565b50600160ff8316106114b7565b5034610210576020366003190112610210576020611bc9611bc46126f8565b6129d0565b604051908152f35b503461021057611be036612786565b9030330361038d578015611cbb578115611c5b57612710808211611ca0578211611c5b579081839260a0558160a15560018060a01b03609d541691823b156103235760648492836040519586948593630dff04f760e31b8552306004860152602485015260448401525af18015610318576103045750604051f35b604051631aac77f760e31b815280611c9c8460048301919060408352600a60408401526917dd1a1c995cda1bdb1960b21b6060840152602060808401930152565b0390fd5b604051631aac77f760e31b815280611c9c846004830161336d565b604051631aac77f760e31b8152908190611c9c906004830161336d565b5034610210576020366003190112610210576020611cf7600435612a8e565b6040516001600160a01b039091168152f35b5034610210578060031936011261021057604051600090609e54611d2c816127b7565b808352600191808316908115611e355750600114611ded575b611d8383611d558187038261286c565b611d5d61288f565b60a0549060a15460a25490611d9160a35493604051978897610140808a528901906126d3565b9087820360208901526126d3565b9360408601526060850152608084015260ff8116151560a084015260ff8160081c16151560c084015260ff8160101c16151560e084015260ff8160181c16151561010084015260018060a01b039060201c166101208301520390f35b609e600090815260209450916000805160206138608339815191525b828410611e2257505050810190910190611d5581611d45565b8054858501870152928501928101611e09565b611d839550611d5593506020915091849260ff191682840152151560051b8201019350611d45565b50602036600319011261021057806004353033036104f55760a2819055609d546001600160a01b031690813b156104f1578291611eb19160405194858094819363d1d3d4f160e01b8352306004840161279c565b03925af1801561031857611ec55750604051f35b611ece90612823565b386102fe565b503461021057610289611ee636612751565b9060405192611ef484612851565b858452613797565b503461021057806003193601126102105780610120604051611f1d816127f1565b60608152606060208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152015260405190611f62826127f1565b604051908181609e54611f74816127b7565b808452936001918083169081156120fd57506001146120b2575b5050611f9c9250038261286c565b8152611fa661288f565b602082015260a054604082015260a154606082015260a254608082015260a35460ff8116151560a083015260ff8160081c16151560c083015260ff8160101c16151560e083015260ff8160181c16151561010083015260018060a01b039060201c16610120820152604051809160208252612048612032825161014060208601526101608501906126d3565b6020830151848203601f190160408601526126d3565b906040810151606084015260608101516080840152608081015160a084015260a0810151151560c084015260c0810151151560e084015260e08101511515610100840152610100810151151561012084015261012060018060a01b03910151166101408301520390f35b609e815291506000805160206138608339815191525b8483106120e25750611f9c93505081016020013880611f8e565b819350908160209254838589010152019101909184926120c8565b91505060209250611f9c94915060ff191682840152151560051b8201013880611f8e565b50346102105760403660031901126102105761213b61270e565b336001600160a01b038216036121575761028990600435612dfc565b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b5034610210576040366003190112610210576004356121d161270e565b81835260976020526121e96001604085200154612af5565b8183526097602052604083209060018060a01b03169081845260205260ff60408420541615612219575b82604051f35b81835260976020526040832081845260205260408320600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d84604051a43880612213565b50346102105761227836612786565b9082526099602052604082206040519061229182612836565b546001600160a01b0380821680845260a09290921c6020840152919015612300575b60208101516001600160601b0316938315156000198590048611166122ec5750906104169151166127106040519485940204908361279c565b634e487b7160e01b81526011600452602490fd5b5060405161230d81612836565b609854828116825260a01c60208201526122b3565b50346102105760203660031901126102105760016040602092600435815260978452200154604051908152f35b50346102105761235e36612751565b90612368816129d0565b60a25410610547576102899261238661238184336135d1565b61352c565b61239460ff60a3541661358e565b613699565b5034610210576080366003190112610210576123b36126f8565b506123bc61270e565b506064356001600160401b038111611110576123dc903690600401612724565b5050604051630a85bd0160e11b8152602090f35b50346102105760403660031901126102105761240a6126f8565b6024356001600160a01b03808061242084612a8e565b16931692808414612519578033149081156124f8575b501561248d5781845260696020526040842080546001600160a01b0319168417905561246182612a8e565b1691604051927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258585a4f35b60405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608490fd5b90508452606a6020526040842033855260205260ff60408520541638612436565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b5034610210576020366003190112610210576020611cf7600435612ab1565b5034610210578060031936011261021057604051816065546125a8816127b7565b8084529060019081811690811561261957506001146125d2575b610416846111d08188038261286c565b60658352602094506000805160206138208339815191525b8284106126065750505081610416936111d092820101936125c2565b80548585018701529285019281016125ea565b61041696506111d09450602092508593915060ff191682840152151560051b820101936125c2565b9050346111105760203660031901126111105760043563ffffffff60e01b811680910361038d576020925063152a902d60e11b8114908115612685575b5015158152f35b637965db0b60e01b81149150811561269f575b503861267e565b6301ffc9a760e01b14905038612698565b60005b8381106126c35750506000910152565b81810151838201526020016126b3565b906020916126ec815180928185528580860191016126b0565b601f01601f1916010190565b600435906001600160a01b0382168203610ae057565b602435906001600160a01b0382168203610ae057565b9181601f84011215610ae0578235916001600160401b038311610ae05760208381860195010111610ae057565b6060906003190112610ae0576001600160a01b03906004358281168103610ae057916024359081168103610ae0579060443590565b6040906003190112610ae0576004359060243590565b6001600160a01b039091168152602081019190915260400190565b90600182811c921680156127e7575b60208310146127d157565b634e487b7160e01b600052602260045260246000fd5b91607f16916127c6565b61014081019081106001600160401b0382111761280d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161280d57604052565b604081019081106001600160401b0382111761280d57604052565b602081019081106001600160401b0382111761280d57604052565b601f909101601f19168101906001600160401b0382119082101761280d57604052565b60405190600082609f54916128a3836127b7565b80835260019380851690811561291957506001146128cb575b506128c99250038361286c565b565b609f600090815260008051602061384083398151915294602093509091905b8183106129015750506128c99350820101386128bc565b855488840185015294850194879450918301916128ea565b90506128c994506020925060ff191682840152151560051b820101386128bc565b600435908115158203610ae057565b6001600160401b03811161280d5760051b60200190565b6001600160401b03811161280d57601f01601f191660200190565b92919261298782612960565b91612995604051938461286c565b829481845281830111610ae0578281602093846000960137010152565b9080601f83011215610ae0578160206129cd9335910161297b565b90565b6001600160a01b031680156129f057600052606860205260406000205490565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608490fd5b15612a4e57565b60405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606490fd5b6000908152606760205260409020546001600160a01b03166129cd811515612a47565b612abd6103b782612ad8565b6000908152606960205260409020546001600160a01b031690565b6000908152606760205260409020546001600160a01b0316151590565b60009080825260209060978252604092838120338252835260ff848220541615612b1f5750505050565b8351916001600160401b0390336060850183811186821017612de8578752602a85528585019187368437855115612dd45760308353855191600192831015612dc0576078602188015360295b838111612d565750612d265790875193608085019085821090821117612d1257885260428452868401946060368737845115612cfe57603086538451821015612cfe5790607860218601536041915b818311612c9057505050612c6057611c9c938693612c4493612c35604894612c0c9a519a8b9576020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8c88015251809260378801906126b0565b8401917001034b99036b4b9b9b4b733903937b6329607d1b6037840152518093868401906126b0565b0103602881018752018561286c565b5192839262461bcd60e51b8452600484015260248301906126d3565b60648587519062461bcd60e51b825280600483015260248201526000805160206138008339815191526044820152fd5b909192600f81166010811015612cea576f181899199a1a9b1b9c1cb0b131b232b360811b901a612cc08588612e74565b5360041c928015612cd657600019019190612bba565b634e487b7160e01b82526011600452602482fd5b634e487b7160e01b83526032600452602483fd5b634e487b7160e01b81526032600452602490fd5b634e487b7160e01b86526041600452602486fd5b60648789519062461bcd60e51b825280600483015260248201526000805160206138008339815191526044820152fd5b90600f81166010811015612dac576f181899199a1a9b1b9c1cb0b131b232b360811b901a612d84838a612e74565b5360041c908015612d985760001901612b6b565b634e487b7160e01b87526011600452602487fd5b634e487b7160e01b88526032600452602488fd5b634e487b7160e01b86526032600452602486fd5b634e487b7160e01b85526032600452602485fd5b634e487b7160e01b85526041600452602485fd5b906000918083526097602052604083209160018060a01b03169182845260205260ff604084205416612e2d57505050565b8083526097602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b3393604051a4565b908151811015612e85570160200190565b634e487b7160e01b600052603260045260246000fd5b15612ea257565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b51906001600160a01b0382168203610ae057565b51908115158203610ae057565b80916101809283910312610ae0576040519182016001600160401b0381118382101761280d57604052805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a0830152612f8760c08201612efb565b60c0830152612f9860e08201612efb565b60e08301526101008082015190830152610120612fb6818301612f0f565b90830152610140612fc8818301612f0f565b90830152612fda610160809201612f0f565b9082015290565b15612fe857565b60405162461bcd60e51b815260206004820152601260248201527113585e081cdd5c1c1b1e481c995858da195960721b6044820152606490fd5b60405161302e81612851565b6000808252926001600160a01b0383169283156130b857816130b3946128c99661306061305a84612ad8565b1561316f565b61306c61305a84612ad8565b818152606860205260408120600181540190558281526067602052604081208260018060a01b031982541617905560008051602061388083398151915281604051a46131ea565b61314f565b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b1561315657565b60405162461bcd60e51b815280611c9c600482016130fc565b1561317657565b60405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b6044820152606490fd5b3d156131e5573d906131cb82612960565b916131d9604051938461286c565b82523d6000602084013e565b606090565b9091600091803b156132d5576132356020918493604051948580948193630a85bd0160e11b9a8b845233600485015284602485015260448401526080606484015260848301906126d3565b03926001600160a01b03165af19082908261328d575b505061327f576132596131ba565b8051908161327a5760405162461bcd60e51b815280611c9c600482016130fc565b602001fd5b6001600160e01b0319161490565b909192506020813d82116132cd575b816132a96020938361286c565b810103126111105751906001600160e01b031982168203610210575090388061324b565b3d915061329c565b50505050600190565b91926000929190813b1561334f576020916133349185604051958680958194630a85bd0160e11b9b8c845233600485015260018060a01b03809516602485015260448401526080606484015260848301906126d3565b0393165af19082908261328d57505061327f576132596131ba565b5050505050600190565b8051821015612e855760209160051b010190565b91906040835260076040840152665f71756f72756d60c81b6060840152602060808401930152565b9190916133a181612ad8565b156134d0576000908152609b602090815260408220845191949092906001600160401b0383116134bc576133d584546127b7565b601f8111613479575b508591601f84116001146134185783949596509261340d575b50508160011b916000199060031b1c1916179055565b0151905038806133f7565b9190601f1984169685845280842093905b88821061346157505083600195969710613448575b505050811b019055565b015160001960f88460031b161c1916905538808061343e565b80600185968294968601518155019501930190613429565b848352868320601f850160051c8101918886106134b2575b601f0160051c01905b8181106134a757506133de565b83815560010161349a565b9091508190613491565b634e487b7160e01b82526041600452602482fd5b60405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608490fd5b1561353357565b60405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608490fd5b1561359557565b60405162461bcd60e51b81526020600482015260146024820152734e4654204e6f6e205472616e7366657261626c6560601b6044820152606490fd5b906001600160a01b0380806135e584612a8e565b16931691838314938415613618575b508315613602575b50505090565b61360e91929350612ab1565b16143880806135fc565b909350600052606a60205260406000208260005260205260ff6040600020541692386135f4565b1561364657565b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b906136c1916136a784612a8e565b6001600160a01b039391841692849290918316841461363f565b1691821561374657816136de916136d786612a8e565b161461363f565b600080516020613880833981519152600084815260696020526040812060018060a01b031990818154169055838252606860205260408220600019815401905584825260408220600181540190558582526067602052846040832091825416179055604051a4565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b919290926137a4846129d0565b60a25410610ae0576128c9936130b3936137c161238184336135d1565b6137cf60ff60a3541661358e565b6137da838383613699565b6132de56fe46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e94354537472696e67733a20686578206c656e67746820696e73756666696369656e748ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c70bc14066c33013fe88f66e314e4cf150b0b2d4d6451a1a51dbbd1c27cd11de28cfe2a20ff701a1f3e14f63bd70d6c6bc6fba8172ec6d5a505cdab3927c0a9de6ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220bcd7ed56c0c28d8d514a65196a6a97abd0c7b5c3016aaa10f1c60b68dab6b97f64736f6c63430008100033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.