ETH Price: $3,314.87 (-4.48%)

Token

Splice (SPLICE)
 

Overview

Max Total Supply

0 SPLICE

Holders

22

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
richpoole.eth
Balance
1 SPLICE
0x7c228e74D601Ee9414277a674ABf9b58950E87CC
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:
Splice

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 36 : Splice.sol
// contracts/Splice.sol
// SPDX-License-Identifier: MIT

/*
     LCL  SSL      CSL  SSL      LCI       ISL       LCL  ISL        CI  ISL
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       LL        PEE  EES       LEEL LL 
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL    
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL LLL
     PEE  LL       EES LEEL      IEE       IPL       PEE  LLL       LEEL EES
LLL  PEE           EES  SSL      IEE       PEC       PEE  LLL       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LLL
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL    
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LL 
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
LSI  LSI           LCL           LSS       ISL       LSI  ISL       LSS  ISL
*/

pragma solidity 0.8.10;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol';

import './BytesLib.sol';
import './ArrayLib.sol';
import './Structs.sol';
import './SpliceStyleNFT.sol';
import './ReplaceablePaymentSplitter.sol';

/// @title Splice is a protocol to mint NFTs out of origin NFTs
/// @author Stefan Adolf @elmariachi111

contract Splice is
  ERC721Upgradeable,
  OwnableUpgradeable,
  PausableUpgradeable,
  ReentrancyGuardUpgradeable,
  IERC2981Upgradeable
{
  using SafeMathUpgradeable for uint256;
  using StringsUpgradeable for uint32;

  /// @notice you didn't send sufficient fees along
  error InsufficientFees();

  /// @notice The combination of origin and style already has been minted
  error ProvenanceAlreadyUsed();

  /// @notice only reserved mints are left or not on allowlist
  error NotAllowedToMint(string reason);

  error NotOwningOrigin();

  uint8 public ROYALTY_PERCENT;

  string private baseUri;

  //lookup table
  //keccak(0xcollection + origin_tokenId + styleTokenId)  => tokenId
  mapping(bytes32 => uint64) public provenanceToTokenId;

  /**
   * @notice the contract that manages all styles as NFTs.
   * Styles are owned by artists and manage fee quoting.
   * Style NFTs are transferrable (you can sell your style to others)
   */
  SpliceStyleNFT public styleNFT;

  /**
   * @notice the splice platform account, i.e. a Gnosis Safe / DAO Treasury etc.
   */
  address public platformBeneficiary;

  event Withdrawn(address indexed user, uint256 amount);
  event Minted(
    bytes32 indexed origin_hash,
    uint64 indexed tokenId,
    uint32 indexed styleTokenId
  );
  event RoyaltiesUpdated(uint8 royalties);
  event BeneficiaryChanged(address newBeneficiary);

  function initialize(
    string memory baseUri_,
    SpliceStyleNFT initializedStyleNFT_
  ) public initializer {
    __ERC721_init('Splice', 'SPLICE');
    __Ownable_init();
    __Pausable_init();
    __ReentrancyGuard_init();
    ROYALTY_PERCENT = 10;
    platformBeneficiary = msg.sender;
    baseUri = baseUri_;
    styleNFT = initializedStyleNFT_;
  }

  function pause() external onlyOwner {
    _pause();
  }

  function unpause() external onlyOwner {
    _unpause();
  }

  function setBaseUri(string memory newBaseUri) external onlyOwner {
    baseUri = newBaseUri;
  }

  function _baseURI() internal view override returns (string memory) {
    return baseUri;
  }

  //todo: the platform benef. should be the only one to name a new beneficiary, not the owner.
  function setPlatformBeneficiary(address payable newAddress)
    external
    onlyOwner
  {
    require(address(0) != newAddress, 'must be a real address');
    platformBeneficiary = newAddress;
    emit BeneficiaryChanged(newAddress);
  }

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

  /**
   * in case anything drops ETH/ERC20/ERC721 on us accidentally,
   * this will help us withdraw it.
   */
  function withdrawEth() external nonReentrant onlyOwner {
    AddressUpgradeable.sendValue(
      payable(platformBeneficiary),
      address(this).balance
    );
  }

  function withdrawERC20(IERC20 token) external nonReentrant onlyOwner {
    bool result = token.transfer(
      platformBeneficiary,
      token.balanceOf(address(this))
    );
    if (!result) revert('the transfer failed');
  }

  function withdrawERC721(IERC721 nftContract, uint256 tokenId)
    external
    nonReentrant
    onlyOwner
  {
    nftContract.transferFrom(address(this), platformBeneficiary, tokenId);
  }

  function styleAndTokenByTokenId(uint256 tokenId)
    public
    pure
    returns (uint32 styleTokenId, uint32 token_tokenId)
  {
    bytes memory tokenIdBytes = abi.encode(tokenId);

    styleTokenId = BytesLib.toUint32(tokenIdBytes, 24);
    token_tokenId = BytesLib.toUint32(tokenIdBytes, 28);
  }

  // for OpenSea
  function contractURI() public pure returns (string memory) {
    return 'https://getsplice.io/contract-metadata';
  }

  function tokenURI(uint256 tokenId)
    public
    view
    override
    returns (string memory)
  {
    require(
      _exists(tokenId),
      'ERC721Metadata: URI query for nonexistent token'
    );

    (uint32 styleTokenId, uint32 spliceTokenId) = styleAndTokenByTokenId(
      tokenId
    );
    if (styleNFT.isFrozen(styleTokenId)) {
      StyleSettings memory settings = styleNFT.getSettings(styleTokenId);
      return
        string(
          abi.encodePacked(
            'ipfs://',
            settings.styleCID,
            '/',
            spliceTokenId.toString()
          )
        );
    } else {
      return super.tokenURI(tokenId);
    }
  }

  function quote(
    uint32 styleTokenId,
    IERC721[] memory nfts,
    uint256[] memory originTokenIds
  ) external view returns (uint256 fee) {
    return styleNFT.quoteFee(styleTokenId, nfts, originTokenIds);
  }

  /**
   * @notice this will only have an effect for new styles
   */
  function updateRoyalties(uint8 royaltyPercentage) external onlyOwner {
    require(royaltyPercentage <= 10, 'royalties must never exceed 10%');
    ROYALTY_PERCENT = royaltyPercentage;
    emit RoyaltiesUpdated(royaltyPercentage);
  }

  // https://eips.ethereum.org/EIPS/eip-2981
  // https://docs.openzeppelin.com/contracts/4.x/api/interfaces#IERC2981
  // https://forum.openzeppelin.com/t/how-do-eip-2891-royalties-work/17177
  /**
   * potentially (hopefully) called by marketplaces to find a target address where to send royalties
   * @notice the returned address will be a payment splitting instance
   */
  function royaltyInfo(uint256 tokenId, uint256 salePrice)
    public
    view
    returns (address receiver, uint256 royaltyAmount)
  {
    (uint32 styleTokenId, ) = styleAndTokenByTokenId(tokenId);
    receiver = styleNFT.getSettings(styleTokenId).paymentSplitter;
    royaltyAmount = (ROYALTY_PERCENT * salePrice).div(100);
  }

  function mint(
    IERC721[] memory originCollections,
    uint256[] memory originTokenIds,
    uint32 styleTokenId,
    bytes32[] memory allowlistProof,
    bytes calldata inputParams
  ) external payable whenNotPaused nonReentrant returns (uint64 tokenId) {
    //CHECKS
    require(
      styleNFT.isMintable(
        styleTokenId,
        originCollections,
        originTokenIds,
        msg.sender
      )
    );

    if (styleNFT.availableForPublicMinting(styleTokenId) == 0) {
      if (
        allowlistProof.length == 0 ||
        !styleNFT.verifyAllowlistEntryProof(
          styleTokenId,
          allowlistProof,
          msg.sender
        )
      ) {
        revert NotAllowedToMint('no reservations left or proof failed');
      } else {
        styleNFT.decreaseAllowance(styleTokenId, msg.sender);
      }
    }

    uint256 fee = styleNFT.quoteFee(
      styleTokenId,
      originCollections,
      originTokenIds
    );
    if (msg.value < fee) revert InsufficientFees();

    bytes32 _provenanceHash = keccak256(
      abi.encodePacked(originCollections, originTokenIds, styleTokenId)
    );

    if (provenanceToTokenId[_provenanceHash] != 0x0) {
      revert ProvenanceAlreadyUsed();
    }

    //EFFECTS
    uint32 nextStyleMintId = styleNFT.incrementMintedPerStyle(styleTokenId);
    tokenId = BytesLib.toUint64(
      abi.encodePacked(styleTokenId, nextStyleMintId),
      0
    );
    provenanceToTokenId[_provenanceHash] = tokenId;

    //INTERACTIONS with external contracts
    for (uint256 i = 0; i < originCollections.length; i++) {
      //https://github.com/crytic/building-secure-contracts/blob/master/development-guidelines/token_integration.md
      address _owner = originCollections[i].ownerOf(originTokenIds[i]);
      if (_owner != msg.sender || _owner == address(0)) {
        revert NotOwningOrigin();
      }
    }

    AddressUpgradeable.sendValue(
      payable(styleNFT.getSettings(styleTokenId).paymentSplitter),
      fee
    );

    _safeMint(msg.sender, tokenId);

    emit Minted(
      keccak256(abi.encode(originCollections, originTokenIds)),
      tokenId,
      styleTokenId
    );

    //if someone sent slightly too much, we're sending it back to them
    uint256 surplus = msg.value.sub(fee);

    if (surplus > 0 && surplus < 100_000_000 gwei) {
      AddressUpgradeable.sendValue(payable(msg.sender), surplus);
    }

    return tokenId;
  }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 36 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

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

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

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

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
    uint256[44] private __gap;
}

File 8 of 36 : IERC2981Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";

/**
 * @dev Interface for the NFT Royalty Standard
 */
interface IERC2981Upgradeable is IERC165Upgradeable {
    /**
     * @dev Called with the sale price to determine how much royalty is owed and to whom.
     * @param tokenId - the NFT asset queried for royalty information
     * @param salePrice - the sale price of the NFT asset specified by `tokenId`
     * @return receiver - address of who should be sent the royalty payment
     * @return royaltyAmount - the royalty payment amount for `salePrice`
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}

File 9 of 36 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)

pragma solidity ^0.8.0;

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

File 10 of 36 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

File 11 of 36 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 12 of 36 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
    uint256[49] private __gap;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

File 14 of 36 : BytesLib.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

//https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol
library BytesLib {
  function toUint32(bytes memory _bytes, uint256 _start)
    internal
    pure
    returns (uint32)
  {
    require(_bytes.length >= _start + 4, 'toUint32_outOfBounds');
    uint32 tempUint;

    assembly {
      tempUint := mload(add(add(_bytes, 0x4), _start))
    }

    return tempUint;
  }

  function toUint64(bytes memory _bytes, uint256 _start)
    internal
    pure
    returns (uint64)
  {
    require(_bytes.length >= _start + 8, 'toUint64_outOfBounds');
    uint64 tempUint;

    assembly {
      tempUint := mload(add(add(_bytes, 0x8), _start))
    }

    return tempUint;
  }
}

File 15 of 36 : ArrayLib.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

//https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol
library ArrayLib {
  function contains(address[] memory arr, address item)
    internal
    pure
    returns (bool)
  {
    for (uint256 j = 0; j < arr.length; j++) {
      if (arr[j] == item) return true;
    }
    return false;
  }
}

File 16 of 36 : Structs.sol
// contracts/ISpliceStyleNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import './ISplicePriceStrategy.sol';

struct Allowlist {
  //counting down
  uint32 numReserved;
  uint64 reservedUntil;
  uint8 mintsPerAddress;
  bytes32 merkleRoot;
}

struct Partnership {
  address[] collections;
  uint64 until;
  /// @notice exclusive partnerships mean that all style inputs must be covered by the partnership
  /// @notice unexclusive partnerships require only 1 input to be covered
  bool exclusive;
}

struct StyleSettings {
  //counting up
  uint32 mintedOfStyle;
  uint32 cap;
  ISplicePriceStrategy priceStrategy;
  bool salesIsActive;
  bool isFrozen;
  string styleCID;
  uint8 maxInputs;
  address paymentSplitter;
}

File 17 of 36 : SpliceStyleNFT.sol
// contracts/SpliceStyleNFT.sol
// SPDX-License-Identifier: MIT

/*
     LCL  SSL      CSL  SSL      LCI       ISL       LCL  ISL        CI  ISL
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       LL        PEE  EES       LEEL LL 
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL    
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL LLL
     PEE  LL       EES LEEL      IEE       IPL       PEE  LLL       LEEL EES
LLL  PEE           EES  SSL      IEE       PEC       PEE  LLL       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LLL
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL    
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LL 
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
LSI  LSI           LCL           LSS       ISL       LSI  ISL       LSS  ISL
*/

pragma solidity 0.8.10;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

import './ISplicePriceStrategy.sol';
import './Splice.sol';
import './Structs.sol';
import './ArrayLib.sol';
import './ReplaceablePaymentSplitter.sol';
import './PaymentSplitterController.sol';

contract SpliceStyleNFT is
  ERC721EnumerableUpgradeable,
  OwnableUpgradeable,
  ReentrancyGuardUpgradeable
{
  using CountersUpgradeable for CountersUpgradeable.Counter;
  using SafeCastUpgradeable for uint256;

  error BadReservationParameters(uint32 reservation, uint32 mintsLeft);
  error AllowlistDurationTooShort(uint256 diff);

  /// @notice you wanted to set an allowlist on a style that already got one
  error AllowlistNotOverridable(uint32 styleTokenId);

  /// @notice someone wanted to modify the style NFT without owning it.
  error NotControllingStyle(uint32 styleTokenId);

  /// @notice The style cap has been reached. You can't mint more items using that style
  error StyleIsFullyMinted();

  /// @notice Sales is not active on the style
  error SaleNotActive(uint32 styleTokenId);

  /// @notice Reservation limit exceeded
  error PersonalReservationLimitExceeded(uint32 styleTokenId);

  /// @notice
  error NotEnoughTokensToMatchReservation(uint32 styleTokenId);

  /// @notice
  error StyleIsFrozen();

  error OriginNotAllowed(string reason);

  error BadMintInput(string reason);

  error CantFreezeAnUncompleteCollection(uint32 mintsLeft);

  error InvalidCID();

  //https://docs.opensea.io/docs/metadata-standards#ipfs-and-arweave-uris
  event PermanentURI(string _value, uint256 indexed _id);
  event Minted(uint32 indexed styleTokenId, uint32 cap, string metadataCID);
  event SharesChanged(uint16 percentage);
  event AllowlistInstalled(
    uint32 indexed styleTokenId,
    uint32 reserved,
    uint8 mintsPerAddress,
    uint64 until
  );

  CountersUpgradeable.Counter private _styleTokenIds;

  mapping(address => bool) public isStyleMinter;
  mapping(uint32 => StyleSettings) styleSettings;
  mapping(uint32 => Allowlist) allowlists;

  /// @notice how many pieces has an (allowed) address already minted on a style
  mapping(uint32 => mapping(address => uint8)) mintsAlreadyAllowed;

  /**
   * @dev styleTokenId => Partnership
   */
  mapping(uint32 => Partnership) private _partnerships;

  uint16 public ARTIST_SHARE;

  Splice public spliceNFT;

  PaymentSplitterController public paymentSplitterController;

  function initialize() public initializer {
    __ERC721_init('Splice Style NFT', 'SPLYLE');
    __ERC721Enumerable_init_unchained();
    __Ownable_init_unchained();
    __ReentrancyGuard_init();
    ARTIST_SHARE = 8500;
  }

  modifier onlyStyleMinter() {
    require(isStyleMinter[msg.sender], 'not allowed to mint styles');
    _;
  }

  modifier onlySplice() {
    require(msg.sender == address(spliceNFT), 'only callable by Splice');
    _;
  }

  modifier controlsStyle(uint32 styleTokenId) {
    if (!isStyleMinter[msg.sender] && msg.sender != ownerOf(styleTokenId)) {
      revert NotControllingStyle(styleTokenId);
    }
    _;
  }

  function updateArtistShare(uint16 share) public onlyOwner {
    require(share <= 10000 && share > 7500, 'we will never take more than 25%');
    ARTIST_SHARE = share;
    emit SharesChanged(share);
  }

  function setPaymentSplitter(PaymentSplitterController ps) external onlyOwner {
    if (address(paymentSplitterController) != address(0)) {
      revert('can only be called once.');
    }
    paymentSplitterController = ps;
  }

  function setSplice(Splice _spliceNFT) external onlyOwner {
    if (address(spliceNFT) != address(0)) {
      revert('can only be called once.');
    }
    spliceNFT = _spliceNFT;
  }

  function toggleStyleMinter(address minter, bool newValue) external onlyOwner {
    isStyleMinter[minter] = newValue;
  }

  function getPartnership(uint32 styleTokenId)
    public
    view
    returns (
      address[] memory collections,
      uint256 until,
      bool exclusive
    )
  {
    Partnership memory p = _partnerships[styleTokenId];
    return (p.collections, p.until, p.exclusive);
  }

  /**
   * @dev we assume that our metadata CIDs are folder roots containing a /metadata.json. That's how nft.storage does it.
   */
  function _metadataURI(string memory metadataCID)
    private
    pure
    returns (string memory)
  {
    return string(abi.encodePacked('ipfs://', metadataCID, '/metadata.json'));
  }

  function tokenURI(uint256 tokenId)
    public
    view
    override
    returns (string memory)
  {
    require(_exists(tokenId), 'nonexistent token');
    return _metadataURI(styleSettings[uint32(tokenId)].styleCID);
  }

  /**
   * todo if there's more than one mint request in one block the quoted fee might be lower
   * than what the artist expects, (when using a bonded price strategy)

   * @return fee the fee required to mint splices of that style
   */
  function quoteFee(
    uint32 styleTokenId,
    IERC721[] memory originCollections,
    uint256[] memory originTokenIds
  ) public view returns (uint256 fee) {
    fee = styleSettings[styleTokenId].priceStrategy.quote(
      styleTokenId,
      originCollections,
      originTokenIds
    );
  }

  function getSettings(uint32 styleTokenId)
    public
    view
    returns (StyleSettings memory)
  {
    return styleSettings[styleTokenId];
  }

  function isSaleActive(uint32 styleTokenId) public view returns (bool) {
    return styleSettings[styleTokenId].salesIsActive;
  }

  function toggleSaleIsActive(uint32 styleTokenId, bool newValue)
    external
    controlsStyle(styleTokenId)
  {
    if (isFrozen(styleTokenId)) {
      revert StyleIsFrozen();
    }
    styleSettings[styleTokenId].salesIsActive = newValue;
  }

  /**
   * @return how many mints are left on that style
   */
  function mintsLeft(uint32 styleTokenId) public view returns (uint32) {
    return
      styleSettings[styleTokenId].cap -
      styleSettings[styleTokenId].mintedOfStyle;
  }

  /**
   * @return how many mints are currently reserved on the allowlist
   */
  function reservedTokens(uint32 styleTokenId) public view returns (uint32) {
    if (block.timestamp > allowlists[styleTokenId].reservedUntil) {
      //reservation period has ended
      return 0;
    }
    return allowlists[styleTokenId].numReserved;
  }

  /**
   * @return how many splices can be minted except those reserved on an allowlist for that style
   */
  function availableForPublicMinting(uint32 styleTokenId)
    public
    view
    returns (uint32)
  {
    return
      styleSettings[styleTokenId].cap -
      styleSettings[styleTokenId].mintedOfStyle -
      reservedTokens(styleTokenId);
  }

  /**
   * @param allowlistProof a list of leaves in the merkle tree that are needed to perform the proof
   * @param requestor the subject account of the proof
   * @return whether the proof could be verified
   */

  function verifyAllowlistEntryProof(
    uint32 styleTokenId,
    bytes32[] memory allowlistProof,
    address requestor
  ) external view returns (bool) {
    return
      MerkleProofUpgradeable.verify(
        allowlistProof,
        allowlists[styleTokenId].merkleRoot,
        //or maybe: https://ethereum.stackexchange.com/questions/884/how-to-convert-an-address-to-bytes-in-solidity/41356
        keccak256(abi.encodePacked(requestor))
      );
  }

  /**
   * @dev called by Splice to decrement the allowance for requestor
   */
  function decreaseAllowance(uint32 styleTokenId, address requestor)
    external
    nonReentrant
    onlySplice
  {
    // CHECKS
    if (
      mintsAlreadyAllowed[styleTokenId][requestor] + 1 >
      allowlists[styleTokenId].mintsPerAddress
    ) {
      revert PersonalReservationLimitExceeded(styleTokenId);
    }

    if (allowlists[styleTokenId].numReserved < 1) {
      revert NotEnoughTokensToMatchReservation(styleTokenId);
    }
    // EFFECTS
    allowlists[styleTokenId].numReserved -= 1;
    mintsAlreadyAllowed[styleTokenId][requestor] += 1;
  }

  /**
   * @notice an allowlist gives privilege to a dedicated list of users to mint this style by presenting a merkle proof
     @param styleTokenId the style token id
   * @param numReserved_ how many reservations shall be made
   * @param mintsPerAddress_ how many mints are allowed per one distinct address
   * @param merkleRoot_ the merkle root of a tree of allowed addresses
   * @param reservedUntil_ a timestamp until when the allowlist shall be in effect
   */
  function addAllowlist(
    uint32 styleTokenId,
    uint32 numReserved_,
    uint8 mintsPerAddress_,
    bytes32 merkleRoot_,
    uint64 reservedUntil_
  ) external controlsStyle(styleTokenId) {
    //CHECKS
    if (allowlists[styleTokenId].reservedUntil != 0) {
      revert AllowlistNotOverridable(styleTokenId);
    }

    uint32 stillAvailable = mintsLeft(styleTokenId);
    if (
      numReserved_ > stillAvailable || mintsPerAddress_ > stillAvailable //that 2nd edge case is actually not important (minting would fail anyway when cap is exceeded)
    ) {
      revert BadReservationParameters(numReserved_, stillAvailable);
    }

    if (reservedUntil_ < block.timestamp + 1 days) {
      revert AllowlistDurationTooShort(reservedUntil_);
    }

    //EFFECTS
    allowlists[styleTokenId] = Allowlist({
      numReserved: numReserved_,
      merkleRoot: merkleRoot_,
      reservedUntil: reservedUntil_,
      mintsPerAddress: mintsPerAddress_
    });
    emit AllowlistInstalled(
      styleTokenId,
      numReserved_,
      mintsPerAddress_,
      reservedUntil_
    );
  }

  /**
   * @dev will revert when something prevents minting a splice
   */
  function isMintable(
    uint32 styleTokenId,
    IERC721[] memory originCollections,
    uint256[] memory originTokenIds,
    address minter
  ) public view returns (bool) {
    if (!isSaleActive(styleTokenId)) {
      revert SaleNotActive(styleTokenId);
    }

    if (
      originCollections.length == 0 ||
      originTokenIds.length == 0 ||
      originCollections.length != originTokenIds.length
    ) {
      revert BadMintInput('inconsistent input lengths');
    }

    if (styleSettings[styleTokenId].maxInputs < originCollections.length) {
      revert OriginNotAllowed('too many inputs');
    }

    Partnership memory partnership = _partnerships[styleTokenId];
    bool partnershipIsActive = (partnership.collections.length > 0 &&
      partnership.until > block.timestamp);
    uint8 partner_count = 0;
    for (uint256 i = 0; i < originCollections.length; i++) {
      if (i > 0) {
        if (
          address(originCollections[i]) <= address(originCollections[i - 1])
        ) {
          revert BadMintInput('duplicate or unordered origin input');
        }
      }
      if (partnershipIsActive) {
        if (
          ArrayLib.contains(
            partnership.collections,
            address(originCollections[i])
          )
        ) {
          partner_count++;
        }
      }
    }

    if (partnershipIsActive) {
      //this saves a very slight amount of gas compared to &&
      if (partnership.exclusive) {
        if (partner_count != originCollections.length) {
          revert OriginNotAllowed('exclusive partnership');
        }
      }
    }

    return true;
  }

  function isFrozen(uint32 styleTokenId) public view returns (bool) {
    return styleSettings[styleTokenId].isFrozen;
  }

  /**
   * @notice freezing a fully minted style means to disable its sale and set its splice's baseUrl to a fixed IPFS CID. That IPFS directory must contain all metadata for the splices.
   * @param cid an IPFS content hash
   */
  function freeze(uint32 styleTokenId, string memory cid)
    public
    onlyStyleMinter
  {
    if (bytes(cid).length < 46) {
      revert InvalidCID();
    }

    //@todo: this might be unnecessarily strict
    if (mintsLeft(styleTokenId) != 0) {
      revert CantFreezeAnUncompleteCollection(mintsLeft(styleTokenId));
    }

    styleSettings[styleTokenId].salesIsActive = false;
    styleSettings[styleTokenId].styleCID = cid;
    styleSettings[styleTokenId].isFrozen = true;
    emit PermanentURI(tokenURI(styleTokenId), styleTokenId);
  }

  /**
   * @dev only called by Splice. Increments the amount of minted splices.
   * @return the new highest amount. Used as incremental part of the splice token id
   */
  function incrementMintedPerStyle(uint32 styleTokenId)
    public
    onlySplice
    returns (uint32)
  {
    if (!isSaleActive(styleTokenId)) {
      revert SaleNotActive(styleTokenId);
    }

    if (mintsLeft(styleTokenId) == 0) {
      revert StyleIsFullyMinted();
    }
    styleSettings[styleTokenId].mintedOfStyle += 1;
    styleSettings[styleTokenId].priceStrategy.onMinted(styleTokenId);
    return styleSettings[styleTokenId].mintedOfStyle;
  }

  /**
   * @notice collection partnerships have an effect on minting availability. They restrict styles to be minted only on certain collections. Partner collections receive a share of the platform fee.
   * @param until after this timestamp the partnership is not in effect anymore. Set to a very high value to add a collection constraint to a style.
   * @param exclusive a non-exclusive partnership allows other origins to mint. When trying to mint on an exclusive partnership with an unsupported input, it will fail.
   */
  function enablePartnership(
    address[] memory collections,
    uint32 styleTokenId,
    uint64 until,
    bool exclusive
  ) external onlyStyleMinter {
    require(
      styleSettings[styleTokenId].mintedOfStyle == 0,
      'cant add a partnership after minting started'
    );

    _partnerships[styleTokenId] = Partnership({
      collections: collections,
      until: until,
      exclusive: exclusive
    });
  }

  function setupPaymentSplitter(
    uint256 styleTokenId,
    address artist,
    address partner
  ) internal returns (address ps) {
    address[] memory members;
    uint256[] memory shares;

    if (partner != address(0)) {
      members = new address[](3);
      shares = new uint256[](3);
      uint256 splitShare = (10_000 - ARTIST_SHARE) / 2;

      members[0] = artist;
      shares[0] = ARTIST_SHARE;
      members[1] = spliceNFT.platformBeneficiary();
      shares[1] = splitShare;
      members[2] = partner;
      shares[2] = splitShare;
    } else {
      members = new address[](2);
      shares = new uint256[](2);
      members[0] = artist;
      shares[0] = ARTIST_SHARE;
      members[1] = spliceNFT.platformBeneficiary();
      shares[1] = 10_000 - ARTIST_SHARE;
    }

    ps = paymentSplitterController.createSplit(styleTokenId, members, shares);
  }

  /**
   * @notice creates a new style NFT
   * @param cap_ how many splices can be minted of this style
   * @param metadataCID_ an IPFS CID pointing to the style metadata. Must be a directory, containing a metadata.json file.
   * @param priceStrategy_ address of an ISplicePriceStrategy instance that's configured to return fee quotes for the new style (e.g. static)
   * @param salesIsActive_ splices of this style can be minted once this method is finished (careful: some other methods will only run when no splices have ever been minted)
   * @param maxInputs_ how many origin inputs are allowed for a mint (e.g. 2 NFT collections)
   * @param artist_ the first owner of that style. If 0 the minter is the first owner.
   * @param partnershipBeneficiary_ an address that gets 50% of platform shares. Can be 0
   */
  function mint(
    uint32 cap_,
    string memory metadataCID_,
    ISplicePriceStrategy priceStrategy_,
    bool salesIsActive_,
    uint8 maxInputs_,
    address artist_,
    address partnershipBeneficiary_
  ) external onlyStyleMinter returns (uint32 styleTokenId) {
    //CHECKS
    if (bytes(metadataCID_).length < 46) {
      revert InvalidCID();
    }

    if (artist_ == address(0)) {
      artist_ = msg.sender;
    }
    //EFFECTS
    _styleTokenIds.increment();
    styleTokenId = _styleTokenIds.current().toUint32();

    styleSettings[styleTokenId] = StyleSettings({
      mintedOfStyle: 0,
      cap: cap_,
      priceStrategy: priceStrategy_,
      salesIsActive: salesIsActive_,
      isFrozen: false,
      styleCID: metadataCID_,
      maxInputs: maxInputs_,
      paymentSplitter: setupPaymentSplitter(
        styleTokenId,
        artist_,
        partnershipBeneficiary_
      )
    });

    //INTERACTIONS
    _safeMint(artist_, styleTokenId);
    emit Minted(styleTokenId, cap_, metadataCID_);
  }

  function _beforeTokenTransfer(
    address from,
    address to,
    uint256 tokenId
  ) internal virtual override {
    super._beforeTokenTransfer(from, to, tokenId);
    if (from != address(0) && to != address(0)) {
      //its not a mint or a burn but a real transfer
      paymentSplitterController.replaceShareholder(tokenId, payable(from), to);
    }
  }
}

File 18 of 36 : ReplaceablePaymentSplitter.sol
// contracts/ReplaceablePaymentSplitter.sol
// SPDX-License-Identifier: MIT

/*
     LCL  SSL      CSL  SSL      LCI       ISL       LCL  ISL        CI  ISL
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       LL        PEE  EES       LEEL LL 
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL    
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL LLL
     PEE  LL       EES LEEL      IEE       IPL       PEE  LLL       LEEL EES
LLL  PEE           EES  SSL      IEE       PEC       PEE  LLL       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LLL
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL    
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LL 
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
LSI  LSI           LCL           LSS       ISL       LSI  ISL       LSS  ISL
*/

pragma solidity 0.8.10;

import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts/proxy/Clones.sol';
import './SpliceStyleNFT.sol';

/**
 * @notice this is an initializeable OZ PaymentSplitter with an additional replace function to
 * update the payees when the owner of the underlying royalty bearing asset has
 * changed. Cannot extend PaymentSplitter because its members are private.
 */
contract ReplaceablePaymentSplitter is Context, Initializable {
  event PayeeAdded(address indexed account, uint256 shares);
  event PayeeReplaced(
    address indexed old,
    address indexed new_,
    uint256 shares
  );
  event PaymentReleased(address to, uint256 amount);
  event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
  event PaymentReceived(address from, uint256 amount);

  uint256 private _totalShares;
  uint256 private _totalReleased;

  mapping(address => uint256) private _shares;
  mapping(address => uint256) private _released;
  address[] private _payees;

  mapping(IERC20 => uint256) private _erc20TotalReleased;
  mapping(IERC20 => mapping(address => uint256)) private _erc20Released;

  address private _controller;

  modifier onlyController() {
    require(msg.sender == address(_controller), 'only callable by controller');
    _;
  }

  function initialize(
    address controller,
    address[] memory payees_,
    uint256[] memory shares_
  ) external payable initializer {
    require(controller != address(0), 'controller mustnt be 0');
    _controller = controller;

    uint256 len = payees_.length;
    uint256 __totalShares = _totalShares;
    for (uint256 i = 0; i < len; i++) {
      _addPayee(payees_[i], shares_[i]);
      __totalShares += shares_[i];
    }
    _totalShares = __totalShares;
  }

  receive() external payable virtual {
    emit PaymentReceived(_msgSender(), msg.value);
  }

  /**
   * @dev Getter for the total shares held by payees.
   */
  function totalShares() public view returns (uint256) {
    return _totalShares;
  }

  /**
   * @dev Getter for the total amount of Ether already released.
   */
  function totalReleased() public view returns (uint256) {
    return _totalReleased;
  }

  /**
   * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
   * contract.
   */
  function totalReleased(IERC20 token) public view returns (uint256) {
    return _erc20TotalReleased[token];
  }

  /**
   * @dev Getter for the amount of shares held by an account.
   */
  function shares(address account) public view returns (uint256) {
    return _shares[account];
  }

  /**
   * @dev Getter for the amount of Ether already released to a payee.
   */
  function released(address account) public view returns (uint256) {
    return _released[account];
  }

  /**
   * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
   * IERC20 contract.
   */
  function released(IERC20 token, address account)
    public
    view
    returns (uint256)
  {
    return _erc20Released[token][account];
  }

  /**
   * @dev Getter for the address of the payee number `index`.
   */
  function payee(uint256 index) public view returns (address) {
    return _payees[index];
  }

  /**
   * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
   * total shares and their previous withdrawals.
   */
  function release(address payable account) external virtual {
    require(_shares[account] > 0, 'PaymentSplitter: account has no shares');

    uint256 totalReceived = address(this).balance + totalReleased();
    uint256 payment = _pendingPayment(
      account,
      totalReceived,
      released(account)
    );

    require(payment != 0, 'PaymentSplitter: account is not due payment');

    _released[account] += payment;
    _totalReleased += payment;

    AddressUpgradeable.sendValue(account, payment);
    emit PaymentReleased(account, payment);
  }

  /**
   * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
   * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
   * contract.
   */
  function release(IERC20 token, address account) external virtual {
    require(_shares[account] > 0, 'PaymentSplitter: account has no shares');

    uint256 totalReceived = token.balanceOf(address(this)) +
      totalReleased(token);
    uint256 payment = _pendingPayment(
      account,
      totalReceived,
      released(token, account)
    );

    require(payment != 0, 'PaymentSplitter: account is not due payment');

    _erc20Released[token][account] += payment;
    _erc20TotalReleased[token] += payment;

    SafeERC20.safeTransfer(token, account, payment);
    emit ERC20PaymentReleased(token, account, payment);
  }

  /**
   * @dev internal logic for computing the pending payment of an `account` given the token historical balances and
   * already released amounts.
   */
  function _pendingPayment(
    address account,
    uint256 totalReceived,
    uint256 alreadyReleased
  ) private view returns (uint256) {
    return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
  }

  /**
   * @dev Add a new payee to the contract.
   * @param account The address of the payee to add.
   * @param shares_ The number of shares owned by the payee.
   */
  function _addPayee(address account, uint256 shares_) private {
    require(
      account != address(0),
      'PaymentSplitter: account is the zero address'
    );
    require(shares_ > 0, 'PaymentSplitter: shares are 0');
    require(
      _shares[account] == 0,
      'PaymentSplitter: account already has shares'
    );

    _payees.push(account);
    _shares[account] = shares_;
    emit PayeeAdded(account, shares_);
  }

  /**
   * @dev the new_ payee will receive splits at the same rate as _old did before.
   *      all pending payouts of _old can be withdrawn by _new.
   */
  function replacePayee(address old, address new_) external onlyController {
    uint256 oldShares = _shares[old];
    require(oldShares > 0, 'PaymentSplitter: old account has no shares');
    require(
      new_ != address(0),
      'PaymentSplitter: new account is the zero address'
    );
    require(
      _shares[new_] == 0,
      'PaymentSplitter: new account already has shares'
    );

    uint256 idx = 0;
    while (idx < _payees.length) {
      if (_payees[idx] == old) {
        _payees[idx] = new_;
        _shares[old] = 0;
        _shares[new_] = oldShares;
        _released[new_] = _released[old];
        emit PayeeReplaced(old, new_, oldShares);
        return;
      }
      idx++;
    }
  }

  function due(address account) external view returns (uint256 pending) {
    uint256 totalReceived = address(this).balance + totalReleased();
    return _pendingPayment(account, totalReceived, released(account));
  }

  function due(IERC20 token, address account)
    external
    view
    returns (uint256 pending)
  {
    uint256 totalReceived = token.balanceOf(address(this)) +
      totalReleased(token);
    return _pendingPayment(account, totalReceived, released(token, account));
  }
}

File 19 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 20 of 36 : IERC165Upgradeable.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 IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 21 of 36 : IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 23 of 36 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 24 of 36 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 26 of 36 : ISplicePriceStrategy.sol
// contracts/ISplicePriceStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import './Structs.sol';
import './SpliceStyleNFT.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/**
 * this is a powerful interface to allow non linear pricing.
 * You could e.g. invent a strategy that increases a base price
 * according to how many items already have been minted.
 * or it could decrease the minting fee depending on when
 * the last style mint has happened, etc.
 */
interface ISplicePriceStrategy {
  function quote(
    uint256 styleTokenId,
    IERC721[] memory collections,
    uint256[] memory tokenIds
  ) external view returns (uint256);

  function onMinted(uint256 styleTokenId) external;
}

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

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
    function __ERC721Enumerable_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721Enumerable_init_unchained();
    }

    function __ERC721Enumerable_init_unchained() internal onlyInitializing {
    }
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721Upgradeable.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
    uint256[46] private __gap;
}

File 28 of 36 : SafeCastUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCastUpgradeable {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 29 of 36 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 30 of 36 : MerkleProofUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProofUpgradeable {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            }
        }
        return computedHash;
    }
}

File 31 of 36 : PaymentSplitterController.sol
// contracts/PaymentSplitterController.sol
// SPDX-License-Identifier: MIT

/*
     LCL  SSL      CSL  SSL      LCI       ISL       LCL  ISL        CI  ISL
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       EEI       PEE  EES       LEEL EES
     PEE  EEL      EES LEEL      IEE       LL        PEE  EES       LEEL LL 
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL    
     PEE  EEL      EES LEEL      IEE                 PEE  EES       LEEL LLL
     PEE  LL       EES LEEL      IEE       IPL       PEE  LLL       LEEL EES
LLL  PEE           EES  SSL      IEE       PEC       PEE  LLL       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LLL
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL    
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL LL 
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
SEE  PEE           EES           IEE       PEC       PEE  EES       LEEL EES
LSI  LSI           LCL           LSS       ISL       LSI  ISL       LSS  ISL
*/

pragma solidity 0.8.10;

import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/proxy/Clones.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import './ReplaceablePaymentSplitter.sol';

contract PaymentSplitterController is
  Initializable,
  ReentrancyGuardUpgradeable
{
  /**
   * @dev each style tokens' payment splitter instance
   */
  mapping(uint256 => ReplaceablePaymentSplitter) public splitters;

  address[] private PAYMENT_TOKENS;

  /**
   * @dev the base instance that minimal proxies are cloned from
   */
  address private _splitterTemplate;

  address private _owner;

  function initialize(address owner_, address[] memory paymentTokens_)
    public
    initializer
  {
    __ReentrancyGuard_init();
    require(owner_ != address(0), 'initial owner mustnt be 0');
    _owner = owner_;
    PAYMENT_TOKENS = paymentTokens_;

    _splitterTemplate = address(new ReplaceablePaymentSplitter());
  }

  modifier onlyOwner() {
    require(msg.sender == _owner, 'only callable by owner');
    _;
  }

  function createSplit(
    uint256 tokenId,
    address[] memory payees_,
    uint256[] memory shares_
  ) external onlyOwner returns (address ps_address) {
    require(payees_.length == shares_.length, 'p and s len mismatch');
    require(payees_.length > 0, 'no payees');
    require(address(splitters[tokenId]) == address(0), 'ps exists');

    // ReplaceablePaymentSplitter ps = new ReplaceablePaymentSplitter();
    ps_address = Clones.clone(_splitterTemplate);
    ReplaceablePaymentSplitter ps = ReplaceablePaymentSplitter(
      payable(ps_address)
    );
    splitters[tokenId] = ps;
    ps.initialize(address(this), payees_, shares_);
  }

  /**
   * @notice when splitters_ is [], we try to get *all* of your funds out
   * to withdraw individual tokens or in case some external call fails,
   * one can still call the payment splitter's release methods directly.
   */
  function withdrawAll(address payable payee, address[] memory splitters_)
    external
    nonReentrant
  {
    for (uint256 i = 0; i < splitters_.length; i++) {
      releaseAll(ReplaceablePaymentSplitter(payable(splitters_[i])), payee);
    }
  }

  function releaseAll(ReplaceablePaymentSplitter ps, address payable account)
    internal
  {
    try ps.release(account) {
      /*empty*/
    } catch {
      /*empty*/
    }
    for (uint256 i = 0; i < PAYMENT_TOKENS.length; i++) {
      try ps.release(IERC20(PAYMENT_TOKENS[i]), account) {
        /*empty*/
      } catch {
        /*empty*/
      }
    }
  }

  function replaceShareholder(
    uint256 styleTokenId,
    address payable from,
    address to
  ) external onlyOwner nonReentrant {
    ReplaceablePaymentSplitter ps = splitters[styleTokenId];
    releaseAll(ps, from);
    ps.replacePayee(from, to);
  }
}

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

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

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

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

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

File 33 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 34 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 35 of 36 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 36 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);
            }
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"InsufficientFees","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"NotAllowedToMint","type":"error"},{"inputs":[],"name":"NotOwningOrigin","type":"error"},{"inputs":[],"name":"ProvenanceAlreadyUsed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newBeneficiary","type":"address"}],"name":"BeneficiaryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"origin_hash","type":"bytes32"},{"indexed":true,"internalType":"uint64","name":"tokenId","type":"uint64"},{"indexed":true,"internalType":"uint32","name":"styleTokenId","type":"uint32"}],"name":"Minted","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"royalties","type":"uint8"}],"name":"RoyaltiesUpdated","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"ROYALTY_PERCENT","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"baseUri_","type":"string"},{"internalType":"contract SpliceStyleNFT","name":"initializedStyleNFT_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721[]","name":"originCollections","type":"address[]"},{"internalType":"uint256[]","name":"originTokenIds","type":"uint256[]"},{"internalType":"uint32","name":"styleTokenId","type":"uint32"},{"internalType":"bytes32[]","name":"allowlistProof","type":"bytes32[]"},{"internalType":"bytes","name":"inputParams","type":"bytes"}],"name":"mint","outputs":[{"internalType":"uint64","name":"tokenId","type":"uint64"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platformBeneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"provenanceToTokenId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"styleTokenId","type":"uint32"},{"internalType":"contract IERC721[]","name":"nfts","type":"address[]"},{"internalType":"uint256[]","name":"originTokenIds","type":"uint256[]"}],"name":"quote","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newBaseUri","type":"string"}],"name":"setBaseUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setPlatformBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"styleAndTokenByTokenId","outputs":[{"internalType":"uint32","name":"styleTokenId","type":"uint32"},{"internalType":"uint32","name":"token_tokenId","type":"uint32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"styleNFT","outputs":[{"internalType":"contract SpliceStyleNFT","name":"","type":"address"}],"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":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"royaltyPercentage","type":"uint8"}],"name":"updateRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"nftContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawEth","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50613908806100206000396000f3fe6080604052600436106102045760003560e01c80638456cb5911610118578063cdcd897e116100a0578063e98585ee1161006f578063e98585ee14610612578063e985e9c514610649578063f2fde38b14610692578063f3e414f8146106b2578063f4f3b200146106d257600080fd5b8063cdcd897e14610590578063d46e6734146105bd578063da90b77d146105dd578063e8a3d485146105fd57600080fd5b8063a0ef91df116100e7578063a0ef91df146104de578063a22cb465146104f3578063b88d4fde14610513578063c0214fd914610533578063c87b56dd1461057057600080fd5b80638456cb59146104765780638da5cb5b1461048b57806395d89b41146104a9578063a0bcfc7f146104be57600080fd5b80632e1688231161019b5780636352211e1161016a5780636352211e146103d357806370a08231146103f3578063715018a6146104215780637362f1a9146104365780637ab4339d1461045657600080fd5b80632e168823146103655780633f4ba83a1461038657806342842e0e1461039b5780635c975abb146103bb57600080fd5b8063104cbfef116101d7578063104cbfef146102ba5780632231fe54146102e557806323b872dd146103065780632a55205a1461032657600080fd5b806301ffc9a71461020957806306fdde031461023e578063081812fc14610260578063095ea7b314610298575b600080fd5b34801561021557600080fd5b50610229610224366004612a89565b6106f2565b60405190151581526020015b60405180910390f35b34801561024a57600080fd5b5061025361071d565b6040516102359190612afe565b34801561026c57600080fd5b5061028061027b366004612b11565b6107af565b6040516001600160a01b039091168152602001610235565b3480156102a457600080fd5b506102b86102b3366004612b3f565b610849565b005b6102cd6102c8366004612d26565b61095f565b6040516001600160401b039091168152602001610235565b3480156102f157600080fd5b5061013054610280906001600160a01b031681565b34801561031257600080fd5b506102b8610321366004612e3e565b61103c565b34801561033257600080fd5b50610346610341366004612e7f565b61106d565b604080516001600160a01b039093168352602083019190915201610235565b34801561037157600080fd5b5061013154610280906001600160a01b031681565b34801561039257600080fd5b506102b8611124565b3480156103a757600080fd5b506102b86103b6366004612e3e565b611158565b3480156103c757600080fd5b5060c95460ff16610229565b3480156103df57600080fd5b506102806103ee366004612b11565b611173565b3480156103ff57600080fd5b5061041361040e366004612ea1565b6111ea565b604051908152602001610235565b34801561042d57600080fd5b506102b8611271565b34801561044257600080fd5b50610413610451366004612ebe565b6112a5565b34801561046257600080fd5b506102b8610471366004612fb3565b611324565b34801561048257600080fd5b506102b861148e565b34801561049757600080fd5b506097546001600160a01b0316610280565b3480156104b557600080fd5b506102536114c0565b3480156104ca57600080fd5b506102b86104d9366004613004565b6114cf565b3480156104ea57600080fd5b506102b8611511565b3480156104ff57600080fd5b506102b861050e366004613046565b611581565b34801561051f57600080fd5b506102b861052e366004613074565b61158c565b34801561053f57600080fd5b5061055361054e366004612b11565b6115c4565b6040805163ffffffff938416815292909116602083015201610235565b34801561057c57600080fd5b5061025361058b366004612b11565b61160d565b34801561059c57600080fd5b5061012d546105ab9060ff1681565b60405160ff9091168152602001610235565b3480156105c957600080fd5b506102b86105d8366004612ea1565b61178d565b3480156105e957600080fd5b506102b86105f8366004613102565b61185c565b34801561060957600080fd5b5061025361191d565b34801561061e57600080fd5b506102cd61062d366004612b11565b61012f602052600090815260409020546001600160401b031681565b34801561065557600080fd5b5061022961066436600461311f565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b34801561069e57600080fd5b506102b86106ad366004612ea1565b61193d565b3480156106be57600080fd5b506102b86106cd366004612b3f565b6119d8565b3480156106de57600080fd5b506102b86106ed366004612ea1565b611aa0565b60006001600160e01b0319821663152a902d60e11b1480610717575061071782611c2c565b92915050565b60606065805461072c9061314d565b80601f01602080910402602001604051908101604052809291908181526020018280546107589061314d565b80156107a55780601f1061077a576101008083540402835291602001916107a5565b820191906000526020600020905b81548152906001019060200180831161078857829003601f168201915b5050505050905090565b6000818152606760205260408120546001600160a01b031661082d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152606960205260409020546001600160a01b031690565b600061085482611173565b9050806001600160a01b0316836001600160a01b031614156108c25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610824565b336001600160a01b03821614806108de57506108de8133610664565b6109505760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610824565b61095a8383611c7c565b505050565b600061096d60c95460ff1690565b156109ad5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610824565b600260fb5414156109d05760405162461bcd60e51b815260040161082490613188565b600260fb556101305460405163b901d35760e01b81526001600160a01b039091169063b901d35790610a0c9088908b908b903390600401613233565b602060405180830381865afa158015610a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4d919061328e565b610a5657600080fd5b610130546040516347984ee760e01b815263ffffffff871660048201526001600160a01b03909116906347984ee790602401602060405180830381865afa158015610aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac991906132b6565b63ffffffff16610c195783511580610b54575061013054604051636c4adf5560e01b81526001600160a01b0390911690636c4adf5590610b11908890889033906004016132d3565b602060405180830381865afa158015610b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b52919061328e565b155b15610bae57604051630ac6f28b60e41b8152602060048201526024808201527f6e6f207265736572766174696f6e73206c656674206f722070726f6f662066616044820152631a5b195960e21b6064820152608401610824565b6101305460405163c728172360e01b815263ffffffff871660048201523360248201526001600160a01b039091169063c728172390604401600060405180830381600087803b158015610c0057600080fd5b505af1158015610c14573d6000803e3d6000fd5b505050505b6101305460405163367c1e4960e21b81526000916001600160a01b03169063d9f0792490610c4f9089908c908c9060040161333c565b602060405180830381865afa158015610c6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c909190613377565b905080341015610cb357604051638d53e55360e01b815260040160405180910390fd5b6000888888604051602001610cca93929190613390565b60408051601f198184030181529181528151602092830120600081815261012f9093529120549091506001600160401b031615610d1a57604051632c48efd760e21b815260040160405180910390fd5b61013054604051621caf6f60e01b815263ffffffff891660048201526000916001600160a01b031690621caf6f906024016020604051808303816000875af1158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e91906132b6565b6040516001600160e01b031960e08b811b8216602084015283901b166024820152909150610dcf906028016040516020818303038152906040526000611cea565b600083815261012f60205260408120805467ffffffffffffffff19166001600160401b0384161790559094505b8a51811015610efa5760008b8281518110610e1957610e1961340f565b60200260200101516001600160a01b0316636352211e8c8481518110610e4157610e4161340f565b60200260200101516040518263ffffffff1660e01b8152600401610e6791815260200190565b602060405180830381865afa158015610e84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea89190613430565b90506001600160a01b03811633141580610ec957506001600160a01b038116155b15610ee75760405163fe6b905b60e01b815260040160405180910390fd5b5080610ef281613463565b915050610dfc565b506101305460405163275fc7d160e21b815263ffffffff8a166004820152610f7e916001600160a01b031690639d7f1f4490602401600060405180830381865afa158015610f4c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7491908101906134ce565b60e0015184611d47565b610f9133856001600160401b0316611e60565b8763ffffffff16846001600160401b03168b8b604051602001610fb59291906135b2565b60408051601f19818403018152908290528051602090910120907fb80f047a8f7705b219221f734fc94ce5e7db261886bcfc0e95d57083fe371fa790600090a460006110013485611e7a565b905060008111801561101a575067016345785d8a000081105b15611029576110293382611d47565b50505050600160fb559695505050505050565b6110463382611e8d565b6110625760405162461bcd60e51b8152600401610824906135e0565b61095a838383611f80565b600080600061107b856115c4565b506101305460405163275fc7d160e21b815263ffffffff831660048201529192506001600160a01b031690639d7f1f4490602401600060405180830381865afa1580156110cc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110f491908101906134ce565b60e0015161012d5490935061111a9060649061111490879060ff16613631565b90612120565b9150509250929050565b6097546001600160a01b0316331461114e5760405162461bcd60e51b815260040161082490613650565b61115661212c565b565b61095a8383836040518060200160405280600081525061158c565b6000818152606760205260408120546001600160a01b0316806107175760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610824565b60006001600160a01b0382166112555760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610824565b506001600160a01b031660009081526068602052604090205490565b6097546001600160a01b0316331461129b5760405162461bcd60e51b815260040161082490613650565b61115660006121bf565b6101305460405163367c1e4960e21b81526000916001600160a01b03169063d9f07924906112db9087908790879060040161333c565b602060405180830381865afa1580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c9190613377565b949350505050565b600054610100900460ff1661133f5760005460ff1615611343565b303b155b6113a65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610824565b600054610100900460ff161580156113c8576000805461ffff19166101011790555b61140e6040518060400160405280600681526020016553706c69636560d01b8152506040518060400160405280600681526020016553504c49434560d01b815250612211565b611416612252565b61141e612289565b6114266122c0565b61012d805460ff1916600a17905561013180546001600160a01b03191633179055825161145b9061012e9060208601906129da565b5061013080546001600160a01b0319166001600160a01b038416179055801561095a576000805461ff0019169055505050565b6097546001600160a01b031633146114b85760405162461bcd60e51b815260040161082490613650565b6111566122ef565b60606066805461072c9061314d565b6097546001600160a01b031633146114f95760405162461bcd60e51b815260040161082490613650565b805161150d9061012e9060208401906129da565b5050565b600260fb5414156115345760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b031633146115635760405162461bcd60e51b815260040161082490613650565b6101315461157a906001600160a01b031647611d47565b600160fb55565b61150d33838361236a565b6115963383611e8d565b6115b25760405162461bcd60e51b8152600401610824906135e0565b6115be84848484612439565b50505050565b6000806000836040516020016115dc91815260200190565b60405160208183030381529060405290506115f881601861246c565b925061160581601c61246c565b915050915091565b6000818152606760205260409020546060906001600160a01b03166116445760405162461bcd60e51b815260040161082490613685565b600080611650846115c4565b6101305460405163b6719c8960e01b815263ffffffff841660048201529294509092506001600160a01b03169063b6719c8990602401602060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c7919061328e565b15611784576101305460405163275fc7d160e21b815263ffffffff841660048201526000916001600160a01b031690639d7f1f4490602401600060405180830381865afa15801561171c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261174491908101906134ce565b90508060a0015161175a8363ffffffff166124c9565b60405160200161176b9291906136d4565b6040516020818303038152906040529350505050919050565b61131c846125c6565b6097546001600160a01b031633146117b75760405162461bcd60e51b815260040161082490613650565b6001600160a01b0381166118065760405162461bcd60e51b81526020600482015260166024820152756d7573742062652061207265616c206164647265737360501b6044820152606401610824565b61013180546001600160a01b0319166001600160a01b0383169081179091556040519081527f373c72efabe4ef3e552ff77838be729f3bc3d8c586df0012902d1baa2377fa1d906020015b60405180910390a150565b6097546001600160a01b031633146118865760405162461bcd60e51b815260040161082490613650565b600a8160ff1611156118da5760405162461bcd60e51b815260206004820152601f60248201527f726f79616c74696573206d757374206e657665722065786365656420313025006044820152606401610824565b61012d805460ff191660ff83169081179091556040519081527facdc039ddefe0ba231b1a075c764b86c103dc99b2bded9c47bebdc4ae605c06c90602001611851565b60606040518060600160405280602681526020016138ad60269139905090565b6097546001600160a01b031633146119675760405162461bcd60e51b815260040161082490613650565b6001600160a01b0381166119cc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610824565b6119d5816121bf565b50565b600260fb5414156119fb5760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b03163314611a2a5760405162461bcd60e51b815260040161082490613650565b610131546040516323b872dd60e01b81523060048201526001600160a01b03918216602482015260448101839052908316906323b872dd90606401600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b5050600160fb5550505050565b600260fb541415611ac35760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b03163314611af25760405162461bcd60e51b815260040161082490613650565b610131546040516370a0823160e01b81523060048201526000916001600160a01b038481169263a9059cbb92919091169083906370a0823190602401602060405180830381865afa158015611b4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6f9190613377565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015611bba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bde919061328e565b905080611c235760405162461bcd60e51b81526020600482015260136024820152721d1a19481d1c985b9cd9995c8819985a5b1959606a1b6044820152606401610824565b5050600160fb55565b60006001600160e01b031982166380ac58cd60e01b1480611c5d57506001600160e01b03198216635b5e139f60e01b145b8061071757506301ffc9a760e01b6001600160e01b0319831614610717565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611cb182611173565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611cf7826008613723565b83511015611d3e5760405162461bcd60e51b8152602060048201526014602482015273746f55696e7436345f6f75744f66426f756e647360601b6044820152606401610824565b50016008015190565b80471015611d975760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610824565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611de4576040519150601f19603f3d011682016040523d82523d6000602084013e611de9565b606091505b505090508061095a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610824565b61150d828260405180602001604052806000815250612658565b6000611e86828461373b565b9392505050565b6000818152606760205260408120546001600160a01b0316611f065760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610824565b6000611f1183611173565b9050806001600160a01b0316846001600160a01b03161480611f4c5750836001600160a01b0316611f41846107af565b6001600160a01b0316145b8061131c57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff1661131c565b826001600160a01b0316611f9382611173565b6001600160a01b031614611ffb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610824565b6001600160a01b03821661205d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610824565b612068600082611c7c565b6001600160a01b038316600090815260686020526040812080546001929061209190849061373b565b90915550506001600160a01b03821660009081526068602052604081208054600192906120bf908490613723565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611e868284613768565b60c95460ff166121755760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610824565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122385760405162461bcd60e51b81526004016108249061377c565b61224061268b565b61224861268b565b61150d82826126b2565b600054610100900460ff166122795760405162461bcd60e51b81526004016108249061377c565b61228161268b565b611156612700565b600054610100900460ff166122b05760405162461bcd60e51b81526004016108249061377c565b6122b861268b565b611156612730565b600054610100900460ff166122e75760405162461bcd60e51b81526004016108249061377c565b611156612763565b60c95460ff16156123355760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610824565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121a23390565b816001600160a01b0316836001600160a01b031614156123cc5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610824565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612444848484611f80565b6124508484848461278a565b6115be5760405162461bcd60e51b8152600401610824906137c7565b6000612479826004613723565b835110156124c05760405162461bcd60e51b8152602060048201526014602482015273746f55696e7433325f6f75744f66426f756e647360601b6044820152606401610824565b50016004015190565b6060816124ed5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612517578061250181613463565b91506125109050600a83613768565b91506124f1565b6000816001600160401b0381111561253157612531612b6b565b6040519080825280601f01601f19166020018201604052801561255b576020820181803683370190505b5090505b841561131c5761257060018361373b565b915061257d600a86613819565b612588906030613723565b60f81b81838151811061259d5761259d61340f565b60200101906001600160f81b031916908160001a9053506125bf600a86613768565b945061255f565b6000818152606760205260409020546060906001600160a01b03166125fd5760405162461bcd60e51b815260040161082490613685565b6000612607612888565b905060008151116126275760405180602001604052806000815250611e86565b80612631846124c9565b60405160200161264292919061382d565b6040516020818303038152906040529392505050565b6126628383612898565b61266f600084848461278a565b61095a5760405162461bcd60e51b8152600401610824906137c7565b600054610100900460ff166111565760405162461bcd60e51b81526004016108249061377c565b600054610100900460ff166126d95760405162461bcd60e51b81526004016108249061377c565b81516126ec9060659060208501906129da565b50805161095a9060669060208401906129da565b600054610100900460ff166127275760405162461bcd60e51b81526004016108249061377c565b611156336121bf565b600054610100900460ff166127575760405162461bcd60e51b81526004016108249061377c565b60c9805460ff19169055565b600054610100900460ff1661157a5760405162461bcd60e51b81526004016108249061377c565b60006001600160a01b0384163b1561287d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906127ce90339089908890889060040161385c565b6020604051808303816000875af1925050508015612809575060408051601f3d908101601f191682019092526128069181019061388f565b60015b612863573d808015612837576040519150601f19603f3d011682016040523d82523d6000602084013e61283c565b606091505b50805161285b5760405162461bcd60e51b8152600401610824906137c7565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061131c565b506001949350505050565b606061012e805461072c9061314d565b6001600160a01b0382166128ee5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610824565b6000818152606760205260409020546001600160a01b0316156129535760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610824565b6001600160a01b038216600090815260686020526040812080546001929061297c908490613723565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546129e69061314d565b90600052602060002090601f016020900481019282612a085760008555612a4e565b82601f10612a2157805160ff1916838001178555612a4e565b82800160010185558215612a4e579182015b82811115612a4e578251825591602001919060010190612a33565b50612a5a929150612a5e565b5090565b5b80821115612a5a5760008155600101612a5f565b6001600160e01b0319811681146119d557600080fd5b600060208284031215612a9b57600080fd5b8135611e8681612a73565b60005b83811015612ac1578181015183820152602001612aa9565b838111156115be5750506000910152565b60008151808452612aea816020860160208601612aa6565b601f01601f19169290920160200192915050565b602081526000611e866020830184612ad2565b600060208284031215612b2357600080fd5b5035919050565b6001600160a01b03811681146119d557600080fd5b60008060408385031215612b5257600080fd5b8235612b5d81612b2a565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b0381118282101715612ba457612ba4612b6b565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612bd257612bd2612b6b565b604052919050565b60006001600160401b03821115612bf357612bf3612b6b565b5060051b60200190565b600082601f830112612c0e57600080fd5b81356020612c23612c1e83612bda565b612baa565b82815260059290921b84018101918181019086841115612c4257600080fd5b8286015b84811015612c66578035612c5981612b2a565b8352918301918301612c46565b509695505050505050565b600082601f830112612c8257600080fd5b81356020612c92612c1e83612bda565b82815260059290921b84018101918181019086841115612cb157600080fd5b8286015b84811015612c665780358352918301918301612cb5565b63ffffffff811681146119d557600080fd5b60008083601f840112612cf057600080fd5b5081356001600160401b03811115612d0757600080fd5b602083019150836020828501011115612d1f57600080fd5b9250929050565b60008060008060008060a08789031215612d3f57600080fd5b86356001600160401b0380821115612d5657600080fd5b612d628a838b01612bfd565b9750602091508189013581811115612d7957600080fd5b612d858b828c01612c71565b9750506040890135612d9681612ccc565b9550606089013581811115612daa57600080fd5b8901601f81018b13612dbb57600080fd5b8035612dc9612c1e82612bda565b81815260059190911b8201840190848101908d831115612de857600080fd5b928501925b82841015612e0657833582529285019290850190612ded565b97505050506080890135915080821115612e1f57600080fd5b50612e2c89828a01612cde565b979a9699509497509295939492505050565b600080600060608486031215612e5357600080fd5b8335612e5e81612b2a565b92506020840135612e6e81612b2a565b929592945050506040919091013590565b60008060408385031215612e9257600080fd5b50508035926020909101359150565b600060208284031215612eb357600080fd5b8135611e8681612b2a565b600080600060608486031215612ed357600080fd5b8335612ede81612ccc565b925060208401356001600160401b0380821115612efa57600080fd5b612f0687838801612bfd565b93506040860135915080821115612f1c57600080fd5b50612f2986828701612c71565b9150509250925092565b60006001600160401b03821115612f4c57612f4c612b6b565b50601f01601f191660200190565b6000612f68612c1e84612f33565b9050828152838383011115612f7c57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612fa457600080fd5b611e8683833560208501612f5a565b60008060408385031215612fc657600080fd5b82356001600160401b03811115612fdc57600080fd5b612fe885828601612f93565b9250506020830135612ff981612b2a565b809150509250929050565b60006020828403121561301657600080fd5b81356001600160401b0381111561302c57600080fd5b61131c84828501612f93565b80151581146119d557600080fd5b6000806040838503121561305957600080fd5b823561306481612b2a565b91506020830135612ff981613038565b6000806000806080858703121561308a57600080fd5b843561309581612b2a565b935060208501356130a581612b2a565b92506040850135915060608501356001600160401b038111156130c757600080fd5b8501601f810187136130d857600080fd5b6130e787823560208401612f5a565b91505092959194509250565b60ff811681146119d557600080fd5b60006020828403121561311457600080fd5b8135611e86816130f3565b6000806040838503121561313257600080fd5b823561313d81612b2a565b91506020830135612ff981612b2a565b600181811c9082168061316157607f821691505b6020821081141561318257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600081518084526020808501945080840160005b838110156131f85781516001600160a01b0316875295820195908201906001016131d3565b509495945050505050565b600081518084526020808501945080840160005b838110156131f857815187529582019590820190600101613217565b63ffffffff8516815260806020820152600061325260808301866131bf565b82810360408401526132648186613203565b91505060018060a01b038316606083015295945050505050565b805161328981613038565b919050565b6000602082840312156132a057600080fd5b8151611e8681613038565b805161328981612ccc565b6000602082840312156132c857600080fd5b8151611e8681612ccc565b60006060820163ffffffff861683526020606081850152818651808452608086019150828801935060005b8181101561331a578451835293830193918301916001016132fe565b50506001600160a01b0395909516604094909401939093525091949350505050565b63ffffffff8416815260606020820152600061335b60608301856131bf565b828103604084015261336d8185613203565b9695505050505050565b60006020828403121561338957600080fd5b5051919050565b835160009082906020808801845b838110156133c35781516001600160a01b03168552938201939082019060010161339e565b5050865181880193925060005b818110156133ec578451845293820193928201926001016133d0565b50505060e09490941b6001600160e01b0319168452505060049091019392505050565b634e487b7160e01b600052603260045260246000fd5b805161328981612b2a565b60006020828403121561344257600080fd5b8151611e8681612b2a565b634e487b7160e01b600052601160045260246000fd5b60006000198214156134775761347761344d565b5060010190565b600082601f83011261348f57600080fd5b815161349d612c1e82612f33565b8181528460208386010111156134b257600080fd5b61131c826020830160208701612aa6565b8051613289816130f3565b6000602082840312156134e057600080fd5b81516001600160401b03808211156134f757600080fd5b90830190610100828603121561350c57600080fd5b613514612b81565b61351d836132ab565b815261352b602084016132ab565b602082015261353c60408401613425565b604082015261354d6060840161327e565b606082015261355e6080840161327e565b608082015260a08301518281111561357557600080fd5b6135818782860161347e565b60a08301525061359360c084016134c3565b60c08201526135a460e08401613425565b60e082015295945050505050565b6040815260006135c560408301856131bf565b82810360208401526135d78185613203565b95945050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600081600019048311821515161561364b5761364b61344d565b500290565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b66697066733a2f2f60c81b8152600083516136f6816007850160208801612aa6565b602f60f81b6007918401918201528351613717816008840160208801612aa6565b01600801949350505050565b600082198211156137365761373661344d565b500190565b60008282101561374d5761374d61344d565b500390565b634e487b7160e01b600052601260045260246000fd5b60008261377757613777613752565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261382857613828613752565b500690565b6000835161383f818460208801612aa6565b835190830190613853818360208801612aa6565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061336d90830184612ad2565b6000602082840312156138a157600080fd5b8151611e8681612a7356fe68747470733a2f2f67657473706c6963652e696f2f636f6e74726163742d6d65746164617461a2646970667358221220eefc55241b0e9d15d85873414905356901cfe5a73e6b7232f0c51c024d70f4c864736f6c634300080a0033

Deployed Bytecode

0x6080604052600436106102045760003560e01c80638456cb5911610118578063cdcd897e116100a0578063e98585ee1161006f578063e98585ee14610612578063e985e9c514610649578063f2fde38b14610692578063f3e414f8146106b2578063f4f3b200146106d257600080fd5b8063cdcd897e14610590578063d46e6734146105bd578063da90b77d146105dd578063e8a3d485146105fd57600080fd5b8063a0ef91df116100e7578063a0ef91df146104de578063a22cb465146104f3578063b88d4fde14610513578063c0214fd914610533578063c87b56dd1461057057600080fd5b80638456cb59146104765780638da5cb5b1461048b57806395d89b41146104a9578063a0bcfc7f146104be57600080fd5b80632e1688231161019b5780636352211e1161016a5780636352211e146103d357806370a08231146103f3578063715018a6146104215780637362f1a9146104365780637ab4339d1461045657600080fd5b80632e168823146103655780633f4ba83a1461038657806342842e0e1461039b5780635c975abb146103bb57600080fd5b8063104cbfef116101d7578063104cbfef146102ba5780632231fe54146102e557806323b872dd146103065780632a55205a1461032657600080fd5b806301ffc9a71461020957806306fdde031461023e578063081812fc14610260578063095ea7b314610298575b600080fd5b34801561021557600080fd5b50610229610224366004612a89565b6106f2565b60405190151581526020015b60405180910390f35b34801561024a57600080fd5b5061025361071d565b6040516102359190612afe565b34801561026c57600080fd5b5061028061027b366004612b11565b6107af565b6040516001600160a01b039091168152602001610235565b3480156102a457600080fd5b506102b86102b3366004612b3f565b610849565b005b6102cd6102c8366004612d26565b61095f565b6040516001600160401b039091168152602001610235565b3480156102f157600080fd5b5061013054610280906001600160a01b031681565b34801561031257600080fd5b506102b8610321366004612e3e565b61103c565b34801561033257600080fd5b50610346610341366004612e7f565b61106d565b604080516001600160a01b039093168352602083019190915201610235565b34801561037157600080fd5b5061013154610280906001600160a01b031681565b34801561039257600080fd5b506102b8611124565b3480156103a757600080fd5b506102b86103b6366004612e3e565b611158565b3480156103c757600080fd5b5060c95460ff16610229565b3480156103df57600080fd5b506102806103ee366004612b11565b611173565b3480156103ff57600080fd5b5061041361040e366004612ea1565b6111ea565b604051908152602001610235565b34801561042d57600080fd5b506102b8611271565b34801561044257600080fd5b50610413610451366004612ebe565b6112a5565b34801561046257600080fd5b506102b8610471366004612fb3565b611324565b34801561048257600080fd5b506102b861148e565b34801561049757600080fd5b506097546001600160a01b0316610280565b3480156104b557600080fd5b506102536114c0565b3480156104ca57600080fd5b506102b86104d9366004613004565b6114cf565b3480156104ea57600080fd5b506102b8611511565b3480156104ff57600080fd5b506102b861050e366004613046565b611581565b34801561051f57600080fd5b506102b861052e366004613074565b61158c565b34801561053f57600080fd5b5061055361054e366004612b11565b6115c4565b6040805163ffffffff938416815292909116602083015201610235565b34801561057c57600080fd5b5061025361058b366004612b11565b61160d565b34801561059c57600080fd5b5061012d546105ab9060ff1681565b60405160ff9091168152602001610235565b3480156105c957600080fd5b506102b86105d8366004612ea1565b61178d565b3480156105e957600080fd5b506102b86105f8366004613102565b61185c565b34801561060957600080fd5b5061025361191d565b34801561061e57600080fd5b506102cd61062d366004612b11565b61012f602052600090815260409020546001600160401b031681565b34801561065557600080fd5b5061022961066436600461311f565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b34801561069e57600080fd5b506102b86106ad366004612ea1565b61193d565b3480156106be57600080fd5b506102b86106cd366004612b3f565b6119d8565b3480156106de57600080fd5b506102b86106ed366004612ea1565b611aa0565b60006001600160e01b0319821663152a902d60e11b1480610717575061071782611c2c565b92915050565b60606065805461072c9061314d565b80601f01602080910402602001604051908101604052809291908181526020018280546107589061314d565b80156107a55780601f1061077a576101008083540402835291602001916107a5565b820191906000526020600020905b81548152906001019060200180831161078857829003601f168201915b5050505050905090565b6000818152606760205260408120546001600160a01b031661082d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152606960205260409020546001600160a01b031690565b600061085482611173565b9050806001600160a01b0316836001600160a01b031614156108c25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610824565b336001600160a01b03821614806108de57506108de8133610664565b6109505760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610824565b61095a8383611c7c565b505050565b600061096d60c95460ff1690565b156109ad5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610824565b600260fb5414156109d05760405162461bcd60e51b815260040161082490613188565b600260fb556101305460405163b901d35760e01b81526001600160a01b039091169063b901d35790610a0c9088908b908b903390600401613233565b602060405180830381865afa158015610a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4d919061328e565b610a5657600080fd5b610130546040516347984ee760e01b815263ffffffff871660048201526001600160a01b03909116906347984ee790602401602060405180830381865afa158015610aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac991906132b6565b63ffffffff16610c195783511580610b54575061013054604051636c4adf5560e01b81526001600160a01b0390911690636c4adf5590610b11908890889033906004016132d3565b602060405180830381865afa158015610b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b52919061328e565b155b15610bae57604051630ac6f28b60e41b8152602060048201526024808201527f6e6f207265736572766174696f6e73206c656674206f722070726f6f662066616044820152631a5b195960e21b6064820152608401610824565b6101305460405163c728172360e01b815263ffffffff871660048201523360248201526001600160a01b039091169063c728172390604401600060405180830381600087803b158015610c0057600080fd5b505af1158015610c14573d6000803e3d6000fd5b505050505b6101305460405163367c1e4960e21b81526000916001600160a01b03169063d9f0792490610c4f9089908c908c9060040161333c565b602060405180830381865afa158015610c6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c909190613377565b905080341015610cb357604051638d53e55360e01b815260040160405180910390fd5b6000888888604051602001610cca93929190613390565b60408051601f198184030181529181528151602092830120600081815261012f9093529120549091506001600160401b031615610d1a57604051632c48efd760e21b815260040160405180910390fd5b61013054604051621caf6f60e01b815263ffffffff891660048201526000916001600160a01b031690621caf6f906024016020604051808303816000875af1158015610d6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8e91906132b6565b6040516001600160e01b031960e08b811b8216602084015283901b166024820152909150610dcf906028016040516020818303038152906040526000611cea565b600083815261012f60205260408120805467ffffffffffffffff19166001600160401b0384161790559094505b8a51811015610efa5760008b8281518110610e1957610e1961340f565b60200260200101516001600160a01b0316636352211e8c8481518110610e4157610e4161340f565b60200260200101516040518263ffffffff1660e01b8152600401610e6791815260200190565b602060405180830381865afa158015610e84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea89190613430565b90506001600160a01b03811633141580610ec957506001600160a01b038116155b15610ee75760405163fe6b905b60e01b815260040160405180910390fd5b5080610ef281613463565b915050610dfc565b506101305460405163275fc7d160e21b815263ffffffff8a166004820152610f7e916001600160a01b031690639d7f1f4490602401600060405180830381865afa158015610f4c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f7491908101906134ce565b60e0015184611d47565b610f9133856001600160401b0316611e60565b8763ffffffff16846001600160401b03168b8b604051602001610fb59291906135b2565b60408051601f19818403018152908290528051602090910120907fb80f047a8f7705b219221f734fc94ce5e7db261886bcfc0e95d57083fe371fa790600090a460006110013485611e7a565b905060008111801561101a575067016345785d8a000081105b15611029576110293382611d47565b50505050600160fb559695505050505050565b6110463382611e8d565b6110625760405162461bcd60e51b8152600401610824906135e0565b61095a838383611f80565b600080600061107b856115c4565b506101305460405163275fc7d160e21b815263ffffffff831660048201529192506001600160a01b031690639d7f1f4490602401600060405180830381865afa1580156110cc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110f491908101906134ce565b60e0015161012d5490935061111a9060649061111490879060ff16613631565b90612120565b9150509250929050565b6097546001600160a01b0316331461114e5760405162461bcd60e51b815260040161082490613650565b61115661212c565b565b61095a8383836040518060200160405280600081525061158c565b6000818152606760205260408120546001600160a01b0316806107175760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610824565b60006001600160a01b0382166112555760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610824565b506001600160a01b031660009081526068602052604090205490565b6097546001600160a01b0316331461129b5760405162461bcd60e51b815260040161082490613650565b61115660006121bf565b6101305460405163367c1e4960e21b81526000916001600160a01b03169063d9f07924906112db9087908790879060040161333c565b602060405180830381865afa1580156112f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131c9190613377565b949350505050565b600054610100900460ff1661133f5760005460ff1615611343565b303b155b6113a65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610824565b600054610100900460ff161580156113c8576000805461ffff19166101011790555b61140e6040518060400160405280600681526020016553706c69636560d01b8152506040518060400160405280600681526020016553504c49434560d01b815250612211565b611416612252565b61141e612289565b6114266122c0565b61012d805460ff1916600a17905561013180546001600160a01b03191633179055825161145b9061012e9060208601906129da565b5061013080546001600160a01b0319166001600160a01b038416179055801561095a576000805461ff0019169055505050565b6097546001600160a01b031633146114b85760405162461bcd60e51b815260040161082490613650565b6111566122ef565b60606066805461072c9061314d565b6097546001600160a01b031633146114f95760405162461bcd60e51b815260040161082490613650565b805161150d9061012e9060208401906129da565b5050565b600260fb5414156115345760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b031633146115635760405162461bcd60e51b815260040161082490613650565b6101315461157a906001600160a01b031647611d47565b600160fb55565b61150d33838361236a565b6115963383611e8d565b6115b25760405162461bcd60e51b8152600401610824906135e0565b6115be84848484612439565b50505050565b6000806000836040516020016115dc91815260200190565b60405160208183030381529060405290506115f881601861246c565b925061160581601c61246c565b915050915091565b6000818152606760205260409020546060906001600160a01b03166116445760405162461bcd60e51b815260040161082490613685565b600080611650846115c4565b6101305460405163b6719c8960e01b815263ffffffff841660048201529294509092506001600160a01b03169063b6719c8990602401602060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c7919061328e565b15611784576101305460405163275fc7d160e21b815263ffffffff841660048201526000916001600160a01b031690639d7f1f4490602401600060405180830381865afa15801561171c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261174491908101906134ce565b90508060a0015161175a8363ffffffff166124c9565b60405160200161176b9291906136d4565b6040516020818303038152906040529350505050919050565b61131c846125c6565b6097546001600160a01b031633146117b75760405162461bcd60e51b815260040161082490613650565b6001600160a01b0381166118065760405162461bcd60e51b81526020600482015260166024820152756d7573742062652061207265616c206164647265737360501b6044820152606401610824565b61013180546001600160a01b0319166001600160a01b0383169081179091556040519081527f373c72efabe4ef3e552ff77838be729f3bc3d8c586df0012902d1baa2377fa1d906020015b60405180910390a150565b6097546001600160a01b031633146118865760405162461bcd60e51b815260040161082490613650565b600a8160ff1611156118da5760405162461bcd60e51b815260206004820152601f60248201527f726f79616c74696573206d757374206e657665722065786365656420313025006044820152606401610824565b61012d805460ff191660ff83169081179091556040519081527facdc039ddefe0ba231b1a075c764b86c103dc99b2bded9c47bebdc4ae605c06c90602001611851565b60606040518060600160405280602681526020016138ad60269139905090565b6097546001600160a01b031633146119675760405162461bcd60e51b815260040161082490613650565b6001600160a01b0381166119cc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610824565b6119d5816121bf565b50565b600260fb5414156119fb5760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b03163314611a2a5760405162461bcd60e51b815260040161082490613650565b610131546040516323b872dd60e01b81523060048201526001600160a01b03918216602482015260448101839052908316906323b872dd90606401600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b5050600160fb5550505050565b600260fb541415611ac35760405162461bcd60e51b815260040161082490613188565b600260fb556097546001600160a01b03163314611af25760405162461bcd60e51b815260040161082490613650565b610131546040516370a0823160e01b81523060048201526000916001600160a01b038481169263a9059cbb92919091169083906370a0823190602401602060405180830381865afa158015611b4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6f9190613377565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015611bba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bde919061328e565b905080611c235760405162461bcd60e51b81526020600482015260136024820152721d1a19481d1c985b9cd9995c8819985a5b1959606a1b6044820152606401610824565b5050600160fb55565b60006001600160e01b031982166380ac58cd60e01b1480611c5d57506001600160e01b03198216635b5e139f60e01b145b8061071757506301ffc9a760e01b6001600160e01b0319831614610717565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611cb182611173565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611cf7826008613723565b83511015611d3e5760405162461bcd60e51b8152602060048201526014602482015273746f55696e7436345f6f75744f66426f756e647360601b6044820152606401610824565b50016008015190565b80471015611d975760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610824565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611de4576040519150601f19603f3d011682016040523d82523d6000602084013e611de9565b606091505b505090508061095a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610824565b61150d828260405180602001604052806000815250612658565b6000611e86828461373b565b9392505050565b6000818152606760205260408120546001600160a01b0316611f065760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610824565b6000611f1183611173565b9050806001600160a01b0316846001600160a01b03161480611f4c5750836001600160a01b0316611f41846107af565b6001600160a01b0316145b8061131c57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff1661131c565b826001600160a01b0316611f9382611173565b6001600160a01b031614611ffb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610824565b6001600160a01b03821661205d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610824565b612068600082611c7c565b6001600160a01b038316600090815260686020526040812080546001929061209190849061373b565b90915550506001600160a01b03821660009081526068602052604081208054600192906120bf908490613723565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611e868284613768565b60c95460ff166121755760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610824565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122385760405162461bcd60e51b81526004016108249061377c565b61224061268b565b61224861268b565b61150d82826126b2565b600054610100900460ff166122795760405162461bcd60e51b81526004016108249061377c565b61228161268b565b611156612700565b600054610100900460ff166122b05760405162461bcd60e51b81526004016108249061377c565b6122b861268b565b611156612730565b600054610100900460ff166122e75760405162461bcd60e51b81526004016108249061377c565b611156612763565b60c95460ff16156123355760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610824565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586121a23390565b816001600160a01b0316836001600160a01b031614156123cc5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610824565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612444848484611f80565b6124508484848461278a565b6115be5760405162461bcd60e51b8152600401610824906137c7565b6000612479826004613723565b835110156124c05760405162461bcd60e51b8152602060048201526014602482015273746f55696e7433325f6f75744f66426f756e647360601b6044820152606401610824565b50016004015190565b6060816124ed5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612517578061250181613463565b91506125109050600a83613768565b91506124f1565b6000816001600160401b0381111561253157612531612b6b565b6040519080825280601f01601f19166020018201604052801561255b576020820181803683370190505b5090505b841561131c5761257060018361373b565b915061257d600a86613819565b612588906030613723565b60f81b81838151811061259d5761259d61340f565b60200101906001600160f81b031916908160001a9053506125bf600a86613768565b945061255f565b6000818152606760205260409020546060906001600160a01b03166125fd5760405162461bcd60e51b815260040161082490613685565b6000612607612888565b905060008151116126275760405180602001604052806000815250611e86565b80612631846124c9565b60405160200161264292919061382d565b6040516020818303038152906040529392505050565b6126628383612898565b61266f600084848461278a565b61095a5760405162461bcd60e51b8152600401610824906137c7565b600054610100900460ff166111565760405162461bcd60e51b81526004016108249061377c565b600054610100900460ff166126d95760405162461bcd60e51b81526004016108249061377c565b81516126ec9060659060208501906129da565b50805161095a9060669060208401906129da565b600054610100900460ff166127275760405162461bcd60e51b81526004016108249061377c565b611156336121bf565b600054610100900460ff166127575760405162461bcd60e51b81526004016108249061377c565b60c9805460ff19169055565b600054610100900460ff1661157a5760405162461bcd60e51b81526004016108249061377c565b60006001600160a01b0384163b1561287d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906127ce90339089908890889060040161385c565b6020604051808303816000875af1925050508015612809575060408051601f3d908101601f191682019092526128069181019061388f565b60015b612863573d808015612837576040519150601f19603f3d011682016040523d82523d6000602084013e61283c565b606091505b50805161285b5760405162461bcd60e51b8152600401610824906137c7565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061131c565b506001949350505050565b606061012e805461072c9061314d565b6001600160a01b0382166128ee5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610824565b6000818152606760205260409020546001600160a01b0316156129535760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610824565b6001600160a01b038216600090815260686020526040812080546001929061297c908490613723565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546129e69061314d565b90600052602060002090601f016020900481019282612a085760008555612a4e565b82601f10612a2157805160ff1916838001178555612a4e565b82800160010185558215612a4e579182015b82811115612a4e578251825591602001919060010190612a33565b50612a5a929150612a5e565b5090565b5b80821115612a5a5760008155600101612a5f565b6001600160e01b0319811681146119d557600080fd5b600060208284031215612a9b57600080fd5b8135611e8681612a73565b60005b83811015612ac1578181015183820152602001612aa9565b838111156115be5750506000910152565b60008151808452612aea816020860160208601612aa6565b601f01601f19169290920160200192915050565b602081526000611e866020830184612ad2565b600060208284031215612b2357600080fd5b5035919050565b6001600160a01b03811681146119d557600080fd5b60008060408385031215612b5257600080fd5b8235612b5d81612b2a565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b0381118282101715612ba457612ba4612b6b565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612bd257612bd2612b6b565b604052919050565b60006001600160401b03821115612bf357612bf3612b6b565b5060051b60200190565b600082601f830112612c0e57600080fd5b81356020612c23612c1e83612bda565b612baa565b82815260059290921b84018101918181019086841115612c4257600080fd5b8286015b84811015612c66578035612c5981612b2a565b8352918301918301612c46565b509695505050505050565b600082601f830112612c8257600080fd5b81356020612c92612c1e83612bda565b82815260059290921b84018101918181019086841115612cb157600080fd5b8286015b84811015612c665780358352918301918301612cb5565b63ffffffff811681146119d557600080fd5b60008083601f840112612cf057600080fd5b5081356001600160401b03811115612d0757600080fd5b602083019150836020828501011115612d1f57600080fd5b9250929050565b60008060008060008060a08789031215612d3f57600080fd5b86356001600160401b0380821115612d5657600080fd5b612d628a838b01612bfd565b9750602091508189013581811115612d7957600080fd5b612d858b828c01612c71565b9750506040890135612d9681612ccc565b9550606089013581811115612daa57600080fd5b8901601f81018b13612dbb57600080fd5b8035612dc9612c1e82612bda565b81815260059190911b8201840190848101908d831115612de857600080fd5b928501925b82841015612e0657833582529285019290850190612ded565b97505050506080890135915080821115612e1f57600080fd5b50612e2c89828a01612cde565b979a9699509497509295939492505050565b600080600060608486031215612e5357600080fd5b8335612e5e81612b2a565b92506020840135612e6e81612b2a565b929592945050506040919091013590565b60008060408385031215612e9257600080fd5b50508035926020909101359150565b600060208284031215612eb357600080fd5b8135611e8681612b2a565b600080600060608486031215612ed357600080fd5b8335612ede81612ccc565b925060208401356001600160401b0380821115612efa57600080fd5b612f0687838801612bfd565b93506040860135915080821115612f1c57600080fd5b50612f2986828701612c71565b9150509250925092565b60006001600160401b03821115612f4c57612f4c612b6b565b50601f01601f191660200190565b6000612f68612c1e84612f33565b9050828152838383011115612f7c57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612fa457600080fd5b611e8683833560208501612f5a565b60008060408385031215612fc657600080fd5b82356001600160401b03811115612fdc57600080fd5b612fe885828601612f93565b9250506020830135612ff981612b2a565b809150509250929050565b60006020828403121561301657600080fd5b81356001600160401b0381111561302c57600080fd5b61131c84828501612f93565b80151581146119d557600080fd5b6000806040838503121561305957600080fd5b823561306481612b2a565b91506020830135612ff981613038565b6000806000806080858703121561308a57600080fd5b843561309581612b2a565b935060208501356130a581612b2a565b92506040850135915060608501356001600160401b038111156130c757600080fd5b8501601f810187136130d857600080fd5b6130e787823560208401612f5a565b91505092959194509250565b60ff811681146119d557600080fd5b60006020828403121561311457600080fd5b8135611e86816130f3565b6000806040838503121561313257600080fd5b823561313d81612b2a565b91506020830135612ff981612b2a565b600181811c9082168061316157607f821691505b6020821081141561318257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600081518084526020808501945080840160005b838110156131f85781516001600160a01b0316875295820195908201906001016131d3565b509495945050505050565b600081518084526020808501945080840160005b838110156131f857815187529582019590820190600101613217565b63ffffffff8516815260806020820152600061325260808301866131bf565b82810360408401526132648186613203565b91505060018060a01b038316606083015295945050505050565b805161328981613038565b919050565b6000602082840312156132a057600080fd5b8151611e8681613038565b805161328981612ccc565b6000602082840312156132c857600080fd5b8151611e8681612ccc565b60006060820163ffffffff861683526020606081850152818651808452608086019150828801935060005b8181101561331a578451835293830193918301916001016132fe565b50506001600160a01b0395909516604094909401939093525091949350505050565b63ffffffff8416815260606020820152600061335b60608301856131bf565b828103604084015261336d8185613203565b9695505050505050565b60006020828403121561338957600080fd5b5051919050565b835160009082906020808801845b838110156133c35781516001600160a01b03168552938201939082019060010161339e565b5050865181880193925060005b818110156133ec578451845293820193928201926001016133d0565b50505060e09490941b6001600160e01b0319168452505060049091019392505050565b634e487b7160e01b600052603260045260246000fd5b805161328981612b2a565b60006020828403121561344257600080fd5b8151611e8681612b2a565b634e487b7160e01b600052601160045260246000fd5b60006000198214156134775761347761344d565b5060010190565b600082601f83011261348f57600080fd5b815161349d612c1e82612f33565b8181528460208386010111156134b257600080fd5b61131c826020830160208701612aa6565b8051613289816130f3565b6000602082840312156134e057600080fd5b81516001600160401b03808211156134f757600080fd5b90830190610100828603121561350c57600080fd5b613514612b81565b61351d836132ab565b815261352b602084016132ab565b602082015261353c60408401613425565b604082015261354d6060840161327e565b606082015261355e6080840161327e565b608082015260a08301518281111561357557600080fd5b6135818782860161347e565b60a08301525061359360c084016134c3565b60c08201526135a460e08401613425565b60e082015295945050505050565b6040815260006135c560408301856131bf565b82810360208401526135d78185613203565b95945050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600081600019048311821515161561364b5761364b61344d565b500290565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b66697066733a2f2f60c81b8152600083516136f6816007850160208801612aa6565b602f60f81b6007918401918201528351613717816008840160208801612aa6565b01600801949350505050565b600082198211156137365761373661344d565b500190565b60008282101561374d5761374d61344d565b500390565b634e487b7160e01b600052601260045260246000fd5b60008261377757613777613752565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261382857613828613752565b500690565b6000835161383f818460208801612aa6565b835190830190613853818360208801612aa6565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061336d90830184612ad2565b6000602082840312156138a157600080fd5b8151611e8681612a7356fe68747470733a2f2f67657473706c6963652e696f2f636f6e74726163742d6d65746164617461a2646970667358221220eefc55241b0e9d15d85873414905356901cfe5a73e6b7232f0c51c024d70f4c864736f6c634300080a0033

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.