ETH Price: $2,508.41 (+0.40%)

Token

NFTfi Locked Bundle (LBNFI)
 

Overview

Max Total Supply

3 LBNFI

Holders

3

Total Transfers

-

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A

Other Info

Loading...
Loading
Loading...
Loading
Loading...
Loading

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

Contract Source Code Verified (Exact Match)

Contract Name:
ImmutableBundle

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 35 : ImmutableBundle.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "./PersonalBundlerFactory.sol";
import "./NftfiBundler.sol";
import "./utils/Ownable.sol";

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/**
 * @title ImmutableBundle
 * @author NFTfi
 * @notice Bundle wrapper that allows users to lock bundles so they can be used for loans.
 * @dev This contract prevents owners of the bundles to remove any child, but they can still receive new children.
 *      Solves the problem of bundles being emptied by their owner between they are listed and the loan begins.
 */
contract ImmutableBundle is ERC721Enumerable, IERC721Receiver, Ownable, Pausable {
    using SafeERC20 for IERC20;
    using Strings for uint256;

    // Incremental token id
    uint256 public tokenCount = 0;

    uint8 public constant personalBundleId = 1;

    // Address of the bundler contract
    NftfiBundler public immutable bundler;

    address public immutable personalBundlerFactory;

    string public baseURI;

    // immutable tokenId => bundleId
    mapping(uint256 => uint256) public bundleOfImmutable;
    // bundleId => immutable tokenId
    mapping(uint256 => uint256) public immutableOfBundle;

    // immutable tokenId => personalBundler contract
    mapping(uint256 => address) public personalBundlerOfImmutable;
    //personalBundler contract => immutable tokenId
    mapping(address => uint256) public immutableOfPersonalBundler;

    event ImmutableMinted(uint256 indexed immutableId, uint256 indexed bundleId, address indexed personalBundler);
    event ConvertedToPersonalBundler(
        uint256 indexed immutableId,
        uint256 indexed bundleId,
        address indexed personalBundler
    );

    /**
     * @dev Stores the bundler, name and symbol
     *
     * @param _bundler Address of the bundler contract
     * @param _name name of the token contract
     * @param _symbol symbol of the token contract
     */
    constructor(
        address _admin,
        address _bundler,
        address _personalBundlerFactory,
        string memory _name,
        string memory _symbol,
        string memory _customBaseURI
    ) ERC721(_name, _symbol) Ownable(_admin) {
        bundler = NftfiBundler(_bundler);
        personalBundlerFactory = _personalBundlerFactory;
        _setBaseURI(_customBaseURI);
    }

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

    /**
     * @notice Mints a new bundle storing it as immutable bundle.
     *         The bundle can receive children but there is no way to remove a child, unless withdrawing the bundle.
     * @param _to The address that owns the new immutable bundle
     * @return The id of the new created immutable bundle
     */
    function mintBundle(address _to) external whenNotPaused returns (uint256) {
        uint256 bundleId = bundler.safeMint(address(this));
        return _mintImmutableBundle(_to, bundleId);
    }

    /**
     * @notice Method invoked when a bundle is received
     * param The address that caused the transfer
     * @param _from The previous owner of the token
     * @param _bundleId The bundle that is being transferred
     * param _data Arbitrary data
     * @return the selector of this method
     */
    function onERC721Received(
        address,
        address _from,
        uint256 _bundleId,
        bytes memory
    ) external virtual override whenNotPaused returns (bytes4) {
        require(
            msg.sender == address(bundler) ||
                PersonalBundlerFactory(personalBundlerFactory).personalBundlerExists(msg.sender),
            "asset not allowed"
        );

        // Special check for when onERC721Received is invoked from `mintBundle` call
        if (_from != address(0)) {
            uint256 immutableId;
            if (msg.sender == address(bundler)) {
                immutableId = _mintImmutableBundle(_from, _bundleId);
            } else {
                immutableId = _mintImmutablePersonalBundle(_from, msg.sender);
            }
        }

        return this.onERC721Received.selector;
    }

    /**
     * @notice Withdraw a bundle
     * @param _immutableId the id of the immutable bundle
     * @param _to the address of the receiver of the bundle
     */
    function withdraw(uint256 _immutableId, address _to) external {
        _validateWithdraw(_immutableId, _to);

        uint256 bundleId = bundleOfImmutable[_immutableId];
        address personalBundler = personalBundlerOfImmutable[_immutableId];

        _burnImmutableBundle(_immutableId);

        if (personalBundler == address(0)) {
            bundler.safeTransferFrom(address(this), _to, bundleId);
        } else {
            IERC721(personalBundler).safeTransferFrom(address(this), _to, personalBundleId);
        }
    }

    /**
     * @notice Withdraw a bundle and remove all the children from the bundle
     * @param _immutableId the id of the immutable bundle
     * @param _to the address of the receiver of the bundle
     */
    function withdrawAndDecompose(uint256 _immutableId, address _to) external {
        _validateWithdraw(_immutableId, _to);

        uint256 bundleId = bundleOfImmutable[_immutableId];
        address personalBundler = personalBundlerOfImmutable[_immutableId];

        _burnImmutableBundle(_immutableId);

        if (personalBundler == address(0)) {
            bundler.decomposeBundle(bundleId, _to);
            bundler.safeTransferFrom(address(this), _to, bundleId);
        } else {
            NftfiBundler(personalBundler).decomposeBundle(personalBundleId, _to);
            IERC721(personalBundler).safeTransferFrom(address(this), _to, personalBundleId);
        }
    }

    /**
     * Takes an existing immutable regular bundle and converts it to a personal bundle,
     * creates the personal bundler contract implicitly.
     *
     * @param _immutableId the id of the immutable bundle
     */
    function createAndConvertToPersonalBundler(uint256 _immutableId) public {
        address personalBundler = PersonalBundlerFactory(personalBundlerFactory).createPersonalBundler(address(this));
        convertToPersonalBundler(_immutableId, personalBundler);
    }

    /**
     * Takes an existing immutable regular bundle and converts it to a personal bundle,
     * has to be provided with a personal bundler contract address
     *
     * @param _immutableId the id of the immutable bundle
     * @param _personalBundler the address of the personal bundler conract
     */
    function convertToPersonalBundler(uint256 _immutableId, address _personalBundler) public {
        require(ownerOf(_immutableId) == msg.sender, "msg.sender not eligible");
        require(personalBundlerOfImmutable[_immutableId] == address(0), "already personal bundler");
        require(
            PersonalBundlerFactory(personalBundlerFactory).personalBundlerExists(_personalBundler),
            "not personal bundler"
        );
        require(ERC721(_personalBundler).ownerOf(personalBundleId) == address(this), "owner has to be this contract");
        uint256 bundleId = bundleOfImmutable[_immutableId];
        delete bundleOfImmutable[_immutableId];
        delete immutableOfBundle[bundleId];
        bundler.sendElementsToPersonalBundler(bundleId, _personalBundler);
        emit ConvertedToPersonalBundler(_immutableId, bundleId, _personalBundler);
        personalBundlerOfImmutable[_immutableId] = _personalBundler;
        immutableOfPersonalBundler[_personalBundler] = _immutableId;
    }

    /**
     * @notice this function initiates a flashloan to pull an airdrop from a tartget contract
     *
     * @param _immutableId - the id of the immutable bundle
     * @param _nftContract - contract address of the target nft of the drop
     * @param _nftId - id of the target nft of the drop
     * @param _target - address of the airdropping contract
     * @param _data - function selector to be called on the airdropping contract
     * @param _nftAirdrop - address of the used claiming nft in the drop
     * @param _nftAirdropId - id of the used claiming nft in the drop
     * @param _is1155 -
     * @param _nftAirdropAmount - amount in case of 1155
     */
    function pullAirdrop(
        uint256 _immutableId,
        address _nftContract,
        uint256 _nftId,
        address _target,
        bytes calldata _data,
        address _nftAirdrop,
        uint256 _nftAirdropId,
        bool _is1155,
        uint256 _nftAirdropAmount
    ) external {
        require(ownerOf(_immutableId) == msg.sender, "pullAirdrop msg.sender not eligible");
        if (personalBundlerOfImmutable[_immutableId] != address(0)) {
            require(
                NftfiBundler(personalBundlerOfImmutable[_immutableId]).childExists(_nftContract, _nftId),
                "immutable-nft mismatch"
            );
            NftfiBundler(personalBundlerOfImmutable[_immutableId]).pullAirdrop(
                _nftContract,
                _nftId,
                _target,
                _data,
                _nftAirdrop,
                _nftAirdropId,
                _is1155,
                _nftAirdropAmount,
                msg.sender
            );
        } else {
            (, uint256 bundleId) = bundler.ownerOfChild(_nftContract, _nftId);
            require(bundleOfImmutable[_immutableId] == bundleId, "immutable-nft mismatch");
            bundler.pullAirdrop(
                _nftContract,
                _nftId,
                _target,
                _data,
                _nftAirdrop,
                _nftAirdropId,
                _is1155,
                _nftAirdropAmount,
                msg.sender
            );
        }
    }

    /**
     * @notice Validates the withdraw params
     * @param _immutableId the id of the immutable bundle
     * @param _to the address of the receiver of the bundle
     */
    function _validateWithdraw(uint256 _immutableId, address _to) internal view {
        require(ownerOf(_immutableId) == msg.sender, "caller is not owner");
        require(_to != address(0), "transfer to zero address");
    }

    /**
     * @notice Mints a new immutable bundle.
     * @param _to The address that owns the new immutable bundle
     * @param _bundleId The associated bundle id
     * @return The id of the new created immutable bundle
     */
    function _mintImmutableBundle(address _to, uint256 _bundleId) internal returns (uint256) {
        uint256 immutableId = ++tokenCount;
        _safeMint(_to, immutableId);
        bundleOfImmutable[immutableId] = _bundleId;
        immutableOfBundle[_bundleId] = immutableId;
        emit ImmutableMinted(immutableId, _bundleId, address(0));
        return immutableId;
    }

    /**
     * @notice Mints a new immutable bundle.
     * @param _to The address that owns the new immutable bundle
     * @param _personalBundler The associated personal bundler
     * @return The id of the new created immutable bundle
     */
    function _mintImmutablePersonalBundle(address _to, address _personalBundler) internal returns (uint256) {
        uint256 immutableId = ++tokenCount;
        _safeMint(_to, immutableId);

        personalBundlerOfImmutable[immutableId] = _personalBundler;
        immutableOfPersonalBundler[_personalBundler] = immutableId;

        emit ImmutableMinted(immutableId, 0, _personalBundler);
        return immutableId;
    }

    /**
     * @notice Burns an immutable bundle
     * @param _immutableId the id of the immutable bundle
     */
    function _burnImmutableBundle(uint256 _immutableId) internal {
        _burn(_immutableId);
        if (personalBundlerOfImmutable[_immutableId] != address(0)) {
            address personalBundler = personalBundlerOfImmutable[_immutableId];
            delete personalBundlerOfImmutable[_immutableId];
            delete immutableOfPersonalBundler[personalBundler];
        } else {
            uint256 bundleId = bundleOfImmutable[_immutableId];
            delete bundleOfImmutable[_immutableId];
            delete immutableOfBundle[bundleId];
        }
    }

    /**
     * @notice used by the owner account to be able to drain ERC721 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _tokenId - id token to be sent out
     * @param _receiver - receiver of the token
     */
    function rescueERC721(
        address _tokenAddress,
        uint256 _tokenId,
        address _receiver
    ) external onlyOwner {
        IERC721 tokenContract = IERC721(_tokenAddress);
        if (_tokenAddress == address(bundler)) {
            require(immutableOfBundle[_tokenId] == 0, "token is in immutable");
        } else if (PersonalBundlerFactory(personalBundlerFactory).personalBundlerExists(_tokenAddress)) {
            require(immutableOfPersonalBundler[_tokenAddress] == 0, "token is in immutable");
        }
        require(tokenContract.ownerOf(_tokenId) == address(this), "nft not owned");
        tokenContract.safeTransferFrom(address(this), _receiver, _tokenId);
    }

    /**
     * @notice used by the owner account to be able to drain ERC20 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _receiver - receiver of the token
     */
    function rescueERC20(address _tokenAddress, address _receiver) external onlyOwner {
        IERC20 tokenContract = IERC20(_tokenAddress);
        uint256 amount = tokenContract.balanceOf(address(this));
        require(amount > 0, "no tokens owned");
        tokenContract.safeTransfer(_receiver, amount);
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - Only the owner can call this method.
     * - The contract must not be paused.
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - Only the owner can call this method.
     * - The contract must be paused.
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @dev Sets baseURI.
     * @param _customBaseURI - Base URI
     */
    function setBaseURI(string memory _customBaseURI) external onlyOwner {
        _setBaseURI(_customBaseURI);
    }

    /**
     * @dev Sets baseURI.
     */
    function _setBaseURI(string memory _customBaseURI) internal virtual {
        baseURI = bytes(_customBaseURI).length > 0
            ? string(abi.encodePacked(_customBaseURI, _getChainID().toString(), "/"))
            : "";
    }

    /** @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`.
     */
    function _baseURI() internal view virtual override returns (string memory) {
        return baseURI;
    }

    /**
     * @dev This function gets the current chain ID.
     */
    function _getChainID() internal view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }
}

File 2 of 35 : PersonalBundlerFactory.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.17;

import "@openzeppelin/contracts/proxy/Clones.sol";

import "./utils/Ownable.sol";

import "./PersonalBundler.sol";

/**
 * @title PersonalBundlerFactory
 * @author NFTfi
 * @dev
 */
contract PersonalBundlerFactory is Ownable {
    address public immutable personalBundlerImplementation;
    string public baseURI;

    mapping(address => bool) public personalBundlerExists;

    event PersonalBundlerCreated(address indexed instance, address indexed owner, address creator);

    /**
     * @param _admin admin address capable of setting URI
     * @param _customBaseURI - Base URI
     * @param _personalBundlerImplementation - deployed master copy of the personal bundler contract
     */
    constructor(
        address _admin,
        string memory _customBaseURI,
        address _personalBundlerImplementation
    ) Ownable(_admin) {
        baseURI = _customBaseURI;
        personalBundlerImplementation = _personalBundlerImplementation;
    }

    /**
     * @dev clones a new personal bundler contract
     *
     * @param _to - owner of the personal bundler
     */
    function createPersonalBundler(address _to) external returns (address) {
        address instance = Clones.clone(personalBundlerImplementation);
        personalBundlerExists[instance] = true;
        PersonalBundler(instance).initialize(owner(), _to, baseURI);
        emit PersonalBundlerCreated(instance, _to, msg.sender);
        return instance;
    }

    /**
     * @dev Sets baseURI.
     * @param _customBaseURI - Base URI
     */
    function setBaseURI(string memory _customBaseURI) external onlyOwner {
        baseURI = _customBaseURI;
    }
}

File 3 of 35 : NftfiBundler.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "./ERC998TopDown.sol";
import "./INftfiBundler.sol";
import "./IBundleBuilder.sol";
import "./IPermittedNFTs.sol";
import "./utils/Ownable.sol";
import "./airdrop/AirdropFlashLoan.sol";

import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/**
 * @title NftfiBundler
 * @author NFTfi
 * @dev ERC998 Top-Down Composable Non-Fungible Token that supports ERC721 children.
 */
contract NftfiBundler is ERC998TopDown, IBundleBuilder {
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableSet for EnumerableSet.AddressSet;
    using SafeERC20 for IERC20;
    using Strings for uint256;

    address public immutable permittedNfts;
    address public immutable airdropFlashLoan;

    string public baseURI;

    /**
     * @dev Stores name and symbol
     *
     * @param _admin - Initial admin of this contract.
     * @param _name name of the token contract
     * @param _symbol symbol of the token contract
     */
    constructor(
        address _admin,
        string memory _name,
        string memory _symbol,
        string memory _customBaseURI,
        address _permittedNfts,
        address _airdropFlashLoan
    ) ERC721(_name, _symbol) ERC998TopDown(_admin) {
        permittedNfts = _permittedNfts;
        airdropFlashLoan = _airdropFlashLoan;
        _setBaseURI(_customBaseURI);
    }

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

    /**
     * @notice Tells if an asset is permitted or not
     * @param _asset address of the asset
     * @return true if permitted, false otherwise
     */
    function permittedAsset(address _asset) public view returns (bool) {
        IPermittedNFTs permittedNFTs = IPermittedNFTs(permittedNfts);
        return permittedNFTs.getNFTPermit(_asset) > 0;
    }

    /**
     * @dev used to build a bundle from the BundleElements struct,
     * returns the id of the created bundle
     *
     * @param _bundleElements - the lists of erc721 tokens that are to be bundled
     */
    function buildBundle(BundleElementERC721[] memory _bundleElements) external override returns (uint256) {
        uint256 tokenId = safeMint(msg.sender);
        _addBundleElements(tokenId, _bundleElements);
        return tokenId;
    }

    /**
     * @dev Adds a set of BundleElementERC721 objects to the specified token ID.
     *
     * @param _tokenId The ID of the token to add the bundle elements to.
     * @param _bundleElements The array of BundleElementERC721 objects to add.
     */
    function addBundleElements(uint256 _tokenId, BundleElementERC721[] memory _bundleElements) external {
        _addBundleElements(_tokenId, _bundleElements);
    }

    /**
     * @dev Removes a set of BundleElementERC721 objects to the specified token ID.
     *
     * @param _tokenId The ID of the token to remove the bundle elements from.
     * @param _bundleElements The array of BundleElementERC721 objects to remove.
     */
    function removeBundleElements(uint256 _tokenId, BundleElementERC721[] memory _bundleElements) external {
        _removeBundleElements(_tokenId, _bundleElements);
    }

    /**
     * @dev Adds and removes a set of BundleElementERC721 objects from the specified token ID.
     *
     * @param _tokenId The ID of the token to add and remove the bundle elements from.
     * @param _toAdd The array of BundleElementERC721 objects to add.
     * @param _toRemove The array of BundleElementERC721 objects to remove.
     */
    function addAndRemoveBundleElements(
        uint256 _tokenId,
        BundleElementERC721[] memory _toAdd,
        BundleElementERC721[] memory _toRemove
    ) external {
        _addBundleElements(_tokenId, _toAdd);
        _removeBundleElements(_tokenId, _toRemove);
    }

    /**
     * @notice Remove all the children from the bundle
     * @dev This method may run out of gas if the list of children is too big. In that case, children can be removed
     *      individually.
     * @param _tokenId the id of the bundle
     * @param _receiver address of the receiver of the children
     */
    function decomposeBundle(uint256 _tokenId, address _receiver) external override {
        _validateReceiver(_receiver);
        _validateTransferSender(_tokenId);

        // In each iteration all contracts children are removed, so eventually all contracts are removed
        while (childContracts[_tokenId].length() > 0) {
            address childContract = childContracts[_tokenId].at(0);

            // In each iteration a child is removed, so eventually all contracts children are removed
            while (childTokens[_tokenId][childContract].length() > 0) {
                uint256 childId = childTokens[_tokenId][childContract].at(0);

                _removeChild(_tokenId, childContract, childId);

                try IERC721(childContract).safeTransferFrom(address(this), _receiver, childId) {
                    // solhint-disable-previous-line no-empty-blocks
                } catch {
                    _oldNFTsTransfer(_receiver, childContract, childId);
                }
                emit TransferChild(_tokenId, _receiver, childContract, childId);
            }
        }
    }

    /**
     * @notice Remove all the children from the bundle and send to personla bundler.
     * If bundle contains a legacy ERC721 element, this will not work.
     * @dev This method may run out of gas if the list of children is too big. In that case, children can be removed
     *      individually.
     * @param _tokenId the id of the bundle
     * @param _personalBundler address of the receiver of the children
     */
    function sendElementsToPersonalBundler(uint256 _tokenId, address _personalBundler) external virtual {
        _validateReceiver(_personalBundler);
        _validateTransferSender(_tokenId);
        require(_personalBundler != address(this), "cannot send to self");
        require(
            IERC165(_personalBundler).supportsInterface(type(IERC998ERC721TopDown).interfaceId),
            "has to implement IERC998ERC721TopDown"
        );
        uint256 personalBundleId = 1;
        //make sure sendeer owns personal bundler token
        require(IERC721(_personalBundler).ownerOf(personalBundleId) == msg.sender, "has to own personal bundle token");

        // In each iteration all contracts children are removed, so eventually all contracts are removed
        while (childContracts[_tokenId].length() > 0) {
            address childContract = childContracts[_tokenId].at(0);

            // In each iteration a child is removed, so eventually all contracts children are removed
            while (childTokens[_tokenId][childContract].length() > 0) {
                uint256 childId = childTokens[_tokenId][childContract].at(0);

                _removeChild(_tokenId, childContract, childId);

                try
                    IERC721(childContract).safeTransferFrom(
                        address(this),
                        _personalBundler,
                        childId,
                        abi.encodePacked(personalBundleId)
                    )
                {
                    // solhint-disable-previous-line no-empty-blocks
                } catch {
                    revert("only safe transfer");
                }
                emit TransferChild(_tokenId, _personalBundler, childContract, childId);
            }
        }
    }

    /**
     * @dev Internal function to add a set of BundleElementERC721 objects to the specified token ID.
     *
     * @param _tokenId The ID of the token to add the bundle elements to.
     * @param _bundleElements The array of BundleElementERC721 objects to add.
     */
    function _addBundleElements(uint256 _tokenId, BundleElementERC721[] memory _bundleElements) internal {
        require(_bundleElements.length > 0, "bundle is empty");
        uint256 elementNumber = _bundleElements.length;
        for (uint256 i; i != elementNumber; ++i) {
            require(permittedAsset(_bundleElements[i].tokenContract), "erc721 not permitted");
            if (_bundleElements[i].safeTransferable) {
                uint256 nuberOfIds = _bundleElements[i].ids.length;
                for (uint256 j; j != nuberOfIds; ++j) {
                    IERC721(_bundleElements[i].tokenContract).safeTransferFrom(
                        msg.sender,
                        address(this),
                        _bundleElements[i].ids[j],
                        abi.encodePacked(_tokenId)
                    );
                }
            } else {
                uint256 nuberOfIds = _bundleElements[i].ids.length;
                for (uint256 j; j != nuberOfIds; ++j) {
                    getChild(msg.sender, _tokenId, _bundleElements[i].tokenContract, _bundleElements[i].ids[j]);
                }
            }
        }

        emit AddBundleElements(_tokenId, _bundleElements);
    }

    /**
     * @dev Internal function to remove a set of BundleElementERC721 objects to the specified token ID.
     *
     * @param _tokenId The ID of the token to remove the bundle elements from.
     * @param _bundleElements The array of BundleElementERC721 objects to remove.
     */
    function _removeBundleElements(uint256 _tokenId, BundleElementERC721[] memory _bundleElements) internal {
        require(_bundleElements.length > 0, "bundle is empty");
        uint256 elementNumber = _bundleElements.length;
        for (uint256 i; i != elementNumber; ++i) {
            address erc721Contract = _bundleElements[i].tokenContract;
            uint256 nuberOfIds = _bundleElements[i].ids.length;
            for (uint256 j; j != nuberOfIds; ++j) {
                uint256 childId = _bundleElements[i].ids[j];
                _validateChildTransfer(_tokenId, erc721Contract, childId);
                _removeChild(_tokenId, erc721Contract, childId);
                if (_bundleElements[i].safeTransferable) {
                    IERC721(erc721Contract).safeTransferFrom(address(this), msg.sender, childId);
                } else {
                    _oldNFTsTransfer(msg.sender, erc721Contract, childId);
                }
                emit TransferChild(_tokenId, msg.sender, erc721Contract, childId);
            }
        }

        emit RemoveBundleElements(_tokenId, _bundleElements);
    }

    /**
     * @dev Update the state to receive a ERC721 child
     * Overrides the implementation to check if the asset is permitted
     * @param _from The owner of the child token
     * @param _tokenId The token receiving the child
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The token that is being transferred to the parent
     */
    function _receiveChild(
        address _from,
        uint256 _tokenId,
        address _childContract,
        uint256 _childTokenId
    ) internal virtual override {
        require(permittedAsset(_childContract), "erc721 not permitted");
        super._receiveChild(_from, _tokenId, _childContract, _childTokenId);
    }

    /**
     * @dev Override validation if it is a transfer from the airdropFlashLoan contract giving back the flashloan.
     * Validates the data from a child transfer and receives it otherwise
     * @param _from The owner of the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The token that is being transferred to the parent
     * @param _data Up to the first 32 bytes contains an integer which is the receiving parent tokenId
     */
    function _validateAndReceiveChild(
        address _from,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) internal virtual override {
        if (_from == airdropFlashLoan) {
            return;
        } else {
            super._validateAndReceiveChild(_from, _childContract, _childTokenId, _data);
        }
    }

    /**
     * @notice this function initiates a flashloan to pull an airdrop from a tartget contract
     *
     * @param _nftContract - contract address of the target nft of the drop
     * @param _nftId - id of the target nft of the drop
     * @param _target - address of the airdropping contract
     * @param _data - function selector to be called on the airdropping contract
     * @param _nftAirdrop - address of the used claiming nft in the drop
     * @param _nftAirdropId - id of the used claiming nft in the drop
     * @param _is1155 -
     * @param _nftAirdropAmount - amount in case of 1155
     */
    function pullAirdrop(
        address _nftContract,
        uint256 _nftId,
        address _target,
        bytes calldata _data,
        address _nftAirdrop,
        uint256 _nftAirdropId,
        bool _is1155,
        uint256 _nftAirdropAmount,
        address _beneficiary
    ) external {
        uint256 tokenId = childTokenOwner[_nftContract][_nftId];
        address rootOwner = address(uint160(uint256(rootOwnerOf(tokenId))));
        require(rootOwner == msg.sender, "pullAirdrop msg.sender not eligible");

        IERC721(_nftContract).safeTransferFrom(address(this), airdropFlashLoan, _nftId);

        AirdropFlashLoan(airdropFlashLoan).pullAirdrop(
            _nftContract,
            _nftId,
            _target,
            _data,
            _nftAirdrop,
            _nftAirdropId,
            _is1155,
            _nftAirdropAmount,
            _beneficiary
        );

        //take back collateral
        IERC721(_nftContract).safeTransferFrom(airdropFlashLoan, address(this), _nftId);
    }

    /**
     * @notice used by the owner account to be able to drain ERC721 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _tokenId - id token to be sent out
     * @param _receiver - receiver of the token
     */
    function rescueERC721(
        address _tokenAddress,
        uint256 _tokenId,
        address _receiver
    ) external onlyOwner {
        IERC721 tokenContract = IERC721(_tokenAddress);
        require(childTokenOwner[_tokenAddress][_tokenId] == 0, "token is in bundle");
        require(tokenContract.ownerOf(_tokenId) == address(this), "nft not owned");
        tokenContract.safeTransferFrom(address(this), _receiver, _tokenId);
    }

    /**
     * @notice used by the owner account to be able to drain ERC20 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _receiver - receiver of the token
     */
    function rescueERC20(address _tokenAddress, address _receiver) external onlyOwner {
        IERC20 tokenContract = IERC20(_tokenAddress);
        uint256 amount = tokenContract.balanceOf(address(this));
        require(amount > 0, "no tokens owned");
        tokenContract.safeTransfer(_receiver, amount);
    }

    /**
     * @dev Sets baseURI.
     * @param _customBaseURI - Base URI
     */
    function setBaseURI(string memory _customBaseURI) external onlyOwner {
        _setBaseURI(_customBaseURI);
    }

    /**
     * @dev Sets baseURI.
     */
    function _setBaseURI(string memory _customBaseURI) internal virtual {
        baseURI = bytes(_customBaseURI).length > 0
            ? string(abi.encodePacked(_customBaseURI, _getChainID().toString(), "/"))
            : "";
    }

    /** @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`.
     */
    function _baseURI() internal view virtual override returns (string memory) {
        return baseURI;
    }

    /**
     * @dev This function gets the current chain ID.
     */
    function _getChainID() internal view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }
}

File 4 of 35 : Ownable.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.17;

import "@openzeppelin/contracts/utils/Context.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.
 *
 * Modified version from openzeppelin/contracts/access/Ownable.sol that allows to
 * initialize the owner using a parameter in the constructor
 */
abstract contract Ownable is Context {
    address private _owner;

    address private _ownerCandidate;

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

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

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

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

    function acceptTransferOwnership() public virtual {
        require(_ownerCandidate == _msgSender(), "Ownable: not owner candidate");
        _setOwner(_ownerCandidate);
        delete _ownerCandidate;
    }

    function cancelTransferOwnership() public virtual onlyOwner {
        delete _ownerCandidate;
    }

    function rejectTransferOwnership() public virtual {
        require(_ownerCandidate == _msgSender(), "Ownable: not owner candidate");
        delete _ownerCandidate;
    }

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

    /**
     * @dev Sets the owner.
     */
    function _setOwner(address _newOwner) internal {
        address oldOwner = _owner;
        _owner = _newOwner;
        emit OwnershipTransferred(oldOwner, _newOwner);
    }
}

File 5 of 35 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 35 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 7 of 35 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 35 : Pausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

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

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

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

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

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

File 9 of 35 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

File 10 of 35 : Clones.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

File 11 of 35 : PersonalBundler.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";

import "./NftfiBundler.sol";

/**
 * @title PersonalBundler
 * @author NFTfi
 * @dev ERC998 Top-Down Composable Non-Fungible Token that supports ERC721 children.
 */
contract PersonalBundler is NftfiBundler, Initializable, IERC1155Receiver {
    using SafeERC20 for IERC20;

    uint8 public constant bundleId = 1;
    address public lastBundleOwner;

    event Initialized(address owner);

    /**
     * @dev only runs when the master copy is deplyoed, when cloned then initializer is ran
     * @param _admin admin address capable of setting URI-s and pausing
     * @param _permittedNfts permitted nft-s contract of the loan system
     * @param _airdropFlashLoan airdrop flashloan contract deplyoed alongside
     */
    constructor(
        address _admin,
        address _permittedNfts,
        address _airdropFlashLoan
    ) NftfiBundler(_admin, "", "", "", _permittedNfts, _airdropFlashLoan) {
        //original implementation rendering it unusable
        safeMint(_admin);
    }

    /** @dev function enforcing that the caller is the bundle token owner */
    function onlyBundleOwner() internal view {
        require(ownerOf(bundleId) == msg.sender, "Only bundle owner");
    }

    /**
     * @dev sets up initial parameters after cloning
     *
     * @param _admin admin address capable of setting URI-s and pausing
     * @param _owner of the personal bundler
     * @param _customBaseURI - Base URI
     */
    function initialize(
        address _admin,
        address _owner,
        string memory _customBaseURI
    ) external initializer nonReentrant {
        _setOwner(_admin);
        _setBaseURI(_customBaseURI);
        safeMint(_owner);
        emit Initialized(_owner);
    }

    /**
     * @dev See {IERC721Metadata-name}.
     * have to override, because cloning doesn't work for it
     */
    function name() public view virtual override returns (string memory) {
        return "NFTFi Personal Bundle";
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     * have to override, because cloning doesn't work for it
     */
    function symbol() public view virtual override returns (string memory) {
        return "PBNFI";
    }

    function safeMint(address _to) public override returns (uint256) {
        require(lastBundleOwner == address(0) || lastBundleOwner == msg.sender, "only last bundle owner");
        require(tokenCount == 0, "only 1 bundle");

        return super.safeMint(_to);
    }

    function burn() public {
        onlyBundleOwner();
        lastBundleOwner = msg.sender;
        require(totalChildContracts(bundleId) == 0, "bundle has to be empty");
        tokenCount -= 1;
        _burn(bundleId);
    }

    /**
     * @notice disabled here
     */
    function sendElementsToPersonalBundler(uint256, address) external virtual override {
        revert("already personal bundler");
    }

    /**
     * @dev Validates the data from a child transfer and receives it
     * @param _from The owner of the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The token that is being transferred to the parent
     * @param _data Up to the first 32 bytes contains an integer which is the receiving parent tokenId
     */
    function _validateAndReceiveChild(
        address _from,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) internal virtual override {
        //CHECK DISABLED require(_data.length > 0, "data must contain tokenId to transfer the child token to");
        // if no data: airdrop
        if (_data.length > 0) {
            // convert up to 32 bytes of _data to uint256, owner nft tokenId passed as uint in bytes
            uint256 tokenId = _parseTokenId(_data);
            // 1 is the only existing valid token id, so all other data is an airdrop
            if (tokenId == bundleId) {
                _receiveChild(_from, tokenId, _childContract, _childTokenId);
            }
        }
    }

    /**
     * @notice used by the owner account to be able to drain ERC721 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _tokenId - id token to be sent out
     * @param _receiver - receiver of the token
     */
    function drainERC721Airdrop(
        address _tokenAddress,
        uint256 _tokenId,
        address _receiver
    ) external {
        onlyBundleOwner();
        IERC721 tokenContract = IERC721(_tokenAddress);
        require(childTokenOwner[_tokenAddress][_tokenId] == 0, "token is in bundle");
        require(tokenContract.ownerOf(_tokenId) == address(this), "nft not owned");
        tokenContract.safeTransferFrom(address(this), _receiver, _tokenId);
    }

    /**
     * @notice used by the owner account to be able to drain ERC1155 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _tokenId - id token to be sent out
     * @param _receiver - receiver of the token
     */
    function drainERC1155Airdrop(
        address _tokenAddress,
        uint256 _tokenId,
        address _receiver
    ) external {
        onlyBundleOwner();
        IERC1155 tokenContract = IERC1155(_tokenAddress);
        uint256 amount = tokenContract.balanceOf(address(this), _tokenId);
        require(amount > 0, "no nfts owned");
        tokenContract.safeTransferFrom(address(this), _receiver, _tokenId, amount, "");
    }

    /**
     * @notice used by the owner account to be able to drain ERC20 tokens received as airdrops
     * for the locked  collateral NFT-s
     * @param _tokenAddress - address of the token contract for the token to be sent out
     * @param _receiver - receiver of the token
     */
    function drainERC20Airdrop(address _tokenAddress, address _receiver) external {
        onlyBundleOwner();
        IERC20 tokenContract = IERC20(_tokenAddress);
        uint256 amount = tokenContract.balanceOf(address(this));
        require(amount > 0, "no tokens owned");
        tokenContract.safeTransfer(_receiver, amount);
    }

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

    /**
     *  @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.
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if allowed
     */
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes calldata
    ) external virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    /**
     *  @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.
     *  @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if allowed
     */
    function onERC1155BatchReceived(
        address,
        address,
        uint256[] calldata,
        uint256[] calldata,
        bytes calldata
    ) external virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 12 of 35 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 13 of 35 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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.
 */
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() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 14 of 35 : 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 15 of 35 : 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 16 of 35 : ERC998TopDown.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "./utils/Ownable.sol";
import "./IERC998ERC721TopDown.sol";
import "./IERC998ERC721TopDownEnumerable.sol";

/**
 * @title ERC998TopDown
 * @author NFTfi
 * @dev ERC998ERC721 Top-Down Composable Non-Fungible Token.
 * See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-998.md
 * This implementation does not support children to be nested bundles, erc20 nor bottom-up
 */
abstract contract ERC998TopDown is
    ERC721Enumerable,
    IERC998ERC721TopDown,
    IERC998ERC721TopDownEnumerable,
    ReentrancyGuard,
    Ownable,
    Pausable
{
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableSet for EnumerableSet.AddressSet;

    // return this.rootOwnerOf.selector ^ this.rootOwnerOfChild.selector ^
    //   this.tokenOwnerOf.selector ^ this.ownerOfChild.selector;
    bytes32 public constant ERC998_MAGIC_VALUE = 0xcd740db500000000000000000000000000000000000000000000000000000000;
    bytes32 internal constant ERC998_MAGIC_MASK = 0xffffffff00000000000000000000000000000000000000000000000000000000;

    uint256 public tokenCount = 0;

    // tokenId => child contract
    mapping(uint256 => EnumerableSet.AddressSet) internal childContracts;

    // tokenId => (child address => array of child tokens)
    mapping(uint256 => mapping(address => EnumerableSet.UintSet)) internal childTokens;

    // child address => childId => tokenId
    // this is used for ERC721 type tokens
    mapping(address => mapping(uint256 => uint256)) internal childTokenOwner;

    /**
     * @dev Stores the admin
     *
     * @param _admin address capable of pausing
     */
    constructor(address _admin) Ownable(_admin) {
        // solhint-disable-previous-line no-empty-blocks
    }

    /**
     * @notice Tells whether the ERC721 type child exists or not
     * @param _childContract The contract address of the child token
     * @param _childTokenId The tokenId of the child
     * @return True if the child exists, false otherwise
     */
    function childExists(address _childContract, uint256 _childTokenId) external view virtual returns (bool) {
        uint256 tokenId = childTokenOwner[_childContract][_childTokenId];
        return tokenId != 0;
    }

    /**
     * @notice Get the total number of child contracts with tokens that are owned by _tokenId
     * @param _tokenId The parent token of child tokens in child contracts
     * @return uint256 The total number of child contracts with tokens owned by _tokenId
     */
    function totalChildContracts(uint256 _tokenId) public view virtual override returns (uint256) {
        return childContracts[_tokenId].length();
    }

    /**
     * @notice Get child contract by tokenId and index
     * @param _tokenId The parent token of child tokens in child contract
     * @param _index The index position of the child contract
     * @return childContract The contract found at the _tokenId and index
     */
    function childContractByIndex(uint256 _tokenId, uint256 _index)
        external
        view
        virtual
        override
        returns (address childContract)
    {
        return childContracts[_tokenId].at(_index);
    }

    /**
     * @notice Get the total number of child tokens owned by tokenId that exist in a child contract
     * @param _tokenId The parent token of child tokens
     * @param _childContract The child contract containing the child tokens
     * @return uint256 The total number of child tokens found in child contract that are owned by _tokenId
     */
    function totalChildTokens(uint256 _tokenId, address _childContract) external view override returns (uint256) {
        return childTokens[_tokenId][_childContract].length();
    }

    /**
     * @notice Get child token owned by _tokenId, in child contract, at index position
     * @param _tokenId The parent token of the child token
     * @param _childContract The child contract of the child token
     * @param _index The index position of the child token
     * @return childTokenId The child tokenId for the parent token, child token and index
     */
    function childTokenByIndex(
        uint256 _tokenId,
        address _childContract,
        uint256 _index
    ) external view virtual override returns (uint256 childTokenId) {
        return childTokens[_tokenId][_childContract].at(_index);
    }

    /**
     * @notice Get the parent tokenId and its owner of a ERC721 child token
     * @param _childContract The contract address of the child token
     * @param _childTokenId The tokenId of the child
     * @return parentTokenOwner The parent address of the parent token and ERC998 magic value
     * @return parentTokenId The parent tokenId of _childTokenId
     */
    function ownerOfChild(address _childContract, uint256 _childTokenId)
        external
        view
        virtual
        override
        returns (bytes32 parentTokenOwner, uint256 parentTokenId)
    {
        parentTokenId = childTokenOwner[_childContract][_childTokenId];
        require(parentTokenId != 0, "child token does not exist");
        address parentTokenOwnerAddress = ownerOf(parentTokenId);
        // solhint-disable-next-line no-inline-assembly
        assembly {
            parentTokenOwner := or(ERC998_MAGIC_VALUE, parentTokenOwnerAddress)
        }
    }

    /**
     * @notice Get the root owner of tokenId
     * @param _tokenId The token to query for a root owner address
     * @return rootOwner The root owner at the top of tree of tokens and ERC998 magic value.
     */
    function rootOwnerOf(uint256 _tokenId) public view virtual override returns (bytes32 rootOwner) {
        return rootOwnerOfChild(address(0), _tokenId);
    }

    /**
     * @notice Get the root owner of a child token
     * @dev Returns the owner at the top of the tree of composables
     * Use Cases handled:
     * - Case 1: Token owner is this contract and token.
     * - Case 2: Token owner is other external top-down composable
     * - Case 3: Token owner is other contract
     * - Case 4: Token owner is user
     * @param _childContract The contract address of the child token
     * @param _childTokenId The tokenId of the child
     * @return rootOwner The root owner at the top of tree of tokens and ERC998 magic value
     */
    function rootOwnerOfChild(address _childContract, uint256 _childTokenId)
        public
        view
        virtual
        override
        returns (bytes32 rootOwner)
    {
        address rootOwnerAddress;
        if (_childContract != address(0)) {
            (rootOwnerAddress, _childTokenId) = _ownerOfChild(_childContract, _childTokenId);
        } else {
            rootOwnerAddress = ownerOf(_childTokenId);
        }

        if (rootOwnerAddress.isContract()) {
            try IERC998ERC721TopDown(rootOwnerAddress).rootOwnerOfChild(address(this), _childTokenId) returns (
                bytes32 returnedRootOwner
            ) {
                // Case 2: Token owner is other external top-down composable
                if (returnedRootOwner & ERC998_MAGIC_MASK == ERC998_MAGIC_VALUE) {
                    return returnedRootOwner;
                }
            } catch {
                // solhint-disable-previous-line no-empty-blocks
            }
        }

        // Case 3: Token owner is other contract
        // Or
        // Case 4: Token owner is user
        // solhint-disable-next-line no-inline-assembly
        assembly {
            rootOwner := or(ERC998_MAGIC_VALUE, rootOwnerAddress)
        }
        return rootOwner;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     * The interface id 0x1efdf36a is added. The spec claims it to be the interface id of IERC998ERC721TopDown.
     * But it is not.
     * It is added anyway in case some contract checks it being compliant with the spec.
     */
    function supportsInterface(bytes4 _interfaceId) public view virtual override(ERC721Enumerable) returns (bool) {
        return
            _interfaceId == type(IERC998ERC721TopDown).interfaceId ||
            _interfaceId == type(IERC998ERC721TopDownEnumerable).interfaceId ||
            _interfaceId == 0x1efdf36a ||
            super.supportsInterface(_interfaceId);
    }

    /**
     * @notice Mints a new bundle
     * @param _to The address that owns the new bundle
     * @return The id of the new bundle
     */
    function safeMint(address _to) public virtual whenNotPaused returns (uint256) {
        uint256 id = ++tokenCount;
        _safeMint(_to, id);

        return id;
    }

    /**
     * @notice Transfer child token from top-down composable to address
     * @param _fromTokenId The owning token to transfer from
     * @param _to The address that receives the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     */
    function safeTransferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) external virtual override nonReentrant {
        _transferChild(_fromTokenId, _to, _childContract, _childTokenId);
        IERC721(_childContract).safeTransferFrom(address(this), _to, _childTokenId);
        emit TransferChild(_fromTokenId, _to, _childContract, _childTokenId);
    }

    /**
     * @notice Transfer child token from top-down composable to address or other top-down composable
     * @param _fromTokenId The owning token to transfer from
     * @param _to The address that receives the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     * @param _data Additional data with no specified format
     */
    function safeTransferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) external virtual override nonReentrant {
        _transferChild(_fromTokenId, _to, _childContract, _childTokenId);
        if (_to == address(this)) {
            _validateAndReceiveChild(msg.sender, _childContract, _childTokenId, _data);
        } else {
            IERC721(_childContract).safeTransferFrom(address(this), _to, _childTokenId, _data);
            emit TransferChild(_fromTokenId, _to, _childContract, _childTokenId);
        }
    }

    /**
     * @dev Transfer child token from top-down composable to address
     * @param _fromTokenId The owning token to transfer from
     * @param _to The address that receives the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     */
    function transferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) external virtual override nonReentrant {
        _transferChild(_fromTokenId, _to, _childContract, _childTokenId);
        _oldNFTsTransfer(_to, _childContract, _childTokenId);
        emit TransferChild(_fromTokenId, _to, _childContract, _childTokenId);
    }

    /**
     * @notice NOT SUPPORTED
     * Intended to transfer bottom-up composable child token from top-down composable to other ERC721 token.
     */
    function transferChildToParent(
        uint256,
        address,
        uint256,
        address,
        uint256,
        bytes memory
    ) external virtual override {
        revert("BOTTOM_UP_CHILD_NOT_SUPPORTED");
    }

    /**
     * @notice Transfer a child token from an ERC721 contract to a composable. Used for old tokens that does not
     * have a safeTransferFrom method like cryptokitties
     * @dev This contract has to be approved first in _childContract
     * @param _from The address that owns the child token.
     * @param _tokenId The token that becomes the parent owner
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the child token
     */
    function getChild(
        address _from,
        uint256 _tokenId,
        address _childContract,
        uint256 _childTokenId
    ) public virtual override whenNotPaused nonReentrant {
        require(_from == msg.sender, "_from should be msg.sender");
        _receiveChild(_from, _tokenId, _childContract, _childTokenId);
        IERC721(_childContract).transferFrom(_from, address(this), _childTokenId);
    }

    /**
     * @notice A token receives a child token
     * param The address that caused the transfer
     * @param _from The owner of the child token
     * @param _childTokenId The token that is being transferred to the parent
     * @param _data Up to the first 32 bytes contains an integer which is the receiving parent tokenId
     * @return the selector of this method
     */
    function onERC721Received(
        address,
        address _from,
        uint256 _childTokenId,
        bytes calldata _data
    ) external virtual override whenNotPaused nonReentrant returns (bytes4) {
        _validateAndReceiveChild(_from, msg.sender, _childTokenId, _data);
        return this.onERC721Received.selector;
    }

    /**
     * @dev ERC721 implementation hook that is called before any token transfer. Prevents nested bundles
     * @param _from address of the current owner of the token
     * @param _to destination address
     * @param _tokenId id of the token to transfer
     */
    function _beforeTokenTransfer(
        address _from,
        address _to,
        uint256 _tokenId
    ) internal virtual override {
        require(_to != address(this), "nested bundles not allowed");
        super._beforeTokenTransfer(_from, _to, _tokenId);
    }

    /**
     * @dev Validates the child transfer parameters and remove the child from the bundle
     * @param _fromTokenId The owning token to transfer from
     * @param _to The address that receives the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     */
    function _transferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) internal virtual {
        _validateReceiver(_to);
        _validateChildTransfer(_fromTokenId, _childContract, _childTokenId);
        _removeChild(_fromTokenId, _childContract, _childTokenId);
    }

    /**
     * @dev Validates the child transfer parameters
     * @param _fromTokenId The owning token to transfer from
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     */
    function _validateChildTransfer(
        uint256 _fromTokenId,
        address _childContract,
        uint256 _childTokenId
    ) internal virtual {
        uint256 tokenId = childTokenOwner[_childContract][_childTokenId];
        require(tokenId != 0, "_transferChild _childContract _childTokenId not found");
        require(tokenId == _fromTokenId, "ComposableTopDown: _transferChild wrong tokenId found");
        _validateTransferSender(tokenId);
    }

    /**
     * @dev Validates the receiver of a child transfer
     * @param _to The address that receives the child token
     */
    function _validateReceiver(address _to) internal virtual {
        require(_to != address(0), "child transfer to zero address");
    }

    /**
     * @dev Updates the state to remove a child
     * @param _tokenId The owning token to transfer from
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The tokenId of the token that is being transferred
     */
    function _removeChild(
        uint256 _tokenId,
        address _childContract,
        uint256 _childTokenId
    ) internal virtual {
        // remove child token
        childTokens[_tokenId][_childContract].remove(_childTokenId);
        delete childTokenOwner[_childContract][_childTokenId];

        // remove contract
        if (childTokens[_tokenId][_childContract].length() == 0) {
            childContracts[_tokenId].remove(_childContract);
        }
    }

    /**
     * @dev Validates the data from a child transfer and receives it
     * @param _from The owner of the child token
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The token that is being transferred to the parent
     * @param _data Up to the first 32 bytes contains an integer which is the receiving parent tokenId
     */
    function _validateAndReceiveChild(
        address _from,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) internal virtual {
        require(_data.length > 0, "data must contain tokenId to transfer the child token to");
        // convert up to 32 bytes of _data to uint256, owner nft tokenId passed as uint in bytes
        uint256 tokenId = _parseTokenId(_data);
        _receiveChild(_from, tokenId, _childContract, _childTokenId);
    }

    /**
     * @dev Update the state to receive a child
     * @param _from The owner of the child token
     * @param _tokenId The token receiving the child
     * @param _childContract The ERC721 contract of the child token
     * @param _childTokenId The token that is being transferred to the parent
     */
    function _receiveChild(
        address _from,
        uint256 _tokenId,
        address _childContract,
        uint256 _childTokenId
    ) internal virtual {
        require(_exists(_tokenId), "bundle tokenId does not exist");
        uint256 childTokensLength = childTokens[_tokenId][_childContract].length();
        if (childTokensLength == 0) {
            childContracts[_tokenId].add(_childContract);
        }
        childTokens[_tokenId][_childContract].add(_childTokenId);
        childTokenOwner[_childContract][_childTokenId] = _tokenId;
        emit ReceivedChild(_from, _tokenId, _childContract, _childTokenId);
    }

    /**
     * @dev Returns the owner of a child
     * @param _childContract The contract address of the child token
     * @param _childTokenId The tokenId of the child
     * @return parentTokenOwner The parent address of the parent token and ERC998 magic value
     * @return parentTokenId The parent tokenId of _childTokenId
     */
    function _ownerOfChild(address _childContract, uint256 _childTokenId)
        internal
        view
        virtual
        returns (address parentTokenOwner, uint256 parentTokenId)
    {
        parentTokenId = childTokenOwner[_childContract][_childTokenId];
        require(parentTokenId != 0, "child token does not exist");
        return (ownerOf(parentTokenId), parentTokenId);
    }

    /**
     * @dev Convert up to 32 bytes of_data to uint256, owner nft tokenId passed as uint in bytes
     * @param _data Up to the first 32 bytes contains an integer which is the receiving parent tokenId
     * @return tokenId the token Id encoded in the data
     */
    function _parseTokenId(bytes memory _data) internal pure virtual returns (uint256 tokenId) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            tokenId := mload(add(_data, 0x20))
        }
    }

    /**
     * @dev Transfers the NFT using method compatible with old token contracts
     * @param _to address of the receiver of the children
     * @param _childContract The contract address of the child token
     * @param _childTokenId The tokenId of the child
     */
    function _oldNFTsTransfer(
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) internal {
        // This is here to be compatible with cryptokitties and other old contracts that require being owner and
        // approved before transferring.
        // Does not work with current standard which does not allow approving self, so we must let it fail in that case.
        try IERC721(_childContract).approve(address(this), _childTokenId) {
            // solhint-disable-previous-line no-empty-blocks
        } catch {
            // solhint-disable-previous-line no-empty-blocks
        }

        IERC721(_childContract).transferFrom(address(this), _to, _childTokenId);
    }

    /**
     * @notice Validates that the sender is authorized to perform a child transfer
     * @param _fromTokenId The owning token to transfer from
     */
    function _validateTransferSender(uint256 _fromTokenId) internal virtual {
        address rootOwner = address(uint160(uint256(rootOwnerOf(_fromTokenId))));
        require(
            rootOwner == msg.sender ||
                getApproved(_fromTokenId) == msg.sender ||
                isApprovedForAll(rootOwner, msg.sender),
            "transferChild msg.sender not eligible"
        );
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - Only the owner can call this method.
     * - The contract must not be paused.
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - Only the owner can call this method.
     * - The contract must be paused.
     */
    function unpause() external onlyOwner {
        _unpause();
    }
}

File 17 of 35 : INftfiBundler.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface INftfiBundler is IERC721 {
    function safeMint(address _to) external returns (uint256);

    function decomposeBundle(uint256 _tokenId, address _receiver) external;
}

File 18 of 35 : IBundleBuilder.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.17;

interface IBundleBuilder {
    /**
     * @notice data of a erc721 bundle element
     *
     * @param tokenContract - address of the token contract
     * @param id - id of the token
     * @param safeTransferable - wether the implementing token contract has a safeTransfer function or not
     */
    struct BundleElementERC721 {
        address tokenContract;
        uint256[] ids;
        bool safeTransferable;
    }

    /**
     * @notice used to build a bundle from the BundleElements struct,
     * returns the id of the created bundle
     *
     * @param _bundleElements - the lists of erc721 tokens that are to be bundled
     */
    function buildBundle(BundleElementERC721[] memory _bundleElements) external returns (uint256);

    /**
     * @notice Remove all the children from the bundle
     * @dev This method may run out of gas if the list of children is too big. In that case, children can be removed
     *      individually or in smaller batches.
     * @param _tokenId the id of the bundle
     * @param _receiver address of the receiver of the children
     */
    function decomposeBundle(uint256 _tokenId, address _receiver) external;

    event AddBundleElements(uint256 indexed _tokenId, BundleElementERC721[] _bundleElements);
    event RemoveBundleElements(uint256 indexed _tokenId, BundleElementERC721[] _bundleElements);
}

File 19 of 35 : IPermittedNFTs.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.17;

interface IPermittedNFTs {
    function getNFTPermit(address _nftContract) external view returns (bytes32);
}

File 20 of 35 : AirdropFlashLoan.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

/**
 * @title AirdropFlashLoan
 * @author NFTfi
 * @dev
 */
contract AirdropFlashLoan is ERC721Holder, ERC1155Holder, ReentrancyGuard {
    using Address for address;
    using SafeERC20 for IERC20;

    /**
     * @notice this function initiates a flashloan to pull an airdrop from a tartget contract
     *
     * @param _nftContract - contract address of the target nft of the drop
     * @param _nftId - id of the target nft of the drop
     * @param _target - address of the airdropping contract
     * @param _data - function selector to be called on the airdropping contract
     * @param _nftAirdrop - address of the used claiming nft in the drop
     * @param _nftAirdropId - id of the used claiming nft in the drop
     * @param _is1155 -
     * @param _nftAirdropAmount - amount in case of 1155
     * @param _beneficiary - address receiving the drop
     */
    function pullAirdrop(
        address _nftContract,
        uint256 _nftId,
        address _target,
        bytes calldata _data,
        address _nftAirdrop,
        uint256 _nftAirdropId,
        bool _is1155,
        uint256 _nftAirdropAmount,
        address _beneficiary
    ) external nonReentrant {
        // assumes that the collateral nft has been transferreded to this contract before calling this function
        _target.functionCall(_data);

        // return the collateral
        IERC721(_nftContract).approve(msg.sender, _nftId);

        // in case that arbitray function from _target does not send the airdrop to a specified address
        if (_nftAirdrop != address(0) && _beneficiary != address(0)) {
            // send the airdrop to the beneficiary
            if (_is1155) {
                IERC1155(_nftAirdrop).safeTransferFrom(
                    address(this),
                    _beneficiary,
                    _nftAirdropId,
                    _nftAirdropAmount,
                    "0x"
                );
            } else {
                IERC721(_nftAirdrop).safeTransferFrom(address(this), _beneficiary, _nftAirdropId);
            }
        }
    }

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

File 21 of 35 : 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];
    }

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private 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 24 of 35 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make 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;
    }
}

File 25 of 35 : IERC998ERC721TopDown.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

interface IERC998ERC721TopDown {
    event ReceivedChild(
        address indexed _from,
        uint256 indexed _tokenId,
        address indexed _childContract,
        uint256 _childTokenId
    );
    event TransferChild(
        uint256 indexed tokenId,
        address indexed _to,
        address indexed _childContract,
        uint256 _childTokenId
    );

    function onERC721Received(
        address _operator,
        address _from,
        uint256 _childTokenId,
        bytes calldata _data
    ) external returns (bytes4);

    function transferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) external;

    function safeTransferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId
    ) external;

    function safeTransferChild(
        uint256 _fromTokenId,
        address _to,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) external;

    function transferChildToParent(
        uint256 _fromTokenId,
        address _toContract,
        uint256 _toTokenId,
        address _childContract,
        uint256 _childTokenId,
        bytes memory _data
    ) external;

    // getChild function enables older contracts like cryptokitties to be transferred into a composable
    // The _childContract must approve this contract. Then getChild can be called.
    function getChild(
        address _from,
        uint256 _tokenId,
        address _childContract,
        uint256 _childTokenId
    ) external;

    function rootOwnerOf(uint256 _tokenId) external view returns (bytes32 rootOwner);

    function rootOwnerOfChild(address _childContract, uint256 _childTokenId) external view returns (bytes32 rootOwner);

    function ownerOfChild(address _childContract, uint256 _childTokenId)
        external
        view
        returns (bytes32 parentTokenOwner, uint256 parentTokenId);
}

File 26 of 35 : IERC998ERC721TopDownEnumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

interface IERC998ERC721TopDownEnumerable {
    function totalChildContracts(uint256 _tokenId) external view returns (uint256);

    function childContractByIndex(uint256 _tokenId, uint256 _index) external view returns (address childContract);

    function totalChildTokens(uint256 _tokenId, address _childContract) external view returns (uint256);

    function childTokenByIndex(
        uint256 _tokenId,
        address _childContract,
        uint256 _index
    ) external view returns (uint256 childTokenId);
}

File 27 of 35 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(from, to, tokenId);
    }

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

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

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

File 28 of 35 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 30 of 35 : 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;
    }
}

File 31 of 35 : 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 32 of 35 : ERC721Holder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Receiver.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 ERC721Holder is IERC721Receiver {
    /**
     * @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;
    }
}

File 33 of 35 : 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 34 of 35 : 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 35 of 35 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_bundler","type":"address"},{"internalType":"address","name":"_personalBundlerFactory","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_customBaseURI","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"immutableId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"bundleId","type":"uint256"},{"indexed":true,"internalType":"address","name":"personalBundler","type":"address"}],"name":"ConvertedToPersonalBundler","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"immutableId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"bundleId","type":"uint256"},{"indexed":true,"internalType":"address","name":"personalBundler","type":"address"}],"name":"ImmutableMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"acceptTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"bundleOfImmutable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bundler","outputs":[{"internalType":"contract NftfiBundler","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_immutableId","type":"uint256"},{"internalType":"address","name":"_personalBundler","type":"address"}],"name":"convertToPersonalBundler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_immutableId","type":"uint256"}],"name":"createAndConvertToPersonalBundler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"immutableOfBundle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"immutableOfPersonalBundler","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"mintBundle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_bundleId","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"personalBundleId","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"personalBundlerFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"personalBundlerOfImmutable","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_immutableId","type":"uint256"},{"internalType":"address","name":"_nftContract","type":"address"},{"internalType":"uint256","name":"_nftId","type":"uint256"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_nftAirdrop","type":"address"},{"internalType":"uint256","name":"_nftAirdropId","type":"uint256"},{"internalType":"bool","name":"_is1155","type":"bool"},{"internalType":"uint256","name":"_nftAirdropAmount","type":"uint256"}],"name":"pullAirdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rejectTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwnerCandidate","type":"address"}],"name":"requestTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_customBaseURI","type":"string"}],"name":"setBaseURI","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":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_immutableId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_immutableId","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"withdrawAndDecompose","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040526000600c553480156200001657600080fd5b506040516200415b3803806200415b83398101604081905262000039916200036e565b85838360006200004a8382620004c6565b506001620000598282620004c6565b5050506200006d81620000a560201b60201c565b50600b805460ff60a01b191690556001600160a01b03808616608052841660a0526200009981620000f7565b5050505050506200068f565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081511162000117576040518060200160405280600081525062000151565b806200012e466200016460201b6200201a1760201c565b6040516020016200014192919062000592565b6040516020818303038152906040525b600d90620001609082620004c6565b5050565b6060816000036200018c5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115620001bc5780620001a381620005e7565b9150620001b49050600a8362000619565b915062000190565b6000816001600160401b03811115620001d957620001d9620002a1565b6040519080825280601f01601f19166020018201604052801562000204576020820181803683370190505b5090505b84156200027c576200021c60018362000630565b91506200022b600a866200064c565b6200023890603062000663565b60f81b81838151811062000250576200025062000679565b60200101906001600160f81b031916908160001a90535062000274600a8662000619565b945062000208565b949350505050565b80516001600160a01b03811681146200029c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620002d4578181015183820152602001620002ba565b50506000910152565b600082601f830112620002ef57600080fd5b81516001600160401b03808211156200030c576200030c620002a1565b604051601f8301601f19908116603f01168101908282118183101715620003375762000337620002a1565b816040528381528660208588010111156200035157600080fd5b62000364846020830160208901620002b7565b9695505050505050565b60008060008060008060c087890312156200038857600080fd5b620003938762000284565b9550620003a36020880162000284565b9450620003b36040880162000284565b60608801519094506001600160401b0380821115620003d157600080fd5b620003df8a838b01620002dd565b94506080890151915080821115620003f657600080fd5b620004048a838b01620002dd565b935060a08901519150808211156200041b57600080fd5b506200042a89828a01620002dd565b9150509295509295509295565b600181811c908216806200044c57607f821691505b6020821081036200046d57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620004c157600081815260208120601f850160051c810160208610156200049c5750805b601f850160051c820191505b81811015620004bd57828155600101620004a8565b5050505b505050565b81516001600160401b03811115620004e257620004e2620002a1565b620004fa81620004f3845462000437565b8462000473565b602080601f831160018114620005325760008415620005195750858301515b600019600386901b1c1916600185901b178555620004bd565b600085815260208120601f198616915b82811015620005635788860151825594840194600190910190840162000542565b5085821015620005825787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008351620005a6818460208801620002b7565b835190830190620005bc818360208801620002b7565b602f60f81b9101908152600101949350505050565b634e487b7160e01b600052601160045260246000fd5b600060018201620005fc57620005fc620005d1565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826200062b576200062b62000603565b500490565b81810381811115620006465762000646620005d1565b92915050565b6000826200065e576200065e62000603565b500690565b80820180821115620006465762000646620005d1565b634e487b7160e01b600052603260045260246000fd5b60805160a051613a4462000717600039600081816105b401528181610a4801528181610c9c015281816118810152611e600152600081816105470152818161069601528181610a0c01528181610b16015281816111bb01528181611299015281816114a001528181611526015281816116da01528181611a3b0152611dbf0152613a446000f3fe608060405234801561001057600080fd5b50600436106102675760003560e01c8063647bec33116101515780639a48b5eb116100c3578063b860fabb11610087578063b860fabb14610569578063b88d4fde14610589578063c87b56dd1461059c578063d90c739d146105af578063e985e9c5146105d6578063fa3e47051461061257600080fd5b80639a48b5eb146104ea5780639d6fa618146105135780639f181b5e14610526578063a22cb4651461052f578063ad0ffd8b1461054257600080fd5b80638456cb59116101155780638456cb591461049b5780638da5cb5b146104a35780638ee1f07a146104b457806392fede00146104c757806395d89b41146104cf5780639993b010146104d757600080fd5b8063647bec33146104525780636c0360eb1461046557806370a082311461046d5780637a82e93c146104805780637b3711071461049357600080fd5b80632f745c59116101ea578063542c4a13116101ae578063542c4a13146103e557806355f804b3146103ff5780635c975abb146104125780635d799f87146104245780635f992fdd146104375780636352211e1461043f57600080fd5b80632f745c59146103915780633f4ba83a146103a457806342842e0e146103ac57806349a931f2146103bf5780634f6ccce7146103d257600080fd5b8063095ea7b311610231578063095ea7b314610317578063098867441461032a578063150b7a021461034a57806318160ddd1461037657806323b872dd1461037e57600080fd5b8062296cd81461026c578062f714ce1461029f57806301ffc9a7146102b457806306fdde03146102d7578063081812fc146102ec575b600080fd5b61028c61027a3660046130ff565b60116020526000908152604090205481565b6040519081526020015b60405180910390f35b6102b26102ad36600461311c565b610625565b005b6102c76102c2366004613162565b610768565b6040519015158152602001610296565b6102df610793565b60405161029691906131cf565b6102ff6102fa3660046131e2565b610825565b6040516001600160a01b039091168152602001610296565b6102b26103253660046131fb565b6108bf565b61028c6103383660046131e2565b600f6020526000908152604090205481565b61035d6103583660046132b3565b6109d4565b6040516001600160e01b03199091168152602001610296565b60085461028c565b6102b261038c366004613333565b610b6e565b61028c61039f3660046131fb565b610b9f565b6102b2610c35565b6102b26103ba366004613333565b610c69565b6102b26103cd3660046131e2565b610c84565b61028c6103e03660046131e2565b610d21565b6103ed600181565b60405160ff9091168152602001610296565b6102b261040d366004613374565b610db4565b600b54600160a01b900460ff166102c7565b6102b26104323660046133bd565b610dea565b6102b2610ed9565b6102ff61044d3660046131e2565b610f45565b6102b2610460366004613404565b610fbc565b6102df611320565b61028c61047b3660046130ff565b6113ae565b6102b261048e36600461311c565b611435565b6102b26115f4565b6102b2611663565b600a546001600160a01b03166102ff565b61028c6104c23660046130ff565b611695565b6102b2611764565b6102df61178e565b6102b26104e536600461311c565b61179d565b6102ff6104f83660046131e2565b6010602052600090815260409020546001600160a01b031681565b6102b26105213660046130ff565b611b09565b61028c600c5481565b6102b261053d3660046134e5565b611bba565b6102ff7f000000000000000000000000000000000000000000000000000000000000000081565b61028c6105773660046131e2565b600e6020526000908152604090205481565b6102b26105973660046132b3565b611c7e565b6102df6105aa3660046131e2565b611cb0565b6102ff7f000000000000000000000000000000000000000000000000000000000000000081565b6102c76105e43660046133bd565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102b2610620366004613513565b611d8a565b61062f828261211b565b6000828152600e60209081526040808320546010909252909120546001600160a01b031661065c846121c7565b6001600160a01b0381166106f857604051632142170760e11b81523060048201526001600160a01b038481166024830152604482018490527f000000000000000000000000000000000000000000000000000000000000000016906342842e0e906064015b600060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b50505050610762565b604051632142170760e11b81523060048201526001600160a01b038481166024830152600160448301528216906342842e0e906064015b600060405180830381600087803b15801561074957600080fd5b505af115801561075d573d6000803e3d6000fd5b505050505b50505050565b60006001600160e01b03198216630a85bd0160e11b148061078d575061078d82612246565b92915050565b6060600080546107a290613555565b80601f01602080910402602001604051908101604052809291908181526020018280546107ce90613555565b801561081b5780601f106107f05761010080835404028352916020019161081b565b820191906000526020600020905b8154815290600101906020018083116107fe57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108a35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108ca82610f45565b9050806001600160a01b0316836001600160a01b0316036109375760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161089a565b336001600160a01b0382161480610953575061095381336105e4565b6109c55760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161089a565b6109cf838361226b565b505050565b600b54600090600160a01b900460ff1615610a015760405162461bcd60e51b815260040161089a9061358f565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610abb575060405163397140fd60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e5c503f490602401602060405180830381865afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb91906135b9565b610afb5760405162461bcd60e51b8152602060048201526011602482015270185cdcd95d081b9bdd08185b1b1bddd959607a1b604482015260640161089a565b6001600160a01b03841615610b5c5760006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163303610b4d57610b4685856122d9565b9050610b5a565b610b57853361234f565b90505b505b50630a85bd0160e11b5b949350505050565b610b7833826123df565b610b945760405162461bcd60e51b815260040161089a906135d6565b6109cf8383836124d2565b6000610baa836113ae565b8210610c0c5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161089a565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610c5f5760405162461bcd60e51b815260040161089a90613627565b610c6761267d565b565b6109cf83838360405180602001604052806000815250611c7e565b60405163464b8be160e11b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690638c9717c2906024016020604051808303816000875af1158015610ced573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d11919061365c565b9050610d1d828261179d565b5050565b6000610d2c60085490565b8210610d8f5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161089a565b60088281548110610da257610da2613679565b90600052602060002001549050919050565b600a546001600160a01b03163314610dde5760405162461bcd60e51b815260040161089a90613627565b610de78161271a565b50565b600a546001600160a01b03163314610e145760405162461bcd60e51b815260040161089a90613627565b6040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e81919061368f565b905060008111610ec55760405162461bcd60e51b815260206004820152600f60248201526e1b9bc81d1bdad95b9cc81bdddb9959608a1b604482015260640161089a565b6107626001600160a01b0383168483612770565b600b546001600160a01b03163314610f335760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161089a565b600b80546001600160a01b0319169055565b6000818152600260205260408120546001600160a01b03168061078d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161089a565b33610fc68b610f45565b6001600160a01b0316146110285760405162461bcd60e51b815260206004820152602360248201527f70756c6c41697264726f70206d73672e73656e646572206e6f7420656c696769604482015262626c6560e81b606482015260840161089a565b60008a8152601060205260409020546001600160a01b0316156111925760008a81526010602052604090819020549051635680a3ad60e01b81526001600160a01b038b81166004830152602482018b905290911690635680a3ad90604401602060405180830381865afa1580156110a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c791906135b9565b61110c5760405162461bcd60e51b81526020600482015260166024820152750d2dadaeae8c2c4d8ca5adccce840dad2e6dac2e8c6d60531b604482015260640161089a565b60008a81526010602052604090819020549051633f77844b60e11b81526001600160a01b0390911690637eef08969061115b908c908c908c908c908c908c908c908c908c9033906004016136a8565b600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b50505050611314565b604051631d5b701760e31b81526001600160a01b038a81166004830152602482018a90526000917f00000000000000000000000000000000000000000000000000000000000000009091169063eadb80b8906044016040805180830381865afa158015611203573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611227919061372a565b60008d8152600e6020526040902054909250821490506112825760405162461bcd60e51b81526020600482015260166024820152750d2dadaeae8c2c4d8ca5adccce840dad2e6dac2e8c6d60531b604482015260640161089a565b604051633f77844b60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637eef0896906112e0908d908d908d908d908d908d908d908d908d9033906004016136a8565b600060405180830381600087803b1580156112fa57600080fd5b505af115801561130e573d6000803e3d6000fd5b50505050505b50505050505050505050565b600d805461132d90613555565b80601f016020809104026020016040519081016040528092919081815260200182805461135990613555565b80156113a65780601f1061137b576101008083540402835291602001916113a6565b820191906000526020600020905b81548152906001019060200180831161138957829003601f168201915b505050505081565b60006001600160a01b0382166114195760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161089a565b506001600160a01b031660009081526003602052604090205490565b61143f828261211b565b6000828152600e60209081526040808320546010909252909120546001600160a01b031661146c846121c7565b6001600160a01b03811661155757604051636fba484360e11b8152600481018390526001600160a01b0384811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063df74908690604401600060405180830381600087803b1580156114e457600080fd5b505af11580156114f8573d6000803e3d6000fd5b5050604051632142170760e11b81523060048201526001600160a01b038681166024830152604482018690527f00000000000000000000000000000000000000000000000000000000000000001692506342842e0e91506064016106c1565b604051636fba484360e11b8152600160048201526001600160a01b03848116602483015282169063df74908690604401600060405180830381600087803b1580156115a157600080fd5b505af11580156115b5573d6000803e3d6000fd5b5050604051632142170760e11b81523060048201526001600160a01b03868116602483015260016044830152841692506342842e0e915060640161072f565b600b546001600160a01b0316331461164e5760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161089a565b600b54610f33906001600160a01b03166127c2565b600a546001600160a01b0316331461168d5760405162461bcd60e51b815260040161089a90613627565b610c67612814565b600b54600090600160a01b900460ff16156116c25760405162461bcd60e51b815260040161089a9061358f565b6040516340d097c360e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906340d097c3906024016020604051808303816000875af115801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f919061368f565b905061175b83826122d9565b9150505b919050565b600a546001600160a01b03163314610f335760405162461bcd60e51b815260040161089a90613627565b6060600180546107a290613555565b336117a783610f45565b6001600160a01b0316146117fd5760405162461bcd60e51b815260206004820152601760248201527f6d73672e73656e646572206e6f7420656c696769626c65000000000000000000604482015260640161089a565b6000828152601060205260409020546001600160a01b0316156118625760405162461bcd60e51b815260206004820152601860248201527f616c726561647920706572736f6e616c2062756e646c65720000000000000000604482015260640161089a565b60405163397140fd60e21b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e5c503f490602401602060405180830381865afa1580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec91906135b9565b61192f5760405162461bcd60e51b81526020600482015260146024820152733737ba103832b939b7b730b610313ab7323632b960611b604482015260640161089a565b6040516331a9108f60e11b81526001600482015230906001600160a01b03831690636352211e90602401602060405180830381865afa158015611976573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199a919061365c565b6001600160a01b0316146119f05760405162461bcd60e51b815260206004820152601d60248201527f6f776e65722068617320746f206265207468697320636f6e7472616374000000604482015260640161089a565b6000828152600e60209081526040808320805490849055808452600f909252808320929092559051638daf2d6160e01b8152600481018290526001600160a01b0383811660248301527f00000000000000000000000000000000000000000000000000000000000000001690638daf2d6190604401600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b50505050816001600160a01b031681847f52ac19043c7718796c5d11822f560e2526c7b5d6f6eea1066befb6d03e82a80560405160405180910390a450600082815260106020908152604080832080546001600160a01b039095166001600160a01b031990951685179055928252601190522055565b600a546001600160a01b03163314611b335760405162461bcd60e51b815260040161089a90613627565b6001600160a01b038116611b985760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161089a565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b03831603611c125760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161089a565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611c8833836123df565b611ca45760405162461bcd60e51b815260040161089a906135d6565b61076284848484612879565b6000818152600260205260409020546060906001600160a01b0316611d2f5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161089a565b6000611d396128ac565b90506000815111611d59576040518060200160405280600081525061175b565b80611d638461201a565b604051602001611d7492919061374e565b6040516020818303038152906040529392505050565b600a546001600160a01b03163314611db45760405162461bcd60e51b815260040161089a90613627565b826001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690821603611e41576000838152600f602052604090205415611e3c5760405162461bcd60e51b8152602060048201526015602482015274746f6b656e20697320696e20696d6d757461626c6560581b604482015260640161089a565b611f2e565b60405163397140fd60e21b81526001600160a01b0385811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063e5c503f490602401602060405180830381865afa158015611ea7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecb91906135b9565b15611f2e576001600160a01b03841660009081526011602052604090205415611f2e5760405162461bcd60e51b8152602060048201526015602482015274746f6b656e20697320696e20696d6d757461626c6560581b604482015260640161089a565b6040516331a9108f60e11b81526004810184905230906001600160a01b03831690636352211e90602401602060405180830381865afa158015611f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f99919061365c565b6001600160a01b031614611fdf5760405162461bcd60e51b815260206004820152600d60248201526c1b999d081b9bdd081bdddb9959609a1b604482015260640161089a565b604051632142170760e11b81523060048201526001600160a01b038381166024830152604482018590528216906342842e0e9060640161072f565b6060816000036120415750506040805180820190915260018152600360fc1b602082015290565b8160005b811561206b578061205581613793565b91506120649050600a836137c2565b9150612045565b60008167ffffffffffffffff81111561208657612086613227565b6040519080825280601f01601f1916602001820160405280156120b0576020820181803683370190505b5090505b8415610b66576120c56001836137d6565b91506120d2600a866137e9565b6120dd9060306137fd565b60f81b8183815181106120f2576120f2613679565b60200101906001600160f81b031916908160001a905350612114600a866137c2565b94506120b4565b3361212583610f45565b6001600160a01b0316146121715760405162461bcd60e51b815260206004820152601360248201527231b0b63632b91034b9903737ba1037bbb732b960691b604482015260640161089a565b6001600160a01b038116610d1d5760405162461bcd60e51b815260206004820152601860248201527f7472616e7366657220746f207a65726f20616464726573730000000000000000604482015260640161089a565b6121d0816128bb565b6000818152601060205260409020546001600160a01b03161561222357600090815260106020908152604080832080546001600160a01b031981169091556001600160a01b031683526011909152812055565b6000908152600e602090815260408083208054908490558352600f909152812055565b60006001600160e01b0319821663780e9d6360e01b148061078d575061078d82612962565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906122a082610f45565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080600c600081546122eb90613793565b918290555090506122fc84826129b2565b6000818152600e60209081526040808320869055858352600f90915280822083905551849083907f3d29d48d72f16f3d1e30b1064f89960da7256796039bcb7cf0e613029188922b908490a49392505050565b600080600c6000815461236190613793565b9182905550905061237284826129b2565b600081815260106020908152604080832080546001600160a01b0319166001600160a01b03881690811790915580845260119092528083208490555190919083907f3d29d48d72f16f3d1e30b1064f89960da7256796039bcb7cf0e613029188922b908390a49392505050565b6000818152600260205260408120546001600160a01b03166124585760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161089a565b600061246383610f45565b9050806001600160a01b0316846001600160a01b0316148061249e5750836001600160a01b031661249384610825565b6001600160a01b0316145b80610b6657506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16610b66565b826001600160a01b03166124e582610f45565b6001600160a01b03161461254d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161089a565b6001600160a01b0382166125af5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161089a565b6125ba8383836129cc565b6125c560008261226b565b6001600160a01b03831660009081526003602052604081208054600192906125ee9084906137d6565b90915550506001600160a01b038216600090815260036020526040812080546001929061261c9084906137fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600b54600160a01b900460ff166126cd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161089a565b600b805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008151116127385760405180602001604052806000815250612763565b806127424661201a565b604051602001612753929190613810565b6040516020818303038152906040525b600d90610d1d9082613899565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109cf908490612a84565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600b54600160a01b900460ff161561283e5760405162461bcd60e51b815260040161089a9061358f565b600b805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126fd3390565b6128848484846124d2565b61289084848484612b56565b6107625760405162461bcd60e51b815260040161089a90613959565b6060600d80546107a290613555565b60006128c682610f45565b90506128d4816000846129cc565b6128df60008361226b565b6001600160a01b03811660009081526003602052604081208054600192906129089084906137d6565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160e01b031982166380ac58cd60e01b148061299357506001600160e01b03198216635b5e139f60e01b145b8061078d57506301ffc9a760e01b6001600160e01b031983161461078d565b610d1d828260405180602001604052806000815250612c54565b6001600160a01b038316612a2757612a2281600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612a4a565b816001600160a01b0316836001600160a01b031614612a4a57612a4a8382612c87565b6001600160a01b038216612a61576109cf81612d24565b826001600160a01b0316826001600160a01b0316146109cf576109cf8282612dd3565b6000612ad9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e179092919063ffffffff16565b8051909150156109cf5780806020019051810190612af791906135b9565b6109cf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161089a565b60006001600160a01b0384163b15612c4c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612b9a9033908990889088906004016139ab565b6020604051808303816000875af1925050508015612bd5575060408051601f3d908101601f19168201909252612bd2918101906139e8565b60015b612c32573d808015612c03576040519150601f19603f3d011682016040523d82523d6000602084013e612c08565b606091505b508051600003612c2a5760405162461bcd60e51b815260040161089a90613959565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610b66565b506001610b66565b612c5e8383612e30565b612c6b6000848484612b56565b6109cf5760405162461bcd60e51b815260040161089a90613959565b60006001612c94846113ae565b612c9e91906137d6565b600083815260076020526040902054909150808214612cf1576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612d36906001906137d6565b60008381526009602052604081205460088054939450909284908110612d5e57612d5e613679565b906000526020600020015490508060088381548110612d7f57612d7f613679565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612db757612db7613a05565b6001900381819060005260206000200160009055905550505050565b6000612dde836113ae565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6060612e268484600085612f7e565b90505b9392505050565b6001600160a01b038216612e865760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161089a565b6000818152600260205260409020546001600160a01b031615612eeb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161089a565b612ef7600083836129cc565b6001600160a01b0382166000908152600360205260408120805460019290612f209084906137fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606082471015612fdf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161089a565b843b61302d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161089a565b600080866001600160a01b031685876040516130499190613a1b565b60006040518083038185875af1925050503d8060008114613086576040519150601f19603f3d011682016040523d82523d6000602084013e61308b565b606091505b509150915061309b8282866130a6565b979650505050505050565b606083156130b5575081612e29565b8251156130c55782518084602001fd5b8160405162461bcd60e51b815260040161089a91906131cf565b6001600160a01b0381168114610de757600080fd5b803561175f816130df565b60006020828403121561311157600080fd5b8135612e29816130df565b6000806040838503121561312f57600080fd5b823591506020830135613141816130df565b809150509250929050565b6001600160e01b031981168114610de757600080fd5b60006020828403121561317457600080fd5b8135612e298161314c565b60005b8381101561319a578181015183820152602001613182565b50506000910152565b600081518084526131bb81602086016020860161317f565b601f01601f19169290920160200192915050565b602081526000612e2960208301846131a3565b6000602082840312156131f457600080fd5b5035919050565b6000806040838503121561320e57600080fd5b8235613219816130df565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561325857613258613227565b604051601f8501601f19908116603f0116810190828211818310171561328057613280613227565b8160405280935085815286868601111561329957600080fd5b858560208301376000602087830101525050509392505050565b600080600080608085870312156132c957600080fd5b84356132d4816130df565b935060208501356132e4816130df565b925060408501359150606085013567ffffffffffffffff81111561330757600080fd5b8501601f8101871361331857600080fd5b6133278782356020840161323d565b91505092959194509250565b60008060006060848603121561334857600080fd5b8335613353816130df565b92506020840135613363816130df565b929592945050506040919091013590565b60006020828403121561338657600080fd5b813567ffffffffffffffff81111561339d57600080fd5b8201601f810184136133ae57600080fd5b610b668482356020840161323d565b600080604083850312156133d057600080fd5b82356133db816130df565b91506020830135613141816130df565b8015158114610de757600080fd5b803561175f816133eb565b6000806000806000806000806000806101208b8d03121561342457600080fd5b8a35995060208b0135613436816130df565b985060408b0135975060608b013561344d816130df565b965060808b013567ffffffffffffffff8082111561346a57600080fd5b818d0191508d601f83011261347e57600080fd5b81358181111561348d57600080fd5b8e602082850101111561349f57600080fd5b6020830198508097505050506134b760a08c016130f4565b935060c08b013592506134cc60e08c016133f9565b91506101008b013590509295989b9194979a5092959850565b600080604083850312156134f857600080fd5b8235613503816130df565b91506020830135613141816133eb565b60008060006060848603121561352857600080fd5b8335613533816130df565b925060208401359150604084013561354a816130df565b809150509250925092565b600181811c9082168061356957607f821691505b60208210810361358957634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6000602082840312156135cb57600080fd5b8151612e29816133eb565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561366e57600080fd5b8151612e29816130df565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156136a157600080fd5b5051919050565b6001600160a01b038b81168252602082018b9052898116604083015261012060608301819052820188905260009061014090898b838601376000848b0183015290971660808301525060a081019490945291151560c084015260e08301526001600160a01b0316610100820152601f909201601f191690910101949350505050565b6000806040838503121561373d57600080fd5b505080516020909101519092909150565b6000835161376081846020880161317f565b83519083019061377481836020880161317f565b01949350505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016137a5576137a561377d565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826137d1576137d16137ac565b500490565b8181038181111561078d5761078d61377d565b6000826137f8576137f86137ac565b500690565b8082018082111561078d5761078d61377d565b6000835161382281846020880161317f565b83519083019061383681836020880161317f565b602f60f81b9101908152600101949350505050565b601f8211156109cf57600081815260208120601f850160051c810160208610156138725750805b601f850160051c820191505b818110156138915782815560010161387e565b505050505050565b815167ffffffffffffffff8111156138b3576138b3613227565b6138c7816138c18454613555565b8461384b565b602080601f8311600181146138fc57600084156138e45750858301515b600019600386901b1c1916600185901b178555613891565b600085815260208120601f198616915b8281101561392b5788860151825594840194600190910190840161390c565b50858210156139495787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906139de908301846131a3565b9695505050505050565b6000602082840312156139fa57600080fd5b8151612e298161314c565b634e487b7160e01b600052603160045260246000fd5b60008251613a2d81846020870161317f565b919091019291505056fea164736f6c6343000811000a000000000000000000000000dca17eedc1aa3dbb14361678566b2da5a1bb4c3100000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a8100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000134e46546669204c6f636b65642042756e646c650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054c424e4649000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d68747470733a2f2f6d657461646174612e6e667466692e636f6d2f62756e646c65732f76312f6c6f636b65642f00000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102675760003560e01c8063647bec33116101515780639a48b5eb116100c3578063b860fabb11610087578063b860fabb14610569578063b88d4fde14610589578063c87b56dd1461059c578063d90c739d146105af578063e985e9c5146105d6578063fa3e47051461061257600080fd5b80639a48b5eb146104ea5780639d6fa618146105135780639f181b5e14610526578063a22cb4651461052f578063ad0ffd8b1461054257600080fd5b80638456cb59116101155780638456cb591461049b5780638da5cb5b146104a35780638ee1f07a146104b457806392fede00146104c757806395d89b41146104cf5780639993b010146104d757600080fd5b8063647bec33146104525780636c0360eb1461046557806370a082311461046d5780637a82e93c146104805780637b3711071461049357600080fd5b80632f745c59116101ea578063542c4a13116101ae578063542c4a13146103e557806355f804b3146103ff5780635c975abb146104125780635d799f87146104245780635f992fdd146104375780636352211e1461043f57600080fd5b80632f745c59146103915780633f4ba83a146103a457806342842e0e146103ac57806349a931f2146103bf5780634f6ccce7146103d257600080fd5b8063095ea7b311610231578063095ea7b314610317578063098867441461032a578063150b7a021461034a57806318160ddd1461037657806323b872dd1461037e57600080fd5b8062296cd81461026c578062f714ce1461029f57806301ffc9a7146102b457806306fdde03146102d7578063081812fc146102ec575b600080fd5b61028c61027a3660046130ff565b60116020526000908152604090205481565b6040519081526020015b60405180910390f35b6102b26102ad36600461311c565b610625565b005b6102c76102c2366004613162565b610768565b6040519015158152602001610296565b6102df610793565b60405161029691906131cf565b6102ff6102fa3660046131e2565b610825565b6040516001600160a01b039091168152602001610296565b6102b26103253660046131fb565b6108bf565b61028c6103383660046131e2565b600f6020526000908152604090205481565b61035d6103583660046132b3565b6109d4565b6040516001600160e01b03199091168152602001610296565b60085461028c565b6102b261038c366004613333565b610b6e565b61028c61039f3660046131fb565b610b9f565b6102b2610c35565b6102b26103ba366004613333565b610c69565b6102b26103cd3660046131e2565b610c84565b61028c6103e03660046131e2565b610d21565b6103ed600181565b60405160ff9091168152602001610296565b6102b261040d366004613374565b610db4565b600b54600160a01b900460ff166102c7565b6102b26104323660046133bd565b610dea565b6102b2610ed9565b6102ff61044d3660046131e2565b610f45565b6102b2610460366004613404565b610fbc565b6102df611320565b61028c61047b3660046130ff565b6113ae565b6102b261048e36600461311c565b611435565b6102b26115f4565b6102b2611663565b600a546001600160a01b03166102ff565b61028c6104c23660046130ff565b611695565b6102b2611764565b6102df61178e565b6102b26104e536600461311c565b61179d565b6102ff6104f83660046131e2565b6010602052600090815260409020546001600160a01b031681565b6102b26105213660046130ff565b611b09565b61028c600c5481565b6102b261053d3660046134e5565b611bba565b6102ff7f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b629009481565b61028c6105773660046131e2565b600e6020526000908152604090205481565b6102b26105973660046132b3565b611c7e565b6102df6105aa3660046131e2565b611cb0565b6102ff7f000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a8181565b6102c76105e43660046133bd565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102b2610620366004613513565b611d8a565b61062f828261211b565b6000828152600e60209081526040808320546010909252909120546001600160a01b031661065c846121c7565b6001600160a01b0381166106f857604051632142170760e11b81523060048201526001600160a01b038481166024830152604482018490527f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b629009416906342842e0e906064015b600060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b50505050610762565b604051632142170760e11b81523060048201526001600160a01b038481166024830152600160448301528216906342842e0e906064015b600060405180830381600087803b15801561074957600080fd5b505af115801561075d573d6000803e3d6000fd5b505050505b50505050565b60006001600160e01b03198216630a85bd0160e11b148061078d575061078d82612246565b92915050565b6060600080546107a290613555565b80601f01602080910402602001604051908101604052809291908181526020018280546107ce90613555565b801561081b5780601f106107f05761010080835404028352916020019161081b565b820191906000526020600020905b8154815290600101906020018083116107fe57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108a35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108ca82610f45565b9050806001600160a01b0316836001600160a01b0316036109375760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161089a565b336001600160a01b0382161480610953575061095381336105e4565b6109c55760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161089a565b6109cf838361226b565b505050565b600b54600090600160a01b900460ff1615610a015760405162461bcd60e51b815260040161089a9061358f565b336001600160a01b037f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094161480610abb575060405163397140fd60e21b81523360048201527f000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a816001600160a01b03169063e5c503f490602401602060405180830381865afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb91906135b9565b610afb5760405162461bcd60e51b8152602060048201526011602482015270185cdcd95d081b9bdd08185b1b1bddd959607a1b604482015260640161089a565b6001600160a01b03841615610b5c5760006001600160a01b037f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094163303610b4d57610b4685856122d9565b9050610b5a565b610b57853361234f565b90505b505b50630a85bd0160e11b5b949350505050565b610b7833826123df565b610b945760405162461bcd60e51b815260040161089a906135d6565b6109cf8383836124d2565b6000610baa836113ae565b8210610c0c5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161089a565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610c5f5760405162461bcd60e51b815260040161089a90613627565b610c6761267d565b565b6109cf83838360405180602001604052806000815250611c7e565b60405163464b8be160e11b81523060048201526000907f000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a816001600160a01b031690638c9717c2906024016020604051808303816000875af1158015610ced573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d11919061365c565b9050610d1d828261179d565b5050565b6000610d2c60085490565b8210610d8f5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161089a565b60088281548110610da257610da2613679565b90600052602060002001549050919050565b600a546001600160a01b03163314610dde5760405162461bcd60e51b815260040161089a90613627565b610de78161271a565b50565b600a546001600160a01b03163314610e145760405162461bcd60e51b815260040161089a90613627565b6040516370a0823160e01b815230600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e81919061368f565b905060008111610ec55760405162461bcd60e51b815260206004820152600f60248201526e1b9bc81d1bdad95b9cc81bdddb9959608a1b604482015260640161089a565b6107626001600160a01b0383168483612770565b600b546001600160a01b03163314610f335760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161089a565b600b80546001600160a01b0319169055565b6000818152600260205260408120546001600160a01b03168061078d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161089a565b33610fc68b610f45565b6001600160a01b0316146110285760405162461bcd60e51b815260206004820152602360248201527f70756c6c41697264726f70206d73672e73656e646572206e6f7420656c696769604482015262626c6560e81b606482015260840161089a565b60008a8152601060205260409020546001600160a01b0316156111925760008a81526010602052604090819020549051635680a3ad60e01b81526001600160a01b038b81166004830152602482018b905290911690635680a3ad90604401602060405180830381865afa1580156110a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c791906135b9565b61110c5760405162461bcd60e51b81526020600482015260166024820152750d2dadaeae8c2c4d8ca5adccce840dad2e6dac2e8c6d60531b604482015260640161089a565b60008a81526010602052604090819020549051633f77844b60e11b81526001600160a01b0390911690637eef08969061115b908c908c908c908c908c908c908c908c908c9033906004016136a8565b600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b50505050611314565b604051631d5b701760e31b81526001600160a01b038a81166004830152602482018a90526000917f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b62900949091169063eadb80b8906044016040805180830381865afa158015611203573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611227919061372a565b60008d8152600e6020526040902054909250821490506112825760405162461bcd60e51b81526020600482015260166024820152750d2dadaeae8c2c4d8ca5adccce840dad2e6dac2e8c6d60531b604482015260640161089a565b604051633f77844b60e11b81526001600160a01b037f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b62900941690637eef0896906112e0908d908d908d908d908d908d908d908d908d9033906004016136a8565b600060405180830381600087803b1580156112fa57600080fd5b505af115801561130e573d6000803e3d6000fd5b50505050505b50505050505050505050565b600d805461132d90613555565b80601f016020809104026020016040519081016040528092919081815260200182805461135990613555565b80156113a65780601f1061137b576101008083540402835291602001916113a6565b820191906000526020600020905b81548152906001019060200180831161138957829003601f168201915b505050505081565b60006001600160a01b0382166114195760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161089a565b506001600160a01b031660009081526003602052604090205490565b61143f828261211b565b6000828152600e60209081526040808320546010909252909120546001600160a01b031661146c846121c7565b6001600160a01b03811661155757604051636fba484360e11b8152600481018390526001600160a01b0384811660248301527f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094169063df74908690604401600060405180830381600087803b1580156114e457600080fd5b505af11580156114f8573d6000803e3d6000fd5b5050604051632142170760e11b81523060048201526001600160a01b038681166024830152604482018690527f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b62900941692506342842e0e91506064016106c1565b604051636fba484360e11b8152600160048201526001600160a01b03848116602483015282169063df74908690604401600060405180830381600087803b1580156115a157600080fd5b505af11580156115b5573d6000803e3d6000fd5b5050604051632142170760e11b81523060048201526001600160a01b03868116602483015260016044830152841692506342842e0e915060640161072f565b600b546001600160a01b0316331461164e5760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a206e6f74206f776e65722063616e64696461746500000000604482015260640161089a565b600b54610f33906001600160a01b03166127c2565b600a546001600160a01b0316331461168d5760405162461bcd60e51b815260040161089a90613627565b610c67612814565b600b54600090600160a01b900460ff16156116c25760405162461bcd60e51b815260040161089a9061358f565b6040516340d097c360e01b81523060048201526000907f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b62900946001600160a01b0316906340d097c3906024016020604051808303816000875af115801561172b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174f919061368f565b905061175b83826122d9565b9150505b919050565b600a546001600160a01b03163314610f335760405162461bcd60e51b815260040161089a90613627565b6060600180546107a290613555565b336117a783610f45565b6001600160a01b0316146117fd5760405162461bcd60e51b815260206004820152601760248201527f6d73672e73656e646572206e6f7420656c696769626c65000000000000000000604482015260640161089a565b6000828152601060205260409020546001600160a01b0316156118625760405162461bcd60e51b815260206004820152601860248201527f616c726561647920706572736f6e616c2062756e646c65720000000000000000604482015260640161089a565b60405163397140fd60e21b81526001600160a01b0382811660048301527f000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a81169063e5c503f490602401602060405180830381865afa1580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec91906135b9565b61192f5760405162461bcd60e51b81526020600482015260146024820152733737ba103832b939b7b730b610313ab7323632b960611b604482015260640161089a565b6040516331a9108f60e11b81526001600482015230906001600160a01b03831690636352211e90602401602060405180830381865afa158015611976573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199a919061365c565b6001600160a01b0316146119f05760405162461bcd60e51b815260206004820152601d60248201527f6f776e65722068617320746f206265207468697320636f6e7472616374000000604482015260640161089a565b6000828152600e60209081526040808320805490849055808452600f909252808320929092559051638daf2d6160e01b8152600481018290526001600160a01b0383811660248301527f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b62900941690638daf2d6190604401600060405180830381600087803b158015611a7f57600080fd5b505af1158015611a93573d6000803e3d6000fd5b50505050816001600160a01b031681847f52ac19043c7718796c5d11822f560e2526c7b5d6f6eea1066befb6d03e82a80560405160405180910390a450600082815260106020908152604080832080546001600160a01b039095166001600160a01b031990951685179055928252601190522055565b600a546001600160a01b03163314611b335760405162461bcd60e51b815260040161089a90613627565b6001600160a01b038116611b985760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161089a565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b03831603611c125760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161089a565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611c8833836123df565b611ca45760405162461bcd60e51b815260040161089a906135d6565b61076284848484612879565b6000818152600260205260409020546060906001600160a01b0316611d2f5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161089a565b6000611d396128ac565b90506000815111611d59576040518060200160405280600081525061175b565b80611d638461201a565b604051602001611d7492919061374e565b6040516020818303038152906040529392505050565b600a546001600160a01b03163314611db45760405162461bcd60e51b815260040161089a90613627565b826001600160a01b037f00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094811690821603611e41576000838152600f602052604090205415611e3c5760405162461bcd60e51b8152602060048201526015602482015274746f6b656e20697320696e20696d6d757461626c6560581b604482015260640161089a565b611f2e565b60405163397140fd60e21b81526001600160a01b0385811660048301527f000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a81169063e5c503f490602401602060405180830381865afa158015611ea7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecb91906135b9565b15611f2e576001600160a01b03841660009081526011602052604090205415611f2e5760405162461bcd60e51b8152602060048201526015602482015274746f6b656e20697320696e20696d6d757461626c6560581b604482015260640161089a565b6040516331a9108f60e11b81526004810184905230906001600160a01b03831690636352211e90602401602060405180830381865afa158015611f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f99919061365c565b6001600160a01b031614611fdf5760405162461bcd60e51b815260206004820152600d60248201526c1b999d081b9bdd081bdddb9959609a1b604482015260640161089a565b604051632142170760e11b81523060048201526001600160a01b038381166024830152604482018590528216906342842e0e9060640161072f565b6060816000036120415750506040805180820190915260018152600360fc1b602082015290565b8160005b811561206b578061205581613793565b91506120649050600a836137c2565b9150612045565b60008167ffffffffffffffff81111561208657612086613227565b6040519080825280601f01601f1916602001820160405280156120b0576020820181803683370190505b5090505b8415610b66576120c56001836137d6565b91506120d2600a866137e9565b6120dd9060306137fd565b60f81b8183815181106120f2576120f2613679565b60200101906001600160f81b031916908160001a905350612114600a866137c2565b94506120b4565b3361212583610f45565b6001600160a01b0316146121715760405162461bcd60e51b815260206004820152601360248201527231b0b63632b91034b9903737ba1037bbb732b960691b604482015260640161089a565b6001600160a01b038116610d1d5760405162461bcd60e51b815260206004820152601860248201527f7472616e7366657220746f207a65726f20616464726573730000000000000000604482015260640161089a565b6121d0816128bb565b6000818152601060205260409020546001600160a01b03161561222357600090815260106020908152604080832080546001600160a01b031981169091556001600160a01b031683526011909152812055565b6000908152600e602090815260408083208054908490558352600f909152812055565b60006001600160e01b0319821663780e9d6360e01b148061078d575061078d82612962565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906122a082610f45565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080600c600081546122eb90613793565b918290555090506122fc84826129b2565b6000818152600e60209081526040808320869055858352600f90915280822083905551849083907f3d29d48d72f16f3d1e30b1064f89960da7256796039bcb7cf0e613029188922b908490a49392505050565b600080600c6000815461236190613793565b9182905550905061237284826129b2565b600081815260106020908152604080832080546001600160a01b0319166001600160a01b03881690811790915580845260119092528083208490555190919083907f3d29d48d72f16f3d1e30b1064f89960da7256796039bcb7cf0e613029188922b908390a49392505050565b6000818152600260205260408120546001600160a01b03166124585760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161089a565b600061246383610f45565b9050806001600160a01b0316846001600160a01b0316148061249e5750836001600160a01b031661249384610825565b6001600160a01b0316145b80610b6657506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff16610b66565b826001600160a01b03166124e582610f45565b6001600160a01b03161461254d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161089a565b6001600160a01b0382166125af5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161089a565b6125ba8383836129cc565b6125c560008261226b565b6001600160a01b03831660009081526003602052604081208054600192906125ee9084906137d6565b90915550506001600160a01b038216600090815260036020526040812080546001929061261c9084906137fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600b54600160a01b900460ff166126cd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161089a565b600b805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008151116127385760405180602001604052806000815250612763565b806127424661201a565b604051602001612753929190613810565b6040516020818303038152906040525b600d90610d1d9082613899565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109cf908490612a84565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600b54600160a01b900460ff161561283e5760405162461bcd60e51b815260040161089a9061358f565b600b805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126fd3390565b6128848484846124d2565b61289084848484612b56565b6107625760405162461bcd60e51b815260040161089a90613959565b6060600d80546107a290613555565b60006128c682610f45565b90506128d4816000846129cc565b6128df60008361226b565b6001600160a01b03811660009081526003602052604081208054600192906129089084906137d6565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160e01b031982166380ac58cd60e01b148061299357506001600160e01b03198216635b5e139f60e01b145b8061078d57506301ffc9a760e01b6001600160e01b031983161461078d565b610d1d828260405180602001604052806000815250612c54565b6001600160a01b038316612a2757612a2281600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612a4a565b816001600160a01b0316836001600160a01b031614612a4a57612a4a8382612c87565b6001600160a01b038216612a61576109cf81612d24565b826001600160a01b0316826001600160a01b0316146109cf576109cf8282612dd3565b6000612ad9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e179092919063ffffffff16565b8051909150156109cf5780806020019051810190612af791906135b9565b6109cf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161089a565b60006001600160a01b0384163b15612c4c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612b9a9033908990889088906004016139ab565b6020604051808303816000875af1925050508015612bd5575060408051601f3d908101601f19168201909252612bd2918101906139e8565b60015b612c32573d808015612c03576040519150601f19603f3d011682016040523d82523d6000602084013e612c08565b606091505b508051600003612c2a5760405162461bcd60e51b815260040161089a90613959565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610b66565b506001610b66565b612c5e8383612e30565b612c6b6000848484612b56565b6109cf5760405162461bcd60e51b815260040161089a90613959565b60006001612c94846113ae565b612c9e91906137d6565b600083815260076020526040902054909150808214612cf1576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612d36906001906137d6565b60008381526009602052604081205460088054939450909284908110612d5e57612d5e613679565b906000526020600020015490508060088381548110612d7f57612d7f613679565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612db757612db7613a05565b6001900381819060005260206000200160009055905550505050565b6000612dde836113ae565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6060612e268484600085612f7e565b90505b9392505050565b6001600160a01b038216612e865760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161089a565b6000818152600260205260409020546001600160a01b031615612eeb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161089a565b612ef7600083836129cc565b6001600160a01b0382166000908152600360205260408120805460019290612f209084906137fd565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606082471015612fdf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161089a565b843b61302d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161089a565b600080866001600160a01b031685876040516130499190613a1b565b60006040518083038185875af1925050503d8060008114613086576040519150601f19603f3d011682016040523d82523d6000602084013e61308b565b606091505b509150915061309b8282866130a6565b979650505050505050565b606083156130b5575081612e29565b8251156130c55782518084602001fd5b8160405162461bcd60e51b815260040161089a91906131cf565b6001600160a01b0381168114610de757600080fd5b803561175f816130df565b60006020828403121561311157600080fd5b8135612e29816130df565b6000806040838503121561312f57600080fd5b823591506020830135613141816130df565b809150509250929050565b6001600160e01b031981168114610de757600080fd5b60006020828403121561317457600080fd5b8135612e298161314c565b60005b8381101561319a578181015183820152602001613182565b50506000910152565b600081518084526131bb81602086016020860161317f565b601f01601f19169290920160200192915050565b602081526000612e2960208301846131a3565b6000602082840312156131f457600080fd5b5035919050565b6000806040838503121561320e57600080fd5b8235613219816130df565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561325857613258613227565b604051601f8501601f19908116603f0116810190828211818310171561328057613280613227565b8160405280935085815286868601111561329957600080fd5b858560208301376000602087830101525050509392505050565b600080600080608085870312156132c957600080fd5b84356132d4816130df565b935060208501356132e4816130df565b925060408501359150606085013567ffffffffffffffff81111561330757600080fd5b8501601f8101871361331857600080fd5b6133278782356020840161323d565b91505092959194509250565b60008060006060848603121561334857600080fd5b8335613353816130df565b92506020840135613363816130df565b929592945050506040919091013590565b60006020828403121561338657600080fd5b813567ffffffffffffffff81111561339d57600080fd5b8201601f810184136133ae57600080fd5b610b668482356020840161323d565b600080604083850312156133d057600080fd5b82356133db816130df565b91506020830135613141816130df565b8015158114610de757600080fd5b803561175f816133eb565b6000806000806000806000806000806101208b8d03121561342457600080fd5b8a35995060208b0135613436816130df565b985060408b0135975060608b013561344d816130df565b965060808b013567ffffffffffffffff8082111561346a57600080fd5b818d0191508d601f83011261347e57600080fd5b81358181111561348d57600080fd5b8e602082850101111561349f57600080fd5b6020830198508097505050506134b760a08c016130f4565b935060c08b013592506134cc60e08c016133f9565b91506101008b013590509295989b9194979a5092959850565b600080604083850312156134f857600080fd5b8235613503816130df565b91506020830135613141816133eb565b60008060006060848603121561352857600080fd5b8335613533816130df565b925060208401359150604084013561354a816130df565b809150509250925092565b600181811c9082168061356957607f821691505b60208210810361358957634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6000602082840312156135cb57600080fd5b8151612e29816133eb565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561366e57600080fd5b8151612e29816130df565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156136a157600080fd5b5051919050565b6001600160a01b038b81168252602082018b9052898116604083015261012060608301819052820188905260009061014090898b838601376000848b0183015290971660808301525060a081019490945291151560c084015260e08301526001600160a01b0316610100820152601f909201601f191690910101949350505050565b6000806040838503121561373d57600080fd5b505080516020909101519092909150565b6000835161376081846020880161317f565b83519083019061377481836020880161317f565b01949350505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016137a5576137a561377d565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826137d1576137d16137ac565b500490565b8181038181111561078d5761078d61377d565b6000826137f8576137f86137ac565b500690565b8082018082111561078d5761078d61377d565b6000835161382281846020880161317f565b83519083019061383681836020880161317f565b602f60f81b9101908152600101949350505050565b601f8211156109cf57600081815260208120601f850160051c810160208610156138725750805b601f850160051c820191505b818110156138915782815560010161387e565b505050505050565b815167ffffffffffffffff8111156138b3576138b3613227565b6138c7816138c18454613555565b8461384b565b602080601f8311600181146138fc57600084156138e45750858301515b600019600386901b1c1916600185901b178555613891565b600085815260208120601f198616915b8281101561392b5788860151825594840194600190910190840161390c565b50858210156139495787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906139de908301846131a3565b9695505050505050565b6000602082840312156139fa57600080fd5b8151612e298161314c565b634e487b7160e01b600052603160045260246000fd5b60008251613a2d81846020870161317f565b919091019291505056fea164736f6c6343000811000a

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

000000000000000000000000dca17eedc1aa3dbb14361678566b2da5a1bb4c3100000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a8100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000134e46546669204c6f636b65642042756e646c650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054c424e4649000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d68747470733a2f2f6d657461646174612e6e667466692e636f6d2f62756e646c65732f76312f6c6f636b65642f00000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _admin (address): 0xDcA17eeDc1aa3dbB14361678566b2dA5A1Bb4C31
Arg [1] : _bundler (address): 0x16c583748faeD1C5A5bcd744b4892ee6B6290094
Arg [2] : _personalBundlerFactory (address): 0xfC0c62626bDa9608D4d63EDd9AB2cF406f751A81
Arg [3] : _name (string): NFTfi Locked Bundle
Arg [4] : _symbol (string): LBNFI
Arg [5] : _customBaseURI (string): https://metadata.nftfi.com/bundles/v1/locked/

-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 000000000000000000000000dca17eedc1aa3dbb14361678566b2da5a1bb4c31
Arg [1] : 00000000000000000000000016c583748faed1c5a5bcd744b4892ee6b6290094
Arg [2] : 000000000000000000000000fc0c62626bda9608d4d63edd9ab2cf406f751a81
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000013
Arg [7] : 4e46546669204c6f636b65642042756e646c6500000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [9] : 4c424e4649000000000000000000000000000000000000000000000000000000
Arg [10] : 000000000000000000000000000000000000000000000000000000000000002d
Arg [11] : 68747470733a2f2f6d657461646174612e6e667466692e636f6d2f62756e646c
Arg [12] : 65732f76312f6c6f636b65642f00000000000000000000000000000000000000


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

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