ETH Price: $3,482.81 (+5.21%)

Contract

0x8F3D19eFE7c9e7411EC8B14e02c2699b5F669628
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60c06040143839302022-03-14 9:37:39989 days ago1647250659IN
 Create: FraktalNFT
0 ETH0.0507311815.49187583

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FraktalNFT

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 29 : FraktalNFT.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import "./PaymentSplitterUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

contract FraktalNFT is ERC1155Upgradeable,ERC721HolderUpgradeable,ERC1155HolderUpgradeable{
  using EnumerableSet for EnumerableSet.AddressSet;
  using EnumerableMap for EnumerableMap.UintToAddressMap;
  address revenueChannelImplementation;
  bool fraktionalized;
  bool public sold;
  uint256 public fraktionsIndex;
  uint16 public majority;
  mapping(uint256 => bool) public indexUsed;
  mapping(uint256 => mapping(address => uint256)) public lockedShares;
  mapping(uint256 => mapping(address => uint256)) public lockedToTotal;
  EnumerableSet.AddressSet private holders;
  EnumerableMap.UintToAddressMap private revenues;
  string public name = "FraktalNFT";
  string public symbol = "FRAK";
  address public factory;
  address collateral;

  event LockedSharesForTransfer(
    address shareOwner,
    address to,
    uint256 numShares
  );
  event unLockedSharesForTransfer(
    address shareOwner,
    address to,
    uint256 numShares
  );
  event ItemSold(address buyer, uint256 indexUsed);
  event NewRevenueAdded(
    address payer,
    address revenueChannel,
    uint256 amount,
    bool sold
  );
  event Fraktionalized(address holder, address minter, uint256 index);
  event Defraktionalized(address holder, uint256 index);
  event MajorityValueChanged(uint16 newValue);

  // constructor() initializer {}

  function init(
    address _creator,
    address _revenueChannelImplementation,
    string calldata uri,
    uint16 _majority,
    string memory _name,
    string memory _symbol
  ) external initializer {
    __ERC1155_init(uri);
    _mint(_creator, 0, 1, "");
    fraktionalized = false;
    sold = false;
    majority = _majority;
    revenueChannelImplementation = _revenueChannelImplementation;
    holders.add(_creator);
    if(keccak256(abi.encodePacked(_name)) != keccak256(abi.encodePacked("")) && 
    keccak256(abi.encodePacked(_symbol)) != keccak256(abi.encodePacked(""))
    ){
      name = _name;
      symbol = _symbol;
    }
    factory = msg.sender;//factory as msg.sender
  }

  // User Functions
  ///////////////////////////
  function fraktionalize(address _to, uint256 _tokenId) external {
    require((_tokenId != 0) && 
    (this.balanceOf(_msgSender(), 0) == 1) && 
    !fraktionalized && 
    (indexUsed[_tokenId] == false)
    );
    // require(this.balanceOf(_msgSender(), 0) == 1);
    // require(fraktionalized == false);
    // require(indexUsed[_tokenId] == false);
    fraktionalized = true;
    sold = false;
    fraktionsIndex = _tokenId;
    _mint(_to, _tokenId, 10000*10**18, "");
    emit Fraktionalized(_msgSender(), _to, _tokenId);
  }

  function defraktionalize() external {
    fraktionalized = false;
    _burn(_msgSender(), fraktionsIndex, 10000*10**18);
    emit Defraktionalized(_msgSender(), fraktionsIndex);
  }

  function setMajority(uint16 newValue) external {
    require((this.balanceOf(_msgSender(), 0) == 1)&&
    (newValue <= 10000*10**18)
    );
    // require(newValue <= 10000*10**18);
    // require(newValue > 0);
    majority = newValue;
    emit MajorityValueChanged(newValue);
  }

  function soldBurn(
    address owner,
    uint256 _tokenId,
    uint256 bal
  ) external {
    if (_msgSender() != owner) {
      require(isApprovedForAll(owner, _msgSender()));
    }
    _burn(owner, _tokenId, bal);
  }

  function lockSharesTransfer(
    address from,
    uint256 numShares,
    address _to
  ) external {
    if (from != _msgSender()) {
      require(isApprovedForAll(from, _msgSender()));
    }
    require(
      balanceOf(from, fraktionsIndex) - lockedShares[fraktionsIndex][from] >=
        numShares
    );
    lockedShares[fraktionsIndex][from] += numShares;
    lockedToTotal[fraktionsIndex][_to] += numShares;
    emit LockedSharesForTransfer(from, _to, numShares);
  }

  function unlockSharesTransfer(address from, address _to) external {
    require(!sold);
    if (from != _msgSender()) {
      require(isApprovedForAll(from, _msgSender()));
    }
    uint256 balance = lockedShares[fraktionsIndex][from];
    lockedShares[fraktionsIndex][from] -= balance;
    lockedToTotal[fraktionsIndex][_to] -= balance;
    emit unLockedSharesForTransfer(from, _to, 0);
  }

  function createRevenuePayment(address _marketAddress) external payable returns (address _clone) {
    cleanUpHolders();
    address[] memory owners = holders.values();
    uint256 listLength = holders.length();
    uint256[] memory fraktions = new uint256[](listLength);
    for (uint256 i = 0; i < listLength; i++) {
      fraktions[i] = this.balanceOf(owners[i], fraktionsIndex);
    }
    _clone = ClonesUpgradeable.clone(revenueChannelImplementation);
    address payable revenueContract = payable(_clone);
    PaymentSplitterUpgradeable(revenueContract).init(owners, fraktions, _marketAddress);
    uint256 bufferedValue = msg.value;
    AddressUpgradeable.sendValue(revenueContract, bufferedValue);
    uint256 index = revenues.length();
    revenues.set(index, _clone);
    emit NewRevenueAdded(_msgSender(), revenueContract, msg.value, sold);
  }

  function sellItem() external payable {
    require(this.balanceOf(_msgSender(), 0) == 1);
    sold = true;
    fraktionalized = false;
    indexUsed[fraktionsIndex] = true;
    emit ItemSold(_msgSender(), fraktionsIndex);
  }

  function cleanUpHolders() internal {
    uint16 cur = 0;
    while(cur < holders.length()){
      if (this.balanceOf(holders.at(cur), fraktionsIndex) < 1) {
        holders.remove(holders.at(cur));
        cur=0;
      }
      cur++;
    }
  }

  // Overrided functions
  ////////////////////////////////
  function _beforeTokenTransfer(
    address operator,
    address from,
    address to,
    uint256[] memory tokenId,
    uint256[] memory amount,
    bytes memory data
  ) internal virtual override {
    super._beforeTokenTransfer(operator, from, to, tokenId, amount, data);
    if (from != address(0) && to != address(0)) {
      if (tokenId[0] == 0) {
        if (fraktionalized == true && sold == false) {
          require((lockedToTotal[fraktionsIndex][to] > 9999));
        }
      } else {
        require(sold != true);
        require(
          (balanceOf(from, tokenId[0]) - lockedShares[fraktionsIndex][from] >=
            amount[0])
        );
      }
      holders.add(to);
    }
  }

  // Getters
  ///////////////////////////
  // function getRevenue(uint256 index) external view returns (address) {
  //   return revenues.get(index);
  // }

  // function getFraktions(address who) external view returns (uint256) {
  //   return this.balanceOf(who, fraktionsIndex);
  // }

  // function getLockedShares(uint256 index, address who)
  //   external
  //   view
  //   returns (uint256)
  // {
  //   return lockedShares[index][who];
  // }

  // function getLockedToTotal(uint256 index, address who)
  //   external
  //   view
  //   returns (uint256)
  // {
  //   return lockedToTotal[index][who];
  // }
  /**
  *@notice transfer contained ERC721 to the Fraktal owner with given address and index
  *@param contractAddress address of ERC721 contained
  *@param index index of the ERC721
   */
  //todo: Should block if collateral is being claimed
  function claimContainedERC721(address contractAddress, uint256 index) external{
    if(msg.sender != factory){
      require(contractAddress != collateral);
    }
    require((this.balanceOf(msg.sender, 0) == 1) && !fraktionalized && (IERC721(contractAddress).ownerOf(index) == address(this)));
    // require(fraktionalized==false);
    // require(IERC721(contractAddress).ownerOf(index) == address(this));
    IERC721(contractAddress).safeTransferFrom(address(this), msg.sender, index);
  }

  /**
  *@notice transfer contained ERC1155 to the Fraktal owner with given address and index
  *@param contractAddress address of ERC1155 contained
  *@param index index of the ERC1155
   */
  //todo: Should block if collateral is being claimed
  function claimContainedERC1155(address contractAddress, uint256 index, uint256 amount) external{
    if(msg.sender != factory){
      require(contractAddress != collateral);
    }
    require((this.balanceOf(msg.sender, 0) == 1) && !fraktionalized);
    IERC1155(contractAddress).safeTransferFrom(address(this), msg.sender, index, amount,"");
  }

  function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155Upgradeable, ERC1155ReceiverUpgradeable) returns (bool) {
        return ERC1155Upgradeable.supportsInterface(interfaceId) || ERC1155ReceiverUpgradeable.supportsInterface(interfaceId);
  }

  function setCollateral(address _collateral ) external{
    require(msg.sender == factory);
    collateral = _collateral;
  }

  // function getStatus() external view returns (bool) {
  //   return sold;
  // }

  // function getFraktionsIndex() external view returns (uint256) {
  //   return fraktionsIndex;
  // }
}

File 2 of 29 : ClonesUpgradeable.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 ClonesUpgradeable {
    /**
     * @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 3 of 29 : ERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155Upgradeable.sol";
import "./IERC1155ReceiverUpgradeable.sol";
import "./extensions/IERC1155MetadataURIUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {
    using AddressUpgradeable for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

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

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    function __ERC1155_init(string memory uri_) internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC1155_init_unchained(uri_);
    }

    function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {
        _setURI(uri_);
    }

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

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

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

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: transfer caller is not owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);
    }

    /**
     * @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, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
    uint256[47] private __gap;
}

File 4 of 29 : PaymentSplitterUpgradeable.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IFraktalNFT.sol";
import "./FraktalNFT.sol";
import "./FraktalMarket.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
 * @title PaymentSplitter
 * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
 * that the Ether will be split in this way, since it is handled transparently by the contract.
 *
 * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
 * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
 * an amount proportional to the percentage of total shares they were assigned.
 *
 * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
 * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
 * function.
 */
contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable {
  event PayeeAdded(address account, uint256 shares);
  event PaymentReleased(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;

  address tokenParent;
  uint256 fraktionsIndex;
  bool public buyout;
  address marketContract;

  /**
   * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
   * the matching position in the `shares` array.
   *
   * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
   * duplicates in `payees`.
   */
  function init(address[] memory payees, uint256[] memory shares_, address _marketContract)
    external
    initializer
  {
    __PaymentSplitter_init(payees, shares_);
    tokenParent = _msgSender();
    fraktionsIndex = FraktalNFT(_msgSender()).fraktionsIndex();
    buyout = FraktalNFT(_msgSender()).sold();
    marketContract = _marketContract;
  }

  function __PaymentSplitter_init(
    address[] memory payees,
    uint256[] memory shares_
  ) internal {
    __Context_init_unchained();
    __PaymentSplitter_init_unchained(payees, shares_);
  }

  function __PaymentSplitter_init_unchained(
    address[] memory payees,
    uint256[] memory shares_
  ) internal {
    require(
      payees.length == shares_.length,
      "PaymentSplitter: payees and shares length mismatch"
    );
    require(payees.length > 0, "PaymentSplitter: no payees");

    for (uint256 i = 0; i < payees.length; i++) {
      _addPayee(payees[i], shares_[i]);
    }
  }

  /**
   * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
   * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
   * reliability of the events, and not the actual splitting of Ether.
   *
   * To learn more about this see the Solidity documentation for
   * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
   * functions].
   */
  receive() external payable virtual {
    emit PaymentReceived(_msgSender(), msg.value);
  }

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

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

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

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

  /**
   * @dev Getter for the address of the payee number `index`.
   */
  function payee(uint256 index) external 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() external virtual {
    address payable operator = payable(_msgSender());
    require(_shares[operator] > 0, "PaymentSplitter: account has no shares");
    if (buyout) {
      // uint256 bal = IFraktalNFT(tokenParent).getFraktions(_msgSender());
      uint256 bal = FraktalNFT(tokenParent).balanceOf(_msgSender(),FraktalNFT(tokenParent).fraktionsIndex());
      IFraktalNFT(tokenParent).soldBurn(_msgSender(), fraktionsIndex, bal);
    }

    uint256 totalReceived = address(this).balance + _totalReleased;
    uint256 payment = (totalReceived * _shares[operator]) /
      _totalShares -
      _released[operator];

    require(payment != 0, "PaymentSplitter: operator is not due payment");

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

    address payable marketPayable = payable(marketContract);
    uint16 marketFee = FraktalMarket(marketPayable).fee();

    uint256 forMarket = (payment * marketFee )/ 10000;
    uint256 forOperator = payment - forMarket;

    AddressUpgradeable.sendValue(operator, forOperator);
    AddressUpgradeable.sendValue(marketPayable, forMarket);
    emit PaymentReleased(operator, payment);
  }

  /**
   * @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_;
    _totalShares = _totalShares + shares_;
    emit PayeeAdded(account, shares_);
  }

  uint256[45] private __gap;
}

File 5 of 29 : 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 6 of 29 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./EnumerableSet.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Map {
        // Storage of keys
        EnumerableSet.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(
        Map storage map,
        bytes32 key,
        bytes32 value
    ) private returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function _remove(Map storage map, bytes32 key) private returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function _contains(Map storage map, bytes32 key) private view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._keys.length();
    }

    /**
     * @dev Returns the key-value pair stored at position `index` in the map. O(1).
     *
     * Note that there are no guarantees on the ordering of entries inside the
     * array, and it may change when more entries are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
        bytes32 key = map._keys.at(index);
        return (key, map._values[key]);
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (_contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function _get(
        Map storage map,
        bytes32 key,
        string memory errorMessage
    ) private view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || _contains(map, key), errorMessage);
        return value;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToAddressMap storage map,
        uint256 key,
        address value
    ) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
        return _remove(map._inner, bytes32(key));
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
        return _contains(map._inner, bytes32(key));
    }

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return _length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the set. O(1).
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

File 7 of 29 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 8 of 29 : ERC1155HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
contract ERC1155HolderUpgradeable is Initializable, ERC1155ReceiverUpgradeable {
    function __ERC1155Holder_init() internal onlyInitializing {
        __ERC165_init_unchained();
        __ERC1155Receiver_init_unchained();
        __ERC1155Holder_init_unchained();
    }

    function __ERC1155Holder_init_unchained() internal onlyInitializing {
    }
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
    uint256[50] private __gap;
}

File 9 of 29 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
        __ERC721Holder_init_unchained();
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
    uint256[50] private __gap;
}

File 10 of 29 : IERC721.sol
// SPDX-License-Identifier: MIT

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 11 of 29 : IERC1155.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 12 of 29 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 13 of 29 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 14 of 29 : IERC1155MetadataURIUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155Upgradeable.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 15 of 29 : 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 16 of 29 : 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 17 of 29 : 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 18 of 29 : 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 19 of 29 : IFraktalNFT.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IFraktalNFT {
    function fraktionalize(address _to, uint _tokenId) external;
    function setMajority(uint16 newValue) external;
    function defraktionalize() external;
    function soldBurn(address owner, uint256 _tokenId, uint256 bal) external;
    function lockSharesTransfer(address from, uint numShares, address _to) external;
    function unlockSharesTransfer(address from, address _to) external;
    function createRevenuePayment() external returns (address _clone);
    function sellItem() external;
    function cleanUpHolders() external;
    function getRevenue(uint256 index) external view returns(address);
    function getFraktions(address who) external view returns(uint);
    function getLockedShares(uint256 index, address who) external view returns(uint);
    function getLockedToTotal(uint256 index, address who) external view returns(uint);
    function getStatus() external view returns (bool);
    function getFraktionsIndex() external view returns (uint256);
}

File 20 of 29 : FraktalMarket.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./FraktalNFT.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
// import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract FraktalMarket is
Initializable,
OwnableUpgradeable,
ReentrancyGuardUpgradeable,
ERC1155Holder
{
  uint16 public fee;
  uint256 public listingFee;
  uint256 private feesAccrued;
  struct Proposal {
    uint256 value;
    bool winner;
  }
  struct Listing {
    address tokenAddress;
    uint256 price;
    uint256 numberOfShares;
    string name;
  }
  struct AuctionListing {
    address tokenAddress;
    uint256 reservePrice;
    uint256 numberOfShares;
    uint256 auctionEndTime;
    string name;
  }
  mapping(address => mapping(address => Listing)) listings;

  mapping(address => mapping(address => mapping(uint256 => AuctionListing))) public auctionListings;
  mapping(address => uint256) public auctionNonce;
  mapping(address => mapping(uint256 => uint256)) public auctionReserve;
  mapping(address => mapping(uint256 => bool)) public auctionSellerRedeemed;
  //use below mapping as like this: participantContribution[auctioneer][sellerNonce][participant]
  mapping(address => mapping(uint256 => mapping(address => uint256))) public participantContribution;

  mapping(address => mapping(address => Proposal)) public offers;
  mapping(address => uint256) public sellersBalance;
  mapping(address => uint256) public maxPriceRegistered;

  event Bought(
    address buyer,
    address seller,
    address tokenAddress,
    uint256 numberOfShares
  );
  event FeeUpdated(uint16 newFee);
  event ListingFeeUpdated(uint256 newFee);
  event ItemListed(
    address owner,
    address tokenAddress,
    uint256 price,
    uint256 amountOfShares,
    string name
  );
  event AuctionItemListed(
    address owner,
    address tokenAddress,
    uint256 reservePrice,
    uint256 amountOfShares,
    uint256 endTime,
    uint256 nonce,
    string name
  );
  event AuctionContribute(
    address participant,
    address tokenAddress,
    address seller,
    uint256 sellerNonce,
    uint256 value
  );
  event FraktalClaimed(address owner, address tokenAddress);
  event SellerPaymentPull(address seller, uint256 balance);
  event AdminWithdrawFees(uint256 feesAccrued);
  event OfferMade(address offerer, address tokenAddress, uint256 value);
  event OfferVoted(address voter, address offerer, address tokenAddress, bool sold);
  event Volume(address user, uint256 volume);

  function initialize() public initializer {
    __Ownable_init();
    fee = 500; //5%
  }

  // Admin Functions
  //////////////////////////////////
  function setFee(uint16 _newFee) external onlyOwner {
    require(_newFee >= 0);
    require(_newFee < 10000);
    fee = _newFee;
    emit FeeUpdated(_newFee);
  }

  function setListingFee(uint256 _newListingFee) external onlyOwner {
    require(_newListingFee >= 0);
    require(_newListingFee < 10000);
    listingFee = _newListingFee;
    emit ListingFeeUpdated(_newListingFee);
  }

  function withdrawAccruedFees()
    external
    onlyOwner
    nonReentrant
    returns (bool)
  {
    address payable wallet = payable(_msgSender());
    uint256 bufferedFees = feesAccrued;
    feesAccrued = 0;
    AddressUpgradeable.sendValue(wallet, bufferedFees);
    emit AdminWithdrawFees(bufferedFees);
    return true;
  }

  // Users Functions
  //////////////////////////////////
  function rescueEth() external nonReentrant {
    require(sellersBalance[_msgSender()] > 0, "No claimed ETH");
    address payable seller = payable(_msgSender());
    uint256 balance = sellersBalance[_msgSender()];
    sellersBalance[_msgSender()] = 0;
    AddressUpgradeable.sendValue(seller, balance);
    emit SellerPaymentPull(_msgSender(), balance);
  }

  function redeemAuctionSeller(
    address _tokenAddress,
    address _seller,
    uint256 _sellerNonce
    ) external nonReentrant {
    require(_seller == _msgSender());
    require(!auctionSellerRedeemed[_seller][_sellerNonce]);//is seller already claim?
    AuctionListing storage auctionListed = auctionListings[_tokenAddress][_msgSender()][_sellerNonce];
    require(block.timestamp >= auctionListed.auctionEndTime);//is auction ended?
    uint256 _auctionReserve = auctionReserve[_seller][_sellerNonce];
    //auction successful
    //give eth minus fee to seller
    if(_auctionReserve>=auctionListed.reservePrice){
      uint256 totalForSeller = _auctionReserve - ((_auctionReserve * fee) / 10000);
      feesAccrued += _auctionReserve - totalForSeller;

      (bool sent,) = _msgSender().call{value: totalForSeller}("");
      auctionSellerRedeemed[_seller][_sellerNonce] = true;
      emit Volume(_msgSender(),totalForSeller);
      require(sent);//check if ether failed to send
    }

    //auction failed
    else{
      auctionSellerRedeemed[_seller][_sellerNonce] = true;

      FraktalNFT(_tokenAddress).safeTransferFrom(
      address(this),
      _msgSender(),
      FraktalNFT(_tokenAddress).fraktionsIndex(),
      auctionListed.numberOfShares,
      ""
      );
    }

  }

  function redeemAuctionParticipant(
    address _tokenAddress,
    address _seller,
    uint256 _sellerNonce
  ) external nonReentrant {
    AuctionListing storage auctionListing = auctionListings[_tokenAddress][_seller][_sellerNonce];
    require(block.timestamp >= auctionListing.auctionEndTime);//is auction ended?
    require(auctionListing.auctionEndTime>0);//is auction exist?
    uint256 _auctionReserve = auctionReserve[_seller][_sellerNonce];
    uint256 fraktionsIndex = FraktalNFT(_tokenAddress).fraktionsIndex();
    //auction successful
    //give participant fraktions according to their contribution
    if(_auctionReserve>=auctionListing.reservePrice){
      uint256 auctionFraks = auctionListing.numberOfShares;
      uint256 _participantContribution = participantContribution[_seller][_sellerNonce][_msgSender()];
      uint256 eligibleFrak = (_participantContribution * auctionFraks) / _auctionReserve;
      participantContribution[_seller][_sellerNonce][_msgSender()] = 0;

      emit Volume(_msgSender(),_participantContribution);

      FraktalNFT(_tokenAddress).safeTransferFrom(
      address(this),
      _msgSender(),
      fraktionsIndex,
      eligibleFrak,
      ""
      );
    }

    //auction failed
    //give back contributed eth to participant
    else{
      uint256 _contributed = participantContribution[_seller][_sellerNonce][_msgSender()];
      participantContribution[_seller][_sellerNonce][_msgSender()] = 0;

      (bool sent,) = _msgSender().call{value: _contributed}("");
      require(sent);//check if ether failed to send
    }

  }

  function importFraktal(address tokenAddress, uint256 fraktionsIndex)
    external
  {
    FraktalNFT(tokenAddress).safeTransferFrom(
      _msgSender(),
      address(this),
      0,
      1,
      ""
    );
    FraktalNFT(tokenAddress).fraktionalize(_msgSender(), fraktionsIndex);
    FraktalNFT(tokenAddress).lockSharesTransfer(
      _msgSender(),
      10000*10**18,
      address(this)
    );
    FraktalNFT(tokenAddress).unlockSharesTransfer(_msgSender(), address(this));
  }

  function buyFraktions(
    address from,
    address tokenAddress,
    uint256 _numberOfShares
  ) external payable nonReentrant {
    Listing storage listing = listings[tokenAddress][from];
    require(!FraktalNFT(tokenAddress).sold(), "item sold");
    require(
      listing.numberOfShares >= _numberOfShares
    );//"Not enough Fraktions on sale"
    uint256 buyPrice = (listing.price * _numberOfShares)/(10**18);
    require(buyPrice!=0);
    uint256 totalFees = (buyPrice * fee) / 10000;
    uint256 totalForSeller = buyPrice - totalFees;
    uint256 fraktionsIndex = FraktalNFT(tokenAddress).fraktionsIndex();
    require(msg.value >= buyPrice);//"FraktalMarket: insufficient funds"
    listing.numberOfShares = listing.numberOfShares - _numberOfShares;
    if (listing.price * 10000 > maxPriceRegistered[tokenAddress]) {
      maxPriceRegistered[tokenAddress] = listing.price * 10000;
    }
    feesAccrued += msg.value - totalForSeller;
    sellersBalance[from] += totalForSeller;
    FraktalNFT(tokenAddress).safeTransferFrom(
      from,
      _msgSender(),
      fraktionsIndex,
      _numberOfShares,
      ""
    );
    emit Bought(_msgSender(), from, tokenAddress, _numberOfShares);
    emit Volume(_msgSender(),msg.value);
    emit Volume(from,msg.value);
  }

  function participateAuction(
    address tokenAddress,
    address seller,
    uint256 sellerNonce
  ) external payable nonReentrant {
    AuctionListing storage auctionListing = auctionListings[tokenAddress][seller][sellerNonce];
    require(block.timestamp < auctionListing.auctionEndTime);//is auction still ongoing?
    require(auctionListing.auctionEndTime>0);//is auction exist?
    uint256 contribution = msg.value;
    require(contribution>0);//need eth to participate


    //note of Eth contribution to auction reserve and participant
    auctionReserve[seller][sellerNonce] += msg.value;
    participantContribution[seller][sellerNonce][_msgSender()] += contribution;
    emit AuctionContribute(_msgSender(), tokenAddress, seller, sellerNonce, contribution);
  }

  function listItem(
    address _tokenAddress,
    uint256 _price,//wei per frak
    uint256 _numberOfShares,
    string memory _name
  ) payable external returns (bool) {
    require(msg.value >= listingFee);
    require(_price>0);
    uint256 fraktionsIndex = FraktalNFT(_tokenAddress).fraktionsIndex();
    require(
      FraktalNFT(_tokenAddress).balanceOf(address(this), 0) == 1
    );// "nft not in market"
    require(!FraktalNFT(_tokenAddress).sold());//"item sold"
    require(
      FraktalNFT(_tokenAddress).balanceOf(_msgSender(), fraktionsIndex) >=
        _numberOfShares
    );//"no valid Fraktions"
    Listing memory listed = listings[_tokenAddress][_msgSender()];
    require(listed.numberOfShares == 0);//"unlist first"
    Listing memory listing = Listing({
      tokenAddress: _tokenAddress,
      price: _price,
      numberOfShares: _numberOfShares,
      name: _name
    });
    listings[_tokenAddress][_msgSender()] = listing;
    emit ItemListed(_msgSender(), _tokenAddress, _price, _numberOfShares, _name);
    return true;
  }

  function listItemAuction(
    address _tokenAddress,
    uint256 _reservePrice,
    uint256 _numberOfShares,
    string memory _name
  ) payable external returns (uint256) {
    require(msg.value >= listingFee);
    uint256 fraktionsIndex = FraktalNFT(_tokenAddress).fraktionsIndex();
    require(
      FraktalNFT(_tokenAddress).balanceOf(address(this), 0) == 1
    );//"nft not in market"
    require(!FraktalNFT(_tokenAddress).sold());// "item sold"
    require(
      FraktalNFT(_tokenAddress).balanceOf(_msgSender(), fraktionsIndex) >=
        _numberOfShares
    );//"no valid Fraktions"
    require(_reservePrice>0);
    uint256 sellerNonce = auctionNonce[_msgSender()]++;

    uint256 _endTime = block.timestamp + (10 days);

    auctionListings[_tokenAddress][_msgSender()][sellerNonce] = AuctionListing({
      tokenAddress: _tokenAddress,
      reservePrice: _reservePrice,
      numberOfShares: _numberOfShares,
      auctionEndTime: _endTime,
      name: _name
    });

    FraktalNFT(_tokenAddress).safeTransferFrom(
      _msgSender(),
      address(this),
      fraktionsIndex,
      _numberOfShares,
      ""
    );
    emit AuctionItemListed(_msgSender(), _tokenAddress, _reservePrice, _numberOfShares, _endTime, sellerNonce, _name);
    return auctionNonce[_msgSender()];
  }

  function exportFraktal(address tokenAddress) public {
    uint256 fraktionsIndex = FraktalNFT(tokenAddress).fraktionsIndex();
    FraktalNFT(tokenAddress).safeTransferFrom(_msgSender(), address(this), fraktionsIndex, 10000*10**18, '');
    FraktalNFT(tokenAddress).defraktionalize();
    FraktalNFT(tokenAddress).safeTransferFrom(address(this), _msgSender(), 0, 1, '');
  }

  function makeOffer(address tokenAddress, uint256 _value) public payable {
    require(msg.value >= _value);//"No pay"
    Proposal storage prop = offers[_msgSender()][tokenAddress];
    address payable offerer = payable(_msgSender());
    require(!prop.winner);// "offer accepted"
    if (_value >= prop.value) {
      require(_value >= maxPriceRegistered[tokenAddress], "Min offer");
      require(msg.value >= _value - prop.value);
    } else {
      uint256 bufferedValue = prop.value;
      prop.value = 0;
      AddressUpgradeable.sendValue(offerer, bufferedValue);
    }
    offers[_msgSender()][tokenAddress] = Proposal({
      value: _value,
      winner: false
    });
    emit OfferMade(_msgSender(), tokenAddress, _value);
  }

  function rejectOffer(address from, address to, address tokenAddress) external {
      FraktalNFT(tokenAddress).unlockSharesTransfer(
      from,
      to
    );
  }

  function voteOffer(address offerer, address tokenAddress) external {
    uint256 fraktionsIndex = FraktalNFT(tokenAddress).fraktionsIndex();
    Proposal storage offer = offers[offerer][tokenAddress];
    uint256 lockedShares = FraktalNFT(tokenAddress).lockedShares(fraktionsIndex,_msgSender());
    uint256 votesAvailable = FraktalNFT(tokenAddress).balanceOf(
      _msgSender(),
      fraktionsIndex
    ) - lockedShares;
    FraktalNFT(tokenAddress).lockSharesTransfer(
      _msgSender(),
      votesAvailable,
      offerer
    );
    uint256 lockedToOfferer = FraktalNFT(tokenAddress).lockedToTotal(fraktionsIndex,offerer);
    bool sold = false;
    if (lockedToOfferer > FraktalNFT(tokenAddress).majority()) {
      FraktalNFT(tokenAddress).sellItem();
      offer.winner = true;
      sold = true;
    }
    emit OfferVoted(_msgSender(), offerer, tokenAddress, sold);
  }

  function claimFraktal(address tokenAddress) external {
    uint256 fraktionsIndex = FraktalNFT(tokenAddress).fraktionsIndex();
    if (FraktalNFT(tokenAddress).sold()) {
      Proposal memory offer = offers[_msgSender()][tokenAddress];
      require(
        FraktalNFT(tokenAddress).lockedToTotal(fraktionsIndex,_msgSender())
         > FraktalNFT(tokenAddress).majority(),
        "not buyer"
      );
      FraktalNFT(tokenAddress).createRevenuePayment{ value: offer.value }(address(this));
      maxPriceRegistered[tokenAddress] = 0;
    }
    FraktalNFT(tokenAddress).safeTransferFrom(
      address(this),
      _msgSender(),
      0,
      1,
      ""
    );
    emit FraktalClaimed(_msgSender(), tokenAddress);
  }

  function unlistItem(address tokenAddress) external {
    delete listings[tokenAddress][_msgSender()];
    emit ItemListed(_msgSender(), tokenAddress, 0, 0, "");
  }

  function unlistAuctionItem(address tokenAddress,uint256 sellerNonce) external {
    AuctionListing storage auctionListed = auctionListings[tokenAddress][_msgSender()][sellerNonce];
    require(auctionListed.auctionEndTime>0);

    auctionListed.auctionEndTime = block.timestamp;

    emit AuctionItemListed(_msgSender(), tokenAddress, 0, 0, auctionListed.auctionEndTime,sellerNonce, "");
  }

  // GETTERS
  //////////////////////////////////
  function getFee() external view returns (uint256) {
    return (fee);
  }

  function getListingPrice(address _listOwner, address tokenAddress)
    external
    view
    returns (uint256)
  {
    return listings[tokenAddress][_listOwner].price;
  }

  function getListingAmount(address _listOwner, address tokenAddress)
    external
    view
    returns (uint256)
  {
    return listings[tokenAddress][_listOwner].numberOfShares;
  }

  function getSellerBalance(address _who) external view returns (uint256) {
    return (sellersBalance[_who]);
  }

  function getOffer(address offerer, address tokenAddress)
    external
    view
    returns (uint256)
  {
    return (offers[offerer][tokenAddress].value);
  }
  fallback() external payable {
      feesAccrued += msg.value;
  }

  receive() external payable {
      feesAccrued += msg.value;
  }
}

File 21 of 29 : ERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155ReceiverUpgradeable.sol";
import "../../../utils/introspection/ERC165Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155ReceiverUpgradeable is Initializable, ERC165Upgradeable, IERC1155ReceiverUpgradeable {
    function __ERC1155Receiver_init() internal onlyInitializing {
        __ERC165_init_unchained();
        __ERC1155Receiver_init_unchained();
    }

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

File 22 of 29 : 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 23 of 29 : IERC165.sol
// SPDX-License-Identifier: MIT

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 24 of 29 : ERC1155Holder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 25 of 29 : 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 26 of 29 : 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 27 of 29 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

File 28 of 29 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":"holder","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Defraktionalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Fraktionalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"indexUsed","type":"uint256"}],"name":"ItemSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"shareOwner","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"numShares","type":"uint256"}],"name":"LockedSharesForTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newValue","type":"uint16"}],"name":"MajorityValueChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"revenueChannel","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"sold","type":"bool"}],"name":"NewRevenueAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"shareOwner","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"numShares","type":"uint256"}],"name":"unLockedSharesForTransfer","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimContainedERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"claimContainedERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"createRevenuePayment","outputs":[{"internalType":"address","name":"_clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"defraktionalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"fraktionalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fraktionsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"indexUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"address","name":"_revenueChannelImplementation","type":"address"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"uint16","name":"_majority","type":"uint16"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"numShares","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"lockSharesTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"lockedShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"lockedToTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"majority","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellItem","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"setCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newValue","type":"uint16"}],"name":"setMajority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"bal","type":"uint256"}],"name":"soldBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"unlockSharesTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

60c0604052600a608081905269119c985add185b13919560b21b60a09081526200002e91610138919062000072565b50604080518082019091526004808252634652414b60e01b60209092019182526200005d916101399162000072565b503480156200006b57600080fd5b5062000155565b828054620000809062000118565b90600052602060002090601f016020900481019282620000a45760008555620000ef565b82601f10620000bf57805160ff1916838001178555620000ef565b82800160010185558215620000ef579182015b82811115620000ef578251825591602001919060010190620000d2565b50620000fd92915062000101565b5090565b5b80821115620000fd576000815560010162000102565b600181811c908216806200012d57607f821691505b602082108114156200014f57634e487b7160e01b600052602260045260246000fd5b50919050565b61397e80620001656000396000f3fe6080604052600436106101e25760003560e01c806368e9840911610102578063b6e54bdf11610095578063eeb0a4af11610064578063eeb0a4af14610635578063f23a6e611461066e578063f242432a1461069a578063fd0c060d146106ba57600080fd5b8063b6e54bdf14610570578063bc197c811461059f578063c45a0155146105cb578063e985e9c5146105ec57600080fd5b806395d89b41116100d157806395d89b41146104ed5780639f37c5dc14610502578063a22cb46514610517578063acb1e9521461053757600080fd5b806368e9840914610476578063811ce7601461048d578063886abef5146104ad5780638b4ae68c146104cd57600080fd5b80632eb2c2d61161017a5780634b4b5025116101495780634b4b5025146103e95780634cdcac40146104095780634d919dd6146104295780634e1273f41461044957600080fd5b80632eb2c2d61461034d578063307a5ff31461036d578063347e6f211461038d57806349323639146103b857600080fd5b806306fdde03116101b657806306fdde031461028e5780630e89341c146102b057806313576725146102d0578063150b7a02146102f057600080fd5b8062fdd58e146101e757806301ffc9a71461021a57806302c7e7af1461024a578063066f39bf1461026c575b600080fd5b3480156101f357600080fd5b5061020761020236600461332c565b6106c2565b6040519081526020015b60405180910390f35b34801561022657600080fd5b5061023a610235366004613499565b610770565b6040519015158152602001610211565b34801561025657600080fd5b5061012d5461023a90600160a81b900460ff1681565b34801561027857600080fd5b5061028c61028736600461305f565b61078a565b005b34801561029a57600080fd5b506102a3610891565b6040516102119190613714565b3480156102bc57600080fd5b506102a36102cb3660046134eb565b610920565b3480156102dc57600080fd5b5061028c6102eb366004613141565b6109b4565b3480156102fc57600080fd5b5061033461030b36600461322a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b03199091168152602001610211565b34801561035957600080fd5b5061028c610368366004613097565b610bfa565b34801561037957600080fd5b5061028c6103883660046134d1565b610c9c565b6103a061039b366004613027565b610d91565b6040516001600160a01b039091168152602001610211565b3480156103c457600080fd5b5061023a6103d33660046134eb565b6101306020526000908152604090205460ff1681565b3480156103f557600080fd5b5061028c610404366004613398565b61103f565b34801561041557600080fd5b5061028c61042436600461332c565b611072565b34801561043557600080fd5b5061028c610444366004613398565b61125f565b34801561045557600080fd5b506104696104643660046133cc565b6113bd565b60405161021191906136d3565b34801561048257600080fd5b5061020761012e5481565b34801561049957600080fd5b5061028c6104a8366004613357565b611533565b3480156104b957600080fd5b5061028c6104c8366004613027565b611660565b3480156104d957600080fd5b5061028c6104e836600461332c565b6116a8565b3480156104f957600080fd5b506102a3611805565b34801561050e57600080fd5b5061028c611813565b34801561052357600080fd5b5061028c6105323660046132fb565b61189f565b34801561054357600080fd5b5061020761055236600461351b565b61013160209081526000928352604080842090915290825290205481565b34801561057c57600080fd5b5061012f5461058c9061ffff1681565b60405161ffff9091168152602001610211565b3480156105ab57600080fd5b506103346105ba366004613097565b63bc197c8160e01b95945050505050565b3480156105d757600080fd5b5061013a546103a0906001600160a01b031681565b3480156105f857600080fd5b5061023a61060736600461305f565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205460ff1690565b34801561064157600080fd5b5061020761065036600461351b565b61013260209081526000928352604080842090915290825290205481565b34801561067a57600080fd5b50610334610689366004613294565b63f23a6e6160e01b95945050505050565b3480156106a657600080fd5b5061028c6106b5366004613294565b6118ae565b61028c611949565b60006001600160a01b0383166107455760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201527f65726f206164647265737300000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060008181526065602090815260408083206001600160a01b03861684529091529020545b92915050565b600061077b82611a34565b8061076a575061076a82611acf565b61012d54600160a81b900460ff16156107a257600080fd5b6001600160a01b03821633146107c5576107bc8233610607565b6107c557600080fd5b61012e546000908152610131602090815260408083206001600160a01b038616845290915281208054918291906107fc8380613763565b909155505061012e546000908152610132602090815260408083206001600160a01b038616845290915281208054839290610838908490613763565b9091555050604080516001600160a01b038086168252841660208201526000918101919091527f6c956f9a0acb32a87bb745b5d3a8411c70a1c60e5ed4c12a86f517c8460dbee9906060015b60405180910390a1505050565b610138805461089f906137aa565b80601f01602080910402602001604051908101604052809291908181526020018280546108cb906137aa565b80156109185780601f106108ed57610100808354040283529160200191610918565b820191906000526020600020905b8154815290600101906020018083116108fb57829003601f168201915b505050505081565b60606067805461092f906137aa565b80601f016020809104026020016040519081016040528092919081815260200182805461095b906137aa565b80156109a85780601f1061097d576101008083540402835291602001916109a8565b820191906000526020600020905b81548152906001019060200180831161098b57829003601f168201915b50505050509050919050565b600054610100900460ff166109cf5760005460ff16156109d3565b303b155b610a455760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161073c565b600054610100900460ff16158015610a67576000805461ffff19166101011790555b610aa686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0d92505050565b610ac3886000600160405180602001604052806000815250611b94565b61012d805461012f805461ffff191661ffff88161790557fffffffffffffffffffff00000000000000000000000000000000000000000000166001600160a01b038916179055610b1561013389611cc2565b506040805160008152602081018083528151902091610b36918691016135a5565b6040516020818303038152906040528051906020012014158015610b8e57506040805160008152602081018083528151902091610b75918591016135a5565b6040516020818303038152906040528051906020012014155b15610bbe578251610ba790610138906020860190612e99565b508151610bbc90610139906020850190612e99565b505b61013a805473ffffffffffffffffffffffffffffffffffffffff1916331790558015610bf0576000805461ff00191690555b5050505050505050565b6001600160a01b038516331480610c165750610c168533610607565b610c885760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161073c565b610c958585858585611cde565b5050505050565b3062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b158015610ce857600080fd5b505afa158015610cfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d209190613503565b6001148015610d3d575069021e19e0c9bab24000008161ffff1611155b610d4657600080fd5b61012f805461ffff191661ffff83169081179091556040519081527f87fa05a809d27617c9cbb60cac6d6f39108e65a739ddb410d7aee8e79c6b19269060200160405180910390a150565b6000610d9b611f76565b6000610da8610133612060565b90506000610db761013361206d565b905060008167ffffffffffffffff811115610de257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610e0b578160200160208202803683370190505b50905060005b82811015610f1157306001600160a01b031662fdd58e858381518110610e4757634e487b7160e01b600052603260045260246000fd5b602002602001015161012e546040518363ffffffff1660e01b8152600401610e849291906001600160a01b03929092168252602082015260400190565b60206040518083038186803b158015610e9c57600080fd5b505afa158015610eb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed49190613503565b828281518110610ef457634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610f0981613834565b915050610e11565b5061012d54610f28906001600160a01b0316612077565b6040517f878be65500000000000000000000000000000000000000000000000000000000815290945084906001600160a01b0382169063878be65590610f7690879086908b90600401613662565b600060405180830381600087803b158015610f9057600080fd5b505af1158015610fa4573d6000803e3d6000fd5b505050506000349050610fb78282612132565b6000610fc461013561224b565b9050610fd36101358289612256565b507fd58600433d64ed1af44960e693d3aaaa01dc799cf469c95c6ec543efdfbe075d3361012d54604080516001600160a01b03938416815292871660208401523490830152600160a81b900460ff161515606082015260800160405180910390a1505050505050919050565b336001600160a01b03841614611062576110598333610607565b61106257600080fd5b61106d838383612274565b505050565b61013a546001600160a01b031633146110a15761013b546001600160a01b03838116911614156110a157600080fd5b604051627eeac760e11b815233600482015260006024820152309062fdd58e9060440160206040518083038186803b1580156110dc57600080fd5b505afa1580156110f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111149190613503565b600114801561112e575061012d54600160a01b900460ff16155b80156111d357506040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810182905230906001600160a01b03841690636352211e9060240160206040518083038186803b15801561119057600080fd5b505afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613043565b6001600160a01b0316145b6111dc57600080fd5b6040517f42842e0e000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018290526001600160a01b038316906342842e0e90606401600060405180830381600087803b15801561124357600080fd5b505af1158015611257573d6000803e3d6000fd5b505050505050565b61013a546001600160a01b0316331461128e5761013b546001600160a01b038481169116141561128e57600080fd5b604051627eeac760e11b815233600482015260006024820152309062fdd58e9060440160206040518083038186803b1580156112c957600080fd5b505afa1580156112dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113019190613503565b600114801561131b575061012d54600160a01b900460ff16155b61132457600080fd5b6040517ff242432a000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018390526064810182905260a06084820152600060a48201526001600160a01b0384169063f242432a9060c401600060405180830381600087803b1580156113a057600080fd5b505af11580156113b4573d6000803e3d6000fd5b50505050505050565b606081518351146114365760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161073c565b6000835167ffffffffffffffff81111561146057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611489578160200160208202803683370190505b50905060005b845181101561152b576114f08582815181106114bb57634e487b7160e01b600052603260045260246000fd5b60200260200101518583815181106114e357634e487b7160e01b600052603260045260246000fd5b60200260200101516106c2565b82828151811061151057634e487b7160e01b600052603260045260246000fd5b602090810291909101015261152481613834565b905061148f565b509392505050565b6001600160a01b03831633146115565761154d8333610607565b61155657600080fd5b61012e546000818152610131602090815260408083206001600160a01b0388168452909152902054839161158b9086906106c2565b6115959190613763565b10156115a057600080fd5b61012e546000908152610131602090815260408083206001600160a01b0387168452909152812080548492906115d790849061374b565b909155505061012e546000908152610132602090815260408083206001600160a01b03851684529091528120805484929061161390849061374b565b9091555050604080516001600160a01b038086168252831660208201529081018390527f1487cf914d0d048518844aa2edc6821fdc6bf7d53edffc84322b4b3ef2bbde9990606001610884565b61013a546001600160a01b0316331461167857600080fd5b61013b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b801580159061173a57503062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b1580156116fe57600080fd5b505afa158015611712573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117369190613503565b6001145b8015611751575061012d54600160a01b900460ff16155b801561176d57506000818152610130602052604090205460ff16155b61177657600080fd5b61012d805461ffff60a01b1916600160a01b17905561012e8190556040805160208101909152600081526117b9908390839069021e19e0c9bab240000090611b94565b604080513381526001600160a01b038416602082015280820183905290517f29dc7bbb1c30db5f8e5e644e9adca7cd3e410cb9236ca67d83232d5406173eaf9181900360600190a15050565b610139805461089f906137aa565b61012d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556118543361012e5469021e19e0c9bab2400000612274565b7fec0fd6fa76edc3e473f9bb9ba9281c27b2ac12ee551cfbd629670b18fc1c90e8335b61012e54604080516001600160a01b03909316835260208301919091520160405180910390a1565b6118aa338383612424565b5050565b6001600160a01b0385163314806118ca57506118ca8533610607565b61193c5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201527f20617070726f7665640000000000000000000000000000000000000000000000606482015260840161073c565b610c958585858585612519565b3062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b15801561199557600080fd5b505afa1580156119a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cd9190613503565b6001146119d957600080fd5b61012d805461ffff60a01b1916600160a81b17905561012e54600090815261013060205260409020805460ff191660011790557fc8edef1fc414675e55c5a6ea7d9d6547df463b23dbdfc36ecaad361408c0894c6118773390565b60006001600160e01b031982167fd9b67a26000000000000000000000000000000000000000000000000000000001480611a9757506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b8061076a57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b031983161461076a565b60006001600160e01b031982167f4e2312e000000000000000000000000000000000000000000000000000000000148061076a575061076a82611a34565b600054610100900460ff16611b785760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b611b806126b2565b611b886126b2565b611b918161271f565b50565b6001600160a01b038416611c105760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161073c565b33611c3081600087611c2188612793565b611c2a88612793565b876127ec565b60008481526065602090815260408083206001600160a01b038916845290915281208054859290611c6290849061374b565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610c9581600087878787612972565b6000611cd7836001600160a01b038416612b27565b9392505050565b8151835114611d555760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161073c565b6001600160a01b038416611db95760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161073c565b33611dc88187878787876127ec565b60005b8451811015611f10576000858281518110611df657634e487b7160e01b600052603260045260246000fd5b602002602001015190506000858381518110611e2257634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526065835260408082206001600160a01b038e168352909352919091205490915081811015611eb65760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161073c565b60008381526065602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611ef590849061374b565b9250508190555050505080611f0990613834565b9050611dcb565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611f609291906136e6565b60405180910390a4611257818787878787612b76565b60005b611f8461013361206d565b8161ffff161015611b915760013062fdd58e611fa661013361ffff8616612c81565b61012e546040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b158015611fee57600080fd5b505afa158015612002573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120269190613503565b101561204e5761204861203f61013361ffff8416612c81565b61013390612c8d565b50600090505b8061205881613812565b915050611f79565b60606000611cd783612ca2565b600061076a825490565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b03811661212d5760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015260640161073c565b919050565b804710156121825760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161073c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146121cf576040519150601f19603f3d011682016040523d82523d6000602084013e6121d4565b606091505b505090508061106d5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161073c565b600061076a82612cfd565b600061226c84846001600160a01b038516612d08565b949350505050565b6001600160a01b0383166122f05760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161073c565b3361231f8185600061230187612793565b61230a87612793565b604051806020016040528060008152506127ec565b60008381526065602090815260408083206001600160a01b0388168452909152902054828110156123b75760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161073c565b60008481526065602090815260408083206001600160a01b03898116808652918452828520888703905582518981529384018890529092908616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050505050565b816001600160a01b0316836001600160a01b031614156124ac5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161073c565b6001600160a01b03838116600081815260666020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841661257d5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161073c565b3361258d818787611c2188612793565b60008481526065602090815260408083206001600160a01b038a168452909152902054838110156126135760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161073c565b60008581526065602090815260408083206001600160a01b038b811685529252808320878503905590881682528120805486929061265290849061374b565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46113b4828888888888612972565b600054610100900460ff1661271d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b565b600054610100900460ff1661278a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b611b9181612d25565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106127db57634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0385161580159061280c57506001600160a01b03841615155b15611257578260008151811061283257634e487b7160e01b600052603260045260246000fd5b6020026020010151600014156128ab5761012d54600160a01b900460ff161515600114801561286c575061012d54600160a81b900460ff16155b156128a65761012e546000908152610132602090815260408083206001600160a01b038816845290915290205461270f106128a657600080fd5b612966565b61012d54600160a81b900460ff161515600114156128c857600080fd5b816000815181106128e957634e487b7160e01b600052603260045260246000fd5b6020026020010151610131600061012e5481526020019081526020016000206000876001600160a01b03166001600160a01b031681526020019081526020016000205461295187866000815181106114e357634e487b7160e01b600052603260045260246000fd5b61295b9190613763565b101561296657600080fd5b6113b461013385611cc2565b6001600160a01b0384163b156112575760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906129b6908990899088908890889060040161361f565b602060405180830381600087803b1580156129d057600080fd5b505af1925050508015612a00575060408051601f3d908101601f191682019092526129fd918101906134b5565b60015b612ab657612a0c61387b565b806308c379a01415612a465750612a21613893565b80612a2c5750612a48565b8060405162461bcd60e51b815260040161073c9190613714565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161073c565b6001600160e01b0319811663f23a6e6160e01b146113b45760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161073c565b6000818152600183016020526040812054612b6e5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561076a565b50600061076a565b6001600160a01b0384163b156112575760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612bba90899089908890889088906004016135c1565b602060405180830381600087803b158015612bd457600080fd5b505af1925050508015612c04575060408051601f3d908101601f19168201909252612c01918101906134b5565b60015b612c1057612a0c61387b565b6001600160e01b0319811663bc197c8160e01b146113b45760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161073c565b6000611cd78383612d38565b6000611cd7836001600160a01b038416612d70565b6060816000018054806020026020016040519081016040528092919081815260200182805480156109a857602002820191906000526020600020905b815481526020019060010190808311612cde5750505050509050919050565b600061076a8261206d565b6000828152600284016020526040812082905561226c8484612e8d565b80516118aa906067906020840190612e99565b6000826000018281548110612d5d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60008181526001830160205260408120548015612e83576000612d94600183613763565b8554909150600090612da890600190613763565b9050818114612e29576000866000018281548110612dd657634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110612e0757634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612e4857634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061076a565b600091505061076a565b6000611cd78383612b27565b828054612ea5906137aa565b90600052602060002090601f016020900481019282612ec75760008555612f0d565b82601f10612ee057805160ff1916838001178555612f0d565b82800160010185558215612f0d579182015b82811115612f0d578251825591602001919060010190612ef2565b50612f19929150612f1d565b5090565b5b80821115612f195760008155600101612f1e565b600082601f830112612f42578081fd5b81356020612f4f82613727565b604051612f5c82826137e5565b8381528281019150858301600585901b87018401881015612f7b578586fd5b855b85811015612f9957813584529284019290840190600101612f7d565b5090979650505050505050565b600082601f830112612fb6578081fd5b813567ffffffffffffffff811115612fd057612fd0613865565b604051612fe7601f8301601f1916602001826137e5565b818152846020838601011115612ffb578283fd5b816020850160208301379081016020019190915292915050565b803561ffff8116811461212d57600080fd5b600060208284031215613038578081fd5b8135611cd78161391d565b600060208284031215613054578081fd5b8151611cd78161391d565b60008060408385031215613071578081fd5b823561307c8161391d565b9150602083013561308c8161391d565b809150509250929050565b600080600080600060a086880312156130ae578081fd5b85356130b98161391d565b945060208601356130c98161391d565b9350604086013567ffffffffffffffff808211156130e5578283fd5b6130f189838a01612f32565b94506060880135915080821115613106578283fd5b61311289838a01612f32565b93506080880135915080821115613127578283fd5b5061313488828901612fa6565b9150509295509295909350565b600080600080600080600060c0888a03121561315b578182fd5b87356131668161391d565b965060208801356131768161391d565b9550604088013567ffffffffffffffff80821115613192578384fd5b818a0191508a601f8301126131a5578384fd5b8135818111156131b3578485fd5b8b60208285010111156131c4578485fd5b60208301975095506131d860608b01613015565b945060808a01359150808211156131ed578384fd5b6131f98b838c01612fa6565b935060a08a013591508082111561320e578283fd5b5061321b8a828b01612fa6565b91505092959891949750929550565b6000806000806080858703121561323f578384fd5b843561324a8161391d565b9350602085013561325a8161391d565b925060408501359150606085013567ffffffffffffffff81111561327c578182fd5b61328887828801612fa6565b91505092959194509250565b600080600080600060a086880312156132ab578283fd5b85356132b68161391d565b945060208601356132c68161391d565b93506040860135925060608601359150608086013567ffffffffffffffff8111156132ef578182fd5b61313488828901612fa6565b6000806040838503121561330d578182fd5b82356133188161391d565b91506020830135801515811461308c578182fd5b6000806040838503121561333e578182fd5b82356133498161391d565b946020939093013593505050565b60008060006060848603121561336b578081fd5b83356133768161391d565b925060208401359150604084013561338d8161391d565b809150509250925092565b6000806000606084860312156133ac578081fd5b83356133b78161391d565b95602085013595506040909401359392505050565b600080604083850312156133de578182fd5b823567ffffffffffffffff808211156133f5578384fd5b818501915085601f830112613408578384fd5b8135602061341582613727565b60405161342282826137e5565b8381528281019150858301600585901b870184018b1015613441578889fd5b8896505b8487101561346c5780356134588161391d565b835260019690960195918301918301613445565b5096505086013592505080821115613482578283fd5b5061348f85828601612f32565b9150509250929050565b6000602082840312156134aa578081fd5b8135611cd781613932565b6000602082840312156134c6578081fd5b8151611cd781613932565b6000602082840312156134e2578081fd5b611cd782613015565b6000602082840312156134fc578081fd5b5035919050565b600060208284031215613514578081fd5b5051919050565b6000806040838503121561352d578182fd5b82359150602083013561308c8161391d565b6000815180845260208085019450808401835b8381101561356e57815187529582019590820190600101613552565b509495945050505050565b6000815180845261359181602086016020860161377a565b601f01601f19169290920160200192915050565b600082516135b781846020870161377a565b9190910192915050565b60006001600160a01b03808816835280871660208401525060a060408301526135ed60a083018661353f565b82810360608401526135ff818661353f565b905082810360808401526136138185613579565b98975050505050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261365760a0830184613579565b979650505050505050565b606080825284519082018190526000906020906080840190828801845b828110156136a45781516001600160a01b03168452928401929084019060010161367f565b505050838103828501526136b8818761353f565b925050506001600160a01b0383166040830152949350505050565b602081526000611cd7602083018461353f565b6040815260006136f9604083018561353f565b828103602084015261370b818561353f565b95945050505050565b602081526000611cd76020830184613579565b600067ffffffffffffffff82111561374157613741613865565b5060051b60200190565b6000821982111561375e5761375e61384f565b500190565b6000828210156137755761377561384f565b500390565b60005b8381101561379557818101518382015260200161377d565b838111156137a4576000848401525b50505050565b600181811c908216806137be57607f821691505b602082108114156137df57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f1916810167ffffffffffffffff8111828210171561380b5761380b613865565b6040525050565b600061ffff8083168181141561382a5761382a61384f565b6001019392505050565b60006000198214156138485761384861384f565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d111561389057600481823e5160e01c5b90565b600060443d10156138a15790565b6040516003193d81016004833e81513d67ffffffffffffffff81602484011181841117156138d157505050505090565b82850191508151818111156138e95750505050505090565b843d87010160208285010111156139035750505050505090565b613912602082860101876137e5565b509095945050505050565b6001600160a01b0381168114611b9157600080fd5b6001600160e01b031981168114611b9157600080fdfea2646970667358221220e00746349278fa82bb395f3abe2552b0272b0491635d7ae9013f0783f7c947f264736f6c63430008040033

Deployed Bytecode

0x6080604052600436106101e25760003560e01c806368e9840911610102578063b6e54bdf11610095578063eeb0a4af11610064578063eeb0a4af14610635578063f23a6e611461066e578063f242432a1461069a578063fd0c060d146106ba57600080fd5b8063b6e54bdf14610570578063bc197c811461059f578063c45a0155146105cb578063e985e9c5146105ec57600080fd5b806395d89b41116100d157806395d89b41146104ed5780639f37c5dc14610502578063a22cb46514610517578063acb1e9521461053757600080fd5b806368e9840914610476578063811ce7601461048d578063886abef5146104ad5780638b4ae68c146104cd57600080fd5b80632eb2c2d61161017a5780634b4b5025116101495780634b4b5025146103e95780634cdcac40146104095780634d919dd6146104295780634e1273f41461044957600080fd5b80632eb2c2d61461034d578063307a5ff31461036d578063347e6f211461038d57806349323639146103b857600080fd5b806306fdde03116101b657806306fdde031461028e5780630e89341c146102b057806313576725146102d0578063150b7a02146102f057600080fd5b8062fdd58e146101e757806301ffc9a71461021a57806302c7e7af1461024a578063066f39bf1461026c575b600080fd5b3480156101f357600080fd5b5061020761020236600461332c565b6106c2565b6040519081526020015b60405180910390f35b34801561022657600080fd5b5061023a610235366004613499565b610770565b6040519015158152602001610211565b34801561025657600080fd5b5061012d5461023a90600160a81b900460ff1681565b34801561027857600080fd5b5061028c61028736600461305f565b61078a565b005b34801561029a57600080fd5b506102a3610891565b6040516102119190613714565b3480156102bc57600080fd5b506102a36102cb3660046134eb565b610920565b3480156102dc57600080fd5b5061028c6102eb366004613141565b6109b4565b3480156102fc57600080fd5b5061033461030b36600461322a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b03199091168152602001610211565b34801561035957600080fd5b5061028c610368366004613097565b610bfa565b34801561037957600080fd5b5061028c6103883660046134d1565b610c9c565b6103a061039b366004613027565b610d91565b6040516001600160a01b039091168152602001610211565b3480156103c457600080fd5b5061023a6103d33660046134eb565b6101306020526000908152604090205460ff1681565b3480156103f557600080fd5b5061028c610404366004613398565b61103f565b34801561041557600080fd5b5061028c61042436600461332c565b611072565b34801561043557600080fd5b5061028c610444366004613398565b61125f565b34801561045557600080fd5b506104696104643660046133cc565b6113bd565b60405161021191906136d3565b34801561048257600080fd5b5061020761012e5481565b34801561049957600080fd5b5061028c6104a8366004613357565b611533565b3480156104b957600080fd5b5061028c6104c8366004613027565b611660565b3480156104d957600080fd5b5061028c6104e836600461332c565b6116a8565b3480156104f957600080fd5b506102a3611805565b34801561050e57600080fd5b5061028c611813565b34801561052357600080fd5b5061028c6105323660046132fb565b61189f565b34801561054357600080fd5b5061020761055236600461351b565b61013160209081526000928352604080842090915290825290205481565b34801561057c57600080fd5b5061012f5461058c9061ffff1681565b60405161ffff9091168152602001610211565b3480156105ab57600080fd5b506103346105ba366004613097565b63bc197c8160e01b95945050505050565b3480156105d757600080fd5b5061013a546103a0906001600160a01b031681565b3480156105f857600080fd5b5061023a61060736600461305f565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205460ff1690565b34801561064157600080fd5b5061020761065036600461351b565b61013260209081526000928352604080842090915290825290205481565b34801561067a57600080fd5b50610334610689366004613294565b63f23a6e6160e01b95945050505050565b3480156106a657600080fd5b5061028c6106b5366004613294565b6118ae565b61028c611949565b60006001600160a01b0383166107455760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201527f65726f206164647265737300000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060008181526065602090815260408083206001600160a01b03861684529091529020545b92915050565b600061077b82611a34565b8061076a575061076a82611acf565b61012d54600160a81b900460ff16156107a257600080fd5b6001600160a01b03821633146107c5576107bc8233610607565b6107c557600080fd5b61012e546000908152610131602090815260408083206001600160a01b038616845290915281208054918291906107fc8380613763565b909155505061012e546000908152610132602090815260408083206001600160a01b038616845290915281208054839290610838908490613763565b9091555050604080516001600160a01b038086168252841660208201526000918101919091527f6c956f9a0acb32a87bb745b5d3a8411c70a1c60e5ed4c12a86f517c8460dbee9906060015b60405180910390a1505050565b610138805461089f906137aa565b80601f01602080910402602001604051908101604052809291908181526020018280546108cb906137aa565b80156109185780601f106108ed57610100808354040283529160200191610918565b820191906000526020600020905b8154815290600101906020018083116108fb57829003601f168201915b505050505081565b60606067805461092f906137aa565b80601f016020809104026020016040519081016040528092919081815260200182805461095b906137aa565b80156109a85780601f1061097d576101008083540402835291602001916109a8565b820191906000526020600020905b81548152906001019060200180831161098b57829003601f168201915b50505050509050919050565b600054610100900460ff166109cf5760005460ff16156109d3565b303b155b610a455760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161073c565b600054610100900460ff16158015610a67576000805461ffff19166101011790555b610aa686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b0d92505050565b610ac3886000600160405180602001604052806000815250611b94565b61012d805461012f805461ffff191661ffff88161790557fffffffffffffffffffff00000000000000000000000000000000000000000000166001600160a01b038916179055610b1561013389611cc2565b506040805160008152602081018083528151902091610b36918691016135a5565b6040516020818303038152906040528051906020012014158015610b8e57506040805160008152602081018083528151902091610b75918591016135a5565b6040516020818303038152906040528051906020012014155b15610bbe578251610ba790610138906020860190612e99565b508151610bbc90610139906020850190612e99565b505b61013a805473ffffffffffffffffffffffffffffffffffffffff1916331790558015610bf0576000805461ff00191690555b5050505050505050565b6001600160a01b038516331480610c165750610c168533610607565b610c885760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161073c565b610c958585858585611cde565b5050505050565b3062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b158015610ce857600080fd5b505afa158015610cfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d209190613503565b6001148015610d3d575069021e19e0c9bab24000008161ffff1611155b610d4657600080fd5b61012f805461ffff191661ffff83169081179091556040519081527f87fa05a809d27617c9cbb60cac6d6f39108e65a739ddb410d7aee8e79c6b19269060200160405180910390a150565b6000610d9b611f76565b6000610da8610133612060565b90506000610db761013361206d565b905060008167ffffffffffffffff811115610de257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610e0b578160200160208202803683370190505b50905060005b82811015610f1157306001600160a01b031662fdd58e858381518110610e4757634e487b7160e01b600052603260045260246000fd5b602002602001015161012e546040518363ffffffff1660e01b8152600401610e849291906001600160a01b03929092168252602082015260400190565b60206040518083038186803b158015610e9c57600080fd5b505afa158015610eb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed49190613503565b828281518110610ef457634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610f0981613834565b915050610e11565b5061012d54610f28906001600160a01b0316612077565b6040517f878be65500000000000000000000000000000000000000000000000000000000815290945084906001600160a01b0382169063878be65590610f7690879086908b90600401613662565b600060405180830381600087803b158015610f9057600080fd5b505af1158015610fa4573d6000803e3d6000fd5b505050506000349050610fb78282612132565b6000610fc461013561224b565b9050610fd36101358289612256565b507fd58600433d64ed1af44960e693d3aaaa01dc799cf469c95c6ec543efdfbe075d3361012d54604080516001600160a01b03938416815292871660208401523490830152600160a81b900460ff161515606082015260800160405180910390a1505050505050919050565b336001600160a01b03841614611062576110598333610607565b61106257600080fd5b61106d838383612274565b505050565b61013a546001600160a01b031633146110a15761013b546001600160a01b03838116911614156110a157600080fd5b604051627eeac760e11b815233600482015260006024820152309062fdd58e9060440160206040518083038186803b1580156110dc57600080fd5b505afa1580156110f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111149190613503565b600114801561112e575061012d54600160a01b900460ff16155b80156111d357506040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810182905230906001600160a01b03841690636352211e9060240160206040518083038186803b15801561119057600080fd5b505afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190613043565b6001600160a01b0316145b6111dc57600080fd5b6040517f42842e0e000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018290526001600160a01b038316906342842e0e90606401600060405180830381600087803b15801561124357600080fd5b505af1158015611257573d6000803e3d6000fd5b505050505050565b61013a546001600160a01b0316331461128e5761013b546001600160a01b038481169116141561128e57600080fd5b604051627eeac760e11b815233600482015260006024820152309062fdd58e9060440160206040518083038186803b1580156112c957600080fd5b505afa1580156112dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113019190613503565b600114801561131b575061012d54600160a01b900460ff16155b61132457600080fd5b6040517ff242432a000000000000000000000000000000000000000000000000000000008152306004820152336024820152604481018390526064810182905260a06084820152600060a48201526001600160a01b0384169063f242432a9060c401600060405180830381600087803b1580156113a057600080fd5b505af11580156113b4573d6000803e3d6000fd5b50505050505050565b606081518351146114365760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161073c565b6000835167ffffffffffffffff81111561146057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611489578160200160208202803683370190505b50905060005b845181101561152b576114f08582815181106114bb57634e487b7160e01b600052603260045260246000fd5b60200260200101518583815181106114e357634e487b7160e01b600052603260045260246000fd5b60200260200101516106c2565b82828151811061151057634e487b7160e01b600052603260045260246000fd5b602090810291909101015261152481613834565b905061148f565b509392505050565b6001600160a01b03831633146115565761154d8333610607565b61155657600080fd5b61012e546000818152610131602090815260408083206001600160a01b0388168452909152902054839161158b9086906106c2565b6115959190613763565b10156115a057600080fd5b61012e546000908152610131602090815260408083206001600160a01b0387168452909152812080548492906115d790849061374b565b909155505061012e546000908152610132602090815260408083206001600160a01b03851684529091528120805484929061161390849061374b565b9091555050604080516001600160a01b038086168252831660208201529081018390527f1487cf914d0d048518844aa2edc6821fdc6bf7d53edffc84322b4b3ef2bbde9990606001610884565b61013a546001600160a01b0316331461167857600080fd5b61013b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b801580159061173a57503062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b1580156116fe57600080fd5b505afa158015611712573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117369190613503565b6001145b8015611751575061012d54600160a01b900460ff16155b801561176d57506000818152610130602052604090205460ff16155b61177657600080fd5b61012d805461ffff60a01b1916600160a01b17905561012e8190556040805160208101909152600081526117b9908390839069021e19e0c9bab240000090611b94565b604080513381526001600160a01b038416602082015280820183905290517f29dc7bbb1c30db5f8e5e644e9adca7cd3e410cb9236ca67d83232d5406173eaf9181900360600190a15050565b610139805461089f906137aa565b61012d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690556118543361012e5469021e19e0c9bab2400000612274565b7fec0fd6fa76edc3e473f9bb9ba9281c27b2ac12ee551cfbd629670b18fc1c90e8335b61012e54604080516001600160a01b03909316835260208301919091520160405180910390a1565b6118aa338383612424565b5050565b6001600160a01b0385163314806118ca57506118ca8533610607565b61193c5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201527f20617070726f7665640000000000000000000000000000000000000000000000606482015260840161073c565b610c958585858585612519565b3062fdd58e336040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482015260440160206040518083038186803b15801561199557600080fd5b505afa1580156119a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cd9190613503565b6001146119d957600080fd5b61012d805461ffff60a01b1916600160a81b17905561012e54600090815261013060205260409020805460ff191660011790557fc8edef1fc414675e55c5a6ea7d9d6547df463b23dbdfc36ecaad361408c0894c6118773390565b60006001600160e01b031982167fd9b67a26000000000000000000000000000000000000000000000000000000001480611a9757506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b8061076a57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b031983161461076a565b60006001600160e01b031982167f4e2312e000000000000000000000000000000000000000000000000000000000148061076a575061076a82611a34565b600054610100900460ff16611b785760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b611b806126b2565b611b886126b2565b611b918161271f565b50565b6001600160a01b038416611c105760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161073c565b33611c3081600087611c2188612793565b611c2a88612793565b876127ec565b60008481526065602090815260408083206001600160a01b038916845290915281208054859290611c6290849061374b565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610c9581600087878787612972565b6000611cd7836001600160a01b038416612b27565b9392505050565b8151835114611d555760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161073c565b6001600160a01b038416611db95760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161073c565b33611dc88187878787876127ec565b60005b8451811015611f10576000858281518110611df657634e487b7160e01b600052603260045260246000fd5b602002602001015190506000858381518110611e2257634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526065835260408082206001600160a01b038e168352909352919091205490915081811015611eb65760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161073c565b60008381526065602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611ef590849061374b565b9250508190555050505080611f0990613834565b9050611dcb565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611f609291906136e6565b60405180910390a4611257818787878787612b76565b60005b611f8461013361206d565b8161ffff161015611b915760013062fdd58e611fa661013361ffff8616612c81565b61012e546040516001600160e01b031960e085901b1681526001600160a01b039092166004830152602482015260440160206040518083038186803b158015611fee57600080fd5b505afa158015612002573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120269190613503565b101561204e5761204861203f61013361ffff8416612c81565b61013390612c8d565b50600090505b8061205881613812565b915050611f79565b60606000611cd783612ca2565b600061076a825490565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b03811661212d5760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015260640161073c565b919050565b804710156121825760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161073c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146121cf576040519150601f19603f3d011682016040523d82523d6000602084013e6121d4565b606091505b505090508061106d5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161073c565b600061076a82612cfd565b600061226c84846001600160a01b038516612d08565b949350505050565b6001600160a01b0383166122f05760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161073c565b3361231f8185600061230187612793565b61230a87612793565b604051806020016040528060008152506127ec565b60008381526065602090815260408083206001600160a01b0388168452909152902054828110156123b75760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161073c565b60008481526065602090815260408083206001600160a01b03898116808652918452828520888703905582518981529384018890529092908616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050505050565b816001600160a01b0316836001600160a01b031614156124ac5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161073c565b6001600160a01b03838116600081815260666020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841661257d5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161073c565b3361258d818787611c2188612793565b60008481526065602090815260408083206001600160a01b038a168452909152902054838110156126135760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161073c565b60008581526065602090815260408083206001600160a01b038b811685529252808320878503905590881682528120805486929061265290849061374b565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46113b4828888888888612972565b600054610100900460ff1661271d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b565b600054610100900460ff1661278a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161073c565b611b9181612d25565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106127db57634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0385161580159061280c57506001600160a01b03841615155b15611257578260008151811061283257634e487b7160e01b600052603260045260246000fd5b6020026020010151600014156128ab5761012d54600160a01b900460ff161515600114801561286c575061012d54600160a81b900460ff16155b156128a65761012e546000908152610132602090815260408083206001600160a01b038816845290915290205461270f106128a657600080fd5b612966565b61012d54600160a81b900460ff161515600114156128c857600080fd5b816000815181106128e957634e487b7160e01b600052603260045260246000fd5b6020026020010151610131600061012e5481526020019081526020016000206000876001600160a01b03166001600160a01b031681526020019081526020016000205461295187866000815181106114e357634e487b7160e01b600052603260045260246000fd5b61295b9190613763565b101561296657600080fd5b6113b461013385611cc2565b6001600160a01b0384163b156112575760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906129b6908990899088908890889060040161361f565b602060405180830381600087803b1580156129d057600080fd5b505af1925050508015612a00575060408051601f3d908101601f191682019092526129fd918101906134b5565b60015b612ab657612a0c61387b565b806308c379a01415612a465750612a21613893565b80612a2c5750612a48565b8060405162461bcd60e51b815260040161073c9190613714565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161073c565b6001600160e01b0319811663f23a6e6160e01b146113b45760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161073c565b6000818152600183016020526040812054612b6e5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561076a565b50600061076a565b6001600160a01b0384163b156112575760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612bba90899089908890889088906004016135c1565b602060405180830381600087803b158015612bd457600080fd5b505af1925050508015612c04575060408051601f3d908101601f19168201909252612c01918101906134b5565b60015b612c1057612a0c61387b565b6001600160e01b0319811663bc197c8160e01b146113b45760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161073c565b6000611cd78383612d38565b6000611cd7836001600160a01b038416612d70565b6060816000018054806020026020016040519081016040528092919081815260200182805480156109a857602002820191906000526020600020905b815481526020019060010190808311612cde5750505050509050919050565b600061076a8261206d565b6000828152600284016020526040812082905561226c8484612e8d565b80516118aa906067906020840190612e99565b6000826000018281548110612d5d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60008181526001830160205260408120548015612e83576000612d94600183613763565b8554909150600090612da890600190613763565b9050818114612e29576000866000018281548110612dd657634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110612e0757634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612e4857634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061076a565b600091505061076a565b6000611cd78383612b27565b828054612ea5906137aa565b90600052602060002090601f016020900481019282612ec75760008555612f0d565b82601f10612ee057805160ff1916838001178555612f0d565b82800160010185558215612f0d579182015b82811115612f0d578251825591602001919060010190612ef2565b50612f19929150612f1d565b5090565b5b80821115612f195760008155600101612f1e565b600082601f830112612f42578081fd5b81356020612f4f82613727565b604051612f5c82826137e5565b8381528281019150858301600585901b87018401881015612f7b578586fd5b855b85811015612f9957813584529284019290840190600101612f7d565b5090979650505050505050565b600082601f830112612fb6578081fd5b813567ffffffffffffffff811115612fd057612fd0613865565b604051612fe7601f8301601f1916602001826137e5565b818152846020838601011115612ffb578283fd5b816020850160208301379081016020019190915292915050565b803561ffff8116811461212d57600080fd5b600060208284031215613038578081fd5b8135611cd78161391d565b600060208284031215613054578081fd5b8151611cd78161391d565b60008060408385031215613071578081fd5b823561307c8161391d565b9150602083013561308c8161391d565b809150509250929050565b600080600080600060a086880312156130ae578081fd5b85356130b98161391d565b945060208601356130c98161391d565b9350604086013567ffffffffffffffff808211156130e5578283fd5b6130f189838a01612f32565b94506060880135915080821115613106578283fd5b61311289838a01612f32565b93506080880135915080821115613127578283fd5b5061313488828901612fa6565b9150509295509295909350565b600080600080600080600060c0888a03121561315b578182fd5b87356131668161391d565b965060208801356131768161391d565b9550604088013567ffffffffffffffff80821115613192578384fd5b818a0191508a601f8301126131a5578384fd5b8135818111156131b3578485fd5b8b60208285010111156131c4578485fd5b60208301975095506131d860608b01613015565b945060808a01359150808211156131ed578384fd5b6131f98b838c01612fa6565b935060a08a013591508082111561320e578283fd5b5061321b8a828b01612fa6565b91505092959891949750929550565b6000806000806080858703121561323f578384fd5b843561324a8161391d565b9350602085013561325a8161391d565b925060408501359150606085013567ffffffffffffffff81111561327c578182fd5b61328887828801612fa6565b91505092959194509250565b600080600080600060a086880312156132ab578283fd5b85356132b68161391d565b945060208601356132c68161391d565b93506040860135925060608601359150608086013567ffffffffffffffff8111156132ef578182fd5b61313488828901612fa6565b6000806040838503121561330d578182fd5b82356133188161391d565b91506020830135801515811461308c578182fd5b6000806040838503121561333e578182fd5b82356133498161391d565b946020939093013593505050565b60008060006060848603121561336b578081fd5b83356133768161391d565b925060208401359150604084013561338d8161391d565b809150509250925092565b6000806000606084860312156133ac578081fd5b83356133b78161391d565b95602085013595506040909401359392505050565b600080604083850312156133de578182fd5b823567ffffffffffffffff808211156133f5578384fd5b818501915085601f830112613408578384fd5b8135602061341582613727565b60405161342282826137e5565b8381528281019150858301600585901b870184018b1015613441578889fd5b8896505b8487101561346c5780356134588161391d565b835260019690960195918301918301613445565b5096505086013592505080821115613482578283fd5b5061348f85828601612f32565b9150509250929050565b6000602082840312156134aa578081fd5b8135611cd781613932565b6000602082840312156134c6578081fd5b8151611cd781613932565b6000602082840312156134e2578081fd5b611cd782613015565b6000602082840312156134fc578081fd5b5035919050565b600060208284031215613514578081fd5b5051919050565b6000806040838503121561352d578182fd5b82359150602083013561308c8161391d565b6000815180845260208085019450808401835b8381101561356e57815187529582019590820190600101613552565b509495945050505050565b6000815180845261359181602086016020860161377a565b601f01601f19169290920160200192915050565b600082516135b781846020870161377a565b9190910192915050565b60006001600160a01b03808816835280871660208401525060a060408301526135ed60a083018661353f565b82810360608401526135ff818661353f565b905082810360808401526136138185613579565b98975050505050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261365760a0830184613579565b979650505050505050565b606080825284519082018190526000906020906080840190828801845b828110156136a45781516001600160a01b03168452928401929084019060010161367f565b505050838103828501526136b8818761353f565b925050506001600160a01b0383166040830152949350505050565b602081526000611cd7602083018461353f565b6040815260006136f9604083018561353f565b828103602084015261370b818561353f565b95945050505050565b602081526000611cd76020830184613579565b600067ffffffffffffffff82111561374157613741613865565b5060051b60200190565b6000821982111561375e5761375e61384f565b500190565b6000828210156137755761377561384f565b500390565b60005b8381101561379557818101518382015260200161377d565b838111156137a4576000848401525b50505050565b600181811c908216806137be57607f821691505b602082108114156137df57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f1916810167ffffffffffffffff8111828210171561380b5761380b613865565b6040525050565b600061ffff8083168181141561382a5761382a61384f565b6001019392505050565b60006000198214156138485761384861384f565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d111561389057600481823e5160e01c5b90565b600060443d10156138a15790565b6040516003193d81016004833e81513d67ffffffffffffffff81602484011181841117156138d157505050505090565b82850191508151818111156138e95750505050505090565b843d87010160208285010111156139035750505050505090565b613912602082860101876137e5565b509095945050505050565b6001600160a01b0381168114611b9157600080fd5b6001600160e01b031981168114611b9157600080fdfea2646970667358221220e00746349278fa82bb395f3abe2552b0272b0491635d7ae9013f0783f7c947f264736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.