ETH Price: $3,261.16 (-2.82%)

Token

Opuscula Genesis (OCG)
 

Overview

Max Total Supply

22 OCG

Holders

18

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
Hbbt2HBB: Deployer
Balance
1 OCG
0xb34E24ba5c8d0bB5c06F2afBf472a2e08E133A11
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
OpusculaGenesis

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 36 : OpusculaGenesis.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "../core/OmmgArtistContract.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title OpusculaGenesis
/// @author OMMG
contract OpusculaGenesis is OmmgArtistContract {
    string public constant Artist = "Opuscula";

    constructor(ArtistContractConfig memory config)
        OmmgArtistContract(config)
    {}
}

File 2 of 36 : OmmgArtistContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

// implementations
import "./impl/ERC721OmmgSnapshot.sol";
import "./impl/OmmgAccessControl.sol";
import "./impl/ERC721Ommg.sol";

// interfaces
import "./interfaces/IERC721OmmgEnumerable.sol";
import "./interfaces/IERC721OmmgMetadata.sol";
import "./interfaces/IERC721OmmgMetadataFreezable.sol";

import "./interfaces/IOmmgAcquirable.sol";
import "./interfaces/IOmmgAcquirableWithToken.sol";
import "./interfaces/IOmmgEmergencyTokenRecoverable.sol";
import "./interfaces/IOmmgWithdrawable.sol";

import "./interfaces/IOmmgProvenanceHash.sol";
import "./interfaces/IOmmgMutablePrice.sol";
import "./interfaces/IOmmgSalePausable.sol";
import "./interfaces/IOmmgSupplyCap.sol";
import "./interfaces/IOmmgFrontEnd.sol";

import "./def/ArtistContractConfig.sol";
import "./def/CustomErrors.sol";

// utility
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

contract OmmgArtistContract is
    IOmmgFrontEnd,
    OmmgAccessControl,
    ERC721Ommg,
    ERC721OmmgSnapshot,
    IERC721OmmgEnumerable,
    IERC721OmmgMetadata,
    IERC721OmmgMetadataFreezable,
    IOmmgSalePausable,
    IOmmgSupplyCap,
    IOmmgMutablePrice,
    IOmmgProvenanceHash,
    IOmmgAcquirable,
    IOmmgAcquirableWithToken,
    IOmmgEmergencyTokenRecoverable,
    IOmmgWithdrawable
{
    using Strings for uint256;
    using SafeERC20 for IERC20;

    /// @notice The identifying hash of the state administrator role. The state
    /// administrator role empowers the accounts that hold it to change state variables.
    /// @dev is just keccak256("CONTRACT_STATE_ADMIN")
    bytes32 public constant CONTRACT_STATE_ADMIN_ROLE =
        0x7e69b879a040173b938f56bb64bfa62bcd758c08ae6ed7cfdf7da6d7dba92708;

    /// @notice The identifying hash of the withdrawal administrator role. The
    /// role empowers the accounts that hold it to withdraw eth.
    /// @dev is just keccak256("CONTRACT_WITHDRAW_ADMIN")
    bytes32 public constant CONTRACT_WITHDRAW_ADMIN_ROLE =
        0x7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a3;

    /// @notice The identifying hash of the free acquire role. The role empowers
    /// the accounts that hold it to mint tokens for free, for example for marketing purposes.
    /// @dev is just keccak256("CONTRACT_FREE_ACQUIRE")
    bytes32 public constant CONTRACT_FREE_ACQUIRE_ROLE =
        0xfdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e;

    /// @dev the immutable max supply cap of this token
    uint256 private immutable _supplyCap;
    /// @dev the mutable public mint price of this token
    uint256 private _price;
    /// @dev the total number of shares held by all shareholders
    uint256 private _totalShares;

    /// @dev indicates whether the token metadata is revealed
    bool private _revealed;
    /// @dev indicates whether the public sale is active
    bool private _saleIsActive;
    /// @dev indicates whether the token metadata is frozen
    bool private _metadataFrozen;
    /// @dev indicates whether the provenance hash is frozen
    bool private _provenanceFrozen;

    /// @dev the name of the token contract
    string private _name;
    /// @dev the symbol of the token contract
    string private _symbol;
    /// @dev the base URI of the token metadata which is prepended to the tokenID,
    /// unless overridden for a token. Only shows when the token is revealed
    string private _baseURI;
    /// @dev the URI of the token metadata for the unrevealed state
    string private _unrevealedTokenURI;
    /// @dev the provenance hash
    string private _provenanceHash;

    /// @dev optional mapping for token URIs to override the default behavior
    mapping(uint256 => string) private _tokenURIs;
    /// @dev whether the token URI for this item is a full override or simply gets appended to the `_baseURI`
    mapping(uint256 => bool) private _overrideFullURI;
    /// @dev Optional mapping for token reveal override, to indicate if an individual token has been revealed
    mapping(uint256 => bool) private _tokenRevealed;

    /// @dev the list of all shareholders who will receive eth when `withdraw` is called
    Shareholder[] private _shareholders;

    /// @dev the list of all configured tokens for the token discount mechanic
    IERC721[] private _configuredTokens;
    /// @dev a shorthand way to check if a token is configured
    mapping(IERC721 => bool) _tokenConfigured;
    /// @dev a mapping per configured token to indicate whether a specific token of that token contract has been used as
    /// a discount token already or not. It goes as follows: `_tokenIdsUsed[address][version][tokenId]`
    mapping(IERC721 => mapping(uint256 => mapping(uint256 => bool))) _tokenIdsUsed;
    /// @dev a mapping per configured token to its tokenIdsUsed version, needed for resets.
    mapping(IERC721 => uint256) _tokensUsedVersion;
    /// @dev a mapping per configured token to its used number.
    mapping(IERC721 => uint256) _tokensUsedNumber;
    /// @dev the configurations (price, active state) of a token discount
    mapping(IERC721 => TokenDiscountConfig) _tokenConfigurations;

    /// @notice Initializes the contract with the given configuration.
    /// @dev The config is the 'magic' behind this contract and the core of it's flexibility
    /// @param config the config of this contract as an {ArtistContractConfig} struct
    /// `config.name` will be the name of the contract.
    /// `config.symbol` will be the symbol.
    /// `config.withdrawAdmins` can be a list of users who will be assigned the `CONTRACT_WITHDRAW_ADMIN_ROLE` on construction.
    /// `config.stateAdmins` can be a list of users who will be assigned the `CONTRACT_STATE_ADMIN_ROLE` on construction.
    /// `config.mintForFree` can be a list of users who will be assigned the `CONTRACT_FREE_ACQUIRE_ROLE` on construction.
    /// `config.initialPrice` is the initial value assigned to the mutable price property.
    /// `config.supplyCap` is the immutable supply cap.
    /// `config.maxBatchSize` is the maximum number of tokens mintable in one transaction.
    /// `config.shareholders` is a list of the shareholders (see {Shareholder} struct).
    /// `config.tokenDiscounts` is a list of token discounts (see {TokenDiscount} struct) which will be usable to mint tokens.
    constructor(ArtistContractConfig memory config)
        ERC721Ommg(config.maxBatchSize)
    {
        _name = config.name;
        _symbol = config.symbol;
        _price = config.initialPrice;
        _supplyCap = config.supplyCap;

        _addRoleToAll(config.withdrawAdmins, CONTRACT_WITHDRAW_ADMIN_ROLE);
        _addRoleToAll(config.stateAdmins, CONTRACT_STATE_ADMIN_ROLE);
        _addRoleToAll(config.mintForFree, CONTRACT_FREE_ACQUIRE_ROLE);

        uint256 amount = config.shareholders.length;
        for (uint256 i = 0; i < config.shareholders.length; i++) {
            _addShareholder(config.shareholders[i]);
        }

        amount = config.tokenDiscounts.length;
        for (uint256 i = 0; i < amount; i++) {
            _addTokenDiscount(
                config.tokenDiscounts[i].tokenAddress,
                config.tokenDiscounts[i].config
            );
        }
    }

    /// @inheritdoc ERC721Ommg
    function maxBatchSize()
        public
        view
        override(ERC721Ommg, IOmmgFrontEnd)
        returns (uint256)
    {
        return super.maxBatchSize();
    }

    function tokensAvailable()
        external
        view
        override
        returns (uint256 amount)
    {
        return supplyCap() - _currentIndex();
    }

    /// @dev little helper function to add `role` to all accounts supplied
    function _addRoleToAll(address[] memory accounts, bytes32 role) private {
        uint256 len = accounts.length;
        if (len > 0) {
            for (uint256 i = 0; i < len; i++) {
                grantRole(role, accounts[i]);
            }
        }
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgWithdrawable //////////////////////////////////////////////

    /// @dev Only callable by the contract owner or someone with the
    /// `CONTRACT_STATE_ADMIN_ROLE`.
    /// @inheritdoc IOmmgWithdrawable
    function addShareholder(address walletAddress, uint256 shares)
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _addShareholder(Shareholder(walletAddress, shares));
    }

    /// @dev Only callable by the contract owner or someone with the
    /// `CONTRACT_STATE_ADMIN_ROLE`.
    /// @inheritdoc IOmmgWithdrawable
    function removeShareholder(address walletAddress)
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        if (walletAddress == address(0)) revert NullAddress();
        uint256 length = _shareholders.length;
        for (uint256 i = 0; i < length; i++) {
            if (_shareholders[i].addr == walletAddress) {
                _removeShareholderAt(i);
                return;
            }
        }
        revert ShareholderDoesNotExist(walletAddress);
    }

    /// @dev Only callable by the contract owner or someone with the
    /// `CONTRACT_STATE_ADMIN_ROLE`.
    /// @inheritdoc IOmmgWithdrawable
    function updateShareholder(address walletAddress, uint256 updatedShares)
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        if (walletAddress == address(0)) revert NullAddress();
        uint256 length = _shareholders.length;
        for (uint256 i = 0; i < length; i++) {
            if (_shareholders[i].addr == walletAddress) {
                _shareholders[i].shares = updatedShares;
                emit ShareholderUpdated(walletAddress, updatedShares);
                return;
            }
        }
        revert ShareholderDoesNotExist(walletAddress);
    }

    /// @dev Only callable by the contract owner or someone with the
    /// `CONTRACT_STATE_ADMIN_ROLE`. Reverts if the address is the null address,
    /// or if a shareholder with this address does not exist.
    /// @inheritdoc IOmmgWithdrawable
    function shares(address walletAddress)
        external
        view
        override
        returns (uint256)
    {
        uint256 length = _shareholders.length;
        for (uint256 i = 0; i < length; i++) {
            if (_shareholders[i].addr == walletAddress) {
                return _shareholders[i].shares;
            }
        }
        revert ShareholderDoesNotExist(walletAddress);
    }

    /// @inheritdoc IOmmgWithdrawable
    function shareholders()
        external
        view
        override
        returns (Shareholder[] memory)
    {
        return _shareholders;
    }

    /// @inheritdoc IOmmgWithdrawable
    function totalShares() external view override returns (uint256) {
        return _totalShares;
    }

    function emergencyWithdraw()
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        uint256 balance = address(this).balance;
        payable(_msgSender()).transfer(balance);
        emit EmergencyWithdrawn(msg.sender, balance);
    }

    /// @inheritdoc IOmmgWithdrawable
    function withdraw()
        external
        override
        onlyOwnerOrRole(CONTRACT_WITHDRAW_ADMIN_ROLE)
    {
        uint256 balance = address(this).balance;
        uint256 totalShares_ = _totalShares;
        uint256 length = _shareholders.length;
        if (totalShares_ == 0 || length == 0) revert ZeroShares();
        uint256 amountPerShare = balance / totalShares_;
        for (uint256 i = 0; i < length; i++) {
            Shareholder memory sh = _shareholders[i];
            uint256 shareholderAmount = sh.shares * amountPerShare;
            payable(sh.addr).transfer(shareholderAmount);
            emit PaidOut(_msgSender(), sh.addr, shareholderAmount);
        }
        emit Withdrawn(_msgSender(), amountPerShare * _totalShares);
    }

    function _removeShareholderAt(uint256 index) private {
        uint256 length = _shareholders.length;
        Shareholder memory sh = _shareholders[index];
        for (uint256 i = index; i < length - 1; i++) {
            _shareholders[i] = _shareholders[i + 1];
        }
        _shareholders.pop();
        _totalShares -= sh.shares;
        emit ShareholderRemoved(sh.addr, sh.shares);
    }

    function _addShareholder(Shareholder memory shareholder) internal {
        if (shareholder.shares == 0) revert ZeroShares();
        if (shareholder.addr == address(0)) revert NullAddress();
        uint256 length = _shareholders.length;
        for (uint256 i = 0; i < length; i++) {
            if (_shareholders[i].addr == shareholder.addr)
                revert ShareholderAlreadyExists(shareholder.addr);
        }
        _shareholders.push(shareholder);
        _totalShares += shareholder.shares;
        emit ShareholderAdded(shareholder.addr, shareholder.shares);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgEmergencyTokenRecoverable /////////////////////////////////

    /// @inheritdoc IOmmgEmergencyTokenRecoverable
    function emergencyRecoverTokens(
        IERC20 token,
        address receiver,
        uint256 amount
    ) public virtual override onlyOwnerOrRole(CONTRACT_WITHDRAW_ADMIN_ROLE) {
        if (receiver == address(0)) revert NullAddress();
        token.safeTransfer(receiver, amount);
        emit TokensRecovered(token, receiver, amount);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgAcquirableWithToken //////////////////////////////////////

    /// @inheritdoc IOmmgAcquirableWithToken
    function acquireWithToken(IERC721 token, uint256[] memory tokenIds)
        external
        payable
        override(IOmmgAcquirableWithToken, IOmmgFrontEnd)
    {
        uint256 amount = tokenIds.length;
        if (amount == 0) revert InvalidAmount(0, 1, maxBatchSize());
        _checkSupplyCapAndMaxBatch(amount);
        _revertIfTokenNotActive(token);
        uint256 price_ = _getTokenDiscountInfo(token).price;
        if (msg.value != price_ * amount) {
            revert InvalidMessageValue(msg.value, price_ * amount);
        }
        _checkTokenElegibility(msg.sender, token, tokenIds);
        _setTokensUsedForDiscount(token, tokenIds);
        _safeMint(msg.sender, amount);
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function tokenDiscounts()
        external
        view
        override(IOmmgAcquirableWithToken, IOmmgFrontEnd)
        returns (TokenDiscountOutput[] memory)
    {
        uint256 len = _configuredTokens.length;
        IERC721[] memory localCopy = _configuredTokens;
        TokenDiscountOutput[] memory td = new TokenDiscountOutput[](len);
        for (uint256 i = 0; i < len; i++) {
            address addr = address(localCopy[i]);
            td[i] = TokenDiscountOutput(
                IERC721(addr),
                _getRemoteNameOrEmpty(address(addr)),
                _getRemoteSymbolOrEmpty(address(addr)),
                _tokensUsedNumber[localCopy[i]],
                _tokenConfigurations[localCopy[i]]
            );
        }
        return td;
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function addTokenDiscount(
        IERC721 tokenAddress,
        TokenDiscountConfig memory config
    ) public onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE) {
        _addTokenDiscount(tokenAddress, config);
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function setTokenDiscountActive(IERC721 tokenAddress, bool active)
        external
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _revertIfTokenNotConfigured(tokenAddress);
        if (_tokenConfigurations[tokenAddress].active != active) {
            _tokenConfigurations[tokenAddress].active = active;
            emit TokenDiscountUpdated(
                tokenAddress,
                _tokenConfigurations[tokenAddress]
            );
        }
    }

    function _getRemoteNameOrEmpty(address remote)
        internal
        view
        returns (string memory)
    {
        try IERC721Metadata(remote).name() returns (string memory name_) {
            return name_;
        } catch {
            return "";
        }
    }

    function _getRemoteSymbolOrEmpty(address remote)
        internal
        view
        returns (string memory)
    {
        try IERC721Metadata(remote).symbol() returns (string memory symbol_) {
            return symbol_;
        } catch {
            return "";
        }
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function tokensUsedForDiscount(
        IERC721 tokenAddress,
        uint256[] memory tokenIds
    )
        external
        view
        virtual
        override(IOmmgAcquirableWithToken, IOmmgFrontEnd)
        returns (bool[] memory used)
    {
        _revertIfTokenNotConfigured(tokenAddress);
        uint256 length = tokenIds.length;
        bool[] memory arr = new bool[](length);
        for (uint256 i = 0; i < length; i++) {
            arr[i] = _tokenIdsUsed[tokenAddress][
                _tokensUsedVersion[tokenAddress]
            ][tokenIds[i]];
        }
        return arr;
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function removeTokenDiscount(IERC721 tokenAddress)
        external
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _revertIfTokenNotConfigured(tokenAddress);
        uint256 length = _configuredTokens.length;
        for (uint256 i = 0; i < length; i++) {
            if (_configuredTokens[i] == tokenAddress) {
                _tokenConfigured[tokenAddress] = false;
                _popTokenConfigAt(i);
                emit TokenDiscountRemoved(tokenAddress);
                return;
            }
        }
        revert TokenNotConfigured(tokenAddress);
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function tokenDiscountInfo(IERC721 tokenAddress)
        external
        view
        returns (TokenDiscountOutput memory)
    {
        _revertIfTokenNotConfigured(tokenAddress);
        return
            TokenDiscountOutput(
                tokenAddress,
                _getRemoteNameOrEmpty(address(tokenAddress)),
                _getRemoteSymbolOrEmpty(address(tokenAddress)),
                _tokensUsedNumber[tokenAddress],
                _getTokenDiscountInfo(tokenAddress)
            );
    }

    function _getTokenDiscountInfo(IERC721 tokenAddress)
        internal
        view
        returns (TokenDiscountConfig memory)
    {
        return _tokenConfigurations[tokenAddress];
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function updateTokenDiscount(
        IERC721 tokenAddress,
        TokenDiscountConfig memory config
    ) external override onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE) {
        _revertIfTokenNotConfigured(tokenAddress);
        _tokenConfigurations[tokenAddress] = config;
        emit TokenDiscountUpdated(tokenAddress, config);
    }

    /// @inheritdoc IOmmgAcquirableWithToken
    function resetTokenDiscountUsed(IERC721 tokenAddress)
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _revertIfTokenNotConfigured(tokenAddress);
        _tokensUsedVersion[tokenAddress]++;
        _tokensUsedNumber[tokenAddress] = 0;
        emit TokenDiscountReset(tokenAddress);
    }

    function _checkTokenElegibility(
        address account,
        IERC721 tokenAddress,
        uint256[] memory tokenIds
    ) internal view {
        uint256 length = tokenIds.length;
        if (
            _tokensUsedNumber[tokenAddress] + length >
            _tokenConfigurations[tokenAddress].supply
        )
            revert TokenSupplyExceeded(
                tokenAddress,
                _tokenConfigurations[tokenAddress].supply
            );
        for (uint256 i = 0; i < length; i++) {
            uint256 tokenId = tokenIds[i];
            // try catch for reverts in ownerOf
            try tokenAddress.ownerOf(tokenId) returns (address owner) {
                if (owner != account)
                    revert TokenNotOwned(tokenAddress, tokenId);
            } catch {
                revert TokenNotOwned(tokenAddress, tokenId);
            }
            if (
                _tokenIdsUsed[tokenAddress][_tokensUsedVersion[tokenAddress]][
                    tokenId
                ]
            ) revert TokenAlreadyUsed(tokenAddress, tokenId);
        }
    }

    function _popTokenConfigAt(uint256 index) private {
        uint256 length = _configuredTokens.length;
        if (index >= length) return;
        for (uint256 i = index; i < length - 1; i++) {
            _configuredTokens[i] = _configuredTokens[i + 1];
        }
        _configuredTokens.pop();
    }

    // no checks
    function _setTokensUsedForDiscount(
        IERC721 token,
        uint256[] memory tokenIds
    ) internal {
        uint256 length = tokenIds.length;
        for (uint256 i = 0; i < length; i++) {
            _tokenIdsUsed[token][_tokensUsedVersion[token]][
                tokenIds[i]
            ] = true;
            emit TokenUsedForDiscount(msg.sender, token, tokenIds[i]);
        }
        _tokensUsedNumber[token] += length;
    }

    function _addTokenDiscount(
        IERC721 tokenAddress,
        TokenDiscountConfig memory config
    ) internal {
        if (address(tokenAddress) == address(0)) revert NullAddress();
        if (_tokenConfigured[tokenAddress])
            revert TokenAlreadyConfigured(tokenAddress);
        _tokenConfigured[tokenAddress] = true;
        _tokensUsedVersion[tokenAddress]++;
        _tokenConfigurations[tokenAddress] = config;
        _configuredTokens.push(tokenAddress);
        emit TokenDiscountAdded(tokenAddress, config);
    }

    function _revertIfTokenNotConfigured(IERC721 tokenAddress) internal view {
        if (address(tokenAddress) == address(0)) revert NullAddress();
        if (!_tokenConfigured[tokenAddress])
            revert TokenNotConfigured(tokenAddress);
    }

    function _revertIfTokenNotActive(IERC721 tokenAddress) internal view {
        if (!_tokenConfigured[tokenAddress])
            revert TokenNotConfigured(tokenAddress);
        if (!_tokenConfigurations[tokenAddress].active)
            revert TokenNotActive(tokenAddress);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgProvenanceHash ///////////////////////////////////////////

    function whenProvenanceIsNotFrozen() private view {
        if (_provenanceFrozen) revert ProvenanceHashIsFrozen();
    }

    /// @inheritdoc IOmmgProvenanceHash
    function provenanceHash() public view override returns (string memory) {
        return _provenanceHash;
    }

    /// @inheritdoc IOmmgProvenanceHash
    function provenanceFrozen() public view override returns (bool) {
        return _provenanceFrozen;
    }

    /// @inheritdoc IOmmgProvenanceHash
    function setProvenanceHash(string memory provenanceHash_)
        public
        virtual
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        whenProvenanceIsNotFrozen();
        _provenanceHash = provenanceHash_;
        emit ProvenanceHashSet(_provenanceHash);
    }

    /// @inheritdoc IOmmgProvenanceHash
    function freezeProvenance()
        public
        virtual
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        whenProvenanceIsNotFrozen();
        _provenanceFrozen = true;
        emit ProvenanceHashFrozen();
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgMutablePrice //////////////////////////////////////////////

    /// @inheritdoc IOmmgMutablePrice
    function price()
        public
        view
        override(IOmmgMutablePrice, IOmmgFrontEnd)
        returns (uint256)
    {
        return _price;
    }

    /// @inheritdoc IOmmgMutablePrice
    function setPrice(uint256 price)
        public
        virtual
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _price = price;
        emit PriceChanged(_price);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgSupplyCap /////////////////////////////////////////////////

    /// @inheritdoc IOmmgSupplyCap
    function supplyCap()
        public
        view
        virtual
        override(IOmmgSupplyCap, IOmmgFrontEnd)
        returns (uint256)
    {
        return _supplyCap;
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgSalePausable //////////////////////////////////////////////

    /// @inheritdoc IOmmgSalePausable
    function saleIsActive()
        public
        view
        override(IOmmgSalePausable, IOmmgFrontEnd)
        returns (bool)
    {
        return _saleIsActive;
    }

    /// @inheritdoc IOmmgSalePausable
    function setSaleIsActive(bool newValue)
        public
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _saleIsActive = newValue;
        emit SaleIsActiveSet(_saleIsActive);
    }

    modifier whenSaleIsActive() {
        if (!_saleIsActive) {
            revert SaleNotActive();
        }
        _;
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IOmmgAcquirable ////////////////////////////////////////////////

    /// @inheritdoc IOmmgAcquirable
    function acquireForCommunity(address receiver, uint256 amount)
        external
        override
        onlyOwnerOrRole(CONTRACT_FREE_ACQUIRE_ROLE)
    {
        _checkSupplyCapAndMaxBatch(amount);
        _safeMint(receiver, amount);
    }

    /// @inheritdoc IOmmgAcquirable
    function acquire(uint256 amount)
        external
        payable
        override(IOmmgAcquirable, IOmmgFrontEnd)
        whenSaleIsActive
    {
        _checkSupplyCapAndMaxBatch(amount);
        if (msg.value != price() * amount) {
            revert InvalidMessageValue(msg.value, price() * amount);
        }

        _safeMint(msg.sender, amount);
    }

    function _checkSupplyCapAndMaxBatch(uint256 amount) private view {
        if (amount > maxBatchSize() || amount == 0) {
            revert InvalidAmount(amount, 1, maxBatchSize());
        }
        if (_currentIndex() + amount > supplyCap()) {
            // +1 because 0 based index
            revert AmountExceedsCap(
                amount,
                supplyCap() - _currentIndex(),
                supplyCap()
            );
        }
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IERC721OmmgEnumerable //////////////////////////////////////////

    /// @inheritdoc IERC721Enumerable
    function totalSupply() public view override returns (uint256) {
        return _currentIndex() - _burned();
    }

    /// @inheritdoc IERC721Enumerable
    function tokenByIndex(uint256 index)
        public
        view
        override
        returns (uint256)
    {
        if (index >= totalSupply())
            revert IndexOutOfBounds(index, totalSupply());
        if (_burned() == 0) return index + 1;
        uint256 j = 0;
        uint256 maxIndex = _currentIndex();
        for (uint256 i = 0; i < maxIndex; i++) {
            if (j == index) return i;
            if (_exists(i)) j++;
        }
        revert OperationFailed();
    }

    /// @inheritdoc IERC721Enumerable
    function tokenOfOwnerByIndex(address owner, uint256 index)
        public
        view
        override
        returns (uint256)
    {
        if (index > balanceOf(owner))
            revert IndexOutOfBounds(index, balanceOf(owner));

        uint256 limit = _currentIndex();
        uint256 tokenIdsIdx = 0;
        for (uint256 i = 0; i < limit; i++) {
            if (_exists(i)) {
                if (_ownershipOf(i).addr == owner) {
                    if (tokenIdsIdx == index) {
                        return i;
                    }
                    tokenIdsIdx++;
                }
            }
        }
        revert OperationFailed();
    }

    /// @inheritdoc IERC721OmmgEnumerable
    function exists(uint256 tokenId) public view override returns (bool) {
        return _exists(tokenId);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IERC721OmmgMetadata ////////////////////////////////////////////

    /// @inheritdoc IERC721Metadata
    function name()
        public
        view
        virtual
        override(IERC721Metadata, IOmmgFrontEnd)
        returns (string memory)
    {
        return _name;
    }

    /// @inheritdoc IERC721Metadata
    function symbol()
        public
        view
        virtual
        override(IERC721Metadata, IOmmgFrontEnd)
        returns (string memory)
    {
        return _symbol;
    }

    /// @inheritdoc IERC721OmmgMetadata
    function revealed() public view returns (bool) {
        return _revealed;
    }

    /// @inheritdoc IERC721OmmgMetadata
    function tokenRevealed(uint256 tokenId)
        public
        view
        override
        returns (bool)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        return _tokenRevealed[tokenId] || _revealed;
    }

    /// @inheritdoc IERC721OmmgMetadata
    function overridesFullURI(uint256 tokenId)
        public
        view
        override
        returns (bool)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        return _overrideFullURI[tokenId];
    }

    /// @inheritdoc IERC721Metadata
    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory _base = _baseURI;

        if (!_revealed && !_tokenRevealed[tokenId]) {
            return _unrevealedTokenURI;
        } else {
            if (bytes(_tokenURI).length > 0) {
                if (_overrideFullURI[tokenId]) return _tokenURI;
                else return string(abi.encodePacked(_base, _tokenURI));
            } else {
                if (bytes(_baseURI).length > 0)
                    return string(abi.encodePacked(_base, tokenId.toString()));
                else return _tokenURI;
            }
        }
    }

    /// @inheritdoc IERC721OmmgMetadata
    function reveal()
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _revealed = true;
        emit Revealed();
    }

    /// @inheritdoc IERC721OmmgMetadata
    function revealToken(uint256 tokenId)
        external
        override
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        _tokenRevealed[tokenId] = true;
        emit TokenRevealed(tokenId);
    }

    /// @inheritdoc IERC721OmmgMetadata
    function setTokenURI(
        uint256 tokenId,
        bool overrideBaseURI,
        bool overrideReveal,
        string memory _tokenURI
    )
        external
        override
        whenMetadataIsNotFrozen
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        _tokenURIs[tokenId] = _tokenURI;
        _overrideFullURI[tokenId] = overrideBaseURI;
        if (overrideReveal && !_tokenRevealed[tokenId]) {
            _tokenRevealed[tokenId] = true;
            emit TokenRevealed(tokenId);
        }
        emit SetTokenUri(tokenId, false, false, _tokenURI);
    }

    /// @inheritdoc IERC721OmmgMetadata
    function setUnrevealedTokenURI(string memory unrevealedTokenURI)
        external
        override
        whenMetadataIsNotFrozen
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _unrevealedTokenURI = unrevealedTokenURI;
        emit UnrevealedTokenUriSet(_unrevealedTokenURI);
    }

    /// @inheritdoc IERC721OmmgMetadata
    function setBaseURI(string memory baseURI)
        external
        override
        whenMetadataIsNotFrozen
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _baseURI = baseURI;
        emit SetBaseUri(baseURI);
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IERC721OmmgMetadataFreezable ///////////////////////////////////

    modifier whenMetadataIsNotFrozen() {
        if (_metadataFrozen) revert MetadataIsFrozen();
        _;
    }

    /// @inheritdoc IERC721OmmgMetadataFreezable
    function metadataFrozen() public view returns (bool) {
        return _metadataFrozen;
    }

    /// @inheritdoc IERC721OmmgMetadataFreezable
    function freezeMetadata()
        public
        virtual
        whenMetadataIsNotFrozen
        onlyOwnerOrRole(CONTRACT_STATE_ADMIN_ROLE)
    {
        _metadataFrozen = true;
        emit MetadataFrozen();
    }

    ////////////////////////////////////////////////////////////////////////////
    /////////// IERC165 ////////////////////////////////////////////////////////

    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(IERC165, ERC721Ommg, ERC721OmmgSnapshot, OmmgAccessControl)
        returns (bool)
    {
        return
            interfaceId == type(IOmmgEmergencyTokenRecoverable).interfaceId ||
            interfaceId == type(IERC721OmmgMetadataFreezable).interfaceId ||
            interfaceId == type(IOmmgAcquirableWithToken).interfaceId ||
            interfaceId == type(IERC721OmmgEnumerable).interfaceId ||
            interfaceId == type(IERC721OmmgMetadata).interfaceId ||
            interfaceId == type(IOmmgProvenanceHash).interfaceId ||
            interfaceId == type(IOmmgMutablePrice).interfaceId ||
            interfaceId == type(IOmmgWithdrawable).interfaceId ||
            interfaceId == type(IOmmgSalePausable).interfaceId ||
            interfaceId == type(IERC721Enumerable).interfaceId ||
            interfaceId == type(IOmmgAcquirable).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            interfaceId == type(IOmmgSupplyCap).interfaceId ||
            interfaceId == type(IOmmgFrontEnd).interfaceId ||
            interfaceId == type(IOmmgOwnable).interfaceId ||
            super.supportsInterface(interfaceId);
    }
}

File 3 of 36 : ERC721OmmgSnapshot.sol
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity ^0.8.0;

import "./ERC721Ommg.sol";
import "../interfaces/IOmmgSnapshot.sol";

abstract contract ERC721OmmgSnapshot is IOmmgSnapshot, ERC721Ommg {
    function snapshot() external view returns (TokenInfo[] memory) {
        uint256 curIndex = _currentIndex();
        TokenInfo[] memory tokenInfo = new TokenInfo[](curIndex);
        for (uint256 i = 1; i <= curIndex; i++) {
            if (_exists(i)) {
                tokenInfo[i - 1] = TokenInfo(i, TokenStatus.OWNED, ownerOf(i));
            } else {
                tokenInfo[i - 1] = TokenInfo(
                    i,
                    TokenStatus.BURNED,
                    address(this)
                );
            }
        }
        return tokenInfo;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            interfaceId == type(IOmmgSnapshot).interfaceId ||
            super.supportsInterface(interfaceId);
    }
}

File 4 of 36 : OmmgAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Strings.sol";

import "./OmmgOwnable.sol";
import "../interfaces/IOmmgAccessControl.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

/// @dev custom role access / ownable
abstract contract OmmgAccessControl is OmmgOwnable, IOmmgAccessControl {
    mapping(bytes32 => RoleData) private _roles;

    /// @dev Reverts if called by any account other than the owner or `role`
    /// @param role The role which is allowed access
    modifier onlyOwnerOrRole(bytes32 role) {
        if (owner() != _msgSender() && !_roles[role].members[_msgSender()])
            revert Unauthorized(_msgSender(), role);
        _;
    }

    /// @dev Reverts if called by any account other than the owner or `role`
    /// @param role The role which is allowed access
    modifier onlyRole(bytes32 role) {
        if (!_roles[role].members[_msgSender()])
            revert Unauthorized(_msgSender(), role);
        _;
    }

    /// @dev Returns `true` if `account` has been granted `role`.
    function hasRole(bytes32 role, address account)
        external
        view
        override
        returns (bool)
    {
        return _roles[role].members[account];
    }

    /// @dev Grants `role` to `account`.
    function grantRole(bytes32 role, address account)
        public
        override
        onlyOwner
    {
        _grantRole(role, account);
    }

    /// @dev Revokes `role` from `account`
    function revokeRole(bytes32 role, address account)
        public
        override
        onlyOwner
    {
        _revokeRole(role, account);
    }

    /// @dev Revokes `role` from the calling account.
    function renounceRole(bytes32 role) public override {
        _revokeRole(role, _msgSender());
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal {
        if (!_roles[role].members[account]) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal {
        if (_roles[role].members[account]) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            interfaceId == type(IOmmgAccessControl).interfaceId ||
            super.supportsInterface(interfaceId);
    }
}

File 5 of 36 : ERC721Ommg.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "../def/CustomErrors.sol";

abstract contract ERC721Ommg is Context, ERC165, IERC721 {
    using Address for address;
    using Strings for uint256;

    struct TokenOwnership {
        address addr;
        uint64 startTimestamp;
    }

    struct AddressData {
        uint128 balance;
        uint128 numberMinted;
    }

    uint256 private currentIndex = 1;
    uint256 private burned;

    uint256 private immutable _maxBatchSize;
    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.
    mapping(uint256 => TokenOwnership) private _ownerOf;
    // Mapping owner address to address data
    mapping(address => AddressData) private _balanceOf;
    // 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;

    constructor(uint256 maxBatchSize_) {
        _maxBatchSize = maxBatchSize_;
    }

    function _currentIndex() internal view returns (uint256) {
        return currentIndex - 1;
    }

    function _burned() internal view returns (uint256) {
        return burned;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC165, IERC165)
        returns (bool)
    {
        return
            interfaceId == type(IERC721).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    function maxBatchSize() public view virtual returns (uint256) {
        return _maxBatchSize;
    }

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) public view override returns (uint256) {
        if (owner == address(0)) revert NullAddress();
        return _balanceOf[owner].balance;
    }

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view returns (address) {
        return _ownershipOf(tokenId).addr;
    }

    function _ownershipOf(uint256 tokenId)
        internal
        view
        returns (TokenOwnership memory)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);

        uint256 lowestTokenToCheck;
        if (tokenId >= _maxBatchSize) {
            lowestTokenToCheck = tokenId - _maxBatchSize + 1;
        }

        for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) {
            TokenOwnership memory ownership = _ownerOf[curr];
            if (ownership.addr != address(0)) return ownership;
        }
        revert OperationFailed();
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @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 memory data
    ) public override {
        _transfer(from, to, tokenId);
        if (!_checkOnERC721Received(from, to, tokenId, data))
            revert SafeTransferFailed(from, to, tokenId);
    }

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override {
        _transfer(from, to, tokenId);
    }

    /**
     * @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 {
        address owner = ownerOf(tokenId);
        // is in ownerOf
        // if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        if (to == owner) revert ApprovalInvalid(_msgSender(), tokenId);

        if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender()))
            revert ApprovalUnauthorized(owner, to, tokenId, _msgSender());

        _approve(to, tokenId, owner);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId)
        public
        view
        returns (address operator)
    {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);
        return _tokenApprovals[tokenId];
    }

    /**
     * @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)
        public
        override
    {
        if (operator == _msgSender())
            revert ApprovalForAllInvalid(_msgSender(), approved);

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator)
        public
        view
        override
        returns (bool)
    {
        return _operatorApprovals[owner][operator];
    }

    function _exists(uint256 tokenId) internal view returns (bool) {
        return
            tokenId > 0 &&
            tokenId < currentIndex &&
            _ownerOf[tokenId].addr != address(this);
    }

    // function _hasBeenMinted(uint256 tokenId) internal view returns (bool) {
    //     return tokenId < currentIndex;
    // }

    // function _ownerAddress(uint256 tokenId) internal view returns (address) {
    //     return _ownerOf[tokenId].addr;
    // }

    function _burn(uint256 tokenId) internal {
        if (!_exists(tokenId)) revert TokenDoesNotExist(tokenId);

        TokenOwnership memory owner = _ownershipOf(tokenId);

        _beforeTokenTransfers(owner.addr, address(this), tokenId, 1);

        // Clear approvals
        _approve(address(0), tokenId, owner.addr);

        _balanceOf[owner.addr].balance -= 1;
        _ownerOf[tokenId].addr = address(this);
        burned++;
        uint256 nextTokenId = tokenId + 1;
        if (_ownerOf[nextTokenId].addr == address(0)) {
            if (_exists(nextTokenId)) {
                _ownerOf[nextTokenId] = TokenOwnership(
                    owner.addr,
                    owner.startTimestamp
                );
            }
        }
        emit Transfer(owner.addr, address(this), tokenId);

        _afterTokenTransfers(owner.addr, address(this), tokenId, 1);
    }

    function _safeMint(address to, uint256 quantity) internal {
        _safeMint(to, quantity, "");
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` cannot be larger than the max batch size.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory data
    ) internal {
        uint256 startTokenId = currentIndex;
        if (to == address(0)) revert NullAddress();
        // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
        // TODO can this even happen?
        // if (_exists(startTokenId)) revert TokenAlreadyExists(startTokenId);

        if (quantity > _maxBatchSize || quantity == 0)
            revert InvalidAmount(quantity, 1, _maxBatchSize);

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        AddressData memory oldData = _balanceOf[to];
        _balanceOf[to] = AddressData(
            oldData.balance + uint128(quantity),
            oldData.numberMinted + uint128(quantity)
        );
        _ownerOf[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
        uint256 updatedIndex = startTokenId;
        for (uint256 i = 0; i < quantity; i++) {
            emit Transfer(address(0), to, updatedIndex);
            if (!_checkOnERC721Received(address(0), to, updatedIndex, data))
                revert SafeTransferFailed(address(0), to, updatedIndex);
            updatedIndex++;
        }
        currentIndex = updatedIndex;
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) private {
        if (to == address(0)) revert NullAddress();

        TokenOwnership memory prevOwner = _ownershipOf(tokenId);

        if (prevOwner.addr != from)
            revert TransferUnauthorized(
                _msgSender(),
                from,
                to,
                tokenId,
                prevOwner.addr
            );

        if (
            _msgSender() != prevOwner.addr &&
            getApproved(tokenId) != _msgSender() &&
            !isApprovedForAll(prevOwner.addr, _msgSender())
        )
            revert TransferUnauthorized(
                _msgSender(),
                from,
                to,
                tokenId,
                prevOwner.addr
            );

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId, prevOwner.addr);

        _balanceOf[from].balance -= 1;
        _balanceOf[to].balance += 1;
        _ownerOf[tokenId] = TokenOwnership(to, uint64(block.timestamp));

        // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
        // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
        uint256 nextTokenId = tokenId + 1;
        if (_ownerOf[nextTokenId].addr == address(0)) {
            if (_exists(nextTokenId)) {
                _ownerOf[nextTokenId] = TokenOwnership(
                    prevOwner.addr,
                    prevOwner.startTimestamp
                );
            }
        }
        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(
        address to,
        uint256 tokenId,
        address owner
    ) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @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
                IERC721Receiver(to).onERC721Received(
                    _msgSender(),
                    from,
                    tokenId,
                    _data
                )
            returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert TargetNonERC721Receiver(to);
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 tokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
     * minting.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 tokenId,
        uint256 quantity
    ) internal virtual {}
}

File 6 of 36 : IERC721OmmgEnumerable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IERC721OmmgEnumerable
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves as an extension to {IERC721Enumerable} and adds
/// functionality to check if a token exists.
interface IERC721OmmgEnumerable is IERC721Enumerable {
    /// @notice Returns whether the token `tokenId` exists.
    /// @param tokenId the token id to check
    /// @return exists whether the token exists
    function exists(uint256 tokenId) external view returns (bool exists);
}

File 7 of 36 : IERC721OmmgMetadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IERC721OmmgMetadata
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves as an extension to {IERC721Metadata} and adds
/// functionality to reveal tokens as well as add more logic to the token uri.
interface IERC721OmmgMetadata is IERC721Metadata {
    /// @notice Triggers when the base uri is updated.
    /// @param baseURI the new base uri
    event SetBaseUri(string indexed baseURI);

    /// @notice Triggers when the URI for a token is overridden.
    /// @param tokenId the token where the URI is overridden
    /// @param fullOverride fullOverride whether the override overrides the base URI or is appended
    /// @param tokenRevealedOverride whether the token should be individually revealed
    /// @param tokenURI the override token URI
    event SetTokenUri(
        uint256 indexed tokenId,
        bool fullOverride,
        bool tokenRevealedOverride,
        string indexed tokenURI
    );
    /// @notice Triggers when the unrevealed token uri is updated.
    /// @param unrevealedTokenURI the new unrevealed token uri
    event UnrevealedTokenUriSet(string indexed unrevealedTokenURI);

    /// @notice Triggers when the collection is revealed.
    event Revealed();

    /// @notice Triggers when a singular token is revealed.
    /// @param tokenId the token which is revealed
    event TokenRevealed(uint256 indexed tokenId);

    /// @notice Returns whether the collection as a whole is revealed.
    /// @param revealed whether the collection is revealed
    function revealed() external view returns (bool revealed);

    /// @notice Reveals the collection. Emits {Revealed}.
    function reveal() external;

    /// @notice Reveals an individual token. Fails if the token does not exist.
    /// Emits {TokenRevealed}.
    /// @param tokenId the id of the revealed token
    function revealToken(uint256 tokenId) external;

    /// @notice Overrides the token URI for an individual token and optionally sets whether the base uri
    /// should be overridden too, and whether the token should be revealed individually. Emits {SetTokenUri}
    /// and {TokenRevealed} if it is revealed in the process.
    /// @param tokenId the id of the token to override these things for
    /// @param overrideBaseURI whether the base URI should be overridden or `_tokenURI` should be
    /// appended to it
    /// @param overrideReveal whether the token should be individually revealed
    /// @param _tokenURI the new token URI
    function setTokenURI(
        uint256 tokenId,
        bool overrideBaseURI,
        bool overrideReveal,
        string memory _tokenURI
    ) external;

    /// @notice Sets the unrevealed token uri. Emits {UnrevealedTokenUriSet}.
    /// @param unrevealedTokenURI the new unrevealed token URI
    function setUnrevealedTokenURI(string memory unrevealedTokenURI) external;

    /// @notice Sets the base URI. Emits {SetBaseURI}.
    /// @param baseURI the new base uri
    function setBaseURI(string memory baseURI) external;

    /// @notice Returns whether the token `tokenId` overrides the full base URI.
    /// @param tokenId the id of the token to check
    /// @return overridesBaseURI whether the token overrides the full base URI
    function overridesFullURI(uint256 tokenId)
        external
        view
        returns (bool overridesBaseURI);

    /// @notice Returns whether the token `tokenId` is revealed.
    /// @param tokenId the id of the token to check
    /// @return revealed whether the token is revealed
    function tokenRevealed(uint256 tokenId)
        external
        view
        returns (bool revealed);
}

File 8 of 36 : IERC721OmmgMetadataFreezable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IERC721OmmgMetadataFreezable
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves as an extension to {IERC721OmmgMetadata} and adds
/// functionality to freeze the metadata, effectively making it immutable.
interface IERC721OmmgMetadataFreezable {
    error MetadataIsFrozen();
    /// @notice Triggers when the metadata is frozen
    event MetadataFrozen();

    /// @notice Returns whether the metadata is frozen.
    /// @return frozen whether the metadata is frozen or not
    function metadataFrozen() external view returns (bool frozen);

    /// @notice Freezes the metadata to effectively turn it immutable. Emits {MetadataFrozen}.
    /// Fails if the metadata is already frozen.
    function freezeMetadata() external;
}

File 9 of 36 : IOmmgAcquirable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgAcquirable
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves for the simple minting functionality of the OMMG Artist Contracts.
interface IOmmgAcquirable {
    /// @notice Mints `amount` NFTs of this contract. The more minted at once, the cheaper gas is for each token.
    /// However, the upper limit for `amount` can be queried via `maxBatchSize`. Fails if the user does not provide
    /// the correct amount of eth, if sale is paused, if the supply catch is reached, or if `maxBatchSize` is exceeded.
    /// @param amount the amount of NFTs to mint.
    function acquire(uint256 amount) external payable;

    /// @notice Mints `amount` NFTs of this contract to `receiver`. The more minted at once, the cheaper gas is for each token.
    /// However, the upper limit for `amount` can be queried via `maxBatchSize`. Fails if the supply catch is reached,
    /// or if `maxBatchSize` is exceeded.
    /// @param receiver the receiver of the NFTs.
    /// @param amount the amount of NFTs to mint.
    function acquireForCommunity(address receiver, uint256 amount) external;
}

File 10 of 36 : IOmmgAcquirableWithToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../def/TokenDiscount.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgAcquirableWithToken
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves for the extended minting functionality of the Ommg Artist Contracts.
/// The general functionality is that special prices can be configured for users to mint if they hold other
/// NFTs. Each NFT can only be used once to receive this discount, unless specifically reset.
interface IOmmgAcquirableWithToken {
    error TokenNotOwned(IERC721 token, uint256 tokenIds);
    error TokenAlreadyUsed(IERC721 token, uint256 tokenId);
    error TokenNotConfigured(IERC721 token);
    error TokenNotActive(IERC721 token);
    error TokenAlreadyConfigured(IERC721 token);
    error TokenSupplyExceeded(IERC721 token, uint256 supplyCap);

    /// @notice Triggers when a token discount is added.
    /// @param tokenAddress the addres of the added NFT contract for discounts
    /// @param config a tuple [uint256 price, uint256 limit, bool active] that represents the configuration for
    /// the discount
    event TokenDiscountAdded(
        IERC721 indexed tokenAddress,
        TokenDiscountConfig config
    );
    /// @notice Triggers when a token discount is updated.
    /// @param tokenAddress the addres of the added NFT contract for discounts
    /// @param config a tuple [uint256 price, uint256 limit, bool active] that represents the new configuration for
    /// the discount
    event TokenDiscountUpdated(
        IERC721 indexed tokenAddress,
        TokenDiscountConfig config
    );
    /// @notice Triggers when a token discount is removed.
    /// @param tokenAddress the addres of the NFT contract
    event TokenDiscountRemoved(IERC721 indexed tokenAddress);
    /// @notice Triggers when a token discount is reset - meaning all token usage data is reset and all tokens
    /// are marked as unused again.
    /// @param tokenAddress the addres of the NFT contract
    event TokenDiscountReset(IERC721 indexed tokenAddress);
    /// @notice Triggers when a token discount is used for a discount and then marked as used
    /// @param sender the user who used the token
    /// @param tokenAddress the addres of the NFT contract
    /// @param tokenId the id of the NFT used for the discount
    event TokenUsedForDiscount(
        address indexed sender,
        IERC721 indexed tokenAddress,
        uint256 indexed tokenId
    );

    /// @notice Adds an NFT contract and thus all of it's tokens to the discount list.
    /// Emits a {TokenDiscountAdded} event and fails if `tokenAddress` is the zero address
    /// or is already configured.
    /// @param tokenAddress the address of the NFT contract
    /// @param config the initial configuration as [uint256 price, uint256 limit, bool active]
    function addTokenDiscount(
        IERC721 tokenAddress,
        TokenDiscountConfig memory config
    ) external;

    /// @notice Removes an NFT contract from the discount list.
    /// Emits a {TokenDiscountRemoved} event and fails if `tokenAddress` is the zero address
    /// or is not already configured.
    /// @param tokenAddress the address of the NFT contract
    function removeTokenDiscount(IERC721 tokenAddress) external;

    /// @notice Updates an NFT contracts configuration of the discount.
    /// Emits a {TokenDiscountUpdated} event and fails if `tokenAddress` is the zero address
    /// or is not already configured.
    /// @param tokenAddress the address of the NFT contract
    /// @param config the new configuration as [uint256 price, uint256 limit, bool active]
    function updateTokenDiscount(
        IERC721 tokenAddress,
        TokenDiscountConfig memory config
    ) external;

    /// @notice Resets the usage state of all NFTs of the contract at `tokenAddress`. This allows all token ids
    /// to be used again.
    /// Emits a {TokenDiscountReset} event and fails if `tokenAddress` is the zero address
    /// or is not already configured.
    /// @param tokenAddress the address of the NFT contract
    function resetTokenDiscountUsed(IERC721 tokenAddress) external;

    /// @notice Returns the current configuration of the token discount of `tokenAddress`
    /// @return config the configuration as [uint256 price, uint256 limit, bool active]
    function tokenDiscountInfo(IERC721 tokenAddress)
        external
        view
        returns (TokenDiscountOutput memory config);

    /// @notice Returns a list of all current tokens configured for discounts and their configurations.
    /// @return discounts the configuration as [IERC721 tokenAddress, [uint256 price, uint256 limit, bool active]]
    function tokenDiscounts()
        external
        view
        returns (TokenDiscountOutput[] memory discounts);

    /// @notice Acquires an NFT of this contract by proving ownership of the tokens in `tokenIds` belonging to
    /// a contract `tokenAddress` that has a configured discount. This way cheaper prices can be achieved for OMMG holders
    /// and potentially other partners. Emits {TokenUsedForDiscount} and requires the user to send the correct amount of
    /// eth as well as to own the tokens within `tokenIds` from `tokenAddress`, and for `tokenAddress` to be a configured token for discounts.
    /// @param tokenAddress the address of the contract which is the reference for `tokenIds`
    /// @param tokenIds the token ids which are to be used to get the discount
    function acquireWithToken(IERC721 tokenAddress, uint256[] memory tokenIds)
        external
        payable;

    /// @notice Sets the active status of the token discount of `tokenAddress`.
    /// Fails if `tokenAddress` is the zero address or is not already configured.
    /// @param tokenAddress the configured token address
    /// @param active the new desired activity state
    function setTokenDiscountActive(IERC721 tokenAddress, bool active)
        external;

    /// @notice Returns whether the tokens `tokenIds` of `tokenAddress` have already been used for a discount.
    /// Fails if `tokenAddress` is the zero address or is not already configured.
    /// @param tokenAddress the address of the token contract
    /// @param tokenIds the ids to check
    /// @return used if the tokens have already been used, each index corresponding to the
    /// token id index in the array
    function tokensUsedForDiscount(
        IERC721 tokenAddress,
        uint256[] memory tokenIds
    ) external view returns (bool[] memory used);
}

File 11 of 36 : IOmmgEmergencyTokenRecoverable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgEmergencyTokenRecoverable
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for emergency ERC20 token recovery. This is needed
/// in the case that someone accidentally sent ERC20 tokens to this contract.
interface IOmmgEmergencyTokenRecoverable {
    /// @notice Triggers when ERC20 tokens are recovered
    /// @param token The address of the ERC20 token contract
    /// @param receiver The recipient of the tokens
    /// @param amount the amount of tokens recovered
    event TokensRecovered(
        IERC20 indexed token,
        address indexed receiver,
        uint256 amount
    );

    /// @notice Recovers ERC20 tokens
    /// @param token The address of the ERC20 token contract
    /// @param receiver The recipient of the tokens
    /// @param amount the amount of tokens to recover
    function emergencyRecoverTokens(
        IERC20 token,
        address receiver,
        uint256 amount
    ) external;
}

File 12 of 36 : IOmmgWithdrawable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "../def/Shareholder.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgWithdrawable
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for automatic distribution of the contract balance
/// to shareholders based on their held shares
interface IOmmgWithdrawable {
    /// @notice triggers whenever a shareholder is added to the contract
    /// @param addr the address of the shareholder
    /// @param shares the number of shares held by the holder
    event ShareholderAdded(address indexed addr, uint256 shares);
    /// @notice triggers whenever a shareholder is added to the contract
    /// @param addr the address of the former shareholder
    /// @param shares the number of shares that was held by the former holder
    event ShareholderRemoved(address indexed addr, uint256 shares);
    /// @notice triggers whenever a shareholder is updated
    /// @param addr the address of the shareholder
    /// @param shares the new number of shares held by the holder
    event ShareholderUpdated(address indexed addr, uint256 shares);
    /// @notice triggers whenever funds are withdrawn
    /// @param txSender the sender of the transaction
    /// @param amount the amount of eth withdrawn
    event Withdrawn(address indexed txSender, uint256 amount);
    /// @notice triggers whenever an emergency withdraw is executed
    /// @param txSender the transaction sender
    /// @param amount the amount of eth withdrawn
    event EmergencyWithdrawn(address indexed txSender, uint256 amount);
    /// @notice triggers whenever a shareholder receives their share of a withdrawal
    /// @param txSender the address that initiated the withdrawal
    /// @param to the address of the shareholder receiving this part of the withdrawal
    /// @param amount the amount of eth received by `to`
    event PaidOut(
        address indexed txSender,
        address indexed to,
        uint256 amount
    );
    /// @notice fires whenever a shareholder already exists but is attempted to be added
    /// @param addr the address already added
    error ShareholderAlreadyExists(address addr);
    /// @notice fires whenever a shareholder does not exist but an access is attempted
    /// @param addr the address of the attempted shareholder acces
    error ShareholderDoesNotExist(address addr);

    /// @notice withdraws the current balance from this contract and distributes it to shareholders
    /// according to their held shares. Triggers a {Withdrawn} event and a {PaidOut} event per shareholder.
    function withdraw() external;

    /// @notice withdraws the current balance from this contract and sends it to the
    /// initiator of the transaction. Triggers an {EmergencyWithdrawn} event.
    function emergencyWithdraw() external;

    /// @notice Adds a shareholder to the contract. When `withdraw` is called,
    /// the shareholder will receive an amount of native tokens proportional to
    /// their shares. Triggers a {ShareholderAdded} event.
    /// Requires `walletAddress` to not be the ZeroAddress and for the shareholder to not already exist,
    /// as well as for `shares` to be greater than 0.
    /// @param walletAddress the address of the shareholder
    /// @param shares the number of shares assigned to that shareholder
    function addShareholder(address walletAddress, uint256 shares) external;

    /// @notice Removes a shareholder from the contract. Triggers a {ShareholderRemoved} event.
    /// Requires `walletAddress` to not be the ZeroAddress and for the shareholder to exist.
    /// @param walletAddress the address of the shareholder to remove
    function removeShareholder(address walletAddress) external;

    /// @notice Updates a shareholder of the contract. Triggers a {ShareholderUpdated} event.
    /// Requires `walletAddress` to not be the ZeroAddress and for the shareholder to exist.
    /// @param walletAddress the address of the shareholder to remove
    /// @param updatedShares the new amount of shares the shareholder will have
    function updateShareholder(address walletAddress, uint256 updatedShares)
        external;

    /// @notice returns a list of all shareholders with their shares
    /// @return shareholders An array of tuples [address, shares], see the {Shareholder} struct
    function shareholders()
        external
        view
        returns (Shareholder[] memory shareholders);

    /// @notice returns the total amount of shares that exist
    /// @return shares the total number of shares in the contract
    function totalShares() external view returns (uint256 shares);

    /// @notice returns the number of shares held by `shareholderAddress`
    /// @return shares the number of shares held by `shareholderAddress`
    function shares(address shareholderAddress)
        external
        view
        returns (uint256 shares);
}

File 13 of 36 : IOmmgProvenanceHash.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgProvenanceHash
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for a freezable provenance hash, to enable full trust that
/// the metadata of the underlying token is not predetermined or tampered with.
interface IOmmgProvenanceHash {
    /// @notice Triggers when an attempt is made to change the provenance
    /// hash after it has been frozen
    error ProvenanceHashIsFrozen();
    /// @notice Triggers when the provenance hash is set to a new value.
    /// @param provenanceHash the new provenance hash.
    event ProvenanceHashSet(string indexed provenanceHash);
    /// @notice Triggers when the provenance hash is frozen.
    event ProvenanceHashFrozen();

    /// @notice Returns the current provenance hash. The idea is for this to be
    /// the proof that the order of token metada has not been tampered with and
    /// that it has not been predetermined.
    /// @return provenanceHash the provenance hash
    function provenanceHash()
        external
        view
        returns (string memory provenanceHash);

    /// @notice Returns a boolean value indicating whether the provenance hash
    /// has been frozen or not. A frozen provenance hash is immutable.
    /// @return isFrozen whether it is frozen or not
    function provenanceFrozen() external view returns (bool isFrozen);

    /// @notice Updates the provenance hash to the new value `provenanceHash`.
    /// Also triggers the event {ProvenanceHashSet} and reverts if the provenance
    /// hash has already been frozen.
    function setProvenanceHash(string memory provenanceHash) external;

    /// @notice freezes the provenance hash and thus makes it immutable.
    /// Triggers a {ProvenanceHashFrozen} event and reverts if the hash is already frozen.
    function freezeProvenance() external;
}

File 14 of 36 : IOmmgMutablePrice.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgMutablePrice
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for a simple mutable price implementation.
interface IOmmgMutablePrice {
    /// @notice Triggers when the price gets changes.
    /// @param newPrice the new price
    event PriceChanged(uint256 newPrice);

    /// @notice Returns the current price.
    /// @return price the current price
    function price() external view returns (uint256 price);

    /// @notice Sets the price to `price`.
    function setPrice(uint256 price) external;
}

File 15 of 36 : IOmmgSalePausable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgSalePausable
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for a simple mutable sale state on any contract
interface IOmmgSalePausable {
    error SaleNotActive();
    /// @notice This event gets triggered whenever the sale state changes
    /// @param newValue the new sale state
    event SaleIsActiveSet(bool newValue);

    /// @notice This function returns a boolean value indicating whether
    /// the public sale is currently active or not
    /// returns currentState whether the sale is active or not
    function saleIsActive() external view returns (bool currentState);

    /// @notice This function can be used to change the sale state to `newValue`.
    /// Triggers a {SaleIsActiveSet} event.
    /// @param newValue the desired new value for the sale state
    function setSaleIsActive(bool newValue) external;
}

File 16 of 36 : IOmmgSupplyCap.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgSupplyCap
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for a supply cap on any contract
interface IOmmgSupplyCap {
    /// @notice this returns the supply cap of the token
    /// @return supplyCap the supply cap of the token
    function supplyCap() external view returns (uint256 supplyCap);
}

File 17 of 36 : IOmmgFrontEnd.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../def/TokenDiscount.sol";

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgFrontEnd
/// @author NotAMeme aka nxlogixnick
/// @notice This interface is for the minting front end
interface IOmmgFrontEnd {
    /// @notice Returns a list of all current tokens configured for discounts and their configurations.
    /// @return discounts the configuration as [IERC721 tokenAddress, [uint256 price, uint256 limit, bool active]]
    function tokenDiscounts()
        external
        view
        returns (TokenDiscountOutput[] memory discounts);

    /// @notice Returns the maximum number of tokens mintable in one transaction
    /// @return maxBatch the maximum amount
    function maxBatchSize() external view returns (uint256 maxBatch);

    /// @notice Acquires an NFT of this contract by proving ownership of the tokens in `tokenIds` belonging to
    /// a contract `tokenAddress` that has a configured discount. This way cheaper prices can be achieved for OMMG holders
    /// and potentially other partners. Emits {TokenUsedForDiscount} and requires the user to send the correct amount of
    /// eth as well as to own the tokens within `tokenIds` from `tokenAddress`, and for `tokenAddress` to be a configured token for discounts.
    /// @param tokenAddress the address of the contract which is the reference for `tokenIds`
    /// @param tokenIds the token ids which are to be used to get the discount
    function acquireWithToken(IERC721 tokenAddress, uint256[] memory tokenIds)
        external
        payable;

    /// @notice Returns whether the tokens `tokenIds` of `tokenAddress` have already been used for a discount.
    /// Fails if `tokenAddress` is the zero address or is not already configured.
    /// @param tokenAddress the address of the token contract
    /// @param tokenIds the ids to check
    /// @return used if the tokens have already been used, each index corresponding to the
    /// token id index in the array
    function tokensUsedForDiscount(
        IERC721 tokenAddress,
        uint256[] memory tokenIds
    ) external view returns (bool[] memory used);

    /// @notice Mints `amount` NFTs of this contract. The more minted at once, the cheaper gas is for each token.
    /// However, the upper limit for `amount` can be queried via `maxBatchSize`. Fails if the user does not provide
    /// the correct amount of eth, if sale is paused, if the supply catch is reached, or if `maxBatchSize` is exceeded.
    /// @param amount the amount of NFTs to mint.
    function acquire(uint256 amount) external payable;

    /// @notice this returns the supply cap of the token
    /// @return supplyCap the supply cap of the token
    function supplyCap() external view returns (uint256 supplyCap);

    /// @notice Returns the current price.
    /// @return price the current price
    function price() external view returns (uint256 price);

    /// @notice This function returns a boolean value indicating whether
    /// the public sale is currently active or not
    /// returns currentState whether the sale is active or not
    function saleIsActive() external view returns (bool currentState);

    /// @notice This function returns the total amount of tokens still available
    /// of the total supply
    function tokensAvailable() external view returns (uint256 amount);

    // docs are in IERC721Metadata
    function name() external view returns (string memory name);

    // docs are in IERC721Metadata
    function symbol() external view returns (string memory name);
}

File 18 of 36 : ArtistContractConfig.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import "../def/Shareholder.sol";
import "../def/TokenDiscount.sol";

struct ArtistContractConfig {
    string name;
    string symbol;
    address[] withdrawAdmins;
    address[] stateAdmins;
    address[] mintForFree;
    uint256 initialPrice;
    uint256 supplyCap;
    uint256 maxBatchSize;
    Shareholder[] shareholders;
    TokenDiscountInput[] tokenDiscounts;
}

File 19 of 36 : CustomErrors.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.11;

/// @dev triggered when an address is the null address
error NullAddress();

error TokenDoesNotExist(uint256 tokenId);
error TokenAlreadyExists(uint256 tokenId);

error SafeTransferFailed(address from, address to, uint256 tokenId);

error TargetNonERC721Receiver(address target);

error TransferUnauthorized(
    address sender,
    address from,
    address to,
    uint256 tokenId,
    address tokenOwner
);

error IndexOutOfBounds(uint256 index, uint256 max);

error ApprovalForAllInvalid(address target, bool targetState);
error ApprovalInvalid(address account, uint256 tokenId);
error ApprovalUnauthorized(
    address from,
    address to,
    uint256 tokenId,
    address sender
);
error OperationFailed();

error InvalidAmount(uint256 amount, uint256 minAmount, uint256 maxAmount);
error AmountExceedsCap(uint256 amount, uint256 available, uint256 cap);
error InvalidMessageValue(uint256 value, uint256 needed);
error ZeroShares();

File 20 of 36 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.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));
        }
    }

    /**
     * @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");
        }
    }
}

File 21 of 36 : IOmmgSnapshot.sol
// SPDX-License-Identifier: BSD-3-Clause

pragma solidity ^0.8.0;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title ISnapshottable
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for simple snapshots of all tokens
interface IOmmgSnapshot {
    enum TokenStatus {
        OWNED,
        BURNED
    }
    struct TokenInfo {
        uint256 tokenId;
        TokenStatus status;
        address owner;
    }

    /// @notice Returns an array of tuples [tokenId, tokenStatus, owner] with the
    /// current state of each minted token. A tokenStatus of 0 means it exists, 1 signals that
    /// the token has been burned.
    /// @return tokenStates the states of all minted tokens
    function snapshot() external view returns (TokenInfo[] memory tokenStates);
}

File 22 of 36 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}

File 23 of 36 : ERC165.sol
// 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;
    }
}

File 24 of 36 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 25 of 36 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 26 of 36 : Context.sol
// 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;
    }
}

File 27 of 36 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 28 of 36 : IERC165.sol
// 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);
}

File 29 of 36 : OmmgOwnable.sol
// SPDX-License-Identifier: MIT

import "@openzeppelin/contracts/utils/Context.sol";
import "../interfaces/IOmmgOwnable.sol";
import "../def/CustomErrors.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

pragma solidity ^0.8.11;

abstract contract OmmgOwnable is IOmmgOwnable, Context, ERC165 {
    address private _owner;

    /// @dev Initializes the contract setting the deployer as the initial owner.
    constructor() {
        _setOwner(_msgSender());
    }

    ///@dev Reverts if called by any account other than the owner
    modifier onlyOwner() {
        if (owner() != _msgSender())
            revert OwnershipUnauthorized(_msgSender());
        _;
    }

    /// @dev Returns the address of the current owner.
    function owner() public view override returns (address) {
        return _owner;
    }

    /// @dev Leaves the contract without owner. It will not be possible to call
    /// `onlyOwner` functions anymore. Can only be called by the current owner
    function renounceOwnershipPermanently() public override onlyOwner {
        _setOwner(address(0));
    }

    /// @dev Transfers ownership of the contract to a new account (`newOwner`).
    /// Can only be called by the current owner.
    function transferOwnership(address newOwner) public override onlyOwner {
        if (newOwner == address(0)) revert NullAddress();
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            interfaceId == type(IOmmgOwnable).interfaceId ||
            super.supportsInterface(interfaceId);
    }
}

File 30 of 36 : IOmmgAccessControl.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgAccessControl
/// @author NotAMeme aka nxlogixnick
/// @notice This interface serves for a lightweight custom implementation of role based permissions.
interface IOmmgAccessControl {
    struct RoleData {
        mapping(address => bool) members;
    }

    /// @notice Triggers when an unauthorized address attempts
    /// a restricted action
    /// @param account initiated the unauthorized action
    /// @param missingRole the missing role identifier
    error Unauthorized(address account, bytes32 missingRole);

    /// @notice Emitted when `account` is granted `role`
    /// @param role the role granted
    /// @param account the account that is granted `role`
    /// @param sender the address that initiated this action
    event RoleGranted(
        bytes32 indexed role,
        address indexed account,
        address indexed sender
    );

    /// @notice Emitted when `account` is revoked `role`
    /// @param role the role revoked
    /// @param account the account that is revoked `role`
    /// @param sender the address that initiated this action
    event RoleRevoked(
        bytes32 indexed role,
        address indexed account,
        address indexed sender
    );

    /// @notice Returns `true` if `account` has been granted `role`.
    /// @param role the role identifier
    /// @param account the account to check
    /// @return hasRole whether `account` has `role` or not.
    function hasRole(bytes32 role, address account)
        external
        view
        returns (bool hasRole);

    /// @notice Grants `role` to `account`. Emits {RoleGranted}.
    /// @param role the role identifier
    /// @param account the account to grant `role` to
    function grantRole(bytes32 role, address account) external;

    /// @notice Grants `role` to `account`. Emits {RoleRevoked}.
    /// @param role the role identifier
    /// @param account the account to revoke `role` from
    function revokeRole(bytes32 role, address account) external;

    /// @notice Rennounces `role` from the calling account. Emits {RoleRevoked}.
    /// @param role the role identifier of the role to rennounce
    function renounceRole(bytes32 role) external;
}

File 31 of 36 : IOmmgOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

//  .----------------.  .----------------.  .----------------.  .----------------.
// | .--------------. || .--------------. || .--------------. || .--------------. |
// | |     ____     | || | ____    ____ | || | ____    ____ | || |    ______    | |
// | |   .'    `.   | || ||_   \  /   _|| || ||_   \  /   _|| || |  .' ___  |   | |
// | |  /  .--.  \  | || |  |   \/   |  | || |  |   \/   |  | || | / .'   \_|   | |
// | |  | |    | |  | || |  | |\  /| |  | || |  | |\  /| |  | || | | |    ____  | |
// | |  \  `--'  /  | || | _| |_\/_| |_ | || | _| |_\/_| |_ | || | \ `.___]  _| | |
// | |   `.____.'   | || ||_____||_____|| || ||_____||_____|| || |  `._____.'   | |
// | |              | || |              | || |              | || |              | |
// | '--------------' || '--------------' || '--------------' || '--------------' |
//  '----------------'  '----------------'  '----------------'  '----------------'

/// @title IOmmgProvenanceHash
/// @author NotAMeme aka nxlogixnick
/// @notice An interface for a custom implementation of Ownable contracts.
interface IOmmgOwnable {
    /// @dev Triggers when an unauthorized address attempts
    /// a restricted action
    /// @param account initiated the unauthorized action
    error OwnershipUnauthorized(address account);
    /// @dev Triggers when the ownership is transferred
    /// @param previousOwner the previous owner of the contract
    /// @param newOwner the new owner of the contract
    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    /// @notice Returns the current owner address.
    /// @return owner the address of the current owner
    function owner() external view returns (address owner);

    /// @notice Leaves the contract without owner. It will not be possible to call
    /// `onlyOwner` functions anymore. Can only be called by the current owner.
    /// Triggers the {OwnershipTransferred} event.
    function renounceOwnershipPermanently() external;

    /// @notice Transfers the ownership to `newOwner`.
    /// Triggers the {OwnershipTransferred} event.
    /// `newOwner` can not be the zero address.
    /// @param newOwner the new owner of the contract
    function transferOwnership(address newOwner) external;
}

File 32 of 36 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 33 of 36 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @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);
}

File 34 of 36 : TokenDiscount.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

struct TokenDiscountConfig {
    uint256 price;
    uint256 supply;
    bool active;
}
struct TokenDiscountInput {
    IERC721 tokenAddress;
    TokenDiscountConfig config;
}
struct TokenDiscountOutput {
    IERC721 tokenAddress;
    string name;
    string symbol;
    uint256 usedAmount;
    TokenDiscountConfig config;
}

File 35 of 36 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 36 of 36 : Shareholder.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

struct Shareholder {
    address addr;
    uint256 shares;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address[]","name":"withdrawAdmins","type":"address[]"},{"internalType":"address[]","name":"stateAdmins","type":"address[]"},{"internalType":"address[]","name":"mintForFree","type":"address[]"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"maxBatchSize","type":"uint256"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"internalType":"struct Shareholder[]","name":"shareholders","type":"tuple[]"},{"components":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"internalType":"struct TokenDiscountInput[]","name":"tokenDiscounts","type":"tuple[]"}],"internalType":"struct ArtistContractConfig","name":"config","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"},{"internalType":"uint256","name":"cap","type":"uint256"}],"name":"AmountExceedsCap","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"targetState","type":"bool"}],"name":"ApprovalForAllInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ApprovalInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"sender","type":"address"}],"name":"ApprovalUnauthorized","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"IndexOutOfBounds","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"InvalidAmount","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InvalidMessageValue","type":"error"},{"inputs":[],"name":"MetadataIsFrozen","type":"error"},{"inputs":[],"name":"NullAddress","type":"error"},{"inputs":[],"name":"OperationFailed","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnershipUnauthorized","type":"error"},{"inputs":[],"name":"ProvenanceHashIsFrozen","type":"error"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"SafeTransferFailed","type":"error"},{"inputs":[],"name":"SaleNotActive","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"ShareholderAlreadyExists","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"ShareholderDoesNotExist","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"TargetNonERC721Receiver","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"}],"name":"TokenAlreadyConfigured","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenAlreadyUsed","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenDoesNotExist","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"}],"name":"TokenNotActive","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"}],"name":"TokenNotConfigured","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenIds","type":"uint256"}],"name":"TokenNotOwned","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"supplyCap","type":"uint256"}],"name":"TokenSupplyExceeded","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"TransferUnauthorized","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"missingRole","type":"bytes32"}],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroShares","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":true,"internalType":"address","name":"txSender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdrawn","type":"event"},{"anonymous":false,"inputs":[],"name":"MetadataFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"txSender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaidOut","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"PriceChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"ProvenanceHashFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"provenanceHash","type":"string"}],"name":"ProvenanceHashSet","type":"event"},{"anonymous":false,"inputs":[],"name":"Revealed","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":false,"internalType":"bool","name":"newValue","type":"bool"}],"name":"SaleIsActiveSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"baseURI","type":"string"}],"name":"SetBaseUri","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"fullOverride","type":"bool"},{"indexed":false,"internalType":"bool","name":"tokenRevealedOverride","type":"bool"},{"indexed":true,"internalType":"string","name":"tokenURI","type":"string"}],"name":"SetTokenUri","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ShareholderAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ShareholderRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ShareholderUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"indexed":false,"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"name":"TokenDiscountAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"tokenAddress","type":"address"}],"name":"TokenDiscountRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"tokenAddress","type":"address"}],"name":"TokenDiscountReset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"indexed":false,"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"name":"TokenDiscountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenRevealed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenUsedForDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensRecovered","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"unrevealedTokenURI","type":"string"}],"name":"UnrevealedTokenUriSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"txSender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"Artist","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_FREE_ACQUIRE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_STATE_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTRACT_WITHDRAW_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"acquire","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"acquireForCommunity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"acquireWithToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"addShareholder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"name":"addTokenDiscount","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyRecoverTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"freezeProvenance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"operator","type":"address"}],"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":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBatchSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metadataFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"overridesFullURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenanceFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenanceHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"}],"name":"removeShareholder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"}],"name":"removeTokenDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnershipPermanently","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"}],"name":"resetTokenDiscountUsed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"revealToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","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":[],"name":"saleIsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"provenanceHash_","type":"string"}],"name":"setProvenanceHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newValue","type":"bool"}],"name":"setSaleIsActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"internalType":"bool","name":"active","type":"bool"}],"name":"setTokenDiscountActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"overrideBaseURI","type":"bool"},{"internalType":"bool","name":"overrideReveal","type":"bool"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"unrevealedTokenURI","type":"string"}],"name":"setUnrevealedTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareholders","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"internalType":"struct Shareholder[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"}],"name":"shares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"snapshot","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"enum IOmmgSnapshot.TokenStatus","name":"status","type":"uint8"},{"internalType":"address","name":"owner","type":"address"}],"internalType":"struct IOmmgSnapshot.TokenInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"supplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"}],"name":"tokenDiscountInfo","outputs":[{"components":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"usedAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"internalType":"struct TokenDiscountOutput","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenDiscounts","outputs":[{"components":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"usedAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"internalType":"struct TokenDiscountOutput[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenRevealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensAvailable","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"tokensUsedForDiscount","outputs":[{"internalType":"bool[]","name":"used","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"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":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"},{"internalType":"uint256","name":"updatedShares","type":"uint256"}],"name":"updateShareholder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"tokenAddress","type":"address"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct TokenDiscountConfig","name":"config","type":"tuple"}],"name":"updateTokenDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c060405260016002553480156200001657600080fd5b50604051620064bc380380620064bc833981016040819052620000399162000af3565b60e081015181906200004b3362000213565b608052805180516200006691600b91602090910190620006ca565b5060208082015180516200007f92600c920190620006ca565b5060a08082015160085560c082015190526040810151620000c1907f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a362000263565b6060810151620000f2907f7e69b879a040173b938f56bb64bfa62bcd758c08ae6ed7cfdf7da6d7dba9270862000263565b608081015162000123907ffdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e62000263565b6101008101515160005b8261010001515181101562000183576200016e83610100015182815181106200015a576200015a62000c76565b6020026020010151620002c260201b60201c565b806200017a8162000ca2565b9150506200012d565b50506101208101515160005b818110156200020957620001f48361012001518281518110620001b657620001b662000c76565b6020026020010151600001518461012001518381518110620001dc57620001dc62000c76565b6020026020010151602001516200048b60201b60201c565b80620002008162000ca2565b9150506200018f565b5050505062000d18565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b81518015620002bd5760005b81811015620002bb57620002a68385838151811062000292576200029262000c76565b60200260200101516200060360201b60201c565b80620002b28162000ca2565b9150506200026f565b505b505050565b6020810151620002e557604051639811e0c760e01b815260040160405180910390fd5b80516001600160a01b03166200030e5760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b81811015620003a35782600001516001600160a01b03166013828154811062000341576200034162000c76565b60009182526020909120600290910201546001600160a01b031614156200038e5782516040516370d2049160e01b81526001600160a01b0390911660048201526024015b60405180910390fd5b806200039a8162000ca2565b91505062000314565b5060138054600181018255600091825283517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a090600290920291820180546001600160a01b0319166001600160a01b0390921691909117905560208401517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a09190910181905560098054919290916200043c90849062000cc0565b909155505081516020808401516040519081526001600160a01b03909216917f3bc19114ca6a687ffd9445c87615db284e96364365d72b010ec53244b45e561b91015b60405180910390a25050565b6001600160a01b038216620004b35760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03821660009081526015602052604090205460ff1615620004fa576040516354d67cef60e01b81526001600160a01b038316600482015260240162000385565b6001600160a01b0382166000908152601560209081526040808320805460ff1916600117905560179091528120805491620005358362000ca2565b90915550506001600160a01b038216600081815260196020908152604080832085518155858301805160018084019190915587840180516002909401805460ff1916941515949094179093556014805491820181559095527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec90940180546001600160a01b0319168617905581518651815293519284019290925290511515908201527fab109b1e3dd4bf279798315182b336f138e930aec9aaeafe98f768450d9fd9b7906060016200047f565b6000546001600160a01b031633146200063257604051630e60d8d360e41b815233600482015260240162000385565b6200063e828262000642565b5050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166200063e5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b828054620006d89062000cdb565b90600052602060002090601f016020900481019282620006fc576000855562000747565b82601f106200071757805160ff191683800117855562000747565b8280016001018555821562000747579182015b82811115620007475782518255916020019190600101906200072a565b506200075592915062000759565b5090565b5b808211156200075557600081556001016200075a565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715620007ab57620007ab62000770565b60405290565b604051606081016001600160401b0381118282101715620007ab57620007ab62000770565b60405161014081016001600160401b0381118282101715620007ab57620007ab62000770565b604051601f8201601f191681016001600160401b038111828210171562000827576200082762000770565b604052919050565b600082601f8301126200084157600080fd5b81516001600160401b038111156200085d576200085d62000770565b602062000873601f8301601f19168201620007fc565b82815285828487010111156200088857600080fd5b60005b83811015620008a85785810183015182820184015282016200088b565b83811115620008ba5760008385840101525b5095945050505050565b60006001600160401b03821115620008e057620008e062000770565b5060051b60200190565b6001600160a01b03811681146200090057600080fd5b50565b600082601f8301126200091557600080fd5b815160206200092e6200092883620008c4565b620007fc565b82815260059290921b840181019181810190868411156200094e57600080fd5b8286015b84811015620009765780516200096881620008ea565b835291830191830162000952565b509695505050505050565b600082601f8301126200099357600080fd5b81516020620009a66200092883620008c4565b82815260069290921b84018101918181019086841115620009c657600080fd5b8286015b84811015620009765760408189031215620009e55760008081fd5b620009ef62000786565b8151620009fc81620008ea565b81528185015185820152835291830191604001620009ca565b600082601f83011262000a2757600080fd5b8151602062000a3a6200092883620008c4565b82815260079290921b8401810191818101908684111562000a5a57600080fd5b8286015b848110156200097657808803608081121562000a7a5760008081fd5b62000a8462000786565b825162000a9181620008ea565b81526060601f19830181131562000aa85760008081fd5b62000ab2620007b1565b925086840151835260408085015188850152818501519150811515821462000ada5760008081fd5b8301528086019190915283529183019160800162000a5e565b60006020828403121562000b0657600080fd5b81516001600160401b038082111562000b1e57600080fd5b90830190610140828603121562000b3457600080fd5b62000b3e620007d6565b82518281111562000b4e57600080fd5b62000b5c878286016200082f565b82525060208301518281111562000b7257600080fd5b62000b80878286016200082f565b60208301525060408301518281111562000b9957600080fd5b62000ba78782860162000903565b60408301525060608301518281111562000bc057600080fd5b62000bce8782860162000903565b60608301525060808301518281111562000be757600080fd5b62000bf58782860162000903565b60808301525060a083015160a082015260c083015160c082015260e083015160e0820152610100808401518381111562000c2e57600080fd5b62000c3c8882870162000981565b828401525050610120808401518381111562000c5757600080fd5b62000c658882870162000a15565b918301919091525095945050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141562000cb95762000cb962000c8c565b5060010190565b6000821982111562000cd65762000cd662000c8c565b500190565b600181811c9082168062000cf057607f821691505b6020821081141562000d1257634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05161573162000d8b6000396000818161096801528181611cc4015281816134180152818161345f015261349f01526000818161061301528181611fa4015281816133be015281816133f201528181613886015281816138b00152818161463c015261468801526157316000f3fe6080604052600436106104055760003560e01c806383085d0911610213578063b88d4fde11610123578063db2e21bc116100ab578063e985e9c51161007a578063e985e9c514610c5d578063eb8d244414610ca6578063f2fde38b14610cc3578063f6b9782d14610ce3578063fb3cc6c214610d1057600080fd5b8063db2e21bc14610bdf578063e110976f14610bf4578063e35bd96b14610c14578063e7d773a014610c4857600080fd5b8063ce7c2ac2116100f2578063ce7c2ac214610b48578063d111515d14610b68578063d2369e0414610b7d578063d547741f14610b9f578063d6a6346e14610bbf57600080fd5b8063b88d4fde14610ad3578063be52be2e14610af3578063c6ab67a314610b13578063c87b56dd14610b2857600080fd5b806391d14854116101a65780639d897351116101755780639d89735114610a49578063a035b1fe14610a69578063a22cb46514610a7e578063a4451df114610a9e578063a475b5dd14610abe57600080fd5b806391d14854146109ac57806395d89b41146109f25780639711715a14610a075780639babdad614610a2957600080fd5b80638bb9c5bf116101e25780638bb9c5bf1461091b5780638da5cb5b1461093b5780638f770ad01461095957806391b7f5ed1461098c57600080fd5b806383085d09146108a657806385f52846146108c6578063871b015a146108d95780638987470e146108f957600080fd5b8063327f64f31161031957806355f804b3116102a15780636352211e116102705780636352211e1461080657806370a08231146108265780637572499014610846578063820de0c51461086657806382dc439a1461088657600080fd5b806355f804b31461077d5780635a46cf3d1461079d5780635f74606c146107bd57806360659a92146107f157600080fd5b80633ccfd60b116102e85780633ccfd60b146106f057806342842e0e146107055780634f558e79146107255780634f6ccce714610745578063518302271461076557600080fd5b8063327f64f31461067757806334d2c0a3146106a45780633723bc0e146106b95780633a98ef39146106db57600080fd5b806314ea928a1161039c57806322be83b71161036b57806322be83b7146105c457806323b872dd146105e45780632913daa0146106045780632f2ff15d146106375780632f745c591461065757600080fd5b806314ea928a1461055d57806318160ddd1461057c5780631a729e671461059157806320889d3b146105b157600080fd5b8063095ea7b3116103d8578063095ea7b3146104bb5780630adeeae8146104db57806310355a43146104fb578063109695231461053d57600080fd5b806301ffc9a71461040a57806302c889891461043f57806306fdde0314610461578063081812fc14610483575b600080fd5b34801561041657600080fd5b5061042a610425366004614c22565b610d2e565b60405190151581526020015b60405180910390f35b34801561044b57600080fd5b5061045f61045a366004614c4d565b610ed2565b005b34801561046d57600080fd5b50610476610fa8565b6040516104369190614cc2565b34801561048f57600080fd5b506104a361049e366004614cd5565b61103a565b6040516001600160a01b039091168152602001610436565b3480156104c757600080fd5b5061045f6104d6366004614d03565b611081565b3480156104e757600080fd5b5061045f6104f6366004614d2f565b611138565b34801561050757600080fd5b5061052f7f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a381565b604051908152602001610436565b34801561054957600080fd5b5061045f610558366004614e17565b611275565b34801561056957600080fd5b50600a546301000000900460ff1661042a565b34801561058857600080fd5b5061052f611324565b34801561059d57600080fd5b5061045f6105ac366004614e4b565b611346565b61045f6105bf366004614cd5565b6114dc565b3480156105d057600080fd5b5061045f6105df366004614d03565b61156b565b3480156105f057600080fd5b5061045f6105ff366004614eb6565b6115e0565b34801561061057600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061052f565b34801561064357600080fd5b5061045f610652366004614ef7565b6115eb565b34801561066357600080fd5b5061052f610672366004614d03565b61162e565b34801561068357600080fd5b50610697610692366004614f27565b611701565b6040516104369190614fe1565b3480156106b057600080fd5b5061045f611801565b3480156106c557600080fd5b506106ce611825565b6040516104369190615027565b3480156106e757600080fd5b5060095461052f565b3480156106fc57600080fd5b5061045f61189a565b34801561071157600080fd5b5061045f610720366004614eb6565b611a84565b34801561073157600080fd5b5061042a610740366004614cd5565b611a9f565b34801561075157600080fd5b5061052f610760366004614cd5565b611aaa565b34801561077157600080fd5b50600a5460ff1661042a565b34801561078957600080fd5b5061045f610798366004614e17565b611b2b565b3480156107a957600080fd5b5061045f6107b8366004614cd5565b611bfb565b3480156107c957600080fd5b50610476604051806040016040528060088152602001674f70757363756c6160c01b81525081565b3480156107fd57600080fd5b5061052f611cb8565b34801561081257600080fd5b506104a3610821366004614cd5565b611ce8565b34801561083257600080fd5b5061052f610841366004614d2f565b611cfa565b34801561085257600080fd5b5061045f610861366004614d03565b611d48565b34801561087257600080fd5b5061045f610881366004614e17565b611dbe565b34801561089257600080fd5b5061042a6108a1366004614cd5565b611e8f565b3480156108b257600080fd5b5061045f6108c1366004614d2f565b611ed0565b61045f6108d4366004614f27565b611f97565b3480156108e557600080fd5b5061045f6108f436600461507f565b61204e565b34801561090557600080fd5b5061052f6000805160206156dc83398151915281565b34801561092757600080fd5b5061045f610936366004614cd5565b6120a8565b34801561094757600080fd5b506000546001600160a01b03166104a3565b34801561096557600080fd5b507f000000000000000000000000000000000000000000000000000000000000000061052f565b34801561099857600080fd5b5061045f6109a7366004614cd5565b6120b2565b3480156109b857600080fd5b5061042a6109c7366004614ef7565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156109fe57600080fd5b50610476612137565b348015610a1357600080fd5b50610a1c612146565b6040516104369190615109565b348015610a3557600080fd5b5061045f610a44366004614d2f565b612289565b348015610a5557600080fd5b5061042a610a64366004614cd5565b61238b565b348015610a7557600080fd5b5060085461052f565b348015610a8a57600080fd5b5061045f610a99366004615189565b6123da565b348015610aaa57600080fd5b5061045f610ab9366004614d03565b61247a565b348015610aca57600080fd5b5061045f6125d7565b348015610adf57600080fd5b5061045f610aee3660046151b7565b612660565b348015610aff57600080fd5b5061045f610b0e366004615189565b6126ae565b348015610b1f57600080fd5b506104766127b5565b348015610b3457600080fd5b50610476610b43366004614cd5565b6127c4565b348015610b5457600080fd5b5061052f610b63366004614d2f565b612a58565b348015610b7457600080fd5b5061045f612ae5565b348015610b8957600080fd5b50610b92612b9c565b604051610436919061529f565b348015610bab57600080fd5b5061045f610bba366004614ef7565b612d92565b348015610bcb57600080fd5b5061045f610bda36600461507f565b612db4565b348015610beb57600080fd5b5061045f612e7c565b348015610c0057600080fd5b5061045f610c0f366004614eb6565b612f36565b348015610c2057600080fd5b5061052f7ffdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e81565b348015610c5457600080fd5b5061045f613026565b348015610c6957600080fd5b5061042a610c78366004615301565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610cb257600080fd5b50600a54610100900460ff1661042a565b348015610ccf57600080fd5b5061045f610cde366004614d2f565b6130bd565b348015610cef57600080fd5b50610d03610cfe366004614d2f565b613105565b604051610436919061532f565b348015610d1c57600080fd5b50600a5462010000900460ff1661042a565b60006001600160e01b0319821663e110976f60e01b1480610d5f57506001600160e01b03198216632a2d979f60e01b145b80610d7a57506001600160e01b0319821663f53c966760e01b145b80610d9557506001600160e01b03198216634f558e7960e01b145b80610db057506001600160e01b03198216637d62321d60e01b145b80610dcb57506001600160e01b0319821663128009d560e11b145b80610de657506001600160e01b03198216633182441360e01b145b80610e0157506001600160e01b03198216636eba00f560e01b145b80610e1c57506001600160e01b0319821663e945adcd60e01b145b80610e3757506001600160e01b0319821663780e9d6360e01b145b80610e5157506001600160e01b03198216628d87a360e21b145b80610e6c57506001600160e01b03198216635b5e139f60e01b145b80610e8757506001600160e01b031982166308f770ad60e41b145b80610ea257506001600160e01b031982166305ba8d5960e41b145b80610ebd57506001600160e01b03198216634b8ae87360e01b145b80610ecc5750610ecc8261317c565b92915050565b6000546000805160206156dc833981519152906001600160a01b03163314801590610f175750600081815260016020908152604080832033845290915290205460ff16155b15610f4f57335b60405163122994e360e11b81526001600160a01b039091166004820152602481018290526044015b60405180910390fd5b600a805461ff0019166101008415158102919091179182905560405160ff9190920416151581527f9ea33dbe4d69c7808ed9609b1dedcb7440e12568855e708b8e8b50825e104329906020015b60405180910390a15050565b6060600b8054610fb790615342565b80601f0160208091040260200160405190810160405280929190818152602001828054610fe390615342565b80156110305780601f1061100557610100808354040283529160200191611030565b820191906000526020600020905b81548152906001019060200180831161101357829003601f168201915b5050505050905090565b6000611045826131a1565b6110655760405163c927e5bf60e01b815260048101839052602401610f46565b506000908152600660205260409020546001600160a01b031690565b600061108c82611ce8565b9050806001600160a01b0316836001600160a01b031614156110ca5760405163307134a760e21b815233600482015260248101839052604401610f46565b336001600160a01b038216148015906110ea57506110e88133610c78565b155b156111285760405163322c2e2960e11b81526001600160a01b0380831660048301528416602482015260448101839052336064820152608401610f46565b6111338383836131db565b505050565b6000546000805160206156dc833981519152906001600160a01b0316331480159061117d5750600081815260016020908152604080832033845290915290205460ff16155b156111885733610f1e565b61119182613237565b60145460005b8181101561124c57836001600160a01b0316601482815481106111bc576111bc61537d565b6000918252602090912001546001600160a01b0316141561123a576001600160a01b0384166000908152601560205260409020805460ff19169055611200816132a2565b6040516001600160a01b038516907fc8dde7702ada02e3271777e080f36befb2dfe4975ff5a35cdcc61f7116c893d390600090a250505050565b80611244816153a9565b915050611197565b5060405163a5be5e0f60e01b81526001600160a01b0384166004820152602401610f46565b5050565b6000546000805160206156dc833981519152906001600160a01b031633148015906112ba5750600081815260016020908152604080832033845290915290205460ff16155b156112c55733610f1e565b6112cd613380565b81516112e090600f906020850190614b18565b50600f6040516112f091906153c4565b604051908190038120907f8aef9948275592a4a1496813f92b3c13911528c06421256850f9f611e001874090600090a25050565b600061132f60035490565b6113376133ab565b6113419190615460565b905090565b600a5462010000900460ff16156113705760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b031633148015906113b55750600081815260016020908152604080832033845290915290205460ff16155b156113c05733610f1e565b6113c9856131a1565b6113e95760405163c927e5bf60e01b815260048101869052602401610f46565b6000858152601060209081526040909120835161140892850190614b18565b506000858152601160205260409020805460ff191685151517905582801561143f575060008581526012602052604090205460ff16155b1561148557600085815260126020526040808220805460ff191660011790555186917fafd1af0d18662bc4cbe66cd3885857264bb71d267eb57c0add879e84a5be317791a25b816040516114939190615477565b60408051918290038220600080845260208401529187917f2a228bf8ab34c4401425e787b89ef2b1cad5e2e93daf585a1e62dd9ce87fcedd910160405180910390a35050505050565b600a54610100900460ff166115045760405163b7b2409760e01b815260040160405180910390fd5b61150d816133bc565b8061151760085490565b6115219190615493565b341461155e57348161153260085490565b61153c9190615493565b60405163e763535560e01b815260048101929092526024820152604401610f46565b61156833826134cb565b50565b6000547ffdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e906001600160a01b031633148015906115c25750600081815260016020908152604080832033845290915290205460ff16155b156115cd5733610f1e565b6115d6826133bc565b61113383836134cb565b6111338383836134e5565b6000546001600160a01b0316331461162457335b604051630e60d8d360e41b81526001600160a01b039091166004820152602401610f46565b61127182826137be565b600061163983611cfa565b82111561166c578161164a84611cfa565b6040516363a056dd60e01b815260048101929092526024820152604401610f46565b60006116766133ab565b90506000805b828110156116e75761168d816131a1565b156116d557856001600160a01b03166116a582613845565b516001600160a01b031614156116d557848214156116c7579250610ecc915050565b816116d1816153a9565b9250505b806116df816153a9565b91505061167c565b506040516301b2776960e11b815260040160405180910390fd5b606061170c83613237565b81516000816001600160401b0381111561172857611728614d4c565b604051908082528060200260200182016040528015611751578160200160208202803683370190505b50905060005b828110156117f8576001600160a01b038616600090815260166020908152604080832060178352818420548452909152812086519091908790849081106117a0576117a061537d565b6020026020010151815260200190815260200160002060009054906101000a900460ff168282815181106117d6576117d661537d565b91151560209283029190910190910152806117f0816153a9565b915050611757565b50949350505050565b6000546001600160a01b0316331461181957336115ff565b611823600061394c565b565b60606013805480602002602001604051908101604052809291908181526020016000905b82821015611891576000848152602090819020604080518082019091526002850290910180546001600160a01b03168252600190810154828401529083529092019101611849565b50505050905090565b6000547f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a3906001600160a01b031633148015906118f15750600081815260016020908152604080832033845290915290205460ff16155b156118fc5733610f1e565b600954601354479190811580611910575080155b1561192e57604051639811e0c760e01b815260040160405180910390fd5b600061193a83856154c8565b905060005b82811015611a395760006013828154811061195c5761195c61537d565b600091825260208083206040805180820190915260029093020180546001600160a01b031683526001015490820181905290925061199b908590615493565b82516040519192506001600160a01b03169082156108fc029083906000818181858888f193505050501580156119d5573d6000803e3d6000fd5b5081516001600160a01b0316336001600160a01b03167f8957f76027b186a481886d5e1dfef5a49a9b792649df75e9dd5e53cde75c71ea83604051611a1c91815260200190565b60405180910390a350508080611a31906153a9565b91505061193f565b5060095433907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590611a6b9084615493565b6040519081526020015b60405180910390a25050505050565b61113383838360405180602001604052806000815250612660565b6000610ecc826131a1565b6000611ab4611324565b8210611ac3578161164a611324565b600354611ad557610ecc8260016154dc565b600080611ae06133ab565b905060005b818110156116e75784831415611afd57949350505050565b611b06816131a1565b15611b195782611b15816153a9565b9350505b80611b23816153a9565b915050611ae5565b600a5462010000900460ff1615611b555760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590611b9a5750600081815260016020908152604080832033845290915290205460ff16155b15611ba55733610f1e565b8151611bb890600d906020850190614b18565b5081604051611bc79190615477565b604051908190038120907fafa35f42f46f5052816d7c6a2e9406eca98294b20726677862d83b4a7418d8d590600090a25050565b6000546000805160206156dc833981519152906001600160a01b03163314801590611c405750600081815260016020908152604080832033845290915290205460ff16155b15611c4b5733610f1e565b611c54826131a1565b611c745760405163c927e5bf60e01b815260048101839052602401610f46565b600082815260126020526040808220805460ff191660011790555183917fafd1af0d18662bc4cbe66cd3885857264bb71d267eb57c0add879e84a5be317791a25050565b6000611cc26133ab565b7f0000000000000000000000000000000000000000000000000000000000000000611337565b6000611cf382613845565b5192915050565b60006001600160a01b038216611d235760405163e99d5ac560e01b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160801b031690565b6000546000805160206156dc833981519152906001600160a01b03163314801590611d8d5750600081815260016020908152604080832033845290915290205460ff16155b15611d985733610f1e565b6111336040518060400160405280856001600160a01b031681526020018481525061399c565b600a5462010000900460ff1615611de85760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590611e2d5750600081815260016020908152604080832033845290915290205460ff16155b15611e385733610f1e565b8151611e4b90600e906020850190614b18565b50600e604051611e5b91906153c4565b604051908190038120907fb6b2b7d0cff2ae8f651bd60fb4eb42b79f6e366900a72af6156ea30044179e8e90600090a25050565b6000611e9a826131a1565b611eba5760405163c927e5bf60e01b815260048101839052602401610f46565b5060009081526011602052604090205460ff1690565b6000546000805160206156dc833981519152906001600160a01b03163314801590611f155750600081815260016020908152604080832033845290915290205460ff16155b15611f205733610f1e565b611f2982613237565b6001600160a01b0382166000908152601760205260408120805491611f4d836153a9565b90915550506001600160a01b038216600081815260186020526040808220829055517ff1d918039d4ced601abd661af27bad3fa7cd09c72e6052e04d27348656f9b7069190a25050565b805180611fee57600060017f00000000000000000000000000000000000000000000000000000000000000005b6040516346f4384b60e01b8152600481019390935260248301919091526044820152606401610f46565b611ff7816133bc565b61200083613b4c565b600061200b84613bd7565b5190506120188282615493565b3414612029573461153c8383615493565b612034338585613c44565b61203e8484613e3b565b61204833836134cb565b50505050565b6000546000805160206156dc833981519152906001600160a01b031633148015906120935750600081815260016020908152604080832033845290915290205460ff16155b1561209e5733610f1e565b6111338383613f56565b61156881336140b1565b6000546000805160206156dc833981519152906001600160a01b031633148015906120f75750600081815260016020908152604080832033845290915290205460ff16155b156121025733610f1e565b60088290556040518281527fa6dc15bdb68da224c66db4b3838d9a2b205138e8cff6774e57d0af91e196d62290602001610f9c565b6060600c8054610fb790615342565b606060006121526133ab565b90506000816001600160401b0381111561216e5761216e614d4c565b6040519080825280602002602001820160405280156121b957816020015b604080516060810182526000808252602080830182905292820152825260001990920191018161218c5790505b50905060015b828111612282576121cf816131a1565b1561222b5760408051606081018252828152600060208201529081016121f483611ce8565b6001600160a01b031690528261220b600184615460565b8151811061221b5761221b61537d565b6020026020010181905250612270565b604080516060810190915281815260208101600181523060209091015282612254600184615460565b815181106122645761226461537d565b60200260200101819052505b8061227a816153a9565b9150506121bf565b5092915050565b6000546000805160206156dc833981519152906001600160a01b031633148015906122ce5750600081815260016020908152604080832033845290915290205460ff16155b156122d95733610f1e565b6001600160a01b0382166123005760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b8181101561236657836001600160a01b03166013828154811061232b5761232b61537d565b60009182526020909120600290910201546001600160a01b031614156123545761204881614134565b8061235e816153a9565b915050612306565b506040516354a932f560e01b81526001600160a01b0384166004820152602401610f46565b6000612396826131a1565b6123b65760405163c927e5bf60e01b815260048101839052602401610f46565b60008281526012602052604090205460ff1680610ecc5750600a5460ff1692915050565b6001600160a01b03821633141561240e576040516372b3985f60e01b81523360048201528115156024820152604401610f46565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000546000805160206156dc833981519152906001600160a01b031633148015906124bf5750600081815260016020908152604080832033845290915290205460ff16155b156124ca5733610f1e565b6001600160a01b0383166124f15760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b818110156125b257846001600160a01b03166013828154811061251c5761251c61537d565b60009182526020909120600290910201546001600160a01b031614156125a05783601382815481106125505761255061537d565b906000526020600020906002020160010181905550846001600160a01b03167f06945c82029753372decfeace485696553ab08354f682b4fa8e08d277e25498585604051611a7591815260200190565b806125aa816153a9565b9150506124f7565b506040516354a932f560e01b81526001600160a01b0385166004820152602401610f46565b6000546000805160206156dc833981519152906001600160a01b0316331480159061261c5750600081815260016020908152604080832033845290915290205460ff16155b156126275733610f1e565b600a805460ff191660011790556040517fe2a7169cedebe39671840370ae19ca4fc41be6191d4c77f174f189a4d8cd08c890600090a150565b61266b8484846134e5565b612677848484846142ba565b6120485760405163a371886b60e01b81526001600160a01b0380861660048301528416602482015260448101839052606401610f46565b6000546000805160206156dc833981519152906001600160a01b031633148015906126f35750600081815260016020908152604080832033845290915290205460ff16155b156126fe5733610f1e565b61270783613237565b6001600160a01b03831660009081526019602052604090206002015460ff16151582151514611133576001600160a01b0383166000818152601960205260409081902060028101805486151560ff1990911617905590517f0e26d8e2549574e8d6493ef972ea195acde7d56ff6b7a7114978c2b5edf9ea8e916127a891815481526001820154602082015260029091015460ff161515604082015260600190565b60405180910390a2505050565b6060600f8054610fb790615342565b60606127cf826131a1565b6127ef5760405163c927e5bf60e01b815260048101839052602401610f46565b6000828152601060205260408120805461280890615342565b80601f016020809104026020016040519081016040528092919081815260200182805461283490615342565b80156128815780601f1061285657610100808354040283529160200191612881565b820191906000526020600020905b81548152906001019060200180831161286457829003601f168201915b505050505090506000600d805461289790615342565b80601f01602080910402602001604051908101604052809291908181526020018280546128c390615342565b80156129105780601f106128e557610100808354040283529160200191612910565b820191906000526020600020905b8154815290600101906020018083116128f357829003601f168201915b5050600a54939450505060ff909116159050801561293d575060008481526012602052604090205460ff16155b156129d657600e805461294f90615342565b80601f016020809104026020016040519081016040528092919081815260200182805461297b90615342565b80156129c85780601f1061299d576101008083540402835291602001916129c8565b820191906000526020600020905b8154815290600101906020018083116129ab57829003601f168201915b505050505092505050919050565b815115612a265760008481526011602052604090205460ff16156129fb575092915050565b8082604051602001612a0e9291906154f4565b60405160208183030381529060405292505050919050565b6000600d8054612a3590615342565b905011156122825780612a47856143c5565b604051602001612a0e9291906154f4565b601354600090815b8181101561236657836001600160a01b031660138281548110612a8557612a8561537d565b60009182526020909120600290910201546001600160a01b03161415612ad35760138181548110612ab857612ab861537d565b90600052602060002090600202016001015492505050919050565b80612add816153a9565b915050612a60565b600a5462010000900460ff1615612b0f5760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590612b545750600081815260016020908152604080832033845290915290205460ff16155b15612b5f5733610f1e565b600a805462ff00001916620100001790556040517feef043febddf4e1d1cf1f72ff1407b84e036e805aa0934418cb82095da8d716490600090a150565b60148054604080516020808402820181019092528281526060936000928490830182828015612bf457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612bd6575b505050505090506000826001600160401b03811115612c1557612c15614d4c565b604051908082528060200260200182016040528015612c4e57816020015b612c3b614b9c565b815260200190600190039081612c335790505b50905060005b83811015612d8a576000838281518110612c7057612c7061537d565b602002602001015190506040518060a00160405280826001600160a01b03168152602001612c9d836144c2565b8152602001612cab8361453b565b815260200160186000878681518110612cc657612cc661537d565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054815260200160196000878681518110612d0a57612d0a61537d565b6020908102919091018101516001600160a01b031682528181019290925260409081016000208151606081018352815481526001820154938101939093526002015460ff1615159082015290528351849084908110612d6b57612d6b61537d565b6020026020010181905250508080612d82906153a9565b915050612c54565b509392505050565b6000546001600160a01b03163314612daa57336115ff565b61127182826140b1565b6000546000805160206156dc833981519152906001600160a01b03163314801590612df95750600081815260016020908152604080832033845290915290205460ff16155b15612e045733610f1e565b612e0d83613237565b6001600160a01b03831660008181526019602090815260409182902085518155908501516001820155848201516002909101805460ff1916911515919091179055517f0e26d8e2549574e8d6493ef972ea195acde7d56ff6b7a7114978c2b5edf9ea8e906127a8908590615523565b6000546000805160206156dc833981519152906001600160a01b03163314801590612ec15750600081815260016020908152604080832033845290915290205460ff16155b15612ecc5733610f1e565b6040514790339082156108fc029083906000818181858888f19350505050158015612efb573d6000803e3d6000fd5b5060405181815233907f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e51906020015b60405180910390a25050565b6000547f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a3906001600160a01b03163314801590612f8d5750600081815260016020908152604080832033845290915290205460ff16155b15612f985733610f1e565b6001600160a01b038316612fbf5760405163e99d5ac560e01b815260040160405180910390fd5b612fd36001600160a01b0385168484614599565b826001600160a01b0316846001600160a01b03167f401f439d865a766757ec78675925bd67198d5e78805aa41691b34b5d6a6cbbe68460405161301891815260200190565b60405180910390a350505050565b6000546000805160206156dc833981519152906001600160a01b0316331480159061306b5750600081815260016020908152604080832033845290915290205460ff16155b156130765733610f1e565b61307e613380565b600a805463ff000000191663010000001790556040517f294f0756ade420332ef086187515f4a3af6e693dfe5ca7e10990f5d61bf06dd390600090a150565b6000546001600160a01b031633146130d557336115ff565b6001600160a01b0381166130fc5760405163e99d5ac560e01b815260040160405180910390fd5b6115688161394c565b61310d614b9c565b61311682613237565b6040518060a00160405280836001600160a01b03168152602001613139846144c2565b81526020016131478461453b565b81526001600160a01b03841660009081526018602090815260409182902054908301520161317484613bd7565b905292915050565b60006001600160e01b03198216634b88b8ad60e11b1480610ecc5750610ecc826145eb565b600080821180156131b3575060025482105b8015610ecc57506000828152600460205260409020546001600160a01b031630141592915050565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6001600160a01b03811661325e5760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03811660009081526015602052604090205460ff166115685760405163a5be5e0f60e01b81526001600160a01b0382166004820152602401610f46565b6014548082106132b0575050565b815b6132bd600183615460565b8110156133485760146132d18260016154dc565b815481106132e1576132e161537d565b600091825260209091200154601480546001600160a01b03909216918390811061330d5761330d61537d565b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905580613340816153a9565b9150506132b2565b50601480548061335a5761335a615546565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b600a546301000000900460ff161561182357604051632edca92560e01b815260040160405180910390fd5b600060016002546113419190615460565b7f00000000000000000000000000000000000000000000000000000000000000008111806133e8575080155b15613416578060017f0000000000000000000000000000000000000000000000000000000000000000611fc4565b7f0000000000000000000000000000000000000000000000000000000000000000816134406133ab565b61344a91906154dc565b111561156857806134596133ab565b613483907f0000000000000000000000000000000000000000000000000000000000000000615460565b6040516302d95a3b60e11b8152600481019290925260248201527f00000000000000000000000000000000000000000000000000000000000000006044820152606401610f46565b611271828260405180602001604052806000815250614610565b6001600160a01b03821661350c5760405163e99d5ac560e01b815260040160405180910390fd5b600061351782613845565b9050836001600160a01b031681600001516001600160a01b03161461357d57335b815160405163753e1c4f60e11b81526001600160a01b03928316600482015282871660248201528286166044820152606481018590529116608482015260a401610f46565b80516001600160a01b0316336001600160a01b0316141580156135b15750336135a58361103a565b6001600160a01b031614155b80156135c6575080516135c49033610c78565b155b156135d15733613538565b6135e160008383600001516131db565b6001600160a01b03841660009081526005602052604081208054600192906136139084906001600160801b031661555c565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0385166000908152600560205260408120805460019450909261365f91859116615584565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380861682526001600160401b03428116602080850191825260008881526004909152948520935184549151909216600160a01b026001600160e01b031990911691909216171790556136e68360016154dc565b6000818152600460205260409020549091506001600160a01b03166137755761370e816131a1565b156137755760408051808201825283516001600160a01b0390811682526020808601516001600160401b039081168285019081526000878152600490935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b82846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166112715760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6040805180820190915260008082526020820152613862826131a1565b6138825760405163c927e5bf60e01b815260048101839052602401610f46565b60007f000000000000000000000000000000000000000000000000000000000000000083106138e3576138d57f000000000000000000000000000000000000000000000000000000000000000084615460565b6138e09060016154dc565b90505b825b8181106116e7576000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b0316918301919091521561393957949350505050565b5080613944816155a6565b9150506138e5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60208101516139be57604051639811e0c760e01b815260040160405180910390fd5b80516001600160a01b03166139e65760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b81811015613a6e5782600001516001600160a01b031660138281548110613a1557613a1561537d565b60009182526020909120600290910201546001600160a01b03161415613a5c5782516040516370d2049160e01b81526001600160a01b039091166004820152602401610f46565b80613a66816153a9565b9150506139ec565b5060138054600181018255600091825283517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a090600290920291820180546001600160a01b0319166001600160a01b0390921691909117905560208401517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0919091018190556009805491929091613b059084906154dc565b909155505081516020808401516040519081526001600160a01b03909216917f3bc19114ca6a687ffd9445c87615db284e96364365d72b010ec53244b45e561b9101612f2a565b6001600160a01b03811660009081526015602052604090205460ff16613b905760405163a5be5e0f60e01b81526001600160a01b0382166004820152602401610f46565b6001600160a01b03811660009081526019602052604090206002015460ff1661156857604051637a08c0fb60e11b81526001600160a01b0382166004820152602401610f46565b613bfd604051806060016040528060008152602001600081526020016000151581525090565b506001600160a01b03166000908152601960209081526040918290208251606081018452815481526001820154928101929092526002015460ff1615159181019190915290565b80516001600160a01b038316600090815260196020908152604080832060010154601890925290912054613c799083906154dc565b1115613cbe576001600160a01b03831660008181526019602052604090819020600101549051635ca6c35960e01b815260048101929092526024820152604401610f46565b60005b818110156137b7576000838281518110613cdd57613cdd61537d565b60200260200101519050846001600160a01b0316636352211e826040518263ffffffff1660e01b8152600401613d1591815260200190565b602060405180830381865afa925050508015613d4e575060408051601f3d908101601f19168201909252613d4b918101906155bd565b60015b613d7d576040516302682da560e41b81526001600160a01b038616600482015260248101829052604401610f46565b866001600160a01b0316816001600160a01b031614613dc1576040516302682da560e41b81526001600160a01b038716600482015260248101839052604401610f46565b506001600160a01b038516600090815260166020908152604080832060178352818420548452825280832084845290915290205460ff1615613e285760405163cf3571af60e01b81526001600160a01b038616600482015260248101829052604401610f46565b5080613e33816153a9565b915050613cc1565b805160005b81811015613f23576001600160a01b0384166000908152601660209081526040808320601783528184205484529091528120845160019290869085908110613e8a57613e8a61537d565b6020026020010151815260200190815260200160002060006101000a81548160ff021916908315150217905550828181518110613ec957613ec961537d565b6020026020010151846001600160a01b0316336001600160a01b03167f728e641386299b5070162250083c0abc8f1d93cd543b23eaed63336575ca994c60405160405180910390a480613f1b816153a9565b915050613e40565b506001600160a01b03831660009081526018602052604081208054839290613f4c9084906154dc565b9091555050505050565b6001600160a01b038216613f7d5760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03821660009081526015602052604090205460ff1615613fc2576040516354d67cef60e01b81526001600160a01b0383166004820152602401610f46565b6001600160a01b0382166000908152601560209081526040808320805460ff1916600117905560179091528120805491613ffb836153a9565b90915550506001600160a01b03821660008181526019602090815260408083208551815591850151600180840191909155858201516002909301805460ff1916931515939093179092556014805492830181559092527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec0180546001600160a01b03191683179055517fab109b1e3dd4bf279798315182b336f138e930aec9aaeafe98f768450d9fd9b790612f2a908490615523565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16156112715760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60138054906000908383811061414c5761414c61537d565b60009182526020918290206040805180820190915260029092020180546001600160a01b0316825260010154918101919091529050825b61418e600184615460565b81101561421d5760136141a28260016154dc565b815481106141b2576141b261537d565b9060005260206000209060020201601382815481106141d3576141d361537d565b60009182526020909120825460029092020180546001600160a01b0319166001600160a01b0390921691909117815560019182015491015580614215816153a9565b915050614183565b50601380548061422f5761422f615546565b6000828152602080822060026000199094019384020180546001600160a01b0319168155600101829055919092558201516009805491929091614273908490615460565b909155505080516020808301516040519081526001600160a01b03909216917f775539f018602cb5533761287430a74c8cc49b559ee2fbcd32e086789206382a91016127a8565b60006001600160a01b0384163b156143b957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906142fe9033908990889088906004016155da565b6020604051808303816000875af1925050508015614339575060408051601f3d908101601f1916820190925261433691810190615617565b60015b61439f573d808015614367576040519150601f19603f3d011682016040523d82523d6000602084013e61436c565b606091505b50805161439757604051634e1cb28960e11b81526001600160a01b0386166004820152602401610f46565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506143bd565b5060015b949350505050565b6060816143e95750506040805180820190915260018152600360fc1b602082015290565b8160005b811561441357806143fd816153a9565b915061440c9050600a836154c8565b91506143ed565b6000816001600160401b0381111561442d5761442d614d4c565b6040519080825280601f01601f191660200182016040528015614457576020820181803683370190505b5090505b84156143bd5761446c600183615460565b9150614479600a86615634565b6144849060306154dc565b60f81b8183815181106144995761449961537d565b60200101906001600160f81b031916908160001a9053506144bb600a866154c8565b945061445b565b6060816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561452357506040513d6000823e601f3d908101601f191682016040526145209190810190615648565b60015b610ecc57505060408051602081019091526000815290565b6060816001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561452357506040513d6000823e601f3d908101601f191682016040526145209190810190615648565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611133908490614872565b60006001600160e01b031982166380ac58cd60e01b1480610ecc5750610ecc82614944565b6002546001600160a01b03841661463a5760405163e99d5ac560e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000000831180614666575082155b156146b4576040516346f4384b60e01b815260048101849052600160248201527f00000000000000000000000000000000000000000000000000000000000000006044820152606401610f46565b6001600160a01b0384166000908152600560209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190614710908790615584565b6001600160801b0316815260200185836020015161472e9190615584565b6001600160801b039081169091526001600160a01b0380881660008181526005602090815260408083208751978301518716600160801b029790961696909617909455845180860186529182526001600160401b034281168386019081528883526004909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b858110156148675760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461481160008884886142ba565b6148475760405163a371886b60e01b8152600060048201526001600160a01b038816602482015260448101839052606401610f46565b81614851816153a9565b925050808061485f906153a9565b9150506147c4565b506002555050505050565b60006148c7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166149699092919063ffffffff16565b80519091501561113357808060200190518101906148e591906156be565b6111335760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f46565b60006001600160e01b0319821663e00008a960e01b1480610ecc5750610ecc82614982565b606061497884846000856149b7565b90505b9392505050565b60006001600160e01b03198216634b8ae87360e01b1480610ecc57506301ffc9a760e01b6001600160e01b0319831614610ecc565b606082471015614a185760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f46565b843b614a665760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f46565b600080866001600160a01b03168587604051614a829190615477565b60006040518083038185875af1925050503d8060008114614abf576040519150601f19603f3d011682016040523d82523d6000602084013e614ac4565b606091505b5091509150614ad4828286614adf565b979650505050505050565b60608315614aee57508161497b565b825115614afe5782518084602001fd5b8160405162461bcd60e51b8152600401610f469190614cc2565b828054614b2490615342565b90600052602060002090601f016020900481019282614b465760008555614b8c565b82601f10614b5f57805160ff1916838001178555614b8c565b82800160010185558215614b8c579182015b82811115614b8c578251825591602001919060010190614b71565b50614b98929150614bf7565b5090565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001614bf2604051806060016040528060008152602001600081526020016000151581525090565b905290565b5b80821115614b985760008155600101614bf8565b6001600160e01b03198116811461156857600080fd5b600060208284031215614c3457600080fd5b813561497b81614c0c565b801515811461156857600080fd5b600060208284031215614c5f57600080fd5b813561497b81614c3f565b60005b83811015614c85578181015183820152602001614c6d565b838111156120485750506000910152565b60008151808452614cae816020860160208601614c6a565b601f01601f19169290920160200192915050565b60208152600061497b6020830184614c96565b600060208284031215614ce757600080fd5b5035919050565b6001600160a01b038116811461156857600080fd5b60008060408385031215614d1657600080fd5b8235614d2181614cee565b946020939093013593505050565b600060208284031215614d4157600080fd5b813561497b81614cee565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614d8a57614d8a614d4c565b604052919050565b60006001600160401b03821115614dab57614dab614d4c565b50601f01601f191660200190565b6000614dcc614dc784614d92565b614d62565b9050828152838383011115614de057600080fd5b828260208301376000602084830101529392505050565b600082601f830112614e0857600080fd5b61497b83833560208501614db9565b600060208284031215614e2957600080fd5b81356001600160401b03811115614e3f57600080fd5b6143bd84828501614df7565b60008060008060808587031215614e6157600080fd5b843593506020850135614e7381614c3f565b92506040850135614e8381614c3f565b915060608501356001600160401b03811115614e9e57600080fd5b614eaa87828801614df7565b91505092959194509250565b600080600060608486031215614ecb57600080fd5b8335614ed681614cee565b92506020840135614ee681614cee565b929592945050506040919091013590565b60008060408385031215614f0a57600080fd5b823591506020830135614f1c81614cee565b809150509250929050565b60008060408385031215614f3a57600080fd5b8235614f4581614cee565b91506020838101356001600160401b0380821115614f6257600080fd5b818601915086601f830112614f7657600080fd5b813581811115614f8857614f88614d4c565b8060051b9150614f99848301614d62565b8181529183018401918481019089841115614fb357600080fd5b938501935b83851015614fd157843582529385019390850190614fb8565b8096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561501b578351151583529284019291840191600101614ffd565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561507257815180516001600160a01b03168552860151868501529284019290850190600101615044565b5091979650505050505050565b600080828403608081121561509357600080fd5b833561509e81614cee565b92506060601f19820112156150b257600080fd5b50604051606081018181106001600160401b03821117156150d5576150d5614d4c565b8060405250602084013581526040840135602082015260608401356150f981614c3f565b6040820152919491935090915050565b60208082528251828201819052600091906040908185019086840185805b8381101561517b57825180518652878101516002811061515557634e487b7160e01b84526021600452602484fd5b868901528601516001600160a01b03168686015260609094019391860191600101615127565b509298975050505050505050565b6000806040838503121561519c57600080fd5b82356151a781614cee565b91506020830135614f1c81614c3f565b600080600080608085870312156151cd57600080fd5b84356151d881614cee565b935060208501356151e881614cee565b92506040850135915060608501356001600160401b0381111561520a57600080fd5b8501601f8101871361521b57600080fd5b614eaa87823560208401614db9565b60018060a01b0381511682526000602082015160e0602085015261525160e0850182614c96565b90506040830151848203604086015261526a8282614c96565b915050606083015160608501526080830151612d8a608086018280518252602080820151908301526040908101511515910152565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156152f457603f198886030184526152e285835161522a565b945092850192908501906001016152c6565b5092979650505050505050565b6000806040838503121561531457600080fd5b823561531f81614cee565b91506020830135614f1c81614cee565b60208152600061497b602083018461522a565b600181811c9082168061535657607f821691505b6020821081141561537757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156153bd576153bd615393565b5060010190565b600080835481600182811c9150808316806153e057607f831692505b602080841082141561540057634e487b7160e01b86526022600452602486fd5b818015615414576001811461542557615452565b60ff19861689528489019650615452565b60008a81526020902060005b8681101561544a5781548b820152908501908301615431565b505084890196505b509498975050505050505050565b60008282101561547257615472615393565b500390565b60008251615489818460208701614c6a565b9190910192915050565b60008160001904831182151516156154ad576154ad615393565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826154d7576154d76154b2565b500490565b600082198211156154ef576154ef615393565b500190565b60008351615506818460208801614c6a565b83519083019061551a818360208801614c6a565b01949350505050565b815181526020808301519082015260408083015115159082015260608101610ecc565b634e487b7160e01b600052603160045260246000fd5b60006001600160801b038381169083168181101561557c5761557c615393565b039392505050565b60006001600160801b0380831681851680830382111561551a5761551a615393565b6000816155b5576155b5615393565b506000190190565b6000602082840312156155cf57600080fd5b815161497b81614cee565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061560d90830184614c96565b9695505050505050565b60006020828403121561562957600080fd5b815161497b81614c0c565b600082615643576156436154b2565b500690565b60006020828403121561565a57600080fd5b81516001600160401b0381111561567057600080fd5b8201601f8101841361568157600080fd5b805161568f614dc782614d92565b8181528560208385010111156156a457600080fd5b6156b5826020830160208601614c6a565b95945050505050565b6000602082840312156156d057600080fd5b815161497b81614c3f56fe7e69b879a040173b938f56bb64bfa62bcd758c08ae6ed7cfdf7da6d7dba92708a2646970667358221220eaeedbc3815edc453aede94422d11eab4daa7592624a84532df15533abfb2f8464736f6c634300080b003300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000002c68af0bb1400000000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000104f70757363756c612047656e657369730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034f434700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c0b1a85255bb74c4b5d7a17af1305f29623d0b540000000000000000000000000000000000000000000000000000000000000050000000000000000000000000b5651a4a8c4ce095f56558a08a1fd1defd2fc6b700000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f7cf6747c81829585f18e8021d267fd4866e518900000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106104055760003560e01c806383085d0911610213578063b88d4fde11610123578063db2e21bc116100ab578063e985e9c51161007a578063e985e9c514610c5d578063eb8d244414610ca6578063f2fde38b14610cc3578063f6b9782d14610ce3578063fb3cc6c214610d1057600080fd5b8063db2e21bc14610bdf578063e110976f14610bf4578063e35bd96b14610c14578063e7d773a014610c4857600080fd5b8063ce7c2ac2116100f2578063ce7c2ac214610b48578063d111515d14610b68578063d2369e0414610b7d578063d547741f14610b9f578063d6a6346e14610bbf57600080fd5b8063b88d4fde14610ad3578063be52be2e14610af3578063c6ab67a314610b13578063c87b56dd14610b2857600080fd5b806391d14854116101a65780639d897351116101755780639d89735114610a49578063a035b1fe14610a69578063a22cb46514610a7e578063a4451df114610a9e578063a475b5dd14610abe57600080fd5b806391d14854146109ac57806395d89b41146109f25780639711715a14610a075780639babdad614610a2957600080fd5b80638bb9c5bf116101e25780638bb9c5bf1461091b5780638da5cb5b1461093b5780638f770ad01461095957806391b7f5ed1461098c57600080fd5b806383085d09146108a657806385f52846146108c6578063871b015a146108d95780638987470e146108f957600080fd5b8063327f64f31161031957806355f804b3116102a15780636352211e116102705780636352211e1461080657806370a08231146108265780637572499014610846578063820de0c51461086657806382dc439a1461088657600080fd5b806355f804b31461077d5780635a46cf3d1461079d5780635f74606c146107bd57806360659a92146107f157600080fd5b80633ccfd60b116102e85780633ccfd60b146106f057806342842e0e146107055780634f558e79146107255780634f6ccce714610745578063518302271461076557600080fd5b8063327f64f31461067757806334d2c0a3146106a45780633723bc0e146106b95780633a98ef39146106db57600080fd5b806314ea928a1161039c57806322be83b71161036b57806322be83b7146105c457806323b872dd146105e45780632913daa0146106045780632f2ff15d146106375780632f745c591461065757600080fd5b806314ea928a1461055d57806318160ddd1461057c5780631a729e671461059157806320889d3b146105b157600080fd5b8063095ea7b3116103d8578063095ea7b3146104bb5780630adeeae8146104db57806310355a43146104fb578063109695231461053d57600080fd5b806301ffc9a71461040a57806302c889891461043f57806306fdde0314610461578063081812fc14610483575b600080fd5b34801561041657600080fd5b5061042a610425366004614c22565b610d2e565b60405190151581526020015b60405180910390f35b34801561044b57600080fd5b5061045f61045a366004614c4d565b610ed2565b005b34801561046d57600080fd5b50610476610fa8565b6040516104369190614cc2565b34801561048f57600080fd5b506104a361049e366004614cd5565b61103a565b6040516001600160a01b039091168152602001610436565b3480156104c757600080fd5b5061045f6104d6366004614d03565b611081565b3480156104e757600080fd5b5061045f6104f6366004614d2f565b611138565b34801561050757600080fd5b5061052f7f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a381565b604051908152602001610436565b34801561054957600080fd5b5061045f610558366004614e17565b611275565b34801561056957600080fd5b50600a546301000000900460ff1661042a565b34801561058857600080fd5b5061052f611324565b34801561059d57600080fd5b5061045f6105ac366004614e4b565b611346565b61045f6105bf366004614cd5565b6114dc565b3480156105d057600080fd5b5061045f6105df366004614d03565b61156b565b3480156105f057600080fd5b5061045f6105ff366004614eb6565b6115e0565b34801561061057600080fd5b507f000000000000000000000000000000000000000000000000000000000000000a61052f565b34801561064357600080fd5b5061045f610652366004614ef7565b6115eb565b34801561066357600080fd5b5061052f610672366004614d03565b61162e565b34801561068357600080fd5b50610697610692366004614f27565b611701565b6040516104369190614fe1565b3480156106b057600080fd5b5061045f611801565b3480156106c557600080fd5b506106ce611825565b6040516104369190615027565b3480156106e757600080fd5b5060095461052f565b3480156106fc57600080fd5b5061045f61189a565b34801561071157600080fd5b5061045f610720366004614eb6565b611a84565b34801561073157600080fd5b5061042a610740366004614cd5565b611a9f565b34801561075157600080fd5b5061052f610760366004614cd5565b611aaa565b34801561077157600080fd5b50600a5460ff1661042a565b34801561078957600080fd5b5061045f610798366004614e17565b611b2b565b3480156107a957600080fd5b5061045f6107b8366004614cd5565b611bfb565b3480156107c957600080fd5b50610476604051806040016040528060088152602001674f70757363756c6160c01b81525081565b3480156107fd57600080fd5b5061052f611cb8565b34801561081257600080fd5b506104a3610821366004614cd5565b611ce8565b34801561083257600080fd5b5061052f610841366004614d2f565b611cfa565b34801561085257600080fd5b5061045f610861366004614d03565b611d48565b34801561087257600080fd5b5061045f610881366004614e17565b611dbe565b34801561089257600080fd5b5061042a6108a1366004614cd5565b611e8f565b3480156108b257600080fd5b5061045f6108c1366004614d2f565b611ed0565b61045f6108d4366004614f27565b611f97565b3480156108e557600080fd5b5061045f6108f436600461507f565b61204e565b34801561090557600080fd5b5061052f6000805160206156dc83398151915281565b34801561092757600080fd5b5061045f610936366004614cd5565b6120a8565b34801561094757600080fd5b506000546001600160a01b03166104a3565b34801561096557600080fd5b507f000000000000000000000000000000000000000000000000000000000000003261052f565b34801561099857600080fd5b5061045f6109a7366004614cd5565b6120b2565b3480156109b857600080fd5b5061042a6109c7366004614ef7565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156109fe57600080fd5b50610476612137565b348015610a1357600080fd5b50610a1c612146565b6040516104369190615109565b348015610a3557600080fd5b5061045f610a44366004614d2f565b612289565b348015610a5557600080fd5b5061042a610a64366004614cd5565b61238b565b348015610a7557600080fd5b5060085461052f565b348015610a8a57600080fd5b5061045f610a99366004615189565b6123da565b348015610aaa57600080fd5b5061045f610ab9366004614d03565b61247a565b348015610aca57600080fd5b5061045f6125d7565b348015610adf57600080fd5b5061045f610aee3660046151b7565b612660565b348015610aff57600080fd5b5061045f610b0e366004615189565b6126ae565b348015610b1f57600080fd5b506104766127b5565b348015610b3457600080fd5b50610476610b43366004614cd5565b6127c4565b348015610b5457600080fd5b5061052f610b63366004614d2f565b612a58565b348015610b7457600080fd5b5061045f612ae5565b348015610b8957600080fd5b50610b92612b9c565b604051610436919061529f565b348015610bab57600080fd5b5061045f610bba366004614ef7565b612d92565b348015610bcb57600080fd5b5061045f610bda36600461507f565b612db4565b348015610beb57600080fd5b5061045f612e7c565b348015610c0057600080fd5b5061045f610c0f366004614eb6565b612f36565b348015610c2057600080fd5b5061052f7ffdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e81565b348015610c5457600080fd5b5061045f613026565b348015610c6957600080fd5b5061042a610c78366004615301565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610cb257600080fd5b50600a54610100900460ff1661042a565b348015610ccf57600080fd5b5061045f610cde366004614d2f565b6130bd565b348015610cef57600080fd5b50610d03610cfe366004614d2f565b613105565b604051610436919061532f565b348015610d1c57600080fd5b50600a5462010000900460ff1661042a565b60006001600160e01b0319821663e110976f60e01b1480610d5f57506001600160e01b03198216632a2d979f60e01b145b80610d7a57506001600160e01b0319821663f53c966760e01b145b80610d9557506001600160e01b03198216634f558e7960e01b145b80610db057506001600160e01b03198216637d62321d60e01b145b80610dcb57506001600160e01b0319821663128009d560e11b145b80610de657506001600160e01b03198216633182441360e01b145b80610e0157506001600160e01b03198216636eba00f560e01b145b80610e1c57506001600160e01b0319821663e945adcd60e01b145b80610e3757506001600160e01b0319821663780e9d6360e01b145b80610e5157506001600160e01b03198216628d87a360e21b145b80610e6c57506001600160e01b03198216635b5e139f60e01b145b80610e8757506001600160e01b031982166308f770ad60e41b145b80610ea257506001600160e01b031982166305ba8d5960e41b145b80610ebd57506001600160e01b03198216634b8ae87360e01b145b80610ecc5750610ecc8261317c565b92915050565b6000546000805160206156dc833981519152906001600160a01b03163314801590610f175750600081815260016020908152604080832033845290915290205460ff16155b15610f4f57335b60405163122994e360e11b81526001600160a01b039091166004820152602481018290526044015b60405180910390fd5b600a805461ff0019166101008415158102919091179182905560405160ff9190920416151581527f9ea33dbe4d69c7808ed9609b1dedcb7440e12568855e708b8e8b50825e104329906020015b60405180910390a15050565b6060600b8054610fb790615342565b80601f0160208091040260200160405190810160405280929190818152602001828054610fe390615342565b80156110305780601f1061100557610100808354040283529160200191611030565b820191906000526020600020905b81548152906001019060200180831161101357829003601f168201915b5050505050905090565b6000611045826131a1565b6110655760405163c927e5bf60e01b815260048101839052602401610f46565b506000908152600660205260409020546001600160a01b031690565b600061108c82611ce8565b9050806001600160a01b0316836001600160a01b031614156110ca5760405163307134a760e21b815233600482015260248101839052604401610f46565b336001600160a01b038216148015906110ea57506110e88133610c78565b155b156111285760405163322c2e2960e11b81526001600160a01b0380831660048301528416602482015260448101839052336064820152608401610f46565b6111338383836131db565b505050565b6000546000805160206156dc833981519152906001600160a01b0316331480159061117d5750600081815260016020908152604080832033845290915290205460ff16155b156111885733610f1e565b61119182613237565b60145460005b8181101561124c57836001600160a01b0316601482815481106111bc576111bc61537d565b6000918252602090912001546001600160a01b0316141561123a576001600160a01b0384166000908152601560205260409020805460ff19169055611200816132a2565b6040516001600160a01b038516907fc8dde7702ada02e3271777e080f36befb2dfe4975ff5a35cdcc61f7116c893d390600090a250505050565b80611244816153a9565b915050611197565b5060405163a5be5e0f60e01b81526001600160a01b0384166004820152602401610f46565b5050565b6000546000805160206156dc833981519152906001600160a01b031633148015906112ba5750600081815260016020908152604080832033845290915290205460ff16155b156112c55733610f1e565b6112cd613380565b81516112e090600f906020850190614b18565b50600f6040516112f091906153c4565b604051908190038120907f8aef9948275592a4a1496813f92b3c13911528c06421256850f9f611e001874090600090a25050565b600061132f60035490565b6113376133ab565b6113419190615460565b905090565b600a5462010000900460ff16156113705760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b031633148015906113b55750600081815260016020908152604080832033845290915290205460ff16155b156113c05733610f1e565b6113c9856131a1565b6113e95760405163c927e5bf60e01b815260048101869052602401610f46565b6000858152601060209081526040909120835161140892850190614b18565b506000858152601160205260409020805460ff191685151517905582801561143f575060008581526012602052604090205460ff16155b1561148557600085815260126020526040808220805460ff191660011790555186917fafd1af0d18662bc4cbe66cd3885857264bb71d267eb57c0add879e84a5be317791a25b816040516114939190615477565b60408051918290038220600080845260208401529187917f2a228bf8ab34c4401425e787b89ef2b1cad5e2e93daf585a1e62dd9ce87fcedd910160405180910390a35050505050565b600a54610100900460ff166115045760405163b7b2409760e01b815260040160405180910390fd5b61150d816133bc565b8061151760085490565b6115219190615493565b341461155e57348161153260085490565b61153c9190615493565b60405163e763535560e01b815260048101929092526024820152604401610f46565b61156833826134cb565b50565b6000547ffdd7b2ba629c0a0b84029cda831836222e5708c95d3e782c0762066b472dad0e906001600160a01b031633148015906115c25750600081815260016020908152604080832033845290915290205460ff16155b156115cd5733610f1e565b6115d6826133bc565b61113383836134cb565b6111338383836134e5565b6000546001600160a01b0316331461162457335b604051630e60d8d360e41b81526001600160a01b039091166004820152602401610f46565b61127182826137be565b600061163983611cfa565b82111561166c578161164a84611cfa565b6040516363a056dd60e01b815260048101929092526024820152604401610f46565b60006116766133ab565b90506000805b828110156116e75761168d816131a1565b156116d557856001600160a01b03166116a582613845565b516001600160a01b031614156116d557848214156116c7579250610ecc915050565b816116d1816153a9565b9250505b806116df816153a9565b91505061167c565b506040516301b2776960e11b815260040160405180910390fd5b606061170c83613237565b81516000816001600160401b0381111561172857611728614d4c565b604051908082528060200260200182016040528015611751578160200160208202803683370190505b50905060005b828110156117f8576001600160a01b038616600090815260166020908152604080832060178352818420548452909152812086519091908790849081106117a0576117a061537d565b6020026020010151815260200190815260200160002060009054906101000a900460ff168282815181106117d6576117d661537d565b91151560209283029190910190910152806117f0816153a9565b915050611757565b50949350505050565b6000546001600160a01b0316331461181957336115ff565b611823600061394c565b565b60606013805480602002602001604051908101604052809291908181526020016000905b82821015611891576000848152602090819020604080518082019091526002850290910180546001600160a01b03168252600190810154828401529083529092019101611849565b50505050905090565b6000547f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a3906001600160a01b031633148015906118f15750600081815260016020908152604080832033845290915290205460ff16155b156118fc5733610f1e565b600954601354479190811580611910575080155b1561192e57604051639811e0c760e01b815260040160405180910390fd5b600061193a83856154c8565b905060005b82811015611a395760006013828154811061195c5761195c61537d565b600091825260208083206040805180820190915260029093020180546001600160a01b031683526001015490820181905290925061199b908590615493565b82516040519192506001600160a01b03169082156108fc029083906000818181858888f193505050501580156119d5573d6000803e3d6000fd5b5081516001600160a01b0316336001600160a01b03167f8957f76027b186a481886d5e1dfef5a49a9b792649df75e9dd5e53cde75c71ea83604051611a1c91815260200190565b60405180910390a350508080611a31906153a9565b91505061193f565b5060095433907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d590611a6b9084615493565b6040519081526020015b60405180910390a25050505050565b61113383838360405180602001604052806000815250612660565b6000610ecc826131a1565b6000611ab4611324565b8210611ac3578161164a611324565b600354611ad557610ecc8260016154dc565b600080611ae06133ab565b905060005b818110156116e75784831415611afd57949350505050565b611b06816131a1565b15611b195782611b15816153a9565b9350505b80611b23816153a9565b915050611ae5565b600a5462010000900460ff1615611b555760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590611b9a5750600081815260016020908152604080832033845290915290205460ff16155b15611ba55733610f1e565b8151611bb890600d906020850190614b18565b5081604051611bc79190615477565b604051908190038120907fafa35f42f46f5052816d7c6a2e9406eca98294b20726677862d83b4a7418d8d590600090a25050565b6000546000805160206156dc833981519152906001600160a01b03163314801590611c405750600081815260016020908152604080832033845290915290205460ff16155b15611c4b5733610f1e565b611c54826131a1565b611c745760405163c927e5bf60e01b815260048101839052602401610f46565b600082815260126020526040808220805460ff191660011790555183917fafd1af0d18662bc4cbe66cd3885857264bb71d267eb57c0add879e84a5be317791a25050565b6000611cc26133ab565b7f0000000000000000000000000000000000000000000000000000000000000032611337565b6000611cf382613845565b5192915050565b60006001600160a01b038216611d235760405163e99d5ac560e01b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160801b031690565b6000546000805160206156dc833981519152906001600160a01b03163314801590611d8d5750600081815260016020908152604080832033845290915290205460ff16155b15611d985733610f1e565b6111336040518060400160405280856001600160a01b031681526020018481525061399c565b600a5462010000900460ff1615611de85760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590611e2d5750600081815260016020908152604080832033845290915290205460ff16155b15611e385733610f1e565b8151611e4b90600e906020850190614b18565b50600e604051611e5b91906153c4565b604051908190038120907fb6b2b7d0cff2ae8f651bd60fb4eb42b79f6e366900a72af6156ea30044179e8e90600090a25050565b6000611e9a826131a1565b611eba5760405163c927e5bf60e01b815260048101839052602401610f46565b5060009081526011602052604090205460ff1690565b6000546000805160206156dc833981519152906001600160a01b03163314801590611f155750600081815260016020908152604080832033845290915290205460ff16155b15611f205733610f1e565b611f2982613237565b6001600160a01b0382166000908152601760205260408120805491611f4d836153a9565b90915550506001600160a01b038216600081815260186020526040808220829055517ff1d918039d4ced601abd661af27bad3fa7cd09c72e6052e04d27348656f9b7069190a25050565b805180611fee57600060017f000000000000000000000000000000000000000000000000000000000000000a5b6040516346f4384b60e01b8152600481019390935260248301919091526044820152606401610f46565b611ff7816133bc565b61200083613b4c565b600061200b84613bd7565b5190506120188282615493565b3414612029573461153c8383615493565b612034338585613c44565b61203e8484613e3b565b61204833836134cb565b50505050565b6000546000805160206156dc833981519152906001600160a01b031633148015906120935750600081815260016020908152604080832033845290915290205460ff16155b1561209e5733610f1e565b6111338383613f56565b61156881336140b1565b6000546000805160206156dc833981519152906001600160a01b031633148015906120f75750600081815260016020908152604080832033845290915290205460ff16155b156121025733610f1e565b60088290556040518281527fa6dc15bdb68da224c66db4b3838d9a2b205138e8cff6774e57d0af91e196d62290602001610f9c565b6060600c8054610fb790615342565b606060006121526133ab565b90506000816001600160401b0381111561216e5761216e614d4c565b6040519080825280602002602001820160405280156121b957816020015b604080516060810182526000808252602080830182905292820152825260001990920191018161218c5790505b50905060015b828111612282576121cf816131a1565b1561222b5760408051606081018252828152600060208201529081016121f483611ce8565b6001600160a01b031690528261220b600184615460565b8151811061221b5761221b61537d565b6020026020010181905250612270565b604080516060810190915281815260208101600181523060209091015282612254600184615460565b815181106122645761226461537d565b60200260200101819052505b8061227a816153a9565b9150506121bf565b5092915050565b6000546000805160206156dc833981519152906001600160a01b031633148015906122ce5750600081815260016020908152604080832033845290915290205460ff16155b156122d95733610f1e565b6001600160a01b0382166123005760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b8181101561236657836001600160a01b03166013828154811061232b5761232b61537d565b60009182526020909120600290910201546001600160a01b031614156123545761204881614134565b8061235e816153a9565b915050612306565b506040516354a932f560e01b81526001600160a01b0384166004820152602401610f46565b6000612396826131a1565b6123b65760405163c927e5bf60e01b815260048101839052602401610f46565b60008281526012602052604090205460ff1680610ecc5750600a5460ff1692915050565b6001600160a01b03821633141561240e576040516372b3985f60e01b81523360048201528115156024820152604401610f46565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000546000805160206156dc833981519152906001600160a01b031633148015906124bf5750600081815260016020908152604080832033845290915290205460ff16155b156124ca5733610f1e565b6001600160a01b0383166124f15760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b818110156125b257846001600160a01b03166013828154811061251c5761251c61537d565b60009182526020909120600290910201546001600160a01b031614156125a05783601382815481106125505761255061537d565b906000526020600020906002020160010181905550846001600160a01b03167f06945c82029753372decfeace485696553ab08354f682b4fa8e08d277e25498585604051611a7591815260200190565b806125aa816153a9565b9150506124f7565b506040516354a932f560e01b81526001600160a01b0385166004820152602401610f46565b6000546000805160206156dc833981519152906001600160a01b0316331480159061261c5750600081815260016020908152604080832033845290915290205460ff16155b156126275733610f1e565b600a805460ff191660011790556040517fe2a7169cedebe39671840370ae19ca4fc41be6191d4c77f174f189a4d8cd08c890600090a150565b61266b8484846134e5565b612677848484846142ba565b6120485760405163a371886b60e01b81526001600160a01b0380861660048301528416602482015260448101839052606401610f46565b6000546000805160206156dc833981519152906001600160a01b031633148015906126f35750600081815260016020908152604080832033845290915290205460ff16155b156126fe5733610f1e565b61270783613237565b6001600160a01b03831660009081526019602052604090206002015460ff16151582151514611133576001600160a01b0383166000818152601960205260409081902060028101805486151560ff1990911617905590517f0e26d8e2549574e8d6493ef972ea195acde7d56ff6b7a7114978c2b5edf9ea8e916127a891815481526001820154602082015260029091015460ff161515604082015260600190565b60405180910390a2505050565b6060600f8054610fb790615342565b60606127cf826131a1565b6127ef5760405163c927e5bf60e01b815260048101839052602401610f46565b6000828152601060205260408120805461280890615342565b80601f016020809104026020016040519081016040528092919081815260200182805461283490615342565b80156128815780601f1061285657610100808354040283529160200191612881565b820191906000526020600020905b81548152906001019060200180831161286457829003601f168201915b505050505090506000600d805461289790615342565b80601f01602080910402602001604051908101604052809291908181526020018280546128c390615342565b80156129105780601f106128e557610100808354040283529160200191612910565b820191906000526020600020905b8154815290600101906020018083116128f357829003601f168201915b5050600a54939450505060ff909116159050801561293d575060008481526012602052604090205460ff16155b156129d657600e805461294f90615342565b80601f016020809104026020016040519081016040528092919081815260200182805461297b90615342565b80156129c85780601f1061299d576101008083540402835291602001916129c8565b820191906000526020600020905b8154815290600101906020018083116129ab57829003601f168201915b505050505092505050919050565b815115612a265760008481526011602052604090205460ff16156129fb575092915050565b8082604051602001612a0e9291906154f4565b60405160208183030381529060405292505050919050565b6000600d8054612a3590615342565b905011156122825780612a47856143c5565b604051602001612a0e9291906154f4565b601354600090815b8181101561236657836001600160a01b031660138281548110612a8557612a8561537d565b60009182526020909120600290910201546001600160a01b03161415612ad35760138181548110612ab857612ab861537d565b90600052602060002090600202016001015492505050919050565b80612add816153a9565b915050612a60565b600a5462010000900460ff1615612b0f5760405163b087bbf360e01b815260040160405180910390fd5b6000546000805160206156dc833981519152906001600160a01b03163314801590612b545750600081815260016020908152604080832033845290915290205460ff16155b15612b5f5733610f1e565b600a805462ff00001916620100001790556040517feef043febddf4e1d1cf1f72ff1407b84e036e805aa0934418cb82095da8d716490600090a150565b60148054604080516020808402820181019092528281526060936000928490830182828015612bf457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612bd6575b505050505090506000826001600160401b03811115612c1557612c15614d4c565b604051908082528060200260200182016040528015612c4e57816020015b612c3b614b9c565b815260200190600190039081612c335790505b50905060005b83811015612d8a576000838281518110612c7057612c7061537d565b602002602001015190506040518060a00160405280826001600160a01b03168152602001612c9d836144c2565b8152602001612cab8361453b565b815260200160186000878681518110612cc657612cc661537d565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054815260200160196000878681518110612d0a57612d0a61537d565b6020908102919091018101516001600160a01b031682528181019290925260409081016000208151606081018352815481526001820154938101939093526002015460ff1615159082015290528351849084908110612d6b57612d6b61537d565b6020026020010181905250508080612d82906153a9565b915050612c54565b509392505050565b6000546001600160a01b03163314612daa57336115ff565b61127182826140b1565b6000546000805160206156dc833981519152906001600160a01b03163314801590612df95750600081815260016020908152604080832033845290915290205460ff16155b15612e045733610f1e565b612e0d83613237565b6001600160a01b03831660008181526019602090815260409182902085518155908501516001820155848201516002909101805460ff1916911515919091179055517f0e26d8e2549574e8d6493ef972ea195acde7d56ff6b7a7114978c2b5edf9ea8e906127a8908590615523565b6000546000805160206156dc833981519152906001600160a01b03163314801590612ec15750600081815260016020908152604080832033845290915290205460ff16155b15612ecc5733610f1e565b6040514790339082156108fc029083906000818181858888f19350505050158015612efb573d6000803e3d6000fd5b5060405181815233907f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e51906020015b60405180910390a25050565b6000547f7c13537556c77ef3fb98601c3356887ddbe5991e86dc065741ce77e1dd2554a3906001600160a01b03163314801590612f8d5750600081815260016020908152604080832033845290915290205460ff16155b15612f985733610f1e565b6001600160a01b038316612fbf5760405163e99d5ac560e01b815260040160405180910390fd5b612fd36001600160a01b0385168484614599565b826001600160a01b0316846001600160a01b03167f401f439d865a766757ec78675925bd67198d5e78805aa41691b34b5d6a6cbbe68460405161301891815260200190565b60405180910390a350505050565b6000546000805160206156dc833981519152906001600160a01b0316331480159061306b5750600081815260016020908152604080832033845290915290205460ff16155b156130765733610f1e565b61307e613380565b600a805463ff000000191663010000001790556040517f294f0756ade420332ef086187515f4a3af6e693dfe5ca7e10990f5d61bf06dd390600090a150565b6000546001600160a01b031633146130d557336115ff565b6001600160a01b0381166130fc5760405163e99d5ac560e01b815260040160405180910390fd5b6115688161394c565b61310d614b9c565b61311682613237565b6040518060a00160405280836001600160a01b03168152602001613139846144c2565b81526020016131478461453b565b81526001600160a01b03841660009081526018602090815260409182902054908301520161317484613bd7565b905292915050565b60006001600160e01b03198216634b88b8ad60e11b1480610ecc5750610ecc826145eb565b600080821180156131b3575060025482105b8015610ecc57506000828152600460205260409020546001600160a01b031630141592915050565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6001600160a01b03811661325e5760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03811660009081526015602052604090205460ff166115685760405163a5be5e0f60e01b81526001600160a01b0382166004820152602401610f46565b6014548082106132b0575050565b815b6132bd600183615460565b8110156133485760146132d18260016154dc565b815481106132e1576132e161537d565b600091825260209091200154601480546001600160a01b03909216918390811061330d5761330d61537d565b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905580613340816153a9565b9150506132b2565b50601480548061335a5761335a615546565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b600a546301000000900460ff161561182357604051632edca92560e01b815260040160405180910390fd5b600060016002546113419190615460565b7f000000000000000000000000000000000000000000000000000000000000000a8111806133e8575080155b15613416578060017f000000000000000000000000000000000000000000000000000000000000000a611fc4565b7f0000000000000000000000000000000000000000000000000000000000000032816134406133ab565b61344a91906154dc565b111561156857806134596133ab565b613483907f0000000000000000000000000000000000000000000000000000000000000032615460565b6040516302d95a3b60e11b8152600481019290925260248201527f00000000000000000000000000000000000000000000000000000000000000326044820152606401610f46565b611271828260405180602001604052806000815250614610565b6001600160a01b03821661350c5760405163e99d5ac560e01b815260040160405180910390fd5b600061351782613845565b9050836001600160a01b031681600001516001600160a01b03161461357d57335b815160405163753e1c4f60e11b81526001600160a01b03928316600482015282871660248201528286166044820152606481018590529116608482015260a401610f46565b80516001600160a01b0316336001600160a01b0316141580156135b15750336135a58361103a565b6001600160a01b031614155b80156135c6575080516135c49033610c78565b155b156135d15733613538565b6135e160008383600001516131db565b6001600160a01b03841660009081526005602052604081208054600192906136139084906001600160801b031661555c565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0385166000908152600560205260408120805460019450909261365f91859116615584565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380861682526001600160401b03428116602080850191825260008881526004909152948520935184549151909216600160a01b026001600160e01b031990911691909216171790556136e68360016154dc565b6000818152600460205260409020549091506001600160a01b03166137755761370e816131a1565b156137755760408051808201825283516001600160a01b0390811682526020808601516001600160401b039081168285019081526000878152600490935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b82846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166112715760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6040805180820190915260008082526020820152613862826131a1565b6138825760405163c927e5bf60e01b815260048101839052602401610f46565b60007f000000000000000000000000000000000000000000000000000000000000000a83106138e3576138d57f000000000000000000000000000000000000000000000000000000000000000a84615460565b6138e09060016154dc565b90505b825b8181106116e7576000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b0316918301919091521561393957949350505050565b5080613944816155a6565b9150506138e5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60208101516139be57604051639811e0c760e01b815260040160405180910390fd5b80516001600160a01b03166139e65760405163e99d5ac560e01b815260040160405180910390fd5b60135460005b81811015613a6e5782600001516001600160a01b031660138281548110613a1557613a1561537d565b60009182526020909120600290910201546001600160a01b03161415613a5c5782516040516370d2049160e01b81526001600160a01b039091166004820152602401610f46565b80613a66816153a9565b9150506139ec565b5060138054600181018255600091825283517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a090600290920291820180546001600160a01b0319166001600160a01b0390921691909117905560208401517f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0919091018190556009805491929091613b059084906154dc565b909155505081516020808401516040519081526001600160a01b03909216917f3bc19114ca6a687ffd9445c87615db284e96364365d72b010ec53244b45e561b9101612f2a565b6001600160a01b03811660009081526015602052604090205460ff16613b905760405163a5be5e0f60e01b81526001600160a01b0382166004820152602401610f46565b6001600160a01b03811660009081526019602052604090206002015460ff1661156857604051637a08c0fb60e11b81526001600160a01b0382166004820152602401610f46565b613bfd604051806060016040528060008152602001600081526020016000151581525090565b506001600160a01b03166000908152601960209081526040918290208251606081018452815481526001820154928101929092526002015460ff1615159181019190915290565b80516001600160a01b038316600090815260196020908152604080832060010154601890925290912054613c799083906154dc565b1115613cbe576001600160a01b03831660008181526019602052604090819020600101549051635ca6c35960e01b815260048101929092526024820152604401610f46565b60005b818110156137b7576000838281518110613cdd57613cdd61537d565b60200260200101519050846001600160a01b0316636352211e826040518263ffffffff1660e01b8152600401613d1591815260200190565b602060405180830381865afa925050508015613d4e575060408051601f3d908101601f19168201909252613d4b918101906155bd565b60015b613d7d576040516302682da560e41b81526001600160a01b038616600482015260248101829052604401610f46565b866001600160a01b0316816001600160a01b031614613dc1576040516302682da560e41b81526001600160a01b038716600482015260248101839052604401610f46565b506001600160a01b038516600090815260166020908152604080832060178352818420548452825280832084845290915290205460ff1615613e285760405163cf3571af60e01b81526001600160a01b038616600482015260248101829052604401610f46565b5080613e33816153a9565b915050613cc1565b805160005b81811015613f23576001600160a01b0384166000908152601660209081526040808320601783528184205484529091528120845160019290869085908110613e8a57613e8a61537d565b6020026020010151815260200190815260200160002060006101000a81548160ff021916908315150217905550828181518110613ec957613ec961537d565b6020026020010151846001600160a01b0316336001600160a01b03167f728e641386299b5070162250083c0abc8f1d93cd543b23eaed63336575ca994c60405160405180910390a480613f1b816153a9565b915050613e40565b506001600160a01b03831660009081526018602052604081208054839290613f4c9084906154dc565b9091555050505050565b6001600160a01b038216613f7d5760405163e99d5ac560e01b815260040160405180910390fd5b6001600160a01b03821660009081526015602052604090205460ff1615613fc2576040516354d67cef60e01b81526001600160a01b0383166004820152602401610f46565b6001600160a01b0382166000908152601560209081526040808320805460ff1916600117905560179091528120805491613ffb836153a9565b90915550506001600160a01b03821660008181526019602090815260408083208551815591850151600180840191909155858201516002909301805460ff1916931515939093179092556014805492830181559092527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec0180546001600160a01b03191683179055517fab109b1e3dd4bf279798315182b336f138e930aec9aaeafe98f768450d9fd9b790612f2a908490615523565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16156112715760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60138054906000908383811061414c5761414c61537d565b60009182526020918290206040805180820190915260029092020180546001600160a01b0316825260010154918101919091529050825b61418e600184615460565b81101561421d5760136141a28260016154dc565b815481106141b2576141b261537d565b9060005260206000209060020201601382815481106141d3576141d361537d565b60009182526020909120825460029092020180546001600160a01b0319166001600160a01b0390921691909117815560019182015491015580614215816153a9565b915050614183565b50601380548061422f5761422f615546565b6000828152602080822060026000199094019384020180546001600160a01b0319168155600101829055919092558201516009805491929091614273908490615460565b909155505080516020808301516040519081526001600160a01b03909216917f775539f018602cb5533761287430a74c8cc49b559ee2fbcd32e086789206382a91016127a8565b60006001600160a01b0384163b156143b957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906142fe9033908990889088906004016155da565b6020604051808303816000875af1925050508015614339575060408051601f3d908101601f1916820190925261433691810190615617565b60015b61439f573d808015614367576040519150601f19603f3d011682016040523d82523d6000602084013e61436c565b606091505b50805161439757604051634e1cb28960e11b81526001600160a01b0386166004820152602401610f46565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506143bd565b5060015b949350505050565b6060816143e95750506040805180820190915260018152600360fc1b602082015290565b8160005b811561441357806143fd816153a9565b915061440c9050600a836154c8565b91506143ed565b6000816001600160401b0381111561442d5761442d614d4c565b6040519080825280601f01601f191660200182016040528015614457576020820181803683370190505b5090505b84156143bd5761446c600183615460565b9150614479600a86615634565b6144849060306154dc565b60f81b8183815181106144995761449961537d565b60200101906001600160f81b031916908160001a9053506144bb600a866154c8565b945061445b565b6060816001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561452357506040513d6000823e601f3d908101601f191682016040526145209190810190615648565b60015b610ecc57505060408051602081019091526000815290565b6060816001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa92505050801561452357506040513d6000823e601f3d908101601f191682016040526145209190810190615648565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611133908490614872565b60006001600160e01b031982166380ac58cd60e01b1480610ecc5750610ecc82614944565b6002546001600160a01b03841661463a5760405163e99d5ac560e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000a831180614666575082155b156146b4576040516346f4384b60e01b815260048101849052600160248201527f000000000000000000000000000000000000000000000000000000000000000a6044820152606401610f46565b6001600160a01b0384166000908152600560209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190614710908790615584565b6001600160801b0316815260200185836020015161472e9190615584565b6001600160801b039081169091526001600160a01b0380881660008181526005602090815260408083208751978301518716600160801b029790961696909617909455845180860186529182526001600160401b034281168386019081528883526004909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b858110156148675760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461481160008884886142ba565b6148475760405163a371886b60e01b8152600060048201526001600160a01b038816602482015260448101839052606401610f46565b81614851816153a9565b925050808061485f906153a9565b9150506147c4565b506002555050505050565b60006148c7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166149699092919063ffffffff16565b80519091501561113357808060200190518101906148e591906156be565b6111335760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f46565b60006001600160e01b0319821663e00008a960e01b1480610ecc5750610ecc82614982565b606061497884846000856149b7565b90505b9392505050565b60006001600160e01b03198216634b8ae87360e01b1480610ecc57506301ffc9a760e01b6001600160e01b0319831614610ecc565b606082471015614a185760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f46565b843b614a665760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f46565b600080866001600160a01b03168587604051614a829190615477565b60006040518083038185875af1925050503d8060008114614abf576040519150601f19603f3d011682016040523d82523d6000602084013e614ac4565b606091505b5091509150614ad4828286614adf565b979650505050505050565b60608315614aee57508161497b565b825115614afe5782518084602001fd5b8160405162461bcd60e51b8152600401610f469190614cc2565b828054614b2490615342565b90600052602060002090601f016020900481019282614b465760008555614b8c565b82601f10614b5f57805160ff1916838001178555614b8c565b82800160010185558215614b8c579182015b82811115614b8c578251825591602001919060010190614b71565b50614b98929150614bf7565b5090565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001614bf2604051806060016040528060008152602001600081526020016000151581525090565b905290565b5b80821115614b985760008155600101614bf8565b6001600160e01b03198116811461156857600080fd5b600060208284031215614c3457600080fd5b813561497b81614c0c565b801515811461156857600080fd5b600060208284031215614c5f57600080fd5b813561497b81614c3f565b60005b83811015614c85578181015183820152602001614c6d565b838111156120485750506000910152565b60008151808452614cae816020860160208601614c6a565b601f01601f19169290920160200192915050565b60208152600061497b6020830184614c96565b600060208284031215614ce757600080fd5b5035919050565b6001600160a01b038116811461156857600080fd5b60008060408385031215614d1657600080fd5b8235614d2181614cee565b946020939093013593505050565b600060208284031215614d4157600080fd5b813561497b81614cee565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614d8a57614d8a614d4c565b604052919050565b60006001600160401b03821115614dab57614dab614d4c565b50601f01601f191660200190565b6000614dcc614dc784614d92565b614d62565b9050828152838383011115614de057600080fd5b828260208301376000602084830101529392505050565b600082601f830112614e0857600080fd5b61497b83833560208501614db9565b600060208284031215614e2957600080fd5b81356001600160401b03811115614e3f57600080fd5b6143bd84828501614df7565b60008060008060808587031215614e6157600080fd5b843593506020850135614e7381614c3f565b92506040850135614e8381614c3f565b915060608501356001600160401b03811115614e9e57600080fd5b614eaa87828801614df7565b91505092959194509250565b600080600060608486031215614ecb57600080fd5b8335614ed681614cee565b92506020840135614ee681614cee565b929592945050506040919091013590565b60008060408385031215614f0a57600080fd5b823591506020830135614f1c81614cee565b809150509250929050565b60008060408385031215614f3a57600080fd5b8235614f4581614cee565b91506020838101356001600160401b0380821115614f6257600080fd5b818601915086601f830112614f7657600080fd5b813581811115614f8857614f88614d4c565b8060051b9150614f99848301614d62565b8181529183018401918481019089841115614fb357600080fd5b938501935b83851015614fd157843582529385019390850190614fb8565b8096505050505050509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561501b578351151583529284019291840191600101614ffd565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561507257815180516001600160a01b03168552860151868501529284019290850190600101615044565b5091979650505050505050565b600080828403608081121561509357600080fd5b833561509e81614cee565b92506060601f19820112156150b257600080fd5b50604051606081018181106001600160401b03821117156150d5576150d5614d4c565b8060405250602084013581526040840135602082015260608401356150f981614c3f565b6040820152919491935090915050565b60208082528251828201819052600091906040908185019086840185805b8381101561517b57825180518652878101516002811061515557634e487b7160e01b84526021600452602484fd5b868901528601516001600160a01b03168686015260609094019391860191600101615127565b509298975050505050505050565b6000806040838503121561519c57600080fd5b82356151a781614cee565b91506020830135614f1c81614c3f565b600080600080608085870312156151cd57600080fd5b84356151d881614cee565b935060208501356151e881614cee565b92506040850135915060608501356001600160401b0381111561520a57600080fd5b8501601f8101871361521b57600080fd5b614eaa87823560208401614db9565b60018060a01b0381511682526000602082015160e0602085015261525160e0850182614c96565b90506040830151848203604086015261526a8282614c96565b915050606083015160608501526080830151612d8a608086018280518252602080820151908301526040908101511515910152565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156152f457603f198886030184526152e285835161522a565b945092850192908501906001016152c6565b5092979650505050505050565b6000806040838503121561531457600080fd5b823561531f81614cee565b91506020830135614f1c81614cee565b60208152600061497b602083018461522a565b600181811c9082168061535657607f821691505b6020821081141561537757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156153bd576153bd615393565b5060010190565b600080835481600182811c9150808316806153e057607f831692505b602080841082141561540057634e487b7160e01b86526022600452602486fd5b818015615414576001811461542557615452565b60ff19861689528489019650615452565b60008a81526020902060005b8681101561544a5781548b820152908501908301615431565b505084890196505b509498975050505050505050565b60008282101561547257615472615393565b500390565b60008251615489818460208701614c6a565b9190910192915050565b60008160001904831182151516156154ad576154ad615393565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826154d7576154d76154b2565b500490565b600082198211156154ef576154ef615393565b500190565b60008351615506818460208801614c6a565b83519083019061551a818360208801614c6a565b01949350505050565b815181526020808301519082015260408083015115159082015260608101610ecc565b634e487b7160e01b600052603160045260246000fd5b60006001600160801b038381169083168181101561557c5761557c615393565b039392505050565b60006001600160801b0380831681851680830382111561551a5761551a615393565b6000816155b5576155b5615393565b506000190190565b6000602082840312156155cf57600080fd5b815161497b81614cee565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061560d90830184614c96565b9695505050505050565b60006020828403121561562957600080fd5b815161497b81614c0c565b600082615643576156436154b2565b500690565b60006020828403121561565a57600080fd5b81516001600160401b0381111561567057600080fd5b8201601f8101841361568157600080fd5b805161568f614dc782614d92565b8181528560208385010111156156a457600080fd5b6156b5826020830160208601614c6a565b95945050505050565b6000602082840312156156d057600080fd5b815161497b81614c3f56fe7e69b879a040173b938f56bb64bfa62bcd758c08ae6ed7cfdf7da6d7dba92708a2646970667358221220eaeedbc3815edc453aede94422d11eab4daa7592624a84532df15533abfb2f8464736f6c634300080b0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000002c68af0bb1400000000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000104f70757363756c612047656e657369730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034f434700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a440000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c0b1a85255bb74c4b5d7a17af1305f29623d0b540000000000000000000000000000000000000000000000000000000000000050000000000000000000000000b5651a4a8c4ce095f56558a08a1fd1defd2fc6b700000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f7cf6747c81829585f18e8021d267fd4866e518900000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : config (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
31 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [3] : 00000000000000000000000000000000000000000000000000000000000001c0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000240
Arg [6] : 00000000000000000000000000000000000000000000000002c68af0bb140000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [8] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000280
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000010
Arg [12] : 4f70757363756c612047656e6573697300000000000000000000000000000000
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [14] : 4f43470000000000000000000000000000000000000000000000000000000000
Arg [15] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [16] : 000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a44
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [18] : 000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a44
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [20] : 000000000000000000000000b25269b24c367beb9eb7102d569b10d86a3b1a44
Arg [21] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [22] : 000000000000000000000000c0b1a85255bb74c4b5d7a17af1305f29623d0b54
Arg [23] : 0000000000000000000000000000000000000000000000000000000000000050
Arg [24] : 000000000000000000000000b5651a4a8c4ce095f56558a08a1fd1defd2fc6b7
Arg [25] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [26] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [27] : 000000000000000000000000f7cf6747c81829585f18e8021d267fd4866e5189
Arg [28] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000
Arg [29] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [30] : 0000000000000000000000000000000000000000000000000000000000000000


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.