Sepolia Testnet

Contract

0x5681F335939C4A07aE72B9eA2e7c94d6adf67eE5
Source Code
Transaction Hash
Method
Block
From
To
Value
Wrap In46857642023-11-13 12:58:1216 days 14 hrs ago1699880292IN
0x5681F3...adf67eE5
0 ETH0.000762052.17941288
Wrap In46572512023-11-09 2:03:3621 days 1 hr ago1699495416IN
0x5681F3...adf67eE5
0 ETH0.00003460.11999991
Wrap In46544412023-11-08 14:56:4821 days 12 hrs ago1699455408IN
0x5681F3...adf67eE5
0 ETH0.000716452.00000002
Wrap In46543902023-11-08 14:43:2421 days 12 hrs ago1699454604IN
0x5681F3...adf67eE5
0 ETH0.000725042.00000002
Wrap In46268292023-11-04 6:30:4825 days 20 hrs ago1699079448IN
0x5681F3...adf67eE5
0 ETH0.000657882.00000001
Wrap In45882222023-10-29 15:37:1231 days 11 hrs ago1698593832IN
0x5681F3...adf67eE5
0 ETH0.000503171.50000001
Wrap In45881952023-10-29 15:31:2431 days 11 hrs ago1698593484IN
0x5681F3...adf67eE5
0 ETH0.000503171.50000001
Wrap In45880562023-10-29 15:00:2431 days 12 hrs ago1698591624IN
0x5681F3...adf67eE5
0 ETH0.000521621.50000001
Wrap In45805242023-10-28 12:58:4832 days 14 hrs ago1698497928IN
0x5681F3...adf67eE5
0 ETH0.000376541.50000001
Wrap In45803322023-10-28 12:18:2432 days 15 hrs ago1698495504IN
0x5681F3...adf67eE5
0 ETH0.000432511.50000001
Wrap In43760292023-09-27 16:48:3663 days 10 hrs ago1695833316IN
0x5681F3...adf67eE5
0 ETH0.0181716880
Wrap In43760062023-09-27 16:43:3663 days 10 hrs ago1695833016IN
0x5681F3...adf67eE5
0 ETH0.0121362480
Wrap In43757742023-09-27 15:52:4863 days 11 hrs ago1695829968IN
0x5681F3...adf67eE5
0 ETH0.022703680
Wrap In43756382023-09-27 15:22:1263 days 12 hrs ago1695828132IN
0x5681F3...adf67eE5
0 ETH0.0257267280
Wrap In43754632023-09-27 14:43:1263 days 12 hrs ago1695825792IN
0x5681F3...adf67eE5
0 ETH0.0105027150.19411135
0x60a0604043751822023-09-27 13:42:3663 days 13 hrs ago1695822156IN
 Create: WrapperUsersV1
0 ETH0.1682372643.40799133

Advanced mode:
Parent Txn Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
WrapperUsersV1

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 30 : WrapperUsersV1.sol
// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT. Wrapper - for users SBT collections
pragma solidity 0.8.21;

//import "Ownable.sol";
import "ERC721Holder.sol";
import "ERC1155Holder.sol";
import "ReentrancyGuard.sol";
import "TokenServiceExtended.sol";
import "IWrapperUsers.sol";
import "IUserCollectionRegistry.sol";


// #### Envelop ProtocolV1 Rules
// This version supportd only:                               +       +
// 15   14   13   12   11   10   9   8   7   6   5   4   3   2   1   0  <= Bit number(dec)
// ------------------------------------------------------------------------------------  
//  1    1    1    1    1    1   1   1   1   1   1   1   1   1   1   1
//  |    |    |    |    |    |   |   |   |   |   |   |   |   |   |   |
//  |    |    |    |    |    |   |   |   |   |   |   |   |   |   |   +-No_Unwrap
//  |    |    |    |    |    |   |   |   |   |   |   |   |   |   +-No_Wrap 
//  |    |    |    |    |    |   |   |   |   |   |   |   |   +-No_Transfer
//  |    |    |    |    |    |   |   |   |   |   |   |   +-No_Collateral
//  |    |    |    |    |    |   |   |   |   |   |   +-reserved_core
//  |    |    |    |    |    |   |   |   |   |   +-reserved_core
//  |    |    |    |    |    |   |   |   |   +-reserved_core  
//  |    |    |    |    |    |   |   |   +-reserved_core
//  |    |    |    |    |    |   |   |
//  |    |    |    |    |    |   |   |
//  +----+----+----+----+----+---+---+
//      for use in extendings
/**
 * @title Non-Fungible Token Wrapper
 * @dev Make  wraping for existing ERC721 & ERC1155 and empty 
 */
contract WrapperUsersV1 is 
    ReentrancyGuard, 
    ERC721Holder, 
    ERC1155Holder, 
    IWrapperUsers, 
    TokenServiceExtended
{

    uint256 public MAX_COLLATERAL_SLOTS = 100;
    address constant public protocolTechToken = address(0);  // Just for backward interface compatibility
    address constant public protocolWhiteList = address(0);  // Just for backward interface compatibility

    address immutable public usersCollectionRegistry;

    // Map from wrapped token address and id => wNFT record 
    mapping(address => mapping(uint256 => ETypes.WNFT)) internal wrappedTokens; 

    constructor(address _usersWNFTRegistry) {
        require(_usersWNFTRegistry != address(0), "Only for non zero registry");
        usersCollectionRegistry = _usersWNFTRegistry;
    }

    function wrap(
        ETypes.INData calldata _inData, 
        ETypes.AssetItem[] calldata _collateral, 
        address _wrappFor
    ) 
        public 
        virtual
        payable 
        returns (ETypes.AssetItem memory) 
    {
      // Just for backward interface compatibility        
    }

    function wrapIn(
        ETypes.INData calldata _inData, 
        ETypes.AssetItem[] calldata _collateral, 
        address _wrappFor,
        address _wrappIn
    )
        public 
        virtual
        payable 
        nonReentrant 
        returns (ETypes.AssetItem memory) 
    {

        // 0. Check assetIn asset
        require(_checkWrap(_inData, _wrappFor, _wrappIn),
            "Wrap check fail"
        );
        
        
        // 2. Mint wNFT
        uint256 wnftId = _mintWNFTWithRules(
            _inData.outType,     // what will be minted instead of wrapping asset
            _wrappIn, // wNFT contract address
            _wrappFor,                                   // wNFT receiver (1st owner) 
            _inData.outBalance,                           // wNFT tokenId
            _inData.rules
        );
        
        // 3. Safe wNFT info
        _saveWNFTinfo(
            _wrappIn, 
            wnftId,
            _inData
        );

        // 1. Take users inAsset
        if ( _inData.inAsset.asset.assetType != ETypes.AssetType.NATIVE &&
             _inData.inAsset.asset.assetType != ETypes.AssetType.EMPTY
        ) 
        {
            require(
                _mustTransfered(_inData.inAsset) == _transferSafe(
                    _inData.inAsset, 
                    msg.sender, 
                    address(this)
                ),
                "Suspicious asset for wrap"
            );
        }

        addCollateral(
            _wrappIn, 
            wnftId,
            _collateral
        ); 
         
        emit WrappedV1(
            _inData.inAsset.asset.contractAddress,        // inAssetAddress
            _wrappIn,                                     // outAssetAddress
            _inData.inAsset.tokenId,                      // inAssetTokenId 
            wnftId,                                       // outTokenId 
            _wrappFor,                                    // wnftFirstOwner
            msg.value,                                    // nativeCollateralAmount
            _inData.rules                                 // rules
        );

        return ETypes.AssetItem(
            ETypes.Asset(_inData.outType, _wrappIn),
            wnftId,
            _inData.outBalance
        );
    }

    function addCollateral(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem[] calldata _collateral
    ) public payable virtual  {
        if (_collateral.length > 0 || msg.value > 0) {
            require(
                _checkAddCollateral(
                    _wNFTAddress, 
                    _wNFTTokenId,
                    _collateral
                ),
                "Forbidden add collateral"
            );
            _addCollateral(
                _wNFTAddress, 
                _wNFTTokenId, 
                _collateral
            );
        }
    }

    

    function unWrap(address _wNFTAddress, uint256 _wNFTTokenId) external virtual {

        unWrap(_getNFTType(_wNFTAddress, _wNFTTokenId), _wNFTAddress, _wNFTTokenId, false);
    }

    function unWrap(
        ETypes.AssetType _wNFTType, 
        address _wNFTAddress, 
        uint256 _wNFTTokenId
    ) external virtual  {
        unWrap(_wNFTType, _wNFTAddress, _wNFTTokenId, false);
    }

    function unWrap(
        ETypes.AssetType _wNFTType, 
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        bool _isEmergency
    ) public virtual nonReentrant{
        // 1. Check core protocol logic:
        // - who and what possible to unwrap
        (address burnFor, uint256 burnBalance) = _checkCoreUnwrap(_wNFTType, _wNFTAddress, _wNFTTokenId);

        // 2. Check  locks = move to _checkUnwrap
        require(
            _checkLocks(_wNFTAddress, _wNFTTokenId)
        );

        // 3. Charge Fee Hook 
        // There is No Any Fees in Protocol
        //
        // So this hook can be used in b2b extensions of Envelop Protocol 
        // 0x03 - feeType for UnWrapFee
        // 
        //_chargeFees(_wNFTAddress, _wNFTTokenId, msg.sender, address(this), 0x03);
        
        (uint256 nativeCollateralAmount, ) = getCollateralBalanceAndIndex(
            _wNFTAddress, 
            _wNFTTokenId,
            ETypes.AssetType.NATIVE,
            address(0),
            0
        );
        ///////////////////////////////////////////////
        ///  Place for hook                        ////
        ///////////////////////////////////////////////
        // 4. Safe return collateral to appropriate benificiary

        if (!_beforeUnWrapHook(_wNFTAddress, _wNFTTokenId, _isEmergency)) {
            return;
        }
        
        // 5. BurnWNFT
        _burnNFT(
            _wNFTType, 
            _wNFTAddress, 
            burnFor,  // msg.sender, 
            _wNFTTokenId, 
            burnBalance
        );
        
        ETypes.WNFT memory w = getWrappedToken(_wNFTAddress, _wNFTTokenId);
        emit UnWrappedV1(
            _wNFTAddress,
            w.inAsset.asset.contractAddress,
            _wNFTTokenId, 
            w.inAsset.tokenId,
            w.unWrapDestination, 
            nativeCollateralAmount,  // TODO Check  GAS
            w.rules
        );
    } 

    function chargeFees(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        address _from, 
        address _to,
        bytes1 _feeType
    ) 
        public
        virtual  
        returns (bool charged) 
    {
        // There is No Any Fees in Protocol
        charged = true;
    }
    /////////////////////////////////////////////////////////////////////
    //                    Admin functions                              //
    /////////////////////////////////////////////////////////////////////
    
    //   There is no admib functions in this implementation            //

    /////////////////////////////////////////////////////////////////////


    function getWrappedToken(address _wNFTAddress, uint256 _wNFTTokenId) 
        public 
        view 
        returns (ETypes.WNFT memory) 
    {
        return wrappedTokens[_wNFTAddress][_wNFTTokenId];
    }

    function getOriginalURI(address _wNFTAddress, uint256 _wNFTTokenId) 
        public 
        view 
        returns(string memory uri_) 
    {
        ETypes.AssetItem memory _wnftInAsset = getWrappedToken(
                _wNFTAddress, _wNFTTokenId
        ).inAsset;

        if (_wnftInAsset.asset.assetType == ETypes.AssetType.ERC721) {
            uri_ = IERC721Metadata(_wnftInAsset.asset.contractAddress).tokenURI(_wnftInAsset.tokenId);
        
        } else if (_wnftInAsset.asset.assetType == ETypes.AssetType.ERC1155) {
            uri_ = IERC1155MetadataURI(_wnftInAsset.asset.contractAddress).uri(_wnftInAsset.tokenId);
        
        } else {
            uri_ = '';
        } 
    }

    function getCollateralBalanceAndIndex(
        address _wNFTAddress, 
        uint256 _wNFTTokenId,
        ETypes.AssetType _collateralType, 
        address _erc,
        uint256 _tokenId
    ) public view returns (uint256, uint256) 
    {
        for (uint256 i = 0; i < wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.length; i ++) {
            if (wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].asset.contractAddress == _erc &&
                wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].tokenId == _tokenId &&
                wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].asset.assetType == _collateralType 
            ) 
            {
                return (wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].amount, i);
            }
        }
    } 

    function getNFTType(address _nftAddress, uint256 _nftTokenId) 
        external 
        view 
        returns (ETypes.AssetType nftType) 
    {
        return _getNFTType(_nftAddress, _nftTokenId);
    }
    
    /////////////////////////////////////////////////////////////////////
    //                    Internals                                    //
    /////////////////////////////////////////////////////////////////////
    function _saveWNFTinfo(
        address wNFTAddress, 
        uint256 tokenId, 
        ETypes.INData calldata _inData
    ) internal virtual 
    {
        wrappedTokens[wNFTAddress][tokenId].inAsset = _inData.inAsset;
        // We will use _inData.unWrapDestination  ONLY for RENT implementation
        // wrappedTokens[wNFTAddress][tokenId].unWrapDestination = _inData.unWrapDestination;
        wrappedTokens[wNFTAddress][tokenId].unWrapDestination = address(0);
        wrappedTokens[wNFTAddress][tokenId].rules = _inData.rules;
        
        // Copying of type struct ETypes.Fee memory[] 
        // memory to storage not yet supported.
        for (uint256 i = 0; i < _inData.fees.length; i ++) {
            wrappedTokens[wNFTAddress][tokenId].fees.push(_inData.fees[i]);            
        }

        for (uint256 i = 0; i < _inData.locks.length; i ++) {
            wrappedTokens[wNFTAddress][tokenId].locks.push(_inData.locks[i]);            
        }

        for (uint256 i = 0; i < _inData.royalties.length; i ++) {
            wrappedTokens[wNFTAddress][tokenId].royalties.push(_inData.royalties[i]);            
        }

    }

    function _addCollateral(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem[] calldata _collateral
    ) internal virtual 
    {
        // Process Native Colleteral
        if (msg.value > 0) {
            _updateCollateralInfo(
                _wNFTAddress, 
                _wNFTTokenId,
                ETypes.AssetItem(
                    ETypes.Asset(ETypes.AssetType.NATIVE, address(0)),
                    0,
                    msg.value
                )
            );
            emit CollateralAdded(
                    _wNFTAddress, 
                    _wNFTTokenId, 
                    uint8(ETypes.AssetType.NATIVE),
                    address(0),
                    0,
                    msg.value
                );
        }
       
        // Process Token Colleteral
        for (uint256 i = 0; i <_collateral.length; i ++) {
            if (_collateral[i].asset.assetType != ETypes.AssetType.NATIVE) {
                require(
                    _mustTransfered(_collateral[i]) == _transferSafe(
                        _collateral[i], 
                        msg.sender, 
                        address(this)
                    ),
                    "Suspicious asset for wrap"
                );
                _updateCollateralInfo(
                    _wNFTAddress, 
                    _wNFTTokenId,
                    _collateral[i]
                );
                emit CollateralAdded(
                    _wNFTAddress, 
                    _wNFTTokenId, 
                    uint8(_collateral[i].asset.assetType),
                    _collateral[i].asset.contractAddress,
                    _collateral[i].tokenId,
                    _collateral[i].amount
                );
            }
        }
    }

    function _updateCollateralInfo(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem memory collateralItem
    ) internal virtual 
    {
        /////////////////////////////////////////
        //  ERC20 & NATIVE Collateral         ///
        /////////////////////////////////////////
        if (collateralItem.asset.assetType == ETypes.AssetType.ERC20  ||
            collateralItem.asset.assetType == ETypes.AssetType.NATIVE) 
        {
            require(collateralItem.tokenId == 0, "TokenId must be zero");
        }

        /////////////////////////////////////////
        //  ERC1155 Collateral                ///
        // /////////////////////////////////////////
        // if (collateralItem.asset.assetType == ETypes.AssetType.ERC1155) {
        //  No need special checks
        // }    

        /////////////////////////////////////////
        //  ERC721 Collateral                 ///
        /////////////////////////////////////////
        if (collateralItem.asset.assetType == ETypes.AssetType.ERC721 ) {
            require(collateralItem.amount == 0, "Amount must be zero");
        }
        /////////////////////////////////////////
        if (wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.length == 0 
            || collateralItem.asset.assetType == ETypes.AssetType.ERC721 
        )
        {
            // First record in collateral or 721
            _newCollateralItem(_wNFTAddress,_wNFTTokenId,collateralItem);
        }  else {
             // length > 0 
            (, uint256 _index) = getCollateralBalanceAndIndex(
                _wNFTAddress, 
                _wNFTTokenId,
                collateralItem.asset.assetType, 
                collateralItem.asset.contractAddress,
                collateralItem.tokenId
            );

            if (_index > 0 ||
                   (_index == 0 
                    && wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[0].asset.contractAddress 
                        == collateralItem.asset.contractAddress 
                    ) 
                ) 
            {
                // We dont need addition if  for erc721 because for erc721 _amnt always be zero
                wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[_index].amount 
                += collateralItem.amount;

            } else {
                // _index == 0 &&  and no this  token record yet
                _newCollateralItem(_wNFTAddress,_wNFTTokenId,collateralItem);
            }
        }
    }

    function _newCollateralItem(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem memory collateralItem
    ) internal virtual 

    {
        require(
            wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.length < MAX_COLLATERAL_SLOTS, 
            "Too much tokens in collateral"
        );

        // No Rules check in this immplementation
        
        wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.push(collateralItem);
    }

    /**
     * @dev This hook may be overriden in inheritor contracts for extend
     * base functionality.
     *
     * @param _wNFTAddress -wrapped token address
     * @param _wNFTTokenId -wrapped token id
     * 
     * must returns true for success unwrapping enable 
     */
    function _beforeUnWrapHook(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        bool _emergency
    ) internal virtual returns (bool)
    {
        uint256 transfered;
        address receiver = msg.sender;
        if (wrappedTokens[_wNFTAddress][_wNFTTokenId].unWrapDestination != address(0)) {
            receiver = wrappedTokens[_wNFTAddress][_wNFTTokenId].unWrapDestination;
        }

        for (uint256 i = 0; i < wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.length; i ++) {
            if (wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].asset.assetType 
                != ETypes.AssetType.EMPTY
            ) {
                if (_emergency) {
                    // In case of something is wrong with any collateral (attack)
                    // user can use  this mode  for skip  malicious asset
                    transfered = _transferEmergency(
                        wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i],
                        address(this),
                        receiver
                    );
                } else {
                    transfered = _transferSafe(
                        wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i],
                        address(this),
                        receiver
                    );
                }

                // we collect info about contracts with not standard behavior
                if (transfered != wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].amount ) {
                    emit SuspiciousFail(
                        _wNFTAddress, 
                        _wNFTTokenId, 
                        wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].asset.contractAddress
                    );
                }

                // mark collateral record as returned
                wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral[i].asset.assetType = ETypes.AssetType.EMPTY;                
            }
            // dont pop due in some case it c can be very costly
            // https://docs.soliditylang.org/en/v0.8.9/types.html#array-members  

            // For safe exit in case of low gaslimit
            // this strange part of code can prevent only case 
            // when when some collateral tokens spent unexpected gas limit
            if (
                gasleft() <= 1_000 &&
                    i < wrappedTokens[_wNFTAddress][_wNFTTokenId].collateral.length - 1
                ) 
            {
                emit PartialUnWrapp(_wNFTAddress, _wNFTTokenId, i);
                //allReturned = false;
                return false;
            }
        }

        // 5. Return Original
        if (wrappedTokens[_wNFTAddress][_wNFTTokenId].inAsset.asset.assetType != ETypes.AssetType.NATIVE && 
            wrappedTokens[_wNFTAddress][_wNFTTokenId].inAsset.asset.assetType != ETypes.AssetType.EMPTY
        ) 
        {

            if (!_emergency){
                _transferSafe(
                    wrappedTokens[_wNFTAddress][_wNFTTokenId].inAsset,
                    address(this),
                    receiver
                );
            } else {
                _transferEmergency (
                    wrappedTokens[_wNFTAddress][_wNFTTokenId].inAsset,
                    address(this),
                    receiver
                );
            }
        }
        return true;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////

    function _getNFTType(address _wNFTAddress, uint256 _wNFTTokenId) 
        internal 
        view 
        returns (ETypes.AssetType _wNFTType)
    {
        if (IERC165(_wNFTAddress).supportsInterface(type(IERC721).interfaceId)) {
            _wNFTType = ETypes.AssetType.ERC721;
        } else if (IERC165(_wNFTAddress).supportsInterface(type(IERC1155).interfaceId)) {
            _wNFTType = ETypes.AssetType.ERC1155;
        } else {
            revert UnSupportedAsset(
                ETypes.AssetItem(
                    ETypes.Asset(_wNFTType, _wNFTAddress),
                    _wNFTTokenId,
                    0
                )
            );
        }
    }

    function _mustTransfered(ETypes.AssetItem calldata _assetForTransfer) 
        internal 
        pure 
        returns (uint256 mustTransfered) 
    {
        // Available for wrap assets must be good transferable (stakable).
        // So for erc721  mustTransfered always be 1
        if (_assetForTransfer.asset.assetType == ETypes.AssetType.ERC721) {
            mustTransfered = 1;
        } else {
            mustTransfered = _assetForTransfer.amount;
        }
    }
     
    function _checkRule(bytes2 _rule, bytes2 _wNFTrules) internal pure returns (bool) {
        return _rule == (_rule & _wNFTrules);
    }

    // 0x00 - TimeLock
    // 0x01 - TransferFeeLock
    // 0x02 - Personal Collateral count Lock check
    function _checkLocks(address _wNFTAddress, uint256 _wNFTTokenId) internal view virtual returns (bool) 
    {
        // There is NO locks checks in this implementation
        return true;
    }


    function _checkWrap(ETypes.INData calldata _inData, address _wrappFor, address _wrappIn) 
        internal 
        view 
        returns (bool enabled)
    {
        

        // Check that _wrappIn belongs to user
        ETypes.Asset[] memory userAssets = IUserCollectionRegistry(usersCollectionRegistry)
            .getUsersCollections(msg.sender);
        bool isUsersAsset;
        for (uint256 i = 0; i < userAssets.length; ++ i ){
            if (userAssets[i].contractAddress == _wrappIn && 
                userAssets[i].assetType == _inData.outType
                ) 
            {
                isUsersAsset = true;
                break;
            }
        }
        
        // Lets check that inAsset 
        enabled =     
            _wrappFor != address(this) && 
            isUsersAsset;
    }
    
    function _checkAddCollateral(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem[] calldata _collateral
    ) 
        internal 
        view
        virtual 
        returns (bool enabled)
    {
        require(IUsersSBT(_wNFTAddress).owner() == msg.sender, 
            'Only wNFT contract owner able to add collateral'
        );
        // Check  that wNFT exist
        ETypes.AssetType wnftType = _getNFTType(_wNFTAddress, _wNFTTokenId);
        if (wnftType == ETypes.AssetType.ERC721) {
            require(IERC721Mintable(_wNFTAddress).exists(_wNFTTokenId), "wNFT not exists");
        } else if(wnftType == ETypes.AssetType.ERC1155) {
            require(IERC1155Mintable(_wNFTAddress).exists(_wNFTTokenId), "wNFT not exists");
        } else {
            revert UnSupportedAsset(
                ETypes.AssetItem(ETypes.Asset(wnftType,_wNFTAddress),_wNFTTokenId, 0)
            );
        }
        enabled = true; 
    }

    function _checkCoreUnwrap(
        ETypes.AssetType _wNFTType, 
        address _wNFTAddress, 
        uint256 _wNFTTokenId
    ) 
        internal 
        view 
        virtual 
        returns (address burnFor, uint256 burnBalance) 
    {
        

        if (_wNFTType == ETypes.AssetType.ERC721) {
            // Only token owner can UnWrap
            burnFor = IERC721Mintable(_wNFTAddress).ownerOf(_wNFTTokenId);
            require(burnFor == msg.sender, 
                'Only owner can unwrap it'
            ); 

        } else if (_wNFTType == ETypes.AssetType.ERC1155) {
            burnBalance = IERC1155Mintable(_wNFTAddress).totalSupply(_wNFTTokenId);
            burnFor = msg.sender;
            require(
                burnBalance ==
                IERC1155Mintable(_wNFTAddress).balanceOf(burnFor, _wNFTTokenId)
                ,'ERC115 unwrap available only for all totalSupply'
            );
            
        } else {
            revert UnSupportedAsset(ETypes.AssetItem(ETypes.Asset(_wNFTType,_wNFTAddress),_wNFTTokenId, 0));
        }
    }
}

File 2 of 30 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "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.
 */
abstract contract Ownable is Context {
    address private _owner;

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

File 3 of 30 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 4 of 30 : ERC721Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)

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 5 of 30 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

File 6 of 30 : ERC1155Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @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 7 of 30 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "IERC1155Receiver.sol";
import "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 8 of 30 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "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.
     *
     * NOTE: 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.
     *
     * NOTE: 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 9 of 30 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

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

pragma solidity ^0.8.0;

import "IERC165.sol";

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

File 11 of 30 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

File 12 of 30 : TokenServiceExtended.sol
// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT. Wrapper - main protocol contract
pragma solidity 0.8.21;

import "TokenService.sol";
import "IUsersSBT.sol";

/// @title Envelop PrtocolV1  helper service for manage ERC(20, 721, 115) getters
/// @author Envelop Team
/// @notice Just as dependence for main wrapper contract
abstract contract TokenServiceExtended is TokenService {
	

    function _balanceOf(
        ETypes.AssetItem memory _assetItem,
        address _holder
    ) internal view virtual returns (uint256 _balance){
        if (_assetItem.asset.assetType == ETypes.AssetType.NATIVE) {
            _balance = _holder.balance;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC20) {
            _balance = IERC20Extended(_assetItem.asset.contractAddress).balanceOf(_holder);
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC721) {
            _balance = IERC721Mintable(_assetItem.asset.contractAddress).balanceOf(_holder); 
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC1155) {
            _balance = IERC1155Mintable(_assetItem.asset.contractAddress).balanceOf(_holder, _assetItem.tokenId);
        } else {
            revert UnSupportedAsset(_assetItem);
        }
    }

    function _ownerOf(
        ETypes.AssetItem memory _assetItem
    ) internal view virtual returns (address _owner){
        if (_assetItem.asset.assetType == ETypes.AssetType.NATIVE) {
            _owner = address(0);
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC20) {
            _owner = address(0);
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC721) {
            _owner = IERC721Mintable(_assetItem.asset.contractAddress).ownerOf(_assetItem.tokenId); 
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC1155) {
            _owner = address(0);
        } else {
            revert UnSupportedAsset(_assetItem);
        }
    }

    function _mintWNFTWithRules(
        ETypes.AssetType _mint_type, 
        address _contract, 
        address _mintFor, 
        uint256 _outBalance,
        bytes2 _rules
    ) 
        internal 
        virtual
        returns(uint256 tokenId)
    {
        if (_mint_type == ETypes.AssetType.ERC721) {
            tokenId = IUsersSBT(_contract).mintWithRules(_mintFor, _rules);
        } else if (_mint_type == ETypes.AssetType.ERC1155) {
            tokenId = IUsersSBT(_contract).mintWithRules(_mintFor, _outBalance, _rules);
        }else {
            revert UnSupportedAsset(
                ETypes.AssetItem(
                    ETypes.Asset(_mint_type, _contract),
                    tokenId, _outBalance
                )
            );
        }
    }
}

File 13 of 30 : TokenService.sol
// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT. Wrapper - main protocol contract
pragma solidity 0.8.21;

import "SafeERC20.sol";
import "IERC20Extended.sol";
import "LibEnvelopTypes.sol";
import "IERC721Mintable.sol";
import "IERC1155Mintable.sol";

/// @title Envelop PrtocolV1  helper service for ERC(20, 721, 115) transfers
/// @author Envelop Team
/// @notice Just as dependence for main wrapper contract
abstract contract TokenService {
	using SafeERC20 for IERC20Extended;
    
    error UnSupportedAsset(ETypes.AssetItem asset);
	
    function _mintNFT(
        ETypes.AssetType _mint_type, 
        address _contract, 
        address _mintFor, 
        uint256 _tokenId, 
        uint256 _outBalance
    ) 
        internal 
        virtual
    {
        if (_mint_type == ETypes.AssetType.ERC721) {
            IERC721Mintable(_contract).mint(_mintFor, _tokenId);
        } else if (_mint_type == ETypes.AssetType.ERC1155) {
            IERC1155Mintable(_contract).mint(_mintFor, _tokenId, _outBalance);
        }else {
            revert UnSupportedAsset(
                ETypes.AssetItem(
                    ETypes.Asset(_mint_type, _contract),
                    _tokenId, _outBalance
                )
            );
        }
    }

    function _burnNFT(
        ETypes.AssetType _burn_type, 
        address _contract, 
        address _burnFor, 
        uint256 _tokenId, 
        uint256 _balance
    ) 
        internal
        virtual 
    {
        if (_burn_type == ETypes.AssetType.ERC721) {
            IERC721Mintable(_contract).burn(_tokenId);

        } else if (_burn_type == ETypes.AssetType.ERC1155) {
            IERC1155Mintable(_contract).burn(_burnFor, _tokenId, _balance);
        }
        
    }

    function _transfer(
        ETypes.AssetItem memory _assetItem,
        address _from,
        address _to
    ) internal virtual returns (bool _transfered){
        if (_assetItem.asset.assetType == ETypes.AssetType.NATIVE) {
            (bool success, ) = _to.call{ value: _assetItem.amount}("");
            require(success, "transfer failed");
            _transfered = true; 
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC20) {
            require(IERC20Extended(_assetItem.asset.contractAddress).balanceOf(_from) <= _assetItem.amount, "UPS!!!!");
            IERC20Extended(_assetItem.asset.contractAddress).safeTransferFrom(_from, _to, _assetItem.amount);
            _transfered = true;
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC721) {
            IERC721Mintable(_assetItem.asset.contractAddress).transferFrom(_from, _to, _assetItem.tokenId);
            _transfered = true;
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC1155) {
            IERC1155Mintable(_assetItem.asset.contractAddress).safeTransferFrom(_from, _to, _assetItem.tokenId, _assetItem.amount, "");
            _transfered = true;
        } else {
            revert UnSupportedAsset(_assetItem);
        }
        return _transfered;
    }

    function _transferSafe(
        ETypes.AssetItem memory _assetItem,
        address _from,
        address _to
    ) internal virtual returns (uint256 _transferedValue){
        //TODO   think about try catch in transfers
        uint256 balanceBefore;
        if (_assetItem.asset.assetType == ETypes.AssetType.NATIVE) {
            balanceBefore = _to.balance;
            (bool success, ) = _to.call{ value: _assetItem.amount}("");
            require(success, "transfer failed");
            _transferedValue = _to.balance - balanceBefore;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC20) {
            balanceBefore = IERC20Extended(_assetItem.asset.contractAddress).balanceOf(_to);
            if (_from == address(this)){
                IERC20Extended(_assetItem.asset.contractAddress).safeTransfer(_to, _assetItem.amount);
            } else {
                IERC20Extended(_assetItem.asset.contractAddress).safeTransferFrom(_from, _to, _assetItem.amount);
            }    
            _transferedValue = IERC20Extended(_assetItem.asset.contractAddress).balanceOf(_to) - balanceBefore;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC721 &&
            IERC721Mintable(_assetItem.asset.contractAddress).ownerOf(_assetItem.tokenId) == _from) {
            balanceBefore = IERC721Mintable(_assetItem.asset.contractAddress).balanceOf(_to); 
            IERC721Mintable(_assetItem.asset.contractAddress).transferFrom(_from, _to, _assetItem.tokenId);
            if (IERC721Mintable(_assetItem.asset.contractAddress).ownerOf(_assetItem.tokenId) == _to &&
                IERC721Mintable(_assetItem.asset.contractAddress).balanceOf(_to) - balanceBefore == 1
                ) {
                _transferedValue = 1;
            }
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC1155) {
            balanceBefore = IERC1155Mintable(_assetItem.asset.contractAddress).balanceOf(_to, _assetItem.tokenId);
            IERC1155Mintable(_assetItem.asset.contractAddress).safeTransferFrom(_from, _to, _assetItem.tokenId, _assetItem.amount, "");
            _transferedValue = IERC1155Mintable(_assetItem.asset.contractAddress).balanceOf(_to, _assetItem.tokenId) - balanceBefore;
        
        } else {
            revert UnSupportedAsset(_assetItem);
        }
        return _transferedValue;
    }

    // This function must never revert. Use it for unwrap in case some 
    // collateral transfers are revert
    function _transferEmergency(
        ETypes.AssetItem memory _assetItem,
        address _from,
        address _to
    ) internal virtual returns (uint256 _transferedValue){
        //TODO   think about try catch in transfers
        uint256 balanceBefore;
        if (_assetItem.asset.assetType == ETypes.AssetType.NATIVE) {
            balanceBefore = _to.balance;
            (bool success, ) = _to.call{ value: _assetItem.amount}("");
            //require(success, "transfer failed");
            _transferedValue = _to.balance - balanceBefore;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC20) {
            if (_from == address(this)){
               (bool success, ) = _assetItem.asset.contractAddress.call(
                   abi.encodeWithSignature("transfer(address,uint256)", _to, _assetItem.amount)
               );
            } else {
                (bool success, ) = _assetItem.asset.contractAddress.call(
                    abi.encodeWithSignature("transferFrom(address,address,uint256)", _from,  _to, _assetItem.amount)
                );
            }    
            _transferedValue = _assetItem.amount;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC721) {
            (bool success, ) = _assetItem.asset.contractAddress.call(
                abi.encodeWithSignature("transferFrom(address,address,uint256)", _from,  _to, _assetItem.tokenId)
            );
            _transferedValue = 1;
        
        } else if (_assetItem.asset.assetType == ETypes.AssetType.ERC1155) {
            (bool success, ) = _assetItem.asset.contractAddress.call(
                abi.encodeWithSignature("safeTransferFrom(address,address,uint256,uint256,bytes)", _from, _to, _assetItem.tokenId, _assetItem.amount, "")
            );
            _transferedValue = _assetItem.amount;
        
        } else {
            revert UnSupportedAsset(_assetItem);
        }
        return _transferedValue;
    }
}

File 14 of 30 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Permit.sol";
import "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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 15 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 16 of 30 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 17 of 30 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 18 of 30 : IERC20Extended.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "IERC20.sol";

interface IERC20Extended is  IERC20 {
     function mint(address _to, uint256 _value) external;
}

File 19 of 30 : LibEnvelopTypes.sol
// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT. 
pragma solidity 0.8.21;

/// @title Flibrary ETypes in Envelop PrtocolV1 
/// @author Envelop Team
/// @notice This contract implement main protocol's data types
library ETypes {

    enum AssetType {EMPTY, NATIVE, ERC20, ERC721, ERC1155, FUTURE1, FUTURE2, FUTURE3}
    
    struct Asset {
        AssetType assetType;
        address contractAddress;
    }

    struct AssetItem {
        Asset asset;
        uint256 tokenId;
        uint256 amount;
    }

    struct NFTItem {
        address contractAddress;
        uint256 tokenId;   
    }

    struct Fee {
        bytes1 feeType;
        uint256 param;
        address token; 
    }

    struct Lock {
        bytes1 lockType;
        uint256 param; 
    }

    struct Royalty {
        address beneficiary;
        uint16 percent;
    }

    struct WNFT {
        AssetItem inAsset;
        AssetItem[] collateral;
        address unWrapDestination;
        Fee[] fees;
        Lock[] locks;
        Royalty[] royalties;
        bytes2 rules;

    }

    struct INData {
        AssetItem inAsset;
        address unWrapDestination;
        Fee[] fees;
        Lock[] locks;
        Royalty[] royalties;
        AssetType outType;
        uint256 outBalance;      //0- for 721 and any amount for 1155
        bytes2 rules;

    }

    struct WhiteListItem {
        bool enabledForFee;
        bool enabledForCollateral;
        bool enabledRemoveFromCollateral;
        address transferFeeModel;
    }

    struct Rules {
        bytes2 onlythis;
        bytes2 disabled;
    }

}

File 20 of 30 : IERC721Mintable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "IERC721Metadata.sol";

interface IERC721Mintable is  IERC721Metadata {
     function mint(address _to, uint256 _tokenId) external;
     function burn(uint256 _tokenId) external;
     function exists(uint256 _tokenId) external view returns(bool);
}

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

pragma solidity ^0.8.0;

import "IERC721.sol";

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

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

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

File 22 of 30 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "IERC165.sol";

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

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

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

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

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

File 23 of 30 : IERC1155Mintable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "IERC1155MetadataURI.sol";

interface IERC1155Mintable is  IERC1155MetadataURI {
     function mint(address _to, uint256 _tokenId, uint256 _amount) external;
     function burn(address _to, uint256 _tokenId, uint256 _amount) external;
     function totalSupply(uint256 _id) external view returns (uint256); 
     function exists(uint256 _tokenId) external view returns(bool);
}

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

pragma solidity ^0.8.0;

import "IERC1155.sol";

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

File 25 of 30 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "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 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 26 of 30 : IUsersSBT.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;


interface IUsersSBT  {

    function mintWithRules(
        address _to,  
        bytes2 _rules
    ) external returns(uint256 tokenId); 
    
    function mintWithRules(
        address _to,  
        uint256 _balance, 
        bytes2 _rules
    ) external returns(uint256 tokenId);

    function owner() external view returns(address);
   
}

File 27 of 30 : IWrapperUsers.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

import "IWrapper.sol";

interface IWrapperUsers is IWrapper  {

    function wrapIn(
        ETypes.INData calldata _inData, 
        ETypes.AssetItem[] calldata _collateral, 
        address _wrappFor,
        address _wrappIn
    ) 
        external
        payable
        returns (ETypes.AssetItem memory); 

   
}

File 28 of 30 : IWrapper.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;

//import "IERC721Enumerable.sol";
import "LibEnvelopTypes.sol";

interface IWrapper  {

    event WrappedV1(
        address indexed inAssetAddress,
        address indexed outAssetAddress, 
        uint256 indexed inAssetTokenId, 
        uint256 outTokenId,
        address wnftFirstOwner,
        uint256 nativeCollateralAmount,
        bytes2  rules
    );

    event UnWrappedV1(
        address indexed wrappedAddress,
        address indexed originalAddress,
        uint256 indexed wrappedId, 
        uint256 originalTokenId, 
        address beneficiary, 
        uint256 nativeCollateralAmount,
        bytes2  rules 
    );

    event CollateralAdded(
        address indexed wrappedAddress,
        uint256 indexed wrappedId,
        uint8   assetType,
        address collateralAddress,
        uint256 collateralTokenId,
        uint256 collateralBalance
    );

    event PartialUnWrapp(
        address indexed wrappedAddress,
        uint256 indexed wrappedId,
        uint256 lastCollateralIndex
    );
    event SuspiciousFail(
        address indexed wrappedAddress,
        uint256 indexed wrappedId, 
        address indexed failedContractAddress
    );

    event EnvelopFee(
        address indexed receiver,
        address indexed wNFTConatract,
        uint256 indexed wNFTTokenId,
        uint256 amount
    );

    function wrap(
        ETypes.INData calldata _inData, 
        ETypes.AssetItem[] calldata _collateral, 
        address _wrappFor
    ) 
        external 
        payable 
    returns (ETypes.AssetItem memory);

    // function wrapUnsafe(
    //     ETypes.INData calldata _inData, 
    //     ETypes.AssetItem[] calldata _collateral, 
    //     address _wrappFor
    // ) 
    //     external 
    //     payable
    // returns (ETypes.AssetItem memory);

    function addCollateral(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        ETypes.AssetItem[] calldata _collateral
    ) external payable;

    // function addCollateralUnsafe(
    //     address _wNFTAddress, 
    //     uint256 _wNFTTokenId, 
    //     ETypes.AssetItem[] calldata _collateral
    // ) 
    //     external 
    //     payable;

    function unWrap(
        address _wNFTAddress, 
        uint256 _wNFTTokenId
    ) external; 

    function unWrap(
        ETypes.AssetType _wNFTType, 
        address _wNFTAddress, 
        uint256 _wNFTTokenId
    ) external; 

    function unWrap(
        ETypes.AssetType _wNFTType, 
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        bool _isEmergency
    ) external;

    function chargeFees(
        address _wNFTAddress, 
        uint256 _wNFTTokenId, 
        address _from, 
        address _to,
        bytes1 _feeType
    ) 
        external  
        returns (bool);   

    ////////////////////////////////////////////////////////////////////// 
    
    function MAX_COLLATERAL_SLOTS() external view returns (uint256);
    function protocolTechToken() external view returns (address);
    function protocolWhiteList() external view returns (address);

    function getWrappedToken(address _wNFTAddress, uint256 _wNFTTokenId) 
        external 
        view 
        returns (ETypes.WNFT memory);

    function getOriginalURI(address _wNFTAddress, uint256 _wNFTTokenId) 
        external 
        view 
        returns(string memory); 
    
    function getCollateralBalanceAndIndex(
        address _wNFTAddress, 
        uint256 _wNFTTokenId,
        ETypes.AssetType _collateralType, 
        address _erc,
        uint256 _tokenId
    ) external view returns (uint256, uint256);
   
}

File 29 of 30 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "IERC721.sol";

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

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

    /**
     * @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 30 of 30 : IUserCollectionRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.21;
import "LibEnvelopTypes.sol";

interface IUserCollectionRegistry {


    function getUsersCollections(address _user) 
        external 
        view 
        returns(ETypes.Asset[] memory);
   
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_usersWNFTRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"asset","type":"tuple"}],"name":"UnSupportedAsset","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wrappedAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"wrappedId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"assetType","type":"uint8"},{"indexed":false,"internalType":"address","name":"collateralAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralBalance","type":"uint256"}],"name":"CollateralAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"wNFTConatract","type":"address"},{"indexed":true,"internalType":"uint256","name":"wNFTTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EnvelopFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wrappedAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"wrappedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastCollateralIndex","type":"uint256"}],"name":"PartialUnWrapp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wrappedAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"wrappedId","type":"uint256"},{"indexed":true,"internalType":"address","name":"failedContractAddress","type":"address"}],"name":"SuspiciousFail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wrappedAddress","type":"address"},{"indexed":true,"internalType":"address","name":"originalAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"wrappedId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"originalTokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"nativeCollateralAmount","type":"uint256"},{"indexed":false,"internalType":"bytes2","name":"rules","type":"bytes2"}],"name":"UnWrappedV1","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"inAssetAddress","type":"address"},{"indexed":true,"internalType":"address","name":"outAssetAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"inAssetTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outTokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"wnftFirstOwner","type":"address"},{"indexed":false,"internalType":"uint256","name":"nativeCollateralAmount","type":"uint256"},{"indexed":false,"internalType":"bytes2","name":"rules","type":"bytes2"}],"name":"WrappedV1","type":"event"},{"inputs":[],"name":"MAX_COLLATERAL_SLOTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"_collateral","type":"tuple[]"}],"name":"addCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"bytes1","name":"_feeType","type":"bytes1"}],"name":"chargeFees","outputs":[{"internalType":"bool","name":"charged","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"},{"internalType":"enum ETypes.AssetType","name":"_collateralType","type":"uint8"},{"internalType":"address","name":"_erc","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getCollateralBalanceAndIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nftAddress","type":"address"},{"internalType":"uint256","name":"_nftTokenId","type":"uint256"}],"name":"getNFTType","outputs":[{"internalType":"enum ETypes.AssetType","name":"nftType","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"}],"name":"getOriginalURI","outputs":[{"internalType":"string","name":"uri_","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"}],"name":"getWrappedToken","outputs":[{"components":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"inAsset","type":"tuple"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"collateral","type":"tuple[]"},{"internalType":"address","name":"unWrapDestination","type":"address"},{"components":[{"internalType":"bytes1","name":"feeType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct ETypes.Fee[]","name":"fees","type":"tuple[]"},{"components":[{"internalType":"bytes1","name":"lockType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"}],"internalType":"struct ETypes.Lock[]","name":"locks","type":"tuple[]"},{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"internalType":"struct ETypes.Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"bytes2","name":"rules","type":"bytes2"}],"internalType":"struct ETypes.WNFT","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"protocolTechToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolWhiteList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ETypes.AssetType","name":"_wNFTType","type":"uint8"},{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"},{"internalType":"bool","name":"_isEmergency","type":"bool"}],"name":"unWrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ETypes.AssetType","name":"_wNFTType","type":"uint8"},{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"}],"name":"unWrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wNFTAddress","type":"address"},{"internalType":"uint256","name":"_wNFTTokenId","type":"uint256"}],"name":"unWrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usersCollectionRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"inAsset","type":"tuple"},{"internalType":"address","name":"unWrapDestination","type":"address"},{"components":[{"internalType":"bytes1","name":"feeType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct ETypes.Fee[]","name":"fees","type":"tuple[]"},{"components":[{"internalType":"bytes1","name":"lockType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"}],"internalType":"struct ETypes.Lock[]","name":"locks","type":"tuple[]"},{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"internalType":"struct ETypes.Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"enum ETypes.AssetType","name":"outType","type":"uint8"},{"internalType":"uint256","name":"outBalance","type":"uint256"},{"internalType":"bytes2","name":"rules","type":"bytes2"}],"internalType":"struct ETypes.INData","name":"_inData","type":"tuple"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"_collateral","type":"tuple[]"},{"internalType":"address","name":"_wrappFor","type":"address"}],"name":"wrap","outputs":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"inAsset","type":"tuple"},{"internalType":"address","name":"unWrapDestination","type":"address"},{"components":[{"internalType":"bytes1","name":"feeType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct ETypes.Fee[]","name":"fees","type":"tuple[]"},{"components":[{"internalType":"bytes1","name":"lockType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"}],"internalType":"struct ETypes.Lock[]","name":"locks","type":"tuple[]"},{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"internalType":"struct ETypes.Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"enum ETypes.AssetType","name":"outType","type":"uint8"},{"internalType":"uint256","name":"outBalance","type":"uint256"},{"internalType":"bytes2","name":"rules","type":"bytes2"}],"internalType":"struct ETypes.INData","name":"_inData","type":"tuple"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"_collateral","type":"tuple[]"},{"internalType":"address","name":"_wrappFor","type":"address"},{"internalType":"address","name":"_wrappIn","type":"address"}],"name":"wrapIn","outputs":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"","type":"tuple"}],"stateMutability":"payable","type":"function"}]

60a060405260646001553480156200001657600080fd5b5060405162004544380380620045448339810160408190526200003991620000ab565b60016000556001600160a01b038116620000995760405162461bcd60e51b815260206004820152601a60248201527f4f6e6c7920666f72206e6f6e207a65726f207265676973747279000000000000604482015260640160405180910390fd5b6001600160a01b0316608052620000dd565b600060208284031215620000be57600080fd5b81516001600160a01b0381168114620000d657600080fd5b9392505050565b60805161444462000100600039600081816102080152611faf01526144446000f3fe6080604052600436106101145760003560e01c806391ddb146116100a0578063bc197c8111610064578063bc197c8114610314578063c424d4f714610340578063f1551a9c1461036d578063f23a6e61146103a2578063faf7d720146103ce57600080fd5b806391ddb1461461027d578063980550ca146102905780639a7b0509146102b4578063a5041040146102e1578063a76537d51461030157600080fd5b806342fb01a8116100e757806342fb01a8146101b45780634d36d085146101d657806355034487146101f65780635f4688c51461022a5780637f6d4c931461025757600080fd5b806301ffc9a71461011957806310118ebb1461014e578063150b7a021461017b578063331758e61461014e575b600080fd5b34801561012557600080fd5b50610139610134366004613531565b6103ee565b60405190151581526020015b60405180910390f35b34801561015a57600080fd5b50610163600081565b6040516001600160a01b039091168152602001610145565b34801561018757600080fd5b5061019b61019636600461365e565b610425565b6040516001600160e01b03199091168152602001610145565b3480156101c057600080fd5b506101d46101cf3660046136e4565b610436565b005b6101e96101e436600461379b565b61051a565b6040516101459190613879565b34801561020257600080fd5b506101637f000000000000000000000000000000000000000000000000000000000000000081565b34801561023657600080fd5b5061024a610245366004613887565b610549565b60405161014591906138b3565b34801561026357600080fd5b506101396102723660046138d7565b506001949350505050565b6101d461028b36600461393f565b61055c565b34801561029c57600080fd5b506102a660015481565b604051908152602001610145565b3480156102c057600080fd5b506102d46102cf366004613887565b6105d8565b60405161014591906139be565b3480156102ed57600080fd5b506101d46102fc3660046139f1565b6106fb565b6101e961030f366004613a32565b61070d565b34801561032057600080fd5b5061019b61032f366004613b3d565b63bc197c8160e01b95945050505050565b34801561034c57600080fd5b5061036061035b366004613887565b61097b565b6040516101459190613d15565b34801561037957600080fd5b5061038d610388366004613de2565b610ceb565b60408051928352602083019190915201610145565b3480156103ae57600080fd5b5061019b6103bd366004613e3d565b63f23a6e6160e01b95945050505050565b3480156103da57600080fd5b506101d46103e9366004613887565b610ec2565b60006001600160e01b03198216630271189760e51b148061041f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b630a85bd0160e11b5b949350505050565b61043e610edc565b60008061044c868686610f35565b9092509050600061046286866001600080610ceb565b5090506104708686866111dd565b61047c5750505061050a565b6104898787858886611820565b6000610495878761097b565b905085816000015160000151602001516001600160a01b0316886001600160a01b03167fabb50c1815800da62a4637d3272d1584df1ee8cbd963d90fb44eb55b63acfcb58460000151602001518560400151878760c001516040516104fd9493929190613ea5565b60405180910390a4505050505b6105146001600055565b50505050565b6040805160a081018252600060608201818152608083018290528252602082018190529181019190915261042e565b60006105558383611922565b9392505050565b8015158061056a5750600034115b156105145761057b84848484611a7c565b6105cc5760405162461bcd60e51b815260206004820152601860248201527f466f7262696464656e2061646420636f6c6c61746572616c000000000000000060448201526064015b60405180910390fd5b61051484848484611cd1565b606060006105e6848461097b565b519050600381515160078111156105ff576105ff61380b565b0361068b5780516020908101519082015160405163c87b56dd60e01b81526001600160a01b039092169163c87b56dd9161063f9160040190815260200190565b600060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106849190810190613ed3565b91506106f4565b600481515160078111156106a1576106a161380b565b036106e1578051602090810151908201516040516303a24d0760e21b81526001600160a01b0390921691630e89341c9161063f9160040190815260200190565b6040518060200160405280600081525091505b5092915050565b6107088383836000610436565b505050565b6040805160a081018252600060608201818152608083018290528252602082018190529181019190915261073f610edc565b61074a868484611f8d565b6107885760405162461bcd60e51b815260206004820152600f60248201526e15dc985c0818da1958dac819985a5b608a1b60448201526064016105c3565b60006107be61079f61012089016101008a01613f40565b84866101208b01356107b96101608d016101408e01613f5d565b6120f9565b90506107cb838289612254565b60016107da6020890189613f40565b60078111156107eb576107eb61380b565b14158015610817575060006108036020890189613f40565b60078111156108145761081461380b565b14155b156108875761083561082e36899003890189613f87565b33306124e0565b61083e88612b3d565b146108875760405162461bcd60e51b81526020600482015260196024820152780537573706963696f757320617373657420666f72207772617603c1b60448201526064016105c3565b6108938382888861055c565b604087018035906001600160a01b038516906108b29060208b0161401b565b6001600160a01b03167fa90a3b8dae41ae10a708d32fec7bf12da5c90879c98b9c4cca3c8fba91ddf4938488348d6101400160208101906108f39190613f5d565b6040516109039493929190613ea5565b60405180910390a46040805160a0810190915280606081018061092e6101208c016101008d01613f40565b600781111561093f5761093f61380b565b8152602001866001600160a01b031681525081526020018281526020018861012001358152509150506109726001600055565b95945050505050565b604080516101808101825260006101408201818152610160830182905260e083019081526101008301829052610120830182905282526060602083018190529282018190528282018390526080820183905260a082019290925260c08101919091526001600160a01b038316600090815260026020908152604080832085845290915290819020815161018081019092528054829060e0820190839082906101408501908390829060ff166007811115610a3757610a3761380b565b6007811115610a4857610a4861380b565b8152905461010090046001600160a01b031660209182015290825260018301548282015260029092015460409182015291835260038401805483518184028101840190945280845293820193909160009084015b82821015610b33576000848152602090206040805160a08101909152600384029091018054829060608201908390829060ff166007811115610ae057610ae061380b565b6007811115610af157610af161380b565b8152905461010090046001600160a01b031660209182015290825260018381015483830152600290930154604090920191909152918352929092019101610a9c565b5050509082525060048201546001600160a01b0316602080830191909152600583018054604080518285028101850182528281529401939260009084015b82821015610bd35760008481526020908190206040805160608101825260038602909201805460f81b6001600160f81b0319168352600180820154848601526002909101546001600160a01b0316918301919091529083529092019101610b71565b50505050815260200160068201805480602002602001604051908101604052809291908181526020016000905b82821015610c4c5760008481526020908190206040805180820190915260028502909101805460f81b6001600160f81b0319168252600190810154828401529083529092019101610c00565b50505050815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015610cc357600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b900461ffff1681830152825260019092019101610c79565b505050908252506008919091015460f01b6001600160f01b0319166020909101529392505050565b60008060005b6001600160a01b03881660009081526002602090815260408083208a8452909152902060030154811015610eb6576001600160a01b0388811660009081526002602090815260408083208b8452909152902060030180549187169183908110610d5c57610d5c614038565b600091825260209091206003909102015461010090046001600160a01b0316148015610dd257506001600160a01b03881660009081526002602090815260408083208a84529091529020600301805485919083908110610dbe57610dbe614038565b906000526020600020906003020160010154145b8015610e4a5750856007811115610deb57610deb61380b565b6001600160a01b03891660009081526002602090815260408083208b84529091529020600301805483908110610e2357610e23614038565b600091825260209091206003909102015460ff166007811115610e4857610e4861380b565b145b15610ea4576001600160a01b03881660009081526002602090815260408083208a84529091529020600301805482908110610e8757610e87614038565b906000526020600020906003020160020154819250925050610eb8565b80610eae81614064565b915050610cf1565b505b9550959350505050565b610ed8610ecf8383611922565b83836000610436565b5050565b600260005403610f2e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105c3565b6002600055565b6000806003856007811115610f4c57610f4c61380b565b03611019576040516331a9108f60e11b8152600481018490526001600160a01b03851690636352211e90602401602060405180830381865afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fba919061407d565b91506001600160a01b03821633146110145760405162461bcd60e51b815260206004820152601860248201527f4f6e6c79206f776e65722063616e20756e77726170206974000000000000000060448201526064016105c3565b6111d5565b600485600781111561102d5761102d61380b565b036111765760405163bd85b03960e01b8152600481018490526001600160a01b0385169063bd85b03990602401602060405180830381865afa158015611077573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109b919061409a565b604051627eeac760e11b815233600482018190526024820186905293509091506001600160a01b0385169062fdd58e90604401602060405180830381865afa1580156110eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110f919061409a565b81146110145760405162461bcd60e51b815260206004820152603060248201527f45524331313520756e7772617020617661696c61626c65206f6e6c7920666f7260448201526f20616c6c20746f74616c537570706c7960801b60648201526084016105c3565b6040805160a081019091528060608101808860078111156111995761119961380b565b8152602001876001600160a01b03168152508152602001848152602001600081525060405163391102fb60e01b81526004016105c39190613879565b935093915050565b6001600160a01b038381166000908152600260209081526040808320868452909152812060040154909182913391161561123c57506001600160a01b038086166000908152600260209081526040808320888452909152902060040154165b60005b6001600160a01b0387166000908152600260209081526040808320898452909152902060030154811015611649576001600160a01b038716600090815260026020908152604080832089845290915281206003018054839081106112a5576112a5614038565b600091825260209091206003909102015460ff1660078111156112ca576112ca61380b565b1461159f57841561139d576001600160a01b03871660009081526002602090815260408083208984529091529020600301805461139691908390811061131257611312614038565b600091825260209091206040805160a081019091526003909202018054829060608201908390829060ff16600781111561134e5761134e61380b565b600781111561135f5761135f61380b565b8152905461010090046001600160a01b03166020918201529082526001830154908201526002909101546040909101523084612b74565b9250611461565b6001600160a01b03871660009081526002602090815260408083208984529091529020600301805461145e9190839081106113da576113da614038565b600091825260209091206040805160a081019091526003909202018054829060608201908390829060ff1660078111156114165761141661380b565b60078111156114275761142761380b565b8152905461010090046001600160a01b031660209182015290825260018301549082015260029091015460409091015230846124e0565b92505b6001600160a01b0387166000908152600260209081526040808320898452909152902060030180548290811061149957611499614038565b9060005260206000209060030201600201548314611537576001600160a01b038716600090815260026020908152604080832089845290915290206003018054829081106114e9576114e9614038565b600091825260208220600390910201546040516001600160a01b0361010090920482169289928b16917ffca203c3f6987c2a1dae80f773c277d67920e7bce0cea9c07cd0eb8142e985ca9190a45b6001600160a01b0387166000908152600260209081526040808320898452909152812060030180548390811061156f5761156f614038565b60009182526020909120600390910201805460ff191660018360078111156115995761159961380b565b02179055505b6103e85a111580156115e257506001600160a01b03871660009081526002602090815260408083208984529091529020600301546115df906001906140b3565b81105b156116375785876001600160a01b03167fd66d44264f9d44e254da71183ff08098f38da4675285592ee80cdbd3b6f5153e8360405161162391815260200190565b60405180910390a360009350505050610555565b8061164181614064565b91505061123f565b5060016001600160a01b038716600090815260026020908152604080832089845290915290205460ff1660078111156116845761168461380b565b141580156116c857506001600160a01b038616600090815260026020908152604080832088845290915281205460ff1660078111156116c5576116c561380b565b14155b156118145783611775576001600160a01b038616600090815260026020908152604080832088845290915290819020815160a08101909252805461176f929190829060608201908390829060ff1660078111156117275761172761380b565b60078111156117385761173861380b565b8152905461010090046001600160a01b031660209182015290825260018301549082015260029091015460409091015230836124e0565b50611814565b6001600160a01b038616600090815260026020908152604080832088845290915290819020815160a081019092528054611812929190829060608201908390829060ff1660078111156117ca576117ca61380b565b60078111156117db576117db61380b565b8152905461010090046001600160a01b03166020918201529082526001830154908201526002909101546040909101523083612b74565b505b50600195945050505050565b60038560078111156118345761183461380b565b0361189857604051630852cd8d60e31b8152600481018390526001600160a01b038516906342966c6890602401600060405180830381600087803b15801561187b57600080fd5b505af115801561188f573d6000803e3d6000fd5b5050505061191b565b60048560078111156118ac576118ac61380b565b0361191b57604051637a94c56560e11b81526001600160a01b038481166004830152602482018490526044820183905285169063f5298aca90606401600060405180830381600087803b15801561190257600080fd5b505af1158015611916573d6000803e3d6000fd5b505050505b5050505050565b6040516301ffc9a760e01b81526380ac58cd60e01b60048201526000906001600160a01b038416906301ffc9a790602401602060405180830381865afa158015611970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199491906140c6565b156119a15750600361041f565b6040516301ffc9a760e01b8152636cdb3d1360e11b60048201526001600160a01b038416906301ffc9a790602401602060405180830381865afa1580156119ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1091906140c6565b15611a1d5750600461041f565b6040805160a08101909152806060810180846007811115611a4057611a4061380b565b8152602001866001600160a01b03168152508152602001838152602001600081525060405163391102fb60e01b81526004016105c39190613879565b6000336001600160a01b0316856001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aea919061407d565b6001600160a01b031614611b585760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c7920774e465420636f6e7472616374206f776e65722061626c6520746f60448201526e081859190818dbdb1b185d195c985b608a1b60648201526084016105c3565b6000611b648686611922565b90506003816007811115611b7a57611b7a61380b565b03611c2c57604051634f558e7960e01b8152600481018690526001600160a01b03871690634f558e79906024015b602060405180830381865afa158015611bc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be991906140c6565b611c275760405162461bcd60e51b815260206004820152600f60248201526e774e4654206e6f742065786973747360881b60448201526064016105c3565b611814565b6004816007811115611c4057611c4061380b565b03611c7257604051634f558e7960e01b8152600481018690526001600160a01b03871690634f558e7990602401611ba8565b6040805160a08101909152806060810180846007811115611c9557611c9561380b565b8152602001896001600160a01b03168152508152602001868152602001600081525060405163391102fb60e01b81526004016105c39190613879565b3415611d65576040805160a08101909152611d109085908590806060810180600181526000602091820181905291835282015234604090910152612f45565b604080516001815260006020820181905281830152346060820152905184916001600160a01b038716917ff3d1350815c4f9db2be36c35f840bfb002835a83ff1c3d8f3a217b1e6227d5aa9181900360800190a35b60005b8181101561191b576001838383818110611d8457611d84614038565b611d9a9260206080909202019081019150613f40565b6007811115611dab57611dab61380b565b14611f7b57611ddb838383818110611dc557611dc5614038565b90506080020180360381019061082e9190613f87565b611dfb848484818110611df057611df0614038565b905060800201612b3d565b14611e445760405162461bcd60e51b81526020600482015260196024820152780537573706963696f757320617373657420666f72207772617603c1b60448201526064016105c3565b611e768585858585818110611e5b57611e5b614038565b905060800201803603810190611e719190613f87565b612f45565b83856001600160a01b03167ff3d1350815c4f9db2be36c35f840bfb002835a83ff1c3d8f3a217b1e6227d5aa858585818110611eb457611eb4614038565b611eca9260206080909202019081019150613f40565b6007811115611edb57611edb61380b565b868686818110611eed57611eed614038565b611f06926040608090920201908101915060200161401b565b878787818110611f1857611f18614038565b90506080020160400135888888818110611f3457611f34614038565b90506080020160600135604051611f72949392919060ff9490941684526001600160a01b039290921660208401526040830152606082015260800190565b60405180910390a35b80611f8581614064565b915050611d68565b60405163e1e3c08d60e01b815233600482015260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e1e3c08d90602401600060405180830381865afa158015611ff6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261201e91908101906140e3565b90506000805b82518110156120d857846001600160a01b031683828151811061204957612049614038565b6020026020010151602001516001600160a01b03161480156120ba575061207861012088016101008901613f40565b60078111156120895761208961380b565b83828151811061209b5761209b614038565b60200260200101516000015160078111156120b8576120b861380b565b145b156120c857600191506120d8565b6120d181614064565b9050612024565b506001600160a01b03851630148015906120ef5750805b9695505050505050565b6000600386600781111561210f5761210f61380b565b036121985760405163288f5b4760e11b81526001600160a01b0385811660048301526001600160f01b03198416602483015286169063511eb68e906044015b6020604051808303816000875af115801561216d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612191919061409a565b9050610972565b60048660078111156121ac576121ac61380b565b036121f657604051635d2d7c2f60e11b81526001600160a01b038581166004830152602482018590526001600160f01b03198416604483015286169063ba5af85e9060640161214e565b6040805160a081019091528060608101808960078111156122195761221961380b565b8152602001886001600160a01b031681525081526020018281526020018481525060405163391102fb60e01b81526004016105c39190613879565b6001600160a01b03831660009081526002602090815260408083208584529091529020819061228382826141a0565b50506001600160a01b0383166000908152600260209081526040808320858452909152902060040180546001600160a01b03191690556122cb61016082016101408301613f5d565b6001600160a01b03841660009081526002602090815260408083208684529091528120600801805461ffff191660f09390931c929092179091555b61231360a0830183614223565b90508110156123a2576001600160a01b0384166000908152600260209081526040808320868452909152902060050161234f60a0840184614223565b8381811061235f5761235f614038565b83546001810185556000948552602090942060609091029290920192600302909101905061238d828261428b565b5050808061239a90614064565b915050612306565b5060005b6123b360c08301836142ca565b9050811015612442576001600160a01b038416600090815260026020908152604080832086845290915290206006016123ef60c08401846142ca565b838181106123ff576123ff614038565b83546001810185556000948552602090942060409091029290920192600202909101905061242d8282614313565b5050808061243a90614064565b9150506123a6565b5060005b61245360e08301836142ca565b9050811015610514576001600160a01b0384166000908152600260209081526040808320868452909152902060070161248f60e08401846142ca565b8381811061249f5761249f614038565b835460018101855560009485526020909420604090910292909201929190910190506124cb828261433b565b505080806124d890614064565b915050612446565b600080600185515160078111156124f9576124f961380b565b036125b3575060408085015190516001600160a01b0384168031926000928381818185875af1925050503d806000811461254f576040519150601f19603f3d011682016040523d82523d6000602084013e612554565b606091505b50509050806125975760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016105c3565b6125ab826001600160a01b038616316140b3565b925050612b35565b600285515160078111156125c9576125c961380b565b0361271f578451602001516040516370a0823160e01b81526001600160a01b038581166004830152909116906370a0823190602401602060405180830381865afa15801561261b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263f919061409a565b9050306001600160a01b03851603612678576040850151855160200151612673916001600160a01b03909116908590613194565b61269c565b604085015185516020015161269c916001600160a01b0390911690869086906131f7565b8451602001516040516370a0823160e01b81526001600160a01b038581166004830152839216906370a08231906024015b602060405180830381865afa1580156126ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270e919061409a565b61271891906140b3565b9150612b35565b600385515160078111156127355761273561380b565b1480156127c157508451602090810151908601516040516331a9108f60e11b815260048101919091526001600160a01b03868116921690636352211e90602401602060405180830381865afa158015612792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b6919061407d565b6001600160a01b0316145b156129cb578451602001516040516370a0823160e01b81526001600160a01b038581166004830152909116906370a0823190602401602060405180830381865afa158015612813573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612837919061409a565b90508460000151602001516001600160a01b03166323b872dd858588602001516040518463ffffffff1660e01b815260040161287593929190614383565b600060405180830381600087803b15801561288f57600080fd5b505af11580156128a3573d6000803e3d6000fd5b50505050826001600160a01b03168560000151602001516001600160a01b0316636352211e87602001516040518263ffffffff1660e01b81526004016128eb91815260200190565b602060405180830381865afa158015612908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292c919061407d565b6001600160a01b03161480156129bc57508451602001516040516370a0823160e01b81526001600160a01b038581166004830152839216906370a0823190602401602060405180830381865afa15801561298a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ae919061409a565b6129b891906140b3565b6001145b156129c657600191505b612b35565b600485515160078111156129e1576129e161380b565b03612b1a57845160209081015190860151604051627eeac760e11b81526001600160a01b038681166004830152602482019290925291169062fdd58e90604401602060405180830381865afa158015612a3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a62919061409a565b90508460000151602001516001600160a01b031663f242432a8585886020015189604001516040518563ffffffff1660e01b8152600401612aa694939291906143a7565b600060405180830381600087803b158015612ac057600080fd5b505af1158015612ad4573d6000803e3d6000fd5b5050865160209081015190880151604051627eeac760e11b81526001600160a01b03888116600483015260248201929092528594509116915062fdd58e906044016126cd565b8460405163391102fb60e01b81526004016105c39190613879565b509392505050565b60006003612b4e6020840184613f40565b6007811115612b5f57612b5f61380b565b03612b6c57506001919050565b506060013590565b60008060018551516007811115612b8d57612b8d61380b565b03612c02575060408085015190516001600160a01b0384168031926000928381818185875af1925050503d8060008114612be3576040519150601f19603f3d011682016040523d82523d6000602084013e612be8565b606091505b5050905081846001600160a01b0316316125ab91906140b3565b60028551516007811115612c1857612c1861380b565b03612da257306001600160a01b03851603612ced5760008560000151602001516001600160a01b0316848760400151604051602401612c6c9291906001600160a01b03929092168252602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b17905251612ca191906143df565b6000604051808303816000865af19150503d8060008114612cde576040519150601f19603f3d011682016040523d82523d6000602084013e612ce3565b606091505b5050905050612d96565b60008560000151602001516001600160a01b031685858860400151604051602401612d1a93929190614383565b60408051601f198184030181529181526020820180516001600160e01b03166323b872dd60e01b17905251612d4f91906143df565b6000604051808303816000865af19150503d8060008114612d8c576040519150601f19603f3d011682016040523d82523d6000602084013e612d91565b606091505b505050505b84604001519150612b35565b60038551516007811115612db857612db861380b565b03612e6f5760008560000151602001516001600160a01b031685858860200151604051602401612dea93929190614383565b60408051601f198184030181529181526020820180516001600160e01b03166323b872dd60e01b17905251612e1f91906143df565b6000604051808303816000865af19150503d8060008114612e5c576040519150601f19603f3d011682016040523d82523d6000602084013e612e61565b606091505b505090506001925050612b35565b60048551516007811115612e8557612e8561380b565b03612b1a5760008560000151602001516001600160a01b0316858588602001518960400151604051602401612ebd94939291906143a7565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251612ef291906143df565b6000604051808303816000865af19150503d8060008114612f2f576040519150601f19603f3d011682016040523d82523d6000602084013e612f34565b606091505b505090508560400151925050612b35565b60028151516007811115612f5b57612f5b61380b565b1480612f7a575060018151516007811115612f7857612f7861380b565b145b15612fc857602081015115612fc85760405162461bcd60e51b8152602060048201526014602482015273546f6b656e4964206d757374206265207a65726f60601b60448201526064016105c3565b60038151516007811115612fde57612fde61380b565b0361302b5760408101511561302b5760405162461bcd60e51b8152602060048201526013602482015272416d6f756e74206d757374206265207a65726f60681b60448201526064016105c3565b6001600160a01b0383166000908152600260209081526040808320858452909152902060030154158061307157506003815151600781111561306f5761306f61380b565b145b1561308157610708838383613218565b60006130a484848460000151600001518560000151602001518660200151610ceb565b915050600081118061311c57508015801561311c575081516020908101516001600160a01b03868116600090815260028452604080822088835290945292832060030180549190921692906130fb576130fb614038565b600091825260209091206003909102015461010090046001600160a01b0316145b15613189576040808301516001600160a01b03861660009081526002602090815283822087835290529190912060030180548390811061315e5761315e614038565b9060005260206000209060030201600201600082825461317e91906143fb565b909155506105149050565b610514848484613218565b6040516001600160a01b03831660248201526044810182905261070890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613339565b610514846323b872dd60e01b8585856040516024016131c093929190614383565b6001546001600160a01b03841660009081526002602090815260408083208684529091529020600301541061328f5760405162461bcd60e51b815260206004820152601d60248201527f546f6f206d75636820746f6b656e7320696e20636f6c6c61746572616c00000060448201526064016105c3565b6001600160a01b03831660009081526002602090815260408083208584528252822060039081018054600181810183559185529290932084518051939092020180548594919384929091839160ff19909116908360078111156132f4576132f461380b565b021790555060209182015181546001600160a01b0390911661010002610100600160a81b03199091161790558201516001820155604090910151600290910155505050565b600061338e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661340e9092919063ffffffff16565b90508051600014806133af5750808060200190518101906133af91906140c6565b6107085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c3565b606061042e848460008585600080866001600160a01b0316858760405161343591906143df565b60006040518083038185875af1925050503d8060008114613472576040519150601f19603f3d011682016040523d82523d6000602084013e613477565b606091505b509150915061348887838387613493565b979650505050505050565b606083156135025782516000036134fb576001600160a01b0385163b6134fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c3565b508161042e565b61042e83838151156135175781518083602001fd5b8060405162461bcd60e51b81526004016105c391906139be565b60006020828403121561354357600080fd5b81356001600160e01b03198116811461055557600080fd5b6001600160a01b038116811461357057600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156135ab576135ab613573565b60405290565b604051601f8201601f191681016001600160401b03811182821017156135d9576135d9613573565b604052919050565b60006001600160401b038211156135fa576135fa613573565b50601f01601f191660200190565b600082601f83011261361957600080fd5b813561362c613627826135e1565b6135b1565b81815284602083860101111561364157600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561367457600080fd5b843561367f8161355b565b9350602085013561368f8161355b565b92506040850135915060608501356001600160401b038111156136b157600080fd5b6136bd87828801613608565b91505092959194509250565b6008811061357057600080fd5b801515811461357057600080fd5b600080600080608085870312156136fa57600080fd5b8435613705816136c9565b935060208501356137158161355b565b925060408501359150606085013561372c816136d6565b939692955090935050565b6000610160828403121561374a57600080fd5b50919050565b60008083601f84011261376257600080fd5b5081356001600160401b0381111561377957600080fd5b6020830191508360208260071b850101111561379457600080fd5b9250929050565b600080600080606085870312156137b157600080fd5b84356001600160401b03808211156137c857600080fd5b6137d488838901613737565b955060208701359150808211156137ea57600080fd5b506137f787828801613750565b909450925050604085013561372c8161355b565b634e487b7160e01b600052602160045260246000fd5b6008811061383f57634e487b7160e01b600052602160045260246000fd5b9052565b8051613850838251613821565b6020908101516001600160a01b0316838201528101516040808401919091520151606090910152565b6080810161041f8284613843565b6000806040838503121561389a57600080fd5b82356138a58161355b565b946020939093013593505050565b6020810161041f8284613821565b6001600160f81b03198116811461357057600080fd5b600080600080600060a086880312156138ef57600080fd5b85356138fa8161355b565b94506020860135935060408601356139118161355b565b925060608601356139218161355b565b91506080860135613931816138c1565b809150509295509295909350565b6000806000806060858703121561395557600080fd5b84356139608161355b565b93506020850135925060408501356001600160401b0381111561398257600080fd5b61398e87828801613750565b95989497509550505050565b60005b838110156139b557818101518382015260200161399d565b50506000910152565b60208152600082518060208401526139dd81604085016020870161399a565b601f01601f19169190910160400192915050565b600080600060608486031215613a0657600080fd5b8335613a11816136c9565b92506020840135613a218161355b565b929592945050506040919091013590565b600080600080600060808688031215613a4a57600080fd5b85356001600160401b0380821115613a6157600080fd5b613a6d89838a01613737565b96506020880135915080821115613a8357600080fd5b50613a9088828901613750565b9095509350506040860135613aa48161355b565b915060608601356139318161355b565b60006001600160401b03821115613acd57613acd613573565b5060051b60200190565b600082601f830112613ae857600080fd5b81356020613af861362783613ab4565b82815260059290921b84018101918181019086841115613b1757600080fd5b8286015b84811015613b325780358352918301918301613b1b565b509695505050505050565b600080600080600060a08688031215613b5557600080fd5b8535613b608161355b565b94506020860135613b708161355b565b935060408601356001600160401b0380821115613b8c57600080fd5b613b9889838a01613ad7565b94506060880135915080821115613bae57600080fd5b613bba89838a01613ad7565b93506080880135915080821115613bd057600080fd5b50613bdd88828901613608565b9150509295509295909350565b600081518084526020808501945080840160005b83811015613c2457613c11878351613843565b6080969096019590820190600101613bfe565b509495945050505050565b600081518084526020808501945080840160005b83811015613c2457815180516001600160f81b031916885283810151848901526040908101516001600160a01b03169088015260609096019590820190600101613c43565b600081518084526020808501945080840160005b83811015613c2457815180516001600160f81b03191688528301518388015260409096019590820190600101613c9c565b600081518084526020808501945080840160005b83811015613c2457815180516001600160a01b0316885283015161ffff168388015260409096019590820190600101613ce1565b60208152613d27602082018351613843565b600060208301516101408060a0850152613d45610160850183613bea565b91506040850151613d6160c08601826001600160a01b03169052565b506060850151601f19808685030160e0870152613d7e8483613c2f565b9350608087015191508086850301610100870152613d9c8483613c88565b935060a08701519150808685030161012087015250613dbb8382613ccd565b92505060c0850151613dd8828601826001600160f01b0319169052565b5090949350505050565b600080600080600060a08688031215613dfa57600080fd5b8535613e058161355b565b9450602086013593506040860135613e1c816136c9565b92506060860135613e2c8161355b565b949793965091946080013592915050565b600080600080600060a08688031215613e5557600080fd5b8535613e608161355b565b94506020860135613e708161355b565b9350604086013592506060860135915060808601356001600160401b03811115613e9957600080fd5b613bdd88828901613608565b9384526001600160a01b0392909216602084015260408301526001600160f01b031916606082015260800190565b600060208284031215613ee557600080fd5b81516001600160401b03811115613efb57600080fd5b8201601f81018413613f0c57600080fd5b8051613f1a613627826135e1565b818152856020838501011115613f2f57600080fd5b61097282602083016020860161399a565b600060208284031215613f5257600080fd5b8135610555816136c9565b600060208284031215613f6f57600080fd5b81356001600160f01b03198116811461055557600080fd5b60008183036080811215613f9a57600080fd5b604051606081018181106001600160401b0382111715613fbc57613fbc613573565b6040908152821215613fcd57600080fd5b613fd5613589565b91508335613fe2816136c9565b82526020840135613ff28161355b565b806020840152508181526040840135602082015260608401356040820152809250505092915050565b60006020828403121561402d57600080fd5b81356105558161355b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016140765761407661404e565b5060010190565b60006020828403121561408f57600080fd5b81516105558161355b565b6000602082840312156140ac57600080fd5b5051919050565b8181038181111561041f5761041f61404e565b6000602082840312156140d857600080fd5b8151610555816136d6565b600060208083850312156140f657600080fd5b82516001600160401b0381111561410c57600080fd5b8301601f8101851361411d57600080fd5b805161412b61362782613ab4565b81815260069190911b8201830190838101908783111561414a57600080fd5b928401925b8284101561348857604084890312156141685760008081fd5b614170613589565b845161417b816136c9565b81528486015161418a8161355b565b818701528252604093909301929084019061414f565b81356141ab816136c9565b600881106141c957634e487b7160e01b600052602160045260246000fd5b815460ff821691508160ff19821617835560208401356141e88161355b565b6001600160a81b03199190911690911760089190911b610100600160a81b031617815560408201356001820155606090910135600290910155565b6000808335601e1984360301811261423a57600080fd5b8301803591506001600160401b0382111561425457600080fd5b602001915060608102360382131561379457600080fd5b80546001600160a01b0319166001600160a01b0392909216919091179055565b8135614296816138c1565b815460ff191660f882901c178255506020820135600182015560408201356142bd8161355b565b610708816002840161426b565b6000808335601e198436030181126142e157600080fd5b8301803591506001600160401b038211156142fb57600080fd5b6020019150600681901b360382131561379457600080fd5b813561431e816138c1565b815460ff191660f882901c17825550602082013560018201555050565b81356143468161355b565b614350818361426b565b50602082013561ffff8116811461436657600080fd5b815461ffff60a01b191660a09190911b61ffff60a01b1617905550565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b600082516143f181846020870161399a565b9190910192915050565b8082018082111561041f5761041f61404e56fea26469706673582212209b858690064bbebe17194d4a6f425b0a80e4bb8e6b58a091cd71f92cd5a3a15064736f6c63430008150033000000000000000000000000e4a88a019346b21c1362f4ba5bfd24109bdd6cdf

Deployed Bytecode

0x6080604052600436106101145760003560e01c806391ddb146116100a0578063bc197c8111610064578063bc197c8114610314578063c424d4f714610340578063f1551a9c1461036d578063f23a6e61146103a2578063faf7d720146103ce57600080fd5b806391ddb1461461027d578063980550ca146102905780639a7b0509146102b4578063a5041040146102e1578063a76537d51461030157600080fd5b806342fb01a8116100e757806342fb01a8146101b45780634d36d085146101d657806355034487146101f65780635f4688c51461022a5780637f6d4c931461025757600080fd5b806301ffc9a71461011957806310118ebb1461014e578063150b7a021461017b578063331758e61461014e575b600080fd5b34801561012557600080fd5b50610139610134366004613531565b6103ee565b60405190151581526020015b60405180910390f35b34801561015a57600080fd5b50610163600081565b6040516001600160a01b039091168152602001610145565b34801561018757600080fd5b5061019b61019636600461365e565b610425565b6040516001600160e01b03199091168152602001610145565b3480156101c057600080fd5b506101d46101cf3660046136e4565b610436565b005b6101e96101e436600461379b565b61051a565b6040516101459190613879565b34801561020257600080fd5b506101637f000000000000000000000000e4a88a019346b21c1362f4ba5bfd24109bdd6cdf81565b34801561023657600080fd5b5061024a610245366004613887565b610549565b60405161014591906138b3565b34801561026357600080fd5b506101396102723660046138d7565b506001949350505050565b6101d461028b36600461393f565b61055c565b34801561029c57600080fd5b506102a660015481565b604051908152602001610145565b3480156102c057600080fd5b506102d46102cf366004613887565b6105d8565b60405161014591906139be565b3480156102ed57600080fd5b506101d46102fc3660046139f1565b6106fb565b6101e961030f366004613a32565b61070d565b34801561032057600080fd5b5061019b61032f366004613b3d565b63bc197c8160e01b95945050505050565b34801561034c57600080fd5b5061036061035b366004613887565b61097b565b6040516101459190613d15565b34801561037957600080fd5b5061038d610388366004613de2565b610ceb565b60408051928352602083019190915201610145565b3480156103ae57600080fd5b5061019b6103bd366004613e3d565b63f23a6e6160e01b95945050505050565b3480156103da57600080fd5b506101d46103e9366004613887565b610ec2565b60006001600160e01b03198216630271189760e51b148061041f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b630a85bd0160e11b5b949350505050565b61043e610edc565b60008061044c868686610f35565b9092509050600061046286866001600080610ceb565b5090506104708686866111dd565b61047c5750505061050a565b6104898787858886611820565b6000610495878761097b565b905085816000015160000151602001516001600160a01b0316886001600160a01b03167fabb50c1815800da62a4637d3272d1584df1ee8cbd963d90fb44eb55b63acfcb58460000151602001518560400151878760c001516040516104fd9493929190613ea5565b60405180910390a4505050505b6105146001600055565b50505050565b6040805160a081018252600060608201818152608083018290528252602082018190529181019190915261042e565b60006105558383611922565b9392505050565b8015158061056a5750600034115b156105145761057b84848484611a7c565b6105cc5760405162461bcd60e51b815260206004820152601860248201527f466f7262696464656e2061646420636f6c6c61746572616c000000000000000060448201526064015b60405180910390fd5b61051484848484611cd1565b606060006105e6848461097b565b519050600381515160078111156105ff576105ff61380b565b0361068b5780516020908101519082015160405163c87b56dd60e01b81526001600160a01b039092169163c87b56dd9161063f9160040190815260200190565b600060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106849190810190613ed3565b91506106f4565b600481515160078111156106a1576106a161380b565b036106e1578051602090810151908201516040516303a24d0760e21b81526001600160a01b0390921691630e89341c9161063f9160040190815260200190565b6040518060200160405280600081525091505b5092915050565b6107088383836000610436565b505050565b6040805160a081018252600060608201818152608083018290528252602082018190529181019190915261073f610edc565b61074a868484611f8d565b6107885760405162461bcd60e51b815260206004820152600f60248201526e15dc985c0818da1958dac819985a5b608a1b60448201526064016105c3565b60006107be61079f61012089016101008a01613f40565b84866101208b01356107b96101608d016101408e01613f5d565b6120f9565b90506107cb838289612254565b60016107da6020890189613f40565b60078111156107eb576107eb61380b565b14158015610817575060006108036020890189613f40565b60078111156108145761081461380b565b14155b156108875761083561082e36899003890189613f87565b33306124e0565b61083e88612b3d565b146108875760405162461bcd60e51b81526020600482015260196024820152780537573706963696f757320617373657420666f72207772617603c1b60448201526064016105c3565b6108938382888861055c565b604087018035906001600160a01b038516906108b29060208b0161401b565b6001600160a01b03167fa90a3b8dae41ae10a708d32fec7bf12da5c90879c98b9c4cca3c8fba91ddf4938488348d6101400160208101906108f39190613f5d565b6040516109039493929190613ea5565b60405180910390a46040805160a0810190915280606081018061092e6101208c016101008d01613f40565b600781111561093f5761093f61380b565b8152602001866001600160a01b031681525081526020018281526020018861012001358152509150506109726001600055565b95945050505050565b604080516101808101825260006101408201818152610160830182905260e083019081526101008301829052610120830182905282526060602083018190529282018190528282018390526080820183905260a082019290925260c08101919091526001600160a01b038316600090815260026020908152604080832085845290915290819020815161018081019092528054829060e0820190839082906101408501908390829060ff166007811115610a3757610a3761380b565b6007811115610a4857610a4861380b565b8152905461010090046001600160a01b031660209182015290825260018301548282015260029092015460409182015291835260038401805483518184028101840190945280845293820193909160009084015b82821015610b33576000848152602090206040805160a08101909152600384029091018054829060608201908390829060ff166007811115610ae057610ae061380b565b6007811115610af157610af161380b565b8152905461010090046001600160a01b031660209182015290825260018381015483830152600290930154604090920191909152918352929092019101610a9c565b5050509082525060048201546001600160a01b0316602080830191909152600583018054604080518285028101850182528281529401939260009084015b82821015610bd35760008481526020908190206040805160608101825260038602909201805460f81b6001600160f81b0319168352600180820154848601526002909101546001600160a01b0316918301919091529083529092019101610b71565b50505050815260200160068201805480602002602001604051908101604052809291908181526020016000905b82821015610c4c5760008481526020908190206040805180820190915260028502909101805460f81b6001600160f81b0319168252600190810154828401529083529092019101610c00565b50505050815260200160078201805480602002602001604051908101604052809291908181526020016000905b82821015610cc357600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b900461ffff1681830152825260019092019101610c79565b505050908252506008919091015460f01b6001600160f01b0319166020909101529392505050565b60008060005b6001600160a01b03881660009081526002602090815260408083208a8452909152902060030154811015610eb6576001600160a01b0388811660009081526002602090815260408083208b8452909152902060030180549187169183908110610d5c57610d5c614038565b600091825260209091206003909102015461010090046001600160a01b0316148015610dd257506001600160a01b03881660009081526002602090815260408083208a84529091529020600301805485919083908110610dbe57610dbe614038565b906000526020600020906003020160010154145b8015610e4a5750856007811115610deb57610deb61380b565b6001600160a01b03891660009081526002602090815260408083208b84529091529020600301805483908110610e2357610e23614038565b600091825260209091206003909102015460ff166007811115610e4857610e4861380b565b145b15610ea4576001600160a01b03881660009081526002602090815260408083208a84529091529020600301805482908110610e8757610e87614038565b906000526020600020906003020160020154819250925050610eb8565b80610eae81614064565b915050610cf1565b505b9550959350505050565b610ed8610ecf8383611922565b83836000610436565b5050565b600260005403610f2e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105c3565b6002600055565b6000806003856007811115610f4c57610f4c61380b565b03611019576040516331a9108f60e11b8152600481018490526001600160a01b03851690636352211e90602401602060405180830381865afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fba919061407d565b91506001600160a01b03821633146110145760405162461bcd60e51b815260206004820152601860248201527f4f6e6c79206f776e65722063616e20756e77726170206974000000000000000060448201526064016105c3565b6111d5565b600485600781111561102d5761102d61380b565b036111765760405163bd85b03960e01b8152600481018490526001600160a01b0385169063bd85b03990602401602060405180830381865afa158015611077573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109b919061409a565b604051627eeac760e11b815233600482018190526024820186905293509091506001600160a01b0385169062fdd58e90604401602060405180830381865afa1580156110eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110f919061409a565b81146110145760405162461bcd60e51b815260206004820152603060248201527f45524331313520756e7772617020617661696c61626c65206f6e6c7920666f7260448201526f20616c6c20746f74616c537570706c7960801b60648201526084016105c3565b6040805160a081019091528060608101808860078111156111995761119961380b565b8152602001876001600160a01b03168152508152602001848152602001600081525060405163391102fb60e01b81526004016105c39190613879565b935093915050565b6001600160a01b038381166000908152600260209081526040808320868452909152812060040154909182913391161561123c57506001600160a01b038086166000908152600260209081526040808320888452909152902060040154165b60005b6001600160a01b0387166000908152600260209081526040808320898452909152902060030154811015611649576001600160a01b038716600090815260026020908152604080832089845290915281206003018054839081106112a5576112a5614038565b600091825260209091206003909102015460ff1660078111156112ca576112ca61380b565b1461159f57841561139d576001600160a01b03871660009081526002602090815260408083208984529091529020600301805461139691908390811061131257611312614038565b600091825260209091206040805160a081019091526003909202018054829060608201908390829060ff16600781111561134e5761134e61380b565b600781111561135f5761135f61380b565b8152905461010090046001600160a01b03166020918201529082526001830154908201526002909101546040909101523084612b74565b9250611461565b6001600160a01b03871660009081526002602090815260408083208984529091529020600301805461145e9190839081106113da576113da614038565b600091825260209091206040805160a081019091526003909202018054829060608201908390829060ff1660078111156114165761141661380b565b60078111156114275761142761380b565b8152905461010090046001600160a01b031660209182015290825260018301549082015260029091015460409091015230846124e0565b92505b6001600160a01b0387166000908152600260209081526040808320898452909152902060030180548290811061149957611499614038565b9060005260206000209060030201600201548314611537576001600160a01b038716600090815260026020908152604080832089845290915290206003018054829081106114e9576114e9614038565b600091825260208220600390910201546040516001600160a01b0361010090920482169289928b16917ffca203c3f6987c2a1dae80f773c277d67920e7bce0cea9c07cd0eb8142e985ca9190a45b6001600160a01b0387166000908152600260209081526040808320898452909152812060030180548390811061156f5761156f614038565b60009182526020909120600390910201805460ff191660018360078111156115995761159961380b565b02179055505b6103e85a111580156115e257506001600160a01b03871660009081526002602090815260408083208984529091529020600301546115df906001906140b3565b81105b156116375785876001600160a01b03167fd66d44264f9d44e254da71183ff08098f38da4675285592ee80cdbd3b6f5153e8360405161162391815260200190565b60405180910390a360009350505050610555565b8061164181614064565b91505061123f565b5060016001600160a01b038716600090815260026020908152604080832089845290915290205460ff1660078111156116845761168461380b565b141580156116c857506001600160a01b038616600090815260026020908152604080832088845290915281205460ff1660078111156116c5576116c561380b565b14155b156118145783611775576001600160a01b038616600090815260026020908152604080832088845290915290819020815160a08101909252805461176f929190829060608201908390829060ff1660078111156117275761172761380b565b60078111156117385761173861380b565b8152905461010090046001600160a01b031660209182015290825260018301549082015260029091015460409091015230836124e0565b50611814565b6001600160a01b038616600090815260026020908152604080832088845290915290819020815160a081019092528054611812929190829060608201908390829060ff1660078111156117ca576117ca61380b565b60078111156117db576117db61380b565b8152905461010090046001600160a01b03166020918201529082526001830154908201526002909101546040909101523083612b74565b505b50600195945050505050565b60038560078111156118345761183461380b565b0361189857604051630852cd8d60e31b8152600481018390526001600160a01b038516906342966c6890602401600060405180830381600087803b15801561187b57600080fd5b505af115801561188f573d6000803e3d6000fd5b5050505061191b565b60048560078111156118ac576118ac61380b565b0361191b57604051637a94c56560e11b81526001600160a01b038481166004830152602482018490526044820183905285169063f5298aca90606401600060405180830381600087803b15801561190257600080fd5b505af1158015611916573d6000803e3d6000fd5b505050505b5050505050565b6040516301ffc9a760e01b81526380ac58cd60e01b60048201526000906001600160a01b038416906301ffc9a790602401602060405180830381865afa158015611970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199491906140c6565b156119a15750600361041f565b6040516301ffc9a760e01b8152636cdb3d1360e11b60048201526001600160a01b038416906301ffc9a790602401602060405180830381865afa1580156119ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1091906140c6565b15611a1d5750600461041f565b6040805160a08101909152806060810180846007811115611a4057611a4061380b565b8152602001866001600160a01b03168152508152602001838152602001600081525060405163391102fb60e01b81526004016105c39190613879565b6000336001600160a01b0316856001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aea919061407d565b6001600160a01b031614611b585760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c7920774e465420636f6e7472616374206f776e65722061626c6520746f60448201526e081859190818dbdb1b185d195c985b608a1b60648201526084016105c3565b6000611b648686611922565b90506003816007811115611b7a57611b7a61380b565b03611c2c57604051634f558e7960e01b8152600481018690526001600160a01b03871690634f558e79906024015b602060405180830381865afa158015611bc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be991906140c6565b611c275760405162461bcd60e51b815260206004820152600f60248201526e774e4654206e6f742065786973747360881b60448201526064016105c3565b611814565b6004816007811115611c4057611c4061380b565b03611c7257604051634f558e7960e01b8152600481018690526001600160a01b03871690634f558e7990602401611ba8565b6040805160a08101909152806060810180846007811115611c9557611c9561380b565b8152602001896001600160a01b03168152508152602001868152602001600081525060405163391102fb60e01b81526004016105c39190613879565b3415611d65576040805160a08101909152611d109085908590806060810180600181526000602091820181905291835282015234604090910152612f45565b604080516001815260006020820181905281830152346060820152905184916001600160a01b038716917ff3d1350815c4f9db2be36c35f840bfb002835a83ff1c3d8f3a217b1e6227d5aa9181900360800190a35b60005b8181101561191b576001838383818110611d8457611d84614038565b611d9a9260206080909202019081019150613f40565b6007811115611dab57611dab61380b565b14611f7b57611ddb838383818110611dc557611dc5614038565b90506080020180360381019061082e9190613f87565b611dfb848484818110611df057611df0614038565b905060800201612b3d565b14611e445760405162461bcd60e51b81526020600482015260196024820152780537573706963696f757320617373657420666f72207772617603c1b60448201526064016105c3565b611e768585858585818110611e5b57611e5b614038565b905060800201803603810190611e719190613f87565b612f45565b83856001600160a01b03167ff3d1350815c4f9db2be36c35f840bfb002835a83ff1c3d8f3a217b1e6227d5aa858585818110611eb457611eb4614038565b611eca9260206080909202019081019150613f40565b6007811115611edb57611edb61380b565b868686818110611eed57611eed614038565b611f06926040608090920201908101915060200161401b565b878787818110611f1857611f18614038565b90506080020160400135888888818110611f3457611f34614038565b90506080020160600135604051611f72949392919060ff9490941684526001600160a01b039290921660208401526040830152606082015260800190565b60405180910390a35b80611f8581614064565b915050611d68565b60405163e1e3c08d60e01b815233600482015260009081906001600160a01b037f000000000000000000000000e4a88a019346b21c1362f4ba5bfd24109bdd6cdf169063e1e3c08d90602401600060405180830381865afa158015611ff6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261201e91908101906140e3565b90506000805b82518110156120d857846001600160a01b031683828151811061204957612049614038565b6020026020010151602001516001600160a01b03161480156120ba575061207861012088016101008901613f40565b60078111156120895761208961380b565b83828151811061209b5761209b614038565b60200260200101516000015160078111156120b8576120b861380b565b145b156120c857600191506120d8565b6120d181614064565b9050612024565b506001600160a01b03851630148015906120ef5750805b9695505050505050565b6000600386600781111561210f5761210f61380b565b036121985760405163288f5b4760e11b81526001600160a01b0385811660048301526001600160f01b03198416602483015286169063511eb68e906044015b6020604051808303816000875af115801561216d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612191919061409a565b9050610972565b60048660078111156121ac576121ac61380b565b036121f657604051635d2d7c2f60e11b81526001600160a01b038581166004830152602482018590526001600160f01b03198416604483015286169063ba5af85e9060640161214e565b6040805160a081019091528060608101808960078111156122195761221961380b565b8152602001886001600160a01b031681525081526020018281526020018481525060405163391102fb60e01b81526004016105c39190613879565b6001600160a01b03831660009081526002602090815260408083208584529091529020819061228382826141a0565b50506001600160a01b0383166000908152600260209081526040808320858452909152902060040180546001600160a01b03191690556122cb61016082016101408301613f5d565b6001600160a01b03841660009081526002602090815260408083208684529091528120600801805461ffff191660f09390931c929092179091555b61231360a0830183614223565b90508110156123a2576001600160a01b0384166000908152600260209081526040808320868452909152902060050161234f60a0840184614223565b8381811061235f5761235f614038565b83546001810185556000948552602090942060609091029290920192600302909101905061238d828261428b565b5050808061239a90614064565b915050612306565b5060005b6123b360c08301836142ca565b9050811015612442576001600160a01b038416600090815260026020908152604080832086845290915290206006016123ef60c08401846142ca565b838181106123ff576123ff614038565b83546001810185556000948552602090942060409091029290920192600202909101905061242d8282614313565b5050808061243a90614064565b9150506123a6565b5060005b61245360e08301836142ca565b9050811015610514576001600160a01b0384166000908152600260209081526040808320868452909152902060070161248f60e08401846142ca565b8381811061249f5761249f614038565b835460018101855560009485526020909420604090910292909201929190910190506124cb828261433b565b505080806124d890614064565b915050612446565b600080600185515160078111156124f9576124f961380b565b036125b3575060408085015190516001600160a01b0384168031926000928381818185875af1925050503d806000811461254f576040519150601f19603f3d011682016040523d82523d6000602084013e612554565b606091505b50509050806125975760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016105c3565b6125ab826001600160a01b038616316140b3565b925050612b35565b600285515160078111156125c9576125c961380b565b0361271f578451602001516040516370a0823160e01b81526001600160a01b038581166004830152909116906370a0823190602401602060405180830381865afa15801561261b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263f919061409a565b9050306001600160a01b03851603612678576040850151855160200151612673916001600160a01b03909116908590613194565b61269c565b604085015185516020015161269c916001600160a01b0390911690869086906131f7565b8451602001516040516370a0823160e01b81526001600160a01b038581166004830152839216906370a08231906024015b602060405180830381865afa1580156126ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270e919061409a565b61271891906140b3565b9150612b35565b600385515160078111156127355761273561380b565b1480156127c157508451602090810151908601516040516331a9108f60e11b815260048101919091526001600160a01b03868116921690636352211e90602401602060405180830381865afa158015612792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b6919061407d565b6001600160a01b0316145b156129cb578451602001516040516370a0823160e01b81526001600160a01b038581166004830152909116906370a0823190602401602060405180830381865afa158015612813573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612837919061409a565b90508460000151602001516001600160a01b03166323b872dd858588602001516040518463ffffffff1660e01b815260040161287593929190614383565b600060405180830381600087803b15801561288f57600080fd5b505af11580156128a3573d6000803e3d6000fd5b50505050826001600160a01b03168560000151602001516001600160a01b0316636352211e87602001516040518263ffffffff1660e01b81526004016128eb91815260200190565b602060405180830381865afa158015612908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061292c919061407d565b6001600160a01b03161480156129bc57508451602001516040516370a0823160e01b81526001600160a01b038581166004830152839216906370a0823190602401602060405180830381865afa15801561298a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ae919061409a565b6129b891906140b3565b6001145b156129c657600191505b612b35565b600485515160078111156129e1576129e161380b565b03612b1a57845160209081015190860151604051627eeac760e11b81526001600160a01b038681166004830152602482019290925291169062fdd58e90604401602060405180830381865afa158015612a3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a62919061409a565b90508460000151602001516001600160a01b031663f242432a8585886020015189604001516040518563ffffffff1660e01b8152600401612aa694939291906143a7565b600060405180830381600087803b158015612ac057600080fd5b505af1158015612ad4573d6000803e3d6000fd5b5050865160209081015190880151604051627eeac760e11b81526001600160a01b03888116600483015260248201929092528594509116915062fdd58e906044016126cd565b8460405163391102fb60e01b81526004016105c39190613879565b509392505050565b60006003612b4e6020840184613f40565b6007811115612b5f57612b5f61380b565b03612b6c57506001919050565b506060013590565b60008060018551516007811115612b8d57612b8d61380b565b03612c02575060408085015190516001600160a01b0384168031926000928381818185875af1925050503d8060008114612be3576040519150601f19603f3d011682016040523d82523d6000602084013e612be8565b606091505b5050905081846001600160a01b0316316125ab91906140b3565b60028551516007811115612c1857612c1861380b565b03612da257306001600160a01b03851603612ced5760008560000151602001516001600160a01b0316848760400151604051602401612c6c9291906001600160a01b03929092168252602082015260400190565b60408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b17905251612ca191906143df565b6000604051808303816000865af19150503d8060008114612cde576040519150601f19603f3d011682016040523d82523d6000602084013e612ce3565b606091505b5050905050612d96565b60008560000151602001516001600160a01b031685858860400151604051602401612d1a93929190614383565b60408051601f198184030181529181526020820180516001600160e01b03166323b872dd60e01b17905251612d4f91906143df565b6000604051808303816000865af19150503d8060008114612d8c576040519150601f19603f3d011682016040523d82523d6000602084013e612d91565b606091505b505050505b84604001519150612b35565b60038551516007811115612db857612db861380b565b03612e6f5760008560000151602001516001600160a01b031685858860200151604051602401612dea93929190614383565b60408051601f198184030181529181526020820180516001600160e01b03166323b872dd60e01b17905251612e1f91906143df565b6000604051808303816000865af19150503d8060008114612e5c576040519150601f19603f3d011682016040523d82523d6000602084013e612e61565b606091505b505090506001925050612b35565b60048551516007811115612e8557612e8561380b565b03612b1a5760008560000151602001516001600160a01b0316858588602001518960400151604051602401612ebd94939291906143a7565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251612ef291906143df565b6000604051808303816000865af19150503d8060008114612f2f576040519150601f19603f3d011682016040523d82523d6000602084013e612f34565b606091505b505090508560400151925050612b35565b60028151516007811115612f5b57612f5b61380b565b1480612f7a575060018151516007811115612f7857612f7861380b565b145b15612fc857602081015115612fc85760405162461bcd60e51b8152602060048201526014602482015273546f6b656e4964206d757374206265207a65726f60601b60448201526064016105c3565b60038151516007811115612fde57612fde61380b565b0361302b5760408101511561302b5760405162461bcd60e51b8152602060048201526013602482015272416d6f756e74206d757374206265207a65726f60681b60448201526064016105c3565b6001600160a01b0383166000908152600260209081526040808320858452909152902060030154158061307157506003815151600781111561306f5761306f61380b565b145b1561308157610708838383613218565b60006130a484848460000151600001518560000151602001518660200151610ceb565b915050600081118061311c57508015801561311c575081516020908101516001600160a01b03868116600090815260028452604080822088835290945292832060030180549190921692906130fb576130fb614038565b600091825260209091206003909102015461010090046001600160a01b0316145b15613189576040808301516001600160a01b03861660009081526002602090815283822087835290529190912060030180548390811061315e5761315e614038565b9060005260206000209060030201600201600082825461317e91906143fb565b909155506105149050565b610514848484613218565b6040516001600160a01b03831660248201526044810182905261070890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613339565b610514846323b872dd60e01b8585856040516024016131c093929190614383565b6001546001600160a01b03841660009081526002602090815260408083208684529091529020600301541061328f5760405162461bcd60e51b815260206004820152601d60248201527f546f6f206d75636820746f6b656e7320696e20636f6c6c61746572616c00000060448201526064016105c3565b6001600160a01b03831660009081526002602090815260408083208584528252822060039081018054600181810183559185529290932084518051939092020180548594919384929091839160ff19909116908360078111156132f4576132f461380b565b021790555060209182015181546001600160a01b0390911661010002610100600160a81b03199091161790558201516001820155604090910151600290910155505050565b600061338e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661340e9092919063ffffffff16565b90508051600014806133af5750808060200190518101906133af91906140c6565b6107085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c3565b606061042e848460008585600080866001600160a01b0316858760405161343591906143df565b60006040518083038185875af1925050503d8060008114613472576040519150601f19603f3d011682016040523d82523d6000602084013e613477565b606091505b509150915061348887838387613493565b979650505050505050565b606083156135025782516000036134fb576001600160a01b0385163b6134fb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c3565b508161042e565b61042e83838151156135175781518083602001fd5b8060405162461bcd60e51b81526004016105c391906139be565b60006020828403121561354357600080fd5b81356001600160e01b03198116811461055557600080fd5b6001600160a01b038116811461357057600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156135ab576135ab613573565b60405290565b604051601f8201601f191681016001600160401b03811182821017156135d9576135d9613573565b604052919050565b60006001600160401b038211156135fa576135fa613573565b50601f01601f191660200190565b600082601f83011261361957600080fd5b813561362c613627826135e1565b6135b1565b81815284602083860101111561364157600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561367457600080fd5b843561367f8161355b565b9350602085013561368f8161355b565b92506040850135915060608501356001600160401b038111156136b157600080fd5b6136bd87828801613608565b91505092959194509250565b6008811061357057600080fd5b801515811461357057600080fd5b600080600080608085870312156136fa57600080fd5b8435613705816136c9565b935060208501356137158161355b565b925060408501359150606085013561372c816136d6565b939692955090935050565b6000610160828403121561374a57600080fd5b50919050565b60008083601f84011261376257600080fd5b5081356001600160401b0381111561377957600080fd5b6020830191508360208260071b850101111561379457600080fd5b9250929050565b600080600080606085870312156137b157600080fd5b84356001600160401b03808211156137c857600080fd5b6137d488838901613737565b955060208701359150808211156137ea57600080fd5b506137f787828801613750565b909450925050604085013561372c8161355b565b634e487b7160e01b600052602160045260246000fd5b6008811061383f57634e487b7160e01b600052602160045260246000fd5b9052565b8051613850838251613821565b6020908101516001600160a01b0316838201528101516040808401919091520151606090910152565b6080810161041f8284613843565b6000806040838503121561389a57600080fd5b82356138a58161355b565b946020939093013593505050565b6020810161041f8284613821565b6001600160f81b03198116811461357057600080fd5b600080600080600060a086880312156138ef57600080fd5b85356138fa8161355b565b94506020860135935060408601356139118161355b565b925060608601356139218161355b565b91506080860135613931816138c1565b809150509295509295909350565b6000806000806060858703121561395557600080fd5b84356139608161355b565b93506020850135925060408501356001600160401b0381111561398257600080fd5b61398e87828801613750565b95989497509550505050565b60005b838110156139b557818101518382015260200161399d565b50506000910152565b60208152600082518060208401526139dd81604085016020870161399a565b601f01601f19169190910160400192915050565b600080600060608486031215613a0657600080fd5b8335613a11816136c9565b92506020840135613a218161355b565b929592945050506040919091013590565b600080600080600060808688031215613a4a57600080fd5b85356001600160401b0380821115613a6157600080fd5b613a6d89838a01613737565b96506020880135915080821115613a8357600080fd5b50613a9088828901613750565b9095509350506040860135613aa48161355b565b915060608601356139318161355b565b60006001600160401b03821115613acd57613acd613573565b5060051b60200190565b600082601f830112613ae857600080fd5b81356020613af861362783613ab4565b82815260059290921b84018101918181019086841115613b1757600080fd5b8286015b84811015613b325780358352918301918301613b1b565b509695505050505050565b600080600080600060a08688031215613b5557600080fd5b8535613b608161355b565b94506020860135613b708161355b565b935060408601356001600160401b0380821115613b8c57600080fd5b613b9889838a01613ad7565b94506060880135915080821115613bae57600080fd5b613bba89838a01613ad7565b93506080880135915080821115613bd057600080fd5b50613bdd88828901613608565b9150509295509295909350565b600081518084526020808501945080840160005b83811015613c2457613c11878351613843565b6080969096019590820190600101613bfe565b509495945050505050565b600081518084526020808501945080840160005b83811015613c2457815180516001600160f81b031916885283810151848901526040908101516001600160a01b03169088015260609096019590820190600101613c43565b600081518084526020808501945080840160005b83811015613c2457815180516001600160f81b03191688528301518388015260409096019590820190600101613c9c565b600081518084526020808501945080840160005b83811015613c2457815180516001600160a01b0316885283015161ffff168388015260409096019590820190600101613ce1565b60208152613d27602082018351613843565b600060208301516101408060a0850152613d45610160850183613bea565b91506040850151613d6160c08601826001600160a01b03169052565b506060850151601f19808685030160e0870152613d7e8483613c2f565b9350608087015191508086850301610100870152613d9c8483613c88565b935060a08701519150808685030161012087015250613dbb8382613ccd565b92505060c0850151613dd8828601826001600160f01b0319169052565b5090949350505050565b600080600080600060a08688031215613dfa57600080fd5b8535613e058161355b565b9450602086013593506040860135613e1c816136c9565b92506060860135613e2c8161355b565b949793965091946080013592915050565b600080600080600060a08688031215613e5557600080fd5b8535613e608161355b565b94506020860135613e708161355b565b9350604086013592506060860135915060808601356001600160401b03811115613e9957600080fd5b613bdd88828901613608565b9384526001600160a01b0392909216602084015260408301526001600160f01b031916606082015260800190565b600060208284031215613ee557600080fd5b81516001600160401b03811115613efb57600080fd5b8201601f81018413613f0c57600080fd5b8051613f1a613627826135e1565b818152856020838501011115613f2f57600080fd5b61097282602083016020860161399a565b600060208284031215613f5257600080fd5b8135610555816136c9565b600060208284031215613f6f57600080fd5b81356001600160f01b03198116811461055557600080fd5b60008183036080811215613f9a57600080fd5b604051606081018181106001600160401b0382111715613fbc57613fbc613573565b6040908152821215613fcd57600080fd5b613fd5613589565b91508335613fe2816136c9565b82526020840135613ff28161355b565b806020840152508181526040840135602082015260608401356040820152809250505092915050565b60006020828403121561402d57600080fd5b81356105558161355b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016140765761407661404e565b5060010190565b60006020828403121561408f57600080fd5b81516105558161355b565b6000602082840312156140ac57600080fd5b5051919050565b8181038181111561041f5761041f61404e565b6000602082840312156140d857600080fd5b8151610555816136d6565b600060208083850312156140f657600080fd5b82516001600160401b0381111561410c57600080fd5b8301601f8101851361411d57600080fd5b805161412b61362782613ab4565b81815260069190911b8201830190838101908783111561414a57600080fd5b928401925b8284101561348857604084890312156141685760008081fd5b614170613589565b845161417b816136c9565b81528486015161418a8161355b565b818701528252604093909301929084019061414f565b81356141ab816136c9565b600881106141c957634e487b7160e01b600052602160045260246000fd5b815460ff821691508160ff19821617835560208401356141e88161355b565b6001600160a81b03199190911690911760089190911b610100600160a81b031617815560408201356001820155606090910135600290910155565b6000808335601e1984360301811261423a57600080fd5b8301803591506001600160401b0382111561425457600080fd5b602001915060608102360382131561379457600080fd5b80546001600160a01b0319166001600160a01b0392909216919091179055565b8135614296816138c1565b815460ff191660f882901c178255506020820135600182015560408201356142bd8161355b565b610708816002840161426b565b6000808335601e198436030181126142e157600080fd5b8301803591506001600160401b038211156142fb57600080fd5b6020019150600681901b360382131561379457600080fd5b813561431e816138c1565b815460ff191660f882901c17825550602082013560018201555050565b81356143468161355b565b614350818361426b565b50602082013561ffff8116811461436657600080fd5b815461ffff60a01b191660a09190911b61ffff60a01b1617905550565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b600082516143f181846020870161399a565b9190910192915050565b8082018082111561041f5761041f61404e56fea26469706673582212209b858690064bbebe17194d4a6f425b0a80e4bb8e6b58a091cd71f92cd5a3a15064736f6c63430008150033

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

000000000000000000000000e4a88a019346b21c1362f4ba5bfd24109bdd6cdf

-----Decoded View---------------
Arg [0] : _usersWNFTRegistry (address): 0xe4A88A019346B21c1362f4ba5bFD24109bDD6cdf

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000e4a88a019346b21c1362f4ba5bfd24109bdd6cdf


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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