ETH Price: $3,434.63 (+7.60%)
Gas: 15 Gwei

Contract

0xE4AC19434ceF450eaD2942Fa9AB01Ec8fc0cf181
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60e06040147095122022-05-04 7:03:39803 days ago1651647819IN
 Create: ERC721OrdersFeature
0 ETH0.1149755525.52103488

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC721OrdersFeature

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 17 : ERC721OrdersFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "../../fixins/FixinERC721Spender.sol";
import "../../storage/LibCommonNftOrdersStorage.sol";
import "../../storage/LibERC721OrdersStorage.sol";
import "../interfaces/IERC721OrdersFeature.sol";
import "./NFTOrders.sol";


/// @dev Feature for interacting with ERC721 orders.
contract ERC721OrdersFeature is IERC721OrdersFeature, FixinERC721Spender, NFTOrders {

    using LibNFTOrder for LibNFTOrder.NFTBuyOrder;

    /// @dev The magic return value indicating the success of a `onERC721Received`.
    bytes4 private constant ERC721_RECEIVED_MAGIC_BYTES = this.onERC721Received.selector;

    constructor(IEtherToken weth) NFTOrders(weth) {
    }

    /// @dev Sells an ERC721 asset to fill the given order.
    /// @param buyOrder The ERC721 buy order.
    /// @param signature The order signature from the maker.
    /// @param erc721TokenId The ID of the ERC721 asset being
    ///        sold. If the given order specifies properties,
    ///        the asset must satisfy those properties. Otherwise,
    ///        it must equal the tokenId in the order.
    /// @param unwrapNativeToken If this parameter is true and the
    ///        ERC20 token of the order is e.g. WETH, unwraps the
    ///        token before transferring it to the taker.
    /// @param callbackData If this parameter is non-zero, invokes
    ///        `zeroExERC721OrderCallback` on `msg.sender` after
    ///        the ERC20 tokens have been transferred to `msg.sender`
    ///        but before transferring the ERC721 asset to the buyer.
    function sellERC721(
        LibNFTOrder.NFTBuyOrder memory buyOrder,
        LibSignature.Signature memory signature,
        uint256 erc721TokenId,
        bool unwrapNativeToken,
        bytes memory callbackData
    ) public override {
        _sellERC721(buyOrder, signature, erc721TokenId, unwrapNativeToken, msg.sender, msg.sender, callbackData);
    }

    /// @dev Buys an ERC721 asset by filling the given order.
    /// @param sellOrder The ERC721 sell order.
    /// @param signature The order signature.
    function buyERC721(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature) public override payable {
        uint256 ethBalanceBefore = address(this).balance - msg.value;

        _buyERC721(sellOrder, signature);

        if (address(this).balance != ethBalanceBefore) {
            // Refund
            _transferEth(payable(msg.sender), address(this).balance - ethBalanceBefore);
        }
    }

    function buyERC721Ex(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibSignature.Signature memory signature,
        address taker,
        bytes memory callbackData
    ) public override payable {
        uint256 ethBalanceBefore = address(this).balance - msg.value;

        _buyERC721Ex(sellOrder, signature, taker, msg.value, callbackData);

        if (address(this).balance != ethBalanceBefore) {
            // Refund
            _transferEth(payable(msg.sender), address(this).balance - ethBalanceBefore);
        }
    }

    /// @dev Cancel a single ERC721 order by its nonce. The caller
    ///      should be the maker of the order. Silently succeeds if
    ///      an order with the same nonce has already been filled or
    ///      cancelled.
    /// @param orderNonce The order nonce.
    function cancelERC721Order(uint256 orderNonce) public override {
        // Mark order as cancelled
        _setOrderStatusBit(msg.sender, orderNonce);
        emit ERC721OrderCancelled(msg.sender, orderNonce);
    }

    /// @dev Cancel multiple ERC721 orders by their nonces. The caller
    ///      should be the maker of the orders. Silently succeeds if
    ///      an order with the same nonce has already been filled or
    ///      cancelled.
    /// @param orderNonces The order nonces.
    function batchCancelERC721Orders(uint256[] calldata orderNonces) external override {
        for (uint256 i = 0; i < orderNonces.length; i++) {
            cancelERC721Order(orderNonces[i]);
        }
    }

    /// @dev Buys multiple ERC721 assets by filling the
    ///      given orders.
    /// @param sellOrders The ERC721 sell orders.
    /// @param signatures The order signatures.
    /// @param revertIfIncomplete If true, reverts if this
    ///        function fails to fill any individual order.
    /// @return successes An array of booleans corresponding to whether
    ///         each order in `orders` was successfully filled.
    function batchBuyERC721s(
        LibNFTOrder.NFTSellOrder[] memory sellOrders,
        LibSignature.Signature[] memory signatures,
        bool revertIfIncomplete
    ) public override payable returns (bool[] memory successes) {
        // Array length must match.
        uint256 length = sellOrders.length;
        require(length == signatures.length, "ARRAY_LENGTH_MISMATCH");

        successes = new bool[](length);
        uint256 ethBalanceBefore = address(this).balance - msg.value;

        if (revertIfIncomplete) {
            for (uint256 i = 0; i < length; i++) {
                // Will revert if _buyERC721 reverts.
                _buyERC721(sellOrders[i], signatures[i]);
                successes[i] = true;
            }
        } else {
            for (uint256 i = 0; i < length; i++) {
                // Delegatecall `buyERC721FromProxy` to swallow reverts while
                // preserving execution context.
                (successes[i], ) = _implementation.delegatecall(
                    abi.encodeWithSelector(this.buyERC721FromProxy.selector, sellOrders[i], signatures[i])
                );
            }
        }

        // Refund
       _transferEth(payable(msg.sender), address(this).balance - ethBalanceBefore);
    }

    function batchBuyERC721sEx(
        LibNFTOrder.NFTSellOrder[] memory sellOrders,
        LibSignature.Signature[] memory signatures,
        address[] calldata takers,
        bytes[] memory callbackData,
        bool revertIfIncomplete
    ) public override payable returns (bool[] memory successes) {
        // All array length must match.
        uint256 length = sellOrders.length;
        require(length == signatures.length && length == takers.length && length == callbackData.length, "ARRAY_LENGTH_MISMATCH");

        successes = new bool[](length);
        uint256 ethBalanceBefore = address(this).balance - msg.value;

        if (revertIfIncomplete) {
            for (uint256 i = 0; i < length; i++) {
                // Will revert if _buyERC721Ex reverts.
                _buyERC721Ex(sellOrders[i], signatures[i], takers[i], address(this).balance - ethBalanceBefore, callbackData[i]);
                successes[i] = true;
            }
        } else {
            for (uint256 i = 0; i < length; i++) {
                // Delegatecall `buyERC721ExFromProxy` to swallow reverts while
                // preserving execution context.
                (successes[i], ) = _implementation.delegatecall(
                    abi.encodeWithSelector(this.buyERC721ExFromProxy.selector, sellOrders[i], signatures[i], takers[i],
                        address(this).balance - ethBalanceBefore, callbackData[i])
                );
            }
        }

        // Refund
       _transferEth(payable(msg.sender), address(this).balance - ethBalanceBefore);
    }

    // @Note `buyERC721FromProxy` is a external function, must call from an external Exchange Proxy,
    //        but should not be registered in the Exchange Proxy.
    function buyERC721FromProxy(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature) external payable {
        require(_implementation != address(this), "MUST_CALL_FROM_PROXY");
        _buyERC721(sellOrder, signature);
    }

    // @Note `buyERC721ExFromProxy` is a external function, must call from an external Exchange Proxy,
    //        but should not be registered in the Exchange Proxy.
    function buyERC721ExFromProxy(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature, address taker, uint256 ethAvailable, bytes memory takerCallbackData) external payable {
        require(_implementation != address(this), "MUST_CALL_FROM_PROXY");
        _buyERC721Ex(sellOrder, signature, taker, ethAvailable, takerCallbackData);
    }

    /// @dev Matches a pair of complementary orders that have
    ///      a non-negative spread. Each order is filled at
    ///      their respective price, and the matcher receives
    ///      a profit denominated in the ERC20 token.
    /// @param sellOrder Order selling an ERC721 asset.
    /// @param buyOrder Order buying an ERC721 asset.
    /// @param sellOrderSignature Signature for the sell order.
    /// @param buyOrderSignature Signature for the buy order.
    /// @return profit The amount of profit earned by the caller
    ///         of this function (denominated in the ERC20 token
    ///         of the matched orders).
    function matchERC721Orders(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibNFTOrder.NFTBuyOrder memory buyOrder,
        LibSignature.Signature memory sellOrderSignature,
        LibSignature.Signature memory buyOrderSignature
    ) public override returns (uint256 profit) {
        // The ERC721 tokens must match
        require(sellOrder.nft == buyOrder.nft, "ERC721_TOKEN_MISMATCH_ERROR");

        LibNFTOrder.OrderInfo memory sellOrderInfo = _getOrderInfo(sellOrder);
        LibNFTOrder.OrderInfo memory buyOrderInfo = _getOrderInfo(buyOrder);

        _validateSellOrder(sellOrder, sellOrderSignature, sellOrderInfo, buyOrder.maker);
        _validateBuyOrder(buyOrder, buyOrderSignature, buyOrderInfo, sellOrder.maker, sellOrder.nftId);

        // English Auction
        if (sellOrder.expiry >> 252 == 2) {
            _resetEnglishAuctionTokenAmountAndFees(sellOrder, buyOrder.erc20TokenAmount, 1, 1);
        }

        // Mark both orders as filled.
        _updateOrderState(sellOrder, sellOrderInfo.orderHash, 1);
        _updateOrderState(buyOrder.asNFTSellOrder(), buyOrderInfo.orderHash, 1);

        // The difference in ERC20 token amounts is the spread.
        uint256 spread = buyOrder.erc20TokenAmount - sellOrder.erc20TokenAmount;

        // Transfer the ERC721 asset from seller to buyer.
        _transferERC721AssetFrom(sellOrder.nft, sellOrder.maker, buyOrder.maker, sellOrder.nftId);

        // Handle the ERC20 side of the order:
        if (address(sellOrder.erc20Token) == NATIVE_TOKEN_ADDRESS && buyOrder.erc20Token == WETH) {
            // The sell order specifies ETH, while the buy order specifies WETH.
            // The orders are still compatible with one another, but we'll have
            // to unwrap the WETH on behalf of the buyer.

            // Step 1: Transfer WETH from the buyer to the EP.
            //         Note that we transfer `buyOrder.erc20TokenAmount`, which
            //         is the amount the buyer signaled they are willing to pay
            //         for the ERC721 asset, which may be more than the seller's
            //         ask.
            _transferERC20TokensFrom(WETH, buyOrder.maker, address(this), buyOrder.erc20TokenAmount);

            // Step 2: Unwrap the WETH into ETH. We unwrap the entire
            //         `buyOrder.erc20TokenAmount`.
            //         The ETH will be used for three purposes:
            //         - To pay the seller
            //         - To pay fees for the sell order
            //         - Any remaining ETH will be sent to
            //           `msg.sender` as profit.
            WETH.withdraw(buyOrder.erc20TokenAmount);

            // Step 3: Pay the seller (in ETH).
            _transferEth(payable(sellOrder.maker), sellOrder.erc20TokenAmount);

            // Step 4: Pay fees for the buy order. Note that these are paid
            //         in _WETH_ by the _buyer_. By signing the buy order, the
            //         buyer signals that they are willing to spend a total
            //         of `erc20TokenAmount` _plus_ fees, all denominated in
            //         the `erc20Token`, which in this case is WETH.
            _payFees(buyOrder.asNFTSellOrder(), buyOrder.maker, 1, 1, false);

            // Step 5: Pay fees for the sell order. The `erc20Token` of the
            //         sell order is ETH, so the fees are paid out in ETH.
            //         There should be `spread` wei of ETH remaining in the
            //         EP at this point, which we will use ETH to pay the
            //         sell order fees.
            uint256 sellOrderFees = _payFees(sellOrder, address(this), 1, 1, true);

            // Step 6: The spread less the sell order fees is the amount of ETH
            //         remaining in the EP that can be sent to `msg.sender` as
            //         the profit from matching these two orders.
            profit = spread - sellOrderFees;
            if (profit > 0) {
                _transferEth(payable(msg.sender), profit);
            }
        } else {
            // ERC20 tokens must match
            require(sellOrder.erc20Token == buyOrder.erc20Token, "ERC20_TOKEN_MISMATCH_ERROR");

            // Step 1: Transfer the ERC20 token from the buyer to the seller.
            //         Note that we transfer `sellOrder.erc20TokenAmount`, which
            //         is at most `buyOrder.erc20TokenAmount`.
            _transferERC20TokensFrom(buyOrder.erc20Token, buyOrder.maker, sellOrder.maker, sellOrder.erc20TokenAmount);

            // Step 2: Pay fees for the buy order. Note that these are paid
            //         by the buyer. By signing the buy order, the buyer signals
            //         that they are willing to spend a total of
            //         `buyOrder.erc20TokenAmount` _plus_ `buyOrder.fees`.
            _payFees(buyOrder.asNFTSellOrder(), buyOrder.maker, 1, 1, false);

            // Step 3: Pay fees for the sell order. These are paid by the buyer
            //         as well. After paying these fees, we may have taken more
            //         from the buyer than they agreed to in the buy order. If
            //         so, we revert in the following step.
            uint256 sellOrderFees = _payFees(sellOrder, buyOrder.maker, 1, 1, false);

            // Step 4: We calculate the profit as:
            //         profit = buyOrder.erc20TokenAmount - sellOrder.erc20TokenAmount - sellOrderFees
            //                = spread - sellOrderFees
            //         I.e. the buyer would've been willing to pay up to `profit`
            //         more to buy the asset, so instead that amount is sent to
            //         `msg.sender` as the profit from matching these two orders.
            profit = spread - sellOrderFees;
            if (profit > 0) {
                _transferERC20TokensFrom(buyOrder.erc20Token, buyOrder.maker, msg.sender, profit);
            }
        }

        emit ERC721SellOrderFilled(
            sellOrder.maker,
            buyOrder.maker, // taker
            sellOrder.erc20Token,
            sellOrder.erc20TokenAmount,
            sellOrder.nft,
            sellOrder.nftId,
            sellOrderInfo.orderHash
        );

        emit ERC721BuyOrderFilled(
            buyOrder.maker,
            sellOrder.maker, // taker
            buyOrder.erc20Token,
            buyOrder.erc20TokenAmount,
            buyOrder.nft,
            sellOrder.nftId,
            buyOrderInfo.orderHash
        );
    }

    /// @dev Matches pairs of complementary orders that have
    ///      non-negative spreads. Each order is filled at
    ///      their respective price, and the matcher receives
    ///      a profit denominated in the ERC20 token.
    /// @param sellOrders Orders selling ERC721 assets.
    /// @param buyOrders Orders buying ERC721 assets.
    /// @param sellOrderSignatures Signatures for the sell orders.
    /// @param buyOrderSignatures Signatures for the buy orders.
    /// @return profits The amount of profit earned by the caller
    ///         of this function for each pair of matched orders
    ///         (denominated in the ERC20 token of the order pair).
    /// @return successes An array of booleans corresponding to
    ///         whether each pair of orders was successfully matched.
    function batchMatchERC721Orders(
        LibNFTOrder.NFTSellOrder[] memory sellOrders,
        LibNFTOrder.NFTBuyOrder[] memory buyOrders,
        LibSignature.Signature[] memory sellOrderSignatures,
        LibSignature.Signature[] memory buyOrderSignatures
    ) public override returns (uint256[] memory profits, bool[] memory successes) {
        // All array length must match.
        uint256 length = sellOrders.length;
        require(length == buyOrders.length && length == sellOrderSignatures.length && length == buyOrderSignatures.length, "ARRAY_LENGTH_MISMATCH");

        profits = new uint256[](length);
        successes = new bool[](length);

        for (uint256 i = 0; i < length; i++) {
            bytes memory returnData;
            // Delegatecall `matchERC721Orders` to catch reverts while
            // preserving execution context.
            (successes[i], returnData) = _implementation.delegatecall(
                abi.encodeWithSelector(this.matchERC721Orders.selector, sellOrders[i], buyOrders[i],
                    sellOrderSignatures[i], buyOrderSignatures[i])
            );
            if (successes[i]) {
                // If the matching succeeded, record the profit.
                (uint256 profit) = abi.decode(returnData, (uint256));
                profits[i] = profit;
            }
        }
    }

    /// @dev Callback for the ERC721 `safeTransferFrom` function.
    ///      This callback can be used to sell an ERC721 asset if
    ///      a valid ERC721 order, signature and `unwrapNativeToken`
    ///      are encoded in `data`. This allows takers to sell their
    ///      ERC721 asset without first calling `setApprovalForAll`.
    /// @param operator The address which called `safeTransferFrom`.
    /// @param tokenId The ID of the asset being transferred.
    /// @param data Additional data with no specified format. If a
    ///        valid ERC721 order, signature and `unwrapNativeToken`
    ///        are encoded in `data`, this function will try to fill
    ///        the order using the received asset.
    /// @return success The selector of this function (0x150b7a02),
    ///         indicating that the callback succeeded.
    function onERC721Received(address operator, address /* from */, uint256 tokenId, bytes calldata data) external override returns (bytes4 success) {
        // Decode the order, signature, and `unwrapNativeToken` from
        // `data`. If `data` does not encode such parameters, this
        // will throw.
        (LibNFTOrder.NFTBuyOrder memory buyOrder, LibSignature.Signature memory signature, bool unwrapNativeToken)
            = abi.decode(data, (LibNFTOrder.NFTBuyOrder, LibSignature.Signature, bool));

        // `onERC721Received` is called by the ERC721 token contract.
        // Check that it matches the ERC721 token in the order.
        require(msg.sender == buyOrder.nft, "ERC721_TOKEN_MISMATCH_ERROR");

        // operator taker
        // address(this) owner (we hold the NFT currently)
        _sellERC721(buyOrder, signature, tokenId, unwrapNativeToken, operator, address(this), new bytes(0));

        return ERC721_RECEIVED_MAGIC_BYTES;
    }

    /// @dev Approves an ERC721 sell order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 sell order.
    function preSignERC721SellOrder(LibNFTOrder.NFTSellOrder memory order) public override {
        require(order.maker == msg.sender, "ONLY_MAKER");

        uint256 hashNonce = LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker];
        bytes32 orderHash = getERC721SellOrderHash(order);
        LibERC721OrdersStorage.getStorage().preSigned[orderHash] = (hashNonce + 1);

        emit ERC721SellOrderPreSigned(order.maker, order.taker, order.expiry, order.nonce,
            order.erc20Token, order.erc20TokenAmount, order.fees, order.nft, order.nftId);
    }

    /// @dev Approves an ERC721 buy order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 buy order.
    function preSignERC721BuyOrder(LibNFTOrder.NFTBuyOrder memory order) public override {
        require(order.maker == msg.sender, "ONLY_MAKER");

        uint256 hashNonce = LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker];
        bytes32 orderHash = getERC721BuyOrderHash(order);
        LibERC721OrdersStorage.getStorage().preSigned[orderHash] = (hashNonce + 1);

        emit ERC721BuyOrderPreSigned(order.maker, order.taker, order.expiry, order.nonce,
            order.erc20Token, order.erc20TokenAmount, order.fees, order.nft, order.nftId, order.nftProperties);
    }

    // Core settlement logic for selling an ERC721 asset.
    // Used by `sellERC721` and `onERC721Received`.
    function _sellERC721(
        LibNFTOrder.NFTBuyOrder memory buyOrder,
        LibSignature.Signature memory signature,
        uint256 erc721TokenId,
        bool unwrapNativeToken,
        address taker,
        address currentNftOwner,
        bytes memory takerCallbackData
    ) private {
        (, bytes32 orderHash) = _sellNFT(
            buyOrder,
            signature,
            SellParams(1, erc721TokenId, unwrapNativeToken, taker, currentNftOwner, takerCallbackData)
        );

        emit ERC721BuyOrderFilled(
            buyOrder.maker,
            taker,
            buyOrder.erc20Token,
            buyOrder.erc20TokenAmount,
            buyOrder.nft,
            erc721TokenId,
            orderHash
        );
    }

    // Core settlement logic for buying an ERC721 asset.
    // Used by `buyERC721` and `batchBuyERC721s`.
    function _buyERC721(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature) internal {
        (, bytes32 orderHash) = _buyNFT(sellOrder, signature, 1);

        emit ERC721SellOrderFilled(
            sellOrder.maker,
            msg.sender,
            sellOrder.erc20Token,
            sellOrder.erc20TokenAmount,
            sellOrder.nft,
            sellOrder.nftId,
            orderHash
        );
    }

    function _buyERC721Ex(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibSignature.Signature memory signature,
        address taker,
        uint256 ethAvailable,
        bytes memory takerCallbackData
    ) internal {
        if (taker == address (0)) {
            taker = msg.sender;
        } else {
            require(taker != address(this), "_buy721Ex/TAKER_CANNOT_SELF");
        }
        (, bytes32 orderHash) = _buyNFTEx(sellOrder, signature, BuyParams(1, ethAvailable, taker, takerCallbackData));

        emit ERC721SellOrderFilled(
            sellOrder.maker,
            taker,
            sellOrder.erc20Token,
            sellOrder.erc20TokenAmount,
            sellOrder.nft,
            sellOrder.nftId,
            orderHash
        );
    }

    /// @dev Checks whether the given signature is valid for the
    ///      the given ERC721 sell order. Reverts if not.
    /// @param order The ERC721 sell order.
    /// @param signature The signature to validate.
    function validateERC721SellOrderSignature(LibNFTOrder.NFTSellOrder memory order, LibSignature.Signature memory signature) public override view {
        _validateOrderSignature(getERC721SellOrderHash(order), signature, order.maker);
    }

    /// @dev Checks whether the given signature is valid for the
    ///      the given ERC721 buy order. Reverts if not.
    /// @param order The ERC721 buy order.
    /// @param signature The signature to validate.
    function validateERC721BuyOrderSignature(LibNFTOrder.NFTBuyOrder memory order, LibSignature.Signature memory signature) public override view {
        _validateOrderSignature(getERC721BuyOrderHash(order), signature, order.maker);
    }

    /// @dev Validates that the given signature is valid for the
    ///      given maker and order hash. Reverts if the signature
    ///      is not valid.
    /// @param orderHash The hash of the order that was signed.
    /// @param signature The signature to check.
    /// @param maker The maker of the order.
    function _validateOrderSignature(bytes32 orderHash, LibSignature.Signature memory signature, address maker) internal override view {
        if (signature.signatureType == LibSignature.SignatureType.PRESIGNED) {
            require(LibERC721OrdersStorage.getStorage().preSigned[orderHash]
                == LibCommonNftOrdersStorage.getStorage().hashNonces[maker] + 1, "PRESIGNED_INVALID_SIGNER");
        } else {
            require(maker != address(0) && maker == ecrecover(orderHash, signature.v, signature.r, signature.s), "INVALID_SIGNER_ERROR");
        }
    }

    /// @dev Transfers an NFT asset.
    /// @param token The address of the NFT contract.
    /// @param from The address currently holding the asset.
    /// @param to The address to transfer the asset to.
    /// @param tokenId The ID of the asset to transfer.
    function _transferNFTAssetFrom(address token, address from, address to, uint256 tokenId, uint256 /* amount */) internal override {
        _transferERC721AssetFrom(token, from, to, tokenId);
    }

    /// @dev Updates storage to indicate that the given order
    ///      has been filled by the given amount.
    /// @param order The order that has been filled.
    function _updateOrderState(LibNFTOrder.NFTSellOrder memory order, bytes32 /* orderHash */, uint128 /* fillAmount */) internal override {
        _setOrderStatusBit(order.maker, order.nonce);
    }

    function _setOrderStatusBit(address maker, uint256 nonce) private {
        // The bitvector is indexed by the lower 8 bits of the nonce.
        uint256 flag = 1 << (nonce & 255);
        // Update order status bit vector to indicate that the given order
        // has been cancelled/filled by setting the designated bit to 1.
        LibERC721OrdersStorage.getStorage().orderStatusByMaker[maker][uint248(nonce >> 8)] |= flag;
    }

    /// @dev Get the current status of an ERC721 sell order.
    /// @param order The ERC721 sell order.
    /// @return status The status of the order.
    function getERC721SellOrderStatus(LibNFTOrder.NFTSellOrder memory order) public override view returns (LibNFTOrder.OrderStatus) {
        // Check for listingTime.
        // Gas Optimize, listingTime only used in rare cases.
        if (order.expiry & 0xffffffff00000000 > 0) {
            if ((order.expiry >> 32) & 0xffffffff > block.timestamp) {
                return LibNFTOrder.OrderStatus.INVALID;
            }
        }

        // Check for expiryTime.
        if (order.expiry & 0xffffffff <= block.timestamp) {
            return LibNFTOrder.OrderStatus.EXPIRED;
        }

        // Check `orderStatusByMaker` state variable to see if the order
        // has been cancelled or previously filled.
        LibERC721OrdersStorage.Storage storage stor = LibERC721OrdersStorage.getStorage();

        // `orderStatusByMaker` is indexed by maker and nonce.
        uint256 orderStatusBitVector = stor.orderStatusByMaker[order.maker][uint248(order.nonce >> 8)];

        // The bitvector is indexed by the lower 8 bits of the nonce.
        uint256 flag = 1 << (order.nonce & 255);

        // If the designated bit is set, the order has been cancelled or
        // previously filled, so it is now unfillable.
        if (orderStatusBitVector & flag != 0) {
            return LibNFTOrder.OrderStatus.UNFILLABLE;
        }

        // Otherwise, the order is fillable.
        return LibNFTOrder.OrderStatus.FILLABLE;
    }

    /// @dev Get the current status of an ERC721 buy order.
    /// @param order The ERC721 buy order.
    /// @return status The status of the order.
    function getERC721BuyOrderStatus(LibNFTOrder.NFTBuyOrder memory order) public override view returns (LibNFTOrder.OrderStatus) {
        // Only buy orders with `nftId` == 0 can be property orders.
        if (order.nftId != 0 && order.nftProperties.length > 0) {
            return LibNFTOrder.OrderStatus.INVALID;
        }

        // Buy orders cannot use ETH as the ERC20 token, since ETH cannot be
        // transferred from the buyer by a contract.
        if (address(order.erc20Token) == NATIVE_TOKEN_ADDRESS) {
            return LibNFTOrder.OrderStatus.INVALID;
        }

        return getERC721SellOrderStatus(order.asNFTSellOrder());
    }

    /// @dev Get the order info for an NFT sell order.
    /// @param nftSellOrder The NFT sell order.
    /// @return orderInfo Info about the order.
    function _getOrderInfo(LibNFTOrder.NFTSellOrder memory nftSellOrder) internal override view returns (LibNFTOrder.OrderInfo memory) {
        LibNFTOrder.OrderInfo memory orderInfo;
        orderInfo.orderHash = getERC721SellOrderHash(nftSellOrder);
        orderInfo.status = getERC721SellOrderStatus(nftSellOrder);
        orderInfo.orderAmount = 1;
        orderInfo.remainingAmount = orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE ? 1 : 0;
        return orderInfo;
    }

    /// @dev Get the order info for an NFT buy order.
    /// @param nftBuyOrder The NFT buy order.
    /// @return orderInfo Info about the order.
    function _getOrderInfo(LibNFTOrder.NFTBuyOrder memory nftBuyOrder) internal override view returns (LibNFTOrder.OrderInfo memory) {
        LibNFTOrder.OrderInfo memory orderInfo;
        orderInfo.orderHash = getERC721BuyOrderHash(nftBuyOrder);
        orderInfo.status = getERC721BuyOrderStatus(nftBuyOrder);
        orderInfo.orderAmount = 1;
        orderInfo.remainingAmount = orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE ? 1 : 0;
        return orderInfo;
    }

    /// @dev Get the EIP-712 hash of an ERC721 sell order.
    /// @param order The ERC721 sell order.
    /// @return orderHash The order hash.
    function getERC721SellOrderHash(LibNFTOrder.NFTSellOrder memory order) public override view returns (bytes32) {
        return _getEIP712Hash(LibNFTOrder.getNFTSellOrderStructHash(
                order, LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker]));
    }

    /// @dev Get the EIP-712 hash of an ERC721 buy order.
    /// @param order The ERC721 buy order.
    /// @return orderHash The order hash.
    function getERC721BuyOrderHash(LibNFTOrder.NFTBuyOrder memory order) public override view returns (bytes32) {
        return _getEIP712Hash(LibNFTOrder.getNFTBuyOrderStructHash(
                order, LibCommonNftOrdersStorage.getStorage().hashNonces[order.maker]));
    }

    /// @dev Get the order status bit vector for the given
    ///      maker address and nonce range.
    /// @param maker The maker of the order.
    /// @param nonceRange Order status bit vectors are indexed
    ///        by maker address and the upper 248 bits of the
    ///        order nonce. We define `nonceRange` to be these
    ///        248 bits.
    /// @return bitVector The order status bit vector for the
    ///         given maker and nonce range.
    function getERC721OrderStatusBitVector(address maker, uint248 nonceRange) external override view returns (uint256) {
        return LibERC721OrdersStorage.getStorage().orderStatusByMaker[maker][nonceRange];
    }

    function getHashNonce(address maker) external override view returns (uint256) {
        return LibCommonNftOrdersStorage.getStorage().hashNonces[maker];
    }

    /// Increment a particular maker's nonce, thereby invalidating all orders that were not signed
    /// with the original nonce.
    function incrementHashNonce() external override {
        uint256 newHashNonce = ++LibCommonNftOrdersStorage.getStorage().hashNonces[msg.sender];
        emit HashNonceIncremented(msg.sender, newHashNonce);
    }
}

File 2 of 17 : FixinERC721Spender.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


/// @dev Helpers for moving ERC721 assets around.
abstract contract FixinERC721Spender {

    // Mask of the lower 20 bytes of a bytes32.
    uint256 constant private ADDRESS_MASK = 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff;

    /// @dev Transfers an ERC721 asset from `owner` to `to`.
    /// @param token The address of the ERC721 token contract.
    /// @param owner The owner of the asset.
    /// @param to The recipient of the asset.
    /// @param tokenId The token ID of the asset to transfer.
    function _transferERC721AssetFrom(address token, address owner, address to, uint256 tokenId) internal {
        uint256 success;
        assembly {
            let ptr := mload(0x40) // free memory pointer

            // selector for transferFrom(address,address,uint256)
            mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK))
            mstore(add(ptr, 0x24), and(to, ADDRESS_MASK))
            mstore(add(ptr, 0x44), tokenId)

            success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x64, 0, 0)
        }
        require(success != 0, "_transferERC721/TRANSFER_FAILED");
    }
}

File 3 of 17 : LibCommonNftOrdersStorage.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2022 Element.Market

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "./LibStorage.sol";


library LibCommonNftOrdersStorage {

    /// @dev Storage bucket for this feature.
    struct Storage {
        /* Track per-maker nonces that can be incremented by the maker to cancel orders in bulk. */
        // The current nonce for the maker represents the only valid nonce that can be signed by the maker
        // If a signature was signed with a nonce that's different from the one stored in nonces, it
        // will fail validation.
        mapping(address => uint256) hashNonces;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        uint256 storageSlot = LibStorage.STORAGE_ID_COMMON_NFT_ORDERS;
        // Dip into assembly to change the slot pointed to by the local
        // variable `stor`.
        // See https://solidity.readthedocs.io/en/v0.6.8/assembly.html?highlight=slot#access-to-external-variables-functions-and-libraries
        assembly { stor.slot := storageSlot }
    }
}

File 4 of 17 : LibERC721OrdersStorage.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "./LibStorage.sol";


/// @dev Storage helpers for `ERC721OrdersFeature`.
library LibERC721OrdersStorage {

    /// @dev Storage bucket for this feature.
    struct Storage {
        // maker => nonce range => order status bit vector
        mapping(address => mapping(uint248 => uint256)) orderStatusByMaker;
        // order hash => hashNonce
        mapping(bytes32 => uint256) preSigned;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        uint256 storageSlot = LibStorage.STORAGE_ID_ERC721_ORDERS;
        // Dip into assembly to change the slot pointed to by the local
        // variable `stor`.
        // See https://solidity.readthedocs.io/en/v0.6.8/assembly.html?highlight=slot#access-to-external-variables-functions-and-libraries
        assembly { stor.slot := storageSlot }
    }
}

File 5 of 17 : IERC721OrdersFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../libs/LibNFTOrder.sol";
import "../libs/LibSignature.sol";


/// @dev Feature for interacting with ERC721 orders.
interface IERC721OrdersFeature {

    /// @dev Emitted whenever an `ERC721SellOrder` is filled.
    /// @param maker The maker of the order.
    /// @param taker The taker of the order.
    /// @param erc20Token The address of the ERC20 token.
    /// @param erc20TokenAmount The amount of ERC20 token to sell.
    /// @param erc721Token The address of the ERC721 token.
    /// @param erc721TokenId The ID of the ERC721 asset.
    /// @param orderHash The `ERC721SellOrder` hash.
    event ERC721SellOrderFilled(
        address maker,
        address taker,
        IERC20 erc20Token,
        uint256 erc20TokenAmount,
        address erc721Token,
        uint256 erc721TokenId,
        bytes32 orderHash
    );

    /// @dev Emitted whenever an `ERC721BuyOrder` is filled.
    /// @param maker The maker of the order.
    /// @param taker The taker of the order.
    /// @param erc20Token The address of the ERC20 token.
    /// @param erc20TokenAmount The amount of ERC20 token to buy.
    /// @param erc721Token The address of the ERC721 token.
    /// @param erc721TokenId The ID of the ERC721 asset.
    /// @param orderHash The `ERC721BuyOrder` hash.
    event ERC721BuyOrderFilled(
        address maker,
        address taker,
        IERC20 erc20Token,
        uint256 erc20TokenAmount,
        address erc721Token,
        uint256 erc721TokenId,
        bytes32 orderHash
    );

    /// @dev Emitted when an `ERC721SellOrder` is pre-signed.
    ///      Contains all the fields of the order.
    event ERC721SellOrderPreSigned(
        address maker,
        address taker,
        uint256 expiry,
        uint256 nonce,
        IERC20 erc20Token,
        uint256 erc20TokenAmount,
        LibNFTOrder.Fee[] fees,
        address erc721Token,
        uint256 erc721TokenId
    );

    /// @dev Emitted when an `ERC721BuyOrder` is pre-signed.
    ///      Contains all the fields of the order.
    event ERC721BuyOrderPreSigned(
        address maker,
        address taker,
        uint256 expiry,
        uint256 nonce,
        IERC20 erc20Token,
        uint256 erc20TokenAmount,
        LibNFTOrder.Fee[] fees,
        address erc721Token,
        uint256 erc721TokenId,
        LibNFTOrder.Property[] nftProperties
    );

    /// @dev Emitted whenever an `ERC721Order` is cancelled.
    /// @param maker The maker of the order.
    /// @param nonce The nonce of the order that was cancelled.
    event ERC721OrderCancelled(address maker, uint256 nonce);

    /// @dev Emitted HashNonceIncremented.
    event HashNonceIncremented(address maker, uint256 newHashNonce);

    /// @dev Sells an ERC721 asset to fill the given order.
    /// @param buyOrder The ERC721 buy order.
    /// @param signature The order signature from the maker.
    /// @param erc721TokenId The ID of the ERC721 asset being
    ///        sold. If the given order specifies properties,
    ///        the asset must satisfy those properties. Otherwise,
    ///        it must equal the tokenId in the order.
    /// @param unwrapNativeToken If this parameter is true and the
    ///        ERC20 token of the order is e.g. WETH, unwraps the
    ///        token before transferring it to the taker.
    /// @param callbackData If this parameter is non-zero, invokes
    ///        `zeroExERC721OrderCallback` on `msg.sender` after
    ///        the ERC20 tokens have been transferred to `msg.sender`
    ///        but before transferring the ERC721 asset to the buyer.
    function sellERC721(LibNFTOrder.NFTBuyOrder calldata buyOrder, LibSignature.Signature calldata signature, uint256 erc721TokenId, bool unwrapNativeToken, bytes calldata callbackData) external;

    /// @dev Buys an ERC721 asset by filling the given order.
    /// @param sellOrder The ERC721 sell order.
    /// @param signature The order signature.
    function buyERC721(LibNFTOrder.NFTSellOrder calldata sellOrder, LibSignature.Signature calldata signature) external payable;

    /// @dev Buys an ERC721 asset by filling the given order.
    /// @param sellOrder The ERC721 sell order.
    /// @param signature The order signature.
    /// @param taker The address to receive ERC721. If this parameter
    ///         is zero, transfer ERC721 to `msg.sender`.
    /// @param callbackData If this parameter is non-zero, invokes
    ///        `zeroExERC721OrderCallback` on `msg.sender` after
    ///        the ERC721 asset has been transferred to `msg.sender`
    ///        but before transferring the ERC20 tokens to the seller.
    ///        Native tokens acquired during the callback can be used
    ///        to fill the order.
    function buyERC721Ex(LibNFTOrder.NFTSellOrder calldata sellOrder, LibSignature.Signature calldata signature, address taker, bytes calldata callbackData) external payable;

    /// @dev Cancel a single ERC721 order by its nonce. The caller
    ///      should be the maker of the order. Silently succeeds if
    ///      an order with the same nonce has already been filled or
    ///      cancelled.
    /// @param orderNonce The order nonce.
    function cancelERC721Order(uint256 orderNonce) external;

    /// @dev Cancel multiple ERC721 orders by their nonces. The caller
    ///      should be the maker of the orders. Silently succeeds if
    ///      an order with the same nonce has already been filled or
    ///      cancelled.
    /// @param orderNonces The order nonces.
    function batchCancelERC721Orders(uint256[] calldata orderNonces) external;

    /// @dev Buys multiple ERC721 assets by filling the
    ///      given orders.
    /// @param sellOrders The ERC721 sell orders.
    /// @param signatures The order signatures.
    /// @param revertIfIncomplete If true, reverts if this
    ///        function fails to fill any individual order.
    /// @return successes An array of booleans corresponding to whether
    ///         each order in `orders` was successfully filled.
    function batchBuyERC721s(
        LibNFTOrder.NFTSellOrder[] calldata sellOrders,
        LibSignature.Signature[] calldata signatures,
        bool revertIfIncomplete
    ) external payable returns (bool[] memory successes);

    /// @dev Buys multiple ERC721 assets by filling the
    ///      given orders.
    /// @param sellOrders The ERC721 sell orders.
    /// @param signatures The order signatures.
    /// @param takers The address to receive ERC721.
    /// @param callbackData The data (if any) to pass to the taker
    ///        callback for each order. Refer to the `callbackData`
    ///        parameter to for `buyERC721`.
    /// @param revertIfIncomplete If true, reverts if this
    ///        function fails to fill any individual order.
    /// @return successes An array of booleans corresponding to whether
    ///         each order in `orders` was successfully filled.
    function batchBuyERC721sEx(
        LibNFTOrder.NFTSellOrder[] calldata sellOrders,
        LibSignature.Signature[] calldata signatures,
        address[] calldata takers,
        bytes[] calldata callbackData,
        bool revertIfIncomplete
    ) external payable returns (bool[] memory successes);

    /// @dev Matches a pair of complementary orders that have
    ///      a non-negative spread. Each order is filled at
    ///      their respective price, and the matcher receives
    ///      a profit denominated in the ERC20 token.
    /// @param sellOrder Order selling an ERC721 asset.
    /// @param buyOrder Order buying an ERC721 asset.
    /// @param sellOrderSignature Signature for the sell order.
    /// @param buyOrderSignature Signature for the buy order.
    /// @return profit The amount of profit earned by the caller
    ///         of this function (denominated in the ERC20 token
    ///         of the matched orders).
    function matchERC721Orders(
        LibNFTOrder.NFTSellOrder calldata sellOrder,
        LibNFTOrder.NFTBuyOrder calldata buyOrder,
        LibSignature.Signature calldata sellOrderSignature,
        LibSignature.Signature calldata buyOrderSignature
    ) external returns (uint256 profit);

    /// @dev Matches pairs of complementary orders that have
    ///      non-negative spreads. Each order is filled at
    ///      their respective price, and the matcher receives
    ///      a profit denominated in the ERC20 token.
    /// @param sellOrders Orders selling ERC721 assets.
    /// @param buyOrders Orders buying ERC721 assets.
    /// @param sellOrderSignatures Signatures for the sell orders.
    /// @param buyOrderSignatures Signatures for the buy orders.
    /// @return profits The amount of profit earned by the caller
    ///         of this function for each pair of matched orders
    ///         (denominated in the ERC20 token of the order pair).
    /// @return successes An array of booleans corresponding to
    ///         whether each pair of orders was successfully matched.
    function batchMatchERC721Orders(
        LibNFTOrder.NFTSellOrder[] calldata sellOrders,
        LibNFTOrder.NFTBuyOrder[] calldata buyOrders,
        LibSignature.Signature[] calldata sellOrderSignatures,
        LibSignature.Signature[] calldata buyOrderSignatures
    ) external returns (uint256[] memory profits, bool[] memory successes);

    /// @dev Callback for the ERC721 `safeTransferFrom` function.
    ///      This callback can be used to sell an ERC721 asset if
    ///      a valid ERC721 order, signature and `unwrapNativeToken`
    ///      are encoded in `data`. This allows takers to sell their
    ///      ERC721 asset without first calling `setApprovalForAll`.
    /// @param operator The address which called `safeTransferFrom`.
    /// @param from The address which previously owned the token.
    /// @param tokenId The ID of the asset being transferred.
    /// @param data Additional data with no specified format. If a
    ///        valid ERC721 order, signature and `unwrapNativeToken`
    ///        are encoded in `data`, this function will try to fill
    ///        the order using the received asset.
    /// @return success The selector of this function (0x150b7a02),
    ///         indicating that the callback succeeded.
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4 success);

    /// @dev Approves an ERC721 sell order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 sell order.
    function preSignERC721SellOrder(LibNFTOrder.NFTSellOrder calldata order) external;

    /// @dev Approves an ERC721 buy order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 buy order.
    function preSignERC721BuyOrder(LibNFTOrder.NFTBuyOrder calldata order) external;

    /// @dev Checks whether the given signature is valid for the
    ///      the given ERC721 sell order. Reverts if not.
    /// @param order The ERC721 sell order.
    /// @param signature The signature to validate.
    function validateERC721SellOrderSignature(LibNFTOrder.NFTSellOrder calldata order, LibSignature.Signature calldata signature) external view;

    /// @dev Checks whether the given signature is valid for the
    ///      the given ERC721 buy order. Reverts if not.
    /// @param order The ERC721 buy order.
    /// @param signature The signature to validate.
    function validateERC721BuyOrderSignature(LibNFTOrder.NFTBuyOrder calldata order, LibSignature.Signature calldata signature) external view;

    /// @dev Get the current status of an ERC721 sell order.
    /// @param order The ERC721 sell order.
    /// @return status The status of the order.
    function getERC721SellOrderStatus(LibNFTOrder.NFTSellOrder calldata order) external view returns (LibNFTOrder.OrderStatus);

    /// @dev Get the current status of an ERC721 buy order.
    /// @param order The ERC721 buy order.
    /// @return status The status of the order.
    function getERC721BuyOrderStatus(LibNFTOrder.NFTBuyOrder calldata order) external view returns (LibNFTOrder.OrderStatus);

    /// @dev Get the EIP-712 hash of an ERC721 sell order.
    /// @param order The ERC721 sell order.
    /// @return orderHash The order hash.
    function getERC721SellOrderHash(LibNFTOrder.NFTSellOrder calldata order) external view returns (bytes32);

    /// @dev Get the EIP-712 hash of an ERC721 buy order.
    /// @param order The ERC721 buy order.
    /// @return orderHash The order hash.
    function getERC721BuyOrderHash(LibNFTOrder.NFTBuyOrder calldata order) external view returns (bytes32);

    /// @dev Get the order status bit vector for the given
    ///      maker address and nonce range.
    /// @param maker The maker of the order.
    /// @param nonceRange Order status bit vectors are indexed
    ///        by maker address and the upper 248 bits of the
    ///        order nonce. We define `nonceRange` to be these
    ///        248 bits.
    /// @return bitVector The order status bit vector for the
    ///         given maker and nonce range.
    function getERC721OrderStatusBitVector(address maker, uint248 nonceRange) external view returns (uint256);

    function getHashNonce(address maker) external view returns (uint256);

    /// Increment a particular maker's nonce, thereby invalidating all orders that were not signed
    /// with the original nonce.
    function incrementHashNonce() external;
}

File 6 of 17 : NFTOrders.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../fixins/FixinEIP712.sol";
import "../../fixins/FixinTokenSpender.sol";
import "../../vendor/IEtherToken.sol";
import "../../vendor/IFeeRecipient.sol";
import "../../vendor/ITakerCallback.sol";
import "../libs/LibSignature.sol";
import "../libs/LibNFTOrder.sol";


/// @dev Abstract base contract inherited by ERC721OrdersFeature and NFTOrders
abstract contract NFTOrders is FixinEIP712, FixinTokenSpender {

    using LibNFTOrder for LibNFTOrder.NFTBuyOrder;

    /// @dev Native token pseudo-address.
    address constant internal NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    /// @dev The WETH token contract.
    IEtherToken internal immutable WETH;
    /// @dev The implementation address of this feature.
    address internal immutable _implementation;

    /// @dev The magic return value indicating the success of a `receiveZeroExFeeCallback`.
    bytes4 private constant FEE_CALLBACK_MAGIC_BYTES = IFeeRecipient.receiveZeroExFeeCallback.selector;
    /// @dev The magic return value indicating the success of a `zeroExTakerCallback`.
    bytes4 private constant TAKER_CALLBACK_MAGIC_BYTES = ITakerCallback.zeroExTakerCallback.selector;

    constructor(IEtherToken weth) {
        require(address(weth) != address(0), "WETH_ADDRESS_ERROR");
        WETH = weth;
        // Remember this feature's original address.
        _implementation = address(this);
    }

    struct SellParams {
        uint128 sellAmount;
        uint256 tokenId;
        bool unwrapNativeToken;
        address taker;
        address currentNftOwner;
        bytes takerCallbackData;
    }

    struct BuyParams {
        uint128 buyAmount;
        uint256 ethAvailable;
        address taker;
        bytes takerCallbackData;
    }

    // Core settlement logic for selling an NFT asset.
    function _sellNFT(
        LibNFTOrder.NFTBuyOrder memory buyOrder,
        LibSignature.Signature memory signature,
        SellParams memory params
    ) internal returns (uint256 erc20FillAmount, bytes32 orderHash) {
        LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(buyOrder);
        orderHash = orderInfo.orderHash;

        // Check that the order can be filled.
        _validateBuyOrder(buyOrder, signature, orderInfo, params.taker, params.tokenId);

        // Check amount.
        if (params.sellAmount > orderInfo.remainingAmount) {
            revert("_sellNFT/EXCEEDS_REMAINING_AMOUNT");
        }

        // Update the order state.
        _updateOrderState(buyOrder.asNFTSellOrder(), orderInfo.orderHash, params.sellAmount);

        // Calculate erc20 pay amount.
        erc20FillAmount = (params.sellAmount == orderInfo.orderAmount) ?
            buyOrder.erc20TokenAmount : buyOrder.erc20TokenAmount * params.sellAmount / orderInfo.orderAmount;

        if (params.unwrapNativeToken) {
            // The ERC20 token must be WETH for it to be unwrapped.
            require(buyOrder.erc20Token == WETH, "_sellNFT/ERC20_TOKEN_MISMATCH_ERROR");

            // Transfer the WETH from the maker to the Exchange Proxy
            // so we can unwrap it before sending it to the seller.
            // TODO: Probably safe to just use WETH.transferFrom for some
            //       small gas savings
            _transferERC20TokensFrom(WETH, buyOrder.maker, address(this), erc20FillAmount);

            // Unwrap WETH into ETH.
            WETH.withdraw(erc20FillAmount);

            // Send ETH to the seller.
            _transferEth(payable(params.taker), erc20FillAmount);
        } else {
            // Transfer the ERC20 token from the buyer to the seller.
            _transferERC20TokensFrom(buyOrder.erc20Token, buyOrder.maker, params.taker, erc20FillAmount);
        }

        if (params.takerCallbackData.length > 0) {
            require(params.taker != address(this), "_sellNFT/CANNOT_CALLBACK_SELF");

            // Invoke the callback
            bytes4 callbackResult = ITakerCallback(params.taker).zeroExTakerCallback(orderInfo.orderHash, params.takerCallbackData);

            // Check for the magic success bytes
            require(callbackResult == TAKER_CALLBACK_MAGIC_BYTES, "_sellNFT/CALLBACK_FAILED");
        }

        // Transfer the NFT asset to the buyer.
        // If this function is called from the
        // `onNFTReceived` callback the Exchange Proxy
        // holds the asset. Otherwise, transfer it from
        // the seller.
        _transferNFTAssetFrom(buyOrder.nft, params.currentNftOwner, buyOrder.maker, params.tokenId, params.sellAmount);

        // The buyer pays the order fees.
        _payFees(buyOrder.asNFTSellOrder(), buyOrder.maker, params.sellAmount, orderInfo.orderAmount, false);
    }

    // Core settlement logic for buying an NFT asset.
    function _buyNFT(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibSignature.Signature memory signature,
        uint128 buyAmount
    ) internal returns (uint256 erc20FillAmount, bytes32 orderHash) {
        LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(sellOrder);
        orderHash = orderInfo.orderHash;

        // Check that the order can be filled.
        _validateSellOrder(sellOrder, signature, orderInfo, msg.sender);

        // Check amount.
        if (buyAmount > orderInfo.remainingAmount) {
            revert("_buyNFT/EXCEEDS_REMAINING_AMOUNT");
        }

        // Update the order state.
        _updateOrderState(sellOrder, orderInfo.orderHash, buyAmount);

        // Calculate erc20 pay amount.
        erc20FillAmount = (buyAmount == orderInfo.orderAmount) ?
            sellOrder.erc20TokenAmount : _ceilDiv(sellOrder.erc20TokenAmount * buyAmount, orderInfo.orderAmount);

        // Transfer the NFT asset to the buyer (`msg.sender`).
        _transferNFTAssetFrom(sellOrder.nft, sellOrder.maker, msg.sender, sellOrder.nftId, buyAmount);

        if (address(sellOrder.erc20Token) == NATIVE_TOKEN_ADDRESS) {
            // Transfer ETH to the seller.
            _transferEth(payable(sellOrder.maker), erc20FillAmount);

            // Fees are paid from the EP's current balance of ETH.
            _payFees(sellOrder, address(this), buyAmount, orderInfo.orderAmount, true);
        } else {
            // Transfer ERC20 token from the buyer to the seller.
            _transferERC20TokensFrom(sellOrder.erc20Token, msg.sender, sellOrder.maker, erc20FillAmount);

            // The buyer pays fees.
            _payFees(sellOrder, msg.sender, buyAmount, orderInfo.orderAmount, false);
        }
    }

    function _buyNFTEx(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibSignature.Signature memory signature,
        BuyParams memory params
    ) internal returns (uint256 erc20FillAmount, bytes32 orderHash) {
        LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(sellOrder);
        orderHash = orderInfo.orderHash;

        // Check that the order can be filled.
        _validateSellOrder(sellOrder, signature, orderInfo, params.taker);

        // Check amount.
        if (params.buyAmount > orderInfo.remainingAmount) {
            revert("_buyNFTEx/EXCEEDS_REMAINING_AMOUNT");
        }

        // Update the order state.
        _updateOrderState(sellOrder, orderInfo.orderHash, params.buyAmount);

        // Dutch Auction
        if (sellOrder.expiry >> 252 == 1) {
            uint256 count = (sellOrder.expiry >> 64) & 0xffffffff;
            if (count > 0) {
                _resetDutchAuctionTokenAmountAndFees(sellOrder, count);
            }
        }

        // Calculate erc20 pay amount.
        erc20FillAmount = (params.buyAmount == orderInfo.orderAmount) ?
            sellOrder.erc20TokenAmount : _ceilDiv(sellOrder.erc20TokenAmount * params.buyAmount, orderInfo.orderAmount);

        // Transfer the NFT asset to the buyer.
        _transferNFTAssetFrom(sellOrder.nft, sellOrder.maker, params.taker, sellOrder.nftId, params.buyAmount);

        uint256 ethAvailable = params.ethAvailable;
        if (params.takerCallbackData.length > 0) {
            require(params.taker != address(this), "_buyNFTEx/CANNOT_CALLBACK_SELF");

            uint256 ethBalanceBeforeCallback = address(this).balance;

            // Invoke the callback
            bytes4 callbackResult = ITakerCallback(params.taker).zeroExTakerCallback(orderInfo.orderHash, params.takerCallbackData);

            // Update `ethAvailable` with amount acquired during
            // the callback
            ethAvailable += address(this).balance - ethBalanceBeforeCallback;

            // Check for the magic success bytes
            require(callbackResult == TAKER_CALLBACK_MAGIC_BYTES, "_buyNFTEx/CALLBACK_FAILED");
        }

        if (address(sellOrder.erc20Token) == NATIVE_TOKEN_ADDRESS) {
            uint256 totalPaid = erc20FillAmount + _calcTotalFeesPaid(sellOrder.fees, params.buyAmount, orderInfo.orderAmount);
            if (ethAvailable < totalPaid) {
                // Transfer WETH from the buyer to this contract.
                uint256 withDrawAmount = totalPaid - ethAvailable;
                _transferERC20TokensFrom(WETH, msg.sender, address(this), withDrawAmount);

                // Unwrap WETH into ETH.
                WETH.withdraw(withDrawAmount);
            }

            // Transfer ETH to the seller.
            _transferEth(payable(sellOrder.maker), erc20FillAmount);

            // Fees are paid from the EP's current balance of ETH.
            _payFees(sellOrder, address(this), params.buyAmount, orderInfo.orderAmount, true);
        } else if (sellOrder.erc20Token == WETH) {
            uint256 totalFeesPaid = _calcTotalFeesPaid(sellOrder.fees, params.buyAmount, orderInfo.orderAmount);
            if (ethAvailable > totalFeesPaid) {
                uint256 depositAmount = ethAvailable - totalFeesPaid;
                if (depositAmount < erc20FillAmount) {
                    // Transfer WETH from the buyer to this contract.
                    _transferERC20TokensFrom(WETH, msg.sender, address(this), (erc20FillAmount - depositAmount));
                } else {
                    depositAmount = erc20FillAmount;
                }

                // Wrap ETH.
                WETH.deposit{value: depositAmount}();

                // Transfer WETH to the seller.
                _transferERC20Tokens(WETH, sellOrder.maker, erc20FillAmount);

                // Fees are paid from the EP's current balance of ETH.
                _payFees(sellOrder, address(this), params.buyAmount, orderInfo.orderAmount, true);
            } else {
                // Transfer WETH from the buyer to the seller.
                _transferERC20TokensFrom(WETH, msg.sender, sellOrder.maker, erc20FillAmount);

                if (ethAvailable > 0) {
                    if (ethAvailable < totalFeesPaid) {
                        // Transfer WETH from the buyer to this contract.
                        uint256 value = totalFeesPaid - ethAvailable;
                        _transferERC20TokensFrom(WETH, msg.sender, address(this), value);

                        // Unwrap WETH into ETH.
                        WETH.withdraw(value);
                    }

                    // Fees are paid from the EP's current balance of ETH.
                    _payFees(sellOrder, address(this), params.buyAmount, orderInfo.orderAmount, true);
                } else {
                    // The buyer pays fees using WETH.
                    _payFees(sellOrder, msg.sender, params.buyAmount, orderInfo.orderAmount, false);
                }
            }
        } else {
            // Transfer ERC20 token from the buyer to the seller.
            _transferERC20TokensFrom(sellOrder.erc20Token, msg.sender, sellOrder.maker, erc20FillAmount);

            // The buyer pays fees.
            _payFees(sellOrder, msg.sender, params.buyAmount, orderInfo.orderAmount, false);
        }
    }

    function _validateSellOrder(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        LibSignature.Signature memory signature,
        LibNFTOrder.OrderInfo memory orderInfo,
        address taker
    ) internal view {
        // Taker must match the order taker, if one is specified.
        require(sellOrder.taker == address(0) || sellOrder.taker == taker, "_validateOrder/ONLY_TAKER");

        // Check that the order is valid and has not expired, been cancelled,
        // or been filled.
        require(orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE, "_validateOrder/ORDER_NOT_FILL");

        // Check the signature.
        _validateOrderSignature(orderInfo.orderHash, signature, sellOrder.maker);
    }

    function _validateBuyOrder(
        LibNFTOrder.NFTBuyOrder memory buyOrder,
        LibSignature.Signature memory signature,
        LibNFTOrder.OrderInfo memory orderInfo,
        address taker,
        uint256 tokenId
    ) internal view {
        // The ERC20 token cannot be ETH.
        require(address(buyOrder.erc20Token) != NATIVE_TOKEN_ADDRESS, "_validateBuyOrder/TOKEN_MISMATCH");

        // Taker must match the order taker, if one is specified.
        require(buyOrder.taker == address(0) || buyOrder.taker == taker, "_validateBuyOrder/ONLY_TAKER");

        // Check that the order is valid and has not expired, been cancelled,
        // or been filled.
        require(orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE, "_validateOrder/ORDER_NOT_FILL");

        // Check that the asset with the given token ID satisfies the properties
        // specified by the order.
        _validateOrderProperties(buyOrder, tokenId);

        // Check the signature.
        _validateOrderSignature(orderInfo.orderHash, signature, buyOrder.maker);
    }

    function _resetDutchAuctionTokenAmountAndFees(LibNFTOrder.NFTSellOrder memory order, uint256 count) internal view {
        require(count <= 100000000, "COUNT_OUT_OF_SIDE");

        uint256 listingTime = (order.expiry >> 32) & 0xffffffff;
        uint256 denominator = ((order.expiry & 0xffffffff) - listingTime) * 100000000;
        uint256 multiplier = (block.timestamp - listingTime) * count;

        // Reset erc20TokenAmount
        uint256 amount = order.erc20TokenAmount;
        order.erc20TokenAmount = amount - amount * multiplier / denominator;

        // Reset fees
        for (uint256 i = 0; i < order.fees.length; i++) {
            amount = order.fees[i].amount;
            order.fees[i].amount = amount - amount * multiplier / denominator;
        }
    }

    function _resetEnglishAuctionTokenAmountAndFees(
        LibNFTOrder.NFTSellOrder memory sellOrder,
        uint256 buyERC20Amount,
        uint256 fillAmount,
        uint256 orderAmount
    ) internal pure {
        uint256 sellOrderFees = _calcTotalFeesPaid(sellOrder.fees, fillAmount, orderAmount);
        uint256 sellTotalAmount = sellOrderFees + sellOrder.erc20TokenAmount;
        if (buyERC20Amount != sellTotalAmount) {
            uint256 spread = buyERC20Amount - sellTotalAmount;
            uint256 sum;

            // Reset fees
            if (sellTotalAmount > 0) {
                for (uint256 i = 0; i < sellOrder.fees.length; i++) {
                    uint256 diff = spread * sellOrder.fees[i].amount / sellTotalAmount;
                    sellOrder.fees[i].amount += diff;
                    sum += diff;
                }
            }

            // Reset erc20TokenAmount
            sellOrder.erc20TokenAmount += spread - sum;
        }
    }

    function _ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // ceil(a / b) = floor((a + b - 1) / b)
        return (a + b - 1) / b;
    }

    function _calcTotalFeesPaid(LibNFTOrder.Fee[] memory fees, uint256 fillAmount, uint256 orderAmount) private pure returns (uint256 totalFeesPaid) {
        if (fillAmount == orderAmount) {
            for (uint256 i = 0; i < fees.length; i++) {
                totalFeesPaid += fees[i].amount;
            }
        } else {
            for (uint256 i = 0; i < fees.length; i++) {
                totalFeesPaid += fees[i].amount * fillAmount / orderAmount;
            }
        }
        return totalFeesPaid;
    }

    function _payFees(
        LibNFTOrder.NFTSellOrder memory order,
        address payer,
        uint128 fillAmount,
        uint128 orderAmount,
        bool useNativeToken
    ) internal returns (uint256 totalFeesPaid) {
        for (uint256 i = 0; i < order.fees.length; i++) {
            LibNFTOrder.Fee memory fee = order.fees[i];

            uint256 feeFillAmount = (fillAmount == orderAmount) ? fee.amount : fee.amount * fillAmount / orderAmount;

            if (useNativeToken) {
                // Transfer ETH to the fee recipient.
                _transferEth(payable(fee.recipient), feeFillAmount);
            } else {
                if (feeFillAmount > 0) {
                    // Transfer ERC20 token from payer to recipient.
                    _transferERC20TokensFrom(order.erc20Token, payer, fee.recipient, feeFillAmount);
                }
            }

            // Note that the fee callback is _not_ called if zero
            // `feeData` is provided. If `feeData` is provided, we assume
            // the fee recipient is a contract that implements the
            // `IFeeRecipient` interface.
            if (fee.feeData.length > 0) {
                // Invoke the callback
                bytes4 callbackResult = IFeeRecipient(fee.recipient).receiveZeroExFeeCallback(
                    useNativeToken ? NATIVE_TOKEN_ADDRESS : address(order.erc20Token),
                    feeFillAmount,
                    fee.feeData
                );

                // Check for the magic success bytes
                require(callbackResult == FEE_CALLBACK_MAGIC_BYTES, "_payFees/CALLBACK_FAILED");
            }

            // Sum the fees paid
            totalFeesPaid += feeFillAmount;
        }
        return totalFeesPaid;
    }

    function _validateOrderProperties(LibNFTOrder.NFTBuyOrder memory order, uint256 tokenId) internal view {
        // If no properties are specified, check that the given
        // `tokenId` matches the one specified in the order.
        if (order.nftProperties.length == 0) {
            require(tokenId == order.nftId, "_validateProperties/TOKEN_ID_ERR");
        } else {
            // Validate each property
            for (uint256 i = 0; i < order.nftProperties.length; i++) {
                LibNFTOrder.Property memory property = order.nftProperties[i];
                // `address(0)` is interpreted as a no-op. Any token ID
                // will satisfy a property with `propertyValidator == address(0)`.
                if (address(property.propertyValidator) != address(0)) {
                    // Call the property validator and throw a descriptive error
                    // if the call reverts.
                    try property.propertyValidator.validateProperty(order.nft, tokenId, property.propertyData) {
                    } catch (bytes memory /* reason */) {
                        revert("PROPERTY_VALIDATION_FAILED");
                    }
                }
            }
        }
    }

    /// @dev Validates that the given signature is valid for the
    ///      given maker and order hash. Reverts if the signature
    ///      is not valid.
    /// @param orderHash The hash of the order that was signed.
    /// @param signature The signature to check.
    /// @param maker The maker of the order.
    function _validateOrderSignature(bytes32 orderHash, LibSignature.Signature memory signature, address maker) internal virtual view;

    /// @dev Transfers an NFT asset.
    /// @param token The address of the NFT contract.
    /// @param from The address currently holding the asset.
    /// @param to The address to transfer the asset to.
    /// @param tokenId The ID of the asset to transfer.
    /// @param amount The amount of the asset to transfer. Always
    ///        1 for ERC721 assets.
    function _transferNFTAssetFrom(address token, address from, address to, uint256 tokenId, uint256 amount) internal virtual;

    /// @dev Updates storage to indicate that the given order
    ///      has been filled by the given amount.
    /// @param order The order that has been filled.
    /// @param orderHash The hash of `order`.
    /// @param fillAmount The amount (denominated in the NFT asset)
    ///        that the order has been filled by.
    function _updateOrderState(LibNFTOrder.NFTSellOrder memory order, bytes32 orderHash, uint128 fillAmount) internal virtual;

    /// @dev Get the order info for an NFT sell order.
    /// @param nftSellOrder The NFT sell order.
    /// @return orderInfo Info about the order.
    function _getOrderInfo(LibNFTOrder.NFTSellOrder memory nftSellOrder) internal virtual view returns (LibNFTOrder.OrderInfo memory);

    /// @dev Get the order info for an NFT buy order.
    /// @param nftBuyOrder The NFT buy order.
    /// @return orderInfo Info about the order.
    function _getOrderInfo(LibNFTOrder.NFTBuyOrder memory nftBuyOrder) internal virtual view returns (LibNFTOrder.OrderInfo memory);
}

File 7 of 17 : LibStorage.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


/// @dev Common storage helpers
library LibStorage {

    /// @dev What to bit-shift a storage ID by to get its slot.
    ///      This gives us a maximum of 2**128 inline fields in each bucket.
    uint256 constant STORAGE_ID_PROXY = 1 << 128;
    uint256 constant STORAGE_ID_SIMPLE_FUNCTION_REGISTRY = 2 << 128;
    uint256 constant STORAGE_ID_OWNABLE = 3 << 128;
    uint256 constant STORAGE_ID_COMMON_NFT_ORDERS = 4 << 128;
    uint256 constant STORAGE_ID_ERC721_ORDERS = 5 << 128;
    uint256 constant STORAGE_ID_ERC1155_ORDERS = 6 << 128;
}

File 8 of 17 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `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);

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

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

File 9 of 17 : LibNFTOrder.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../vendor/IPropertyValidator.sol";


/// @dev A library for common NFT order operations.
library LibNFTOrder {

    enum OrderStatus {
        INVALID,
        FILLABLE,
        UNFILLABLE,
        EXPIRED
    }

    struct Property {
        IPropertyValidator propertyValidator;
        bytes propertyData;
    }

    struct Fee {
        address recipient;
        uint256 amount;
        bytes feeData;
    }

    struct NFTSellOrder {
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        address nft;
        uint256 nftId;
    }

    // All fields except `nftProperties` align
    // with those of NFTSellOrder
    struct NFTBuyOrder {
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        address nft;
        uint256 nftId;
        Property[] nftProperties;
    }

    // All fields except `erc1155TokenAmount` align
    // with those of NFTSellOrder
    struct ERC1155SellOrder {
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        address erc1155Token;
        uint256 erc1155TokenId;
        // End of fields shared with NFTOrder
        uint128 erc1155TokenAmount;
    }

    // All fields except `erc1155TokenAmount` align
    // with those of NFTBuyOrder
    struct ERC1155BuyOrder {
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        address erc1155Token;
        uint256 erc1155TokenId;
        Property[] erc1155TokenProperties;
        // End of fields shared with NFTOrder
        uint128 erc1155TokenAmount;
    }

    struct OrderInfo {
        bytes32 orderHash;
        OrderStatus status;
        // `orderAmount` is 1 for all ERC721Orders, and
        // `erc1155TokenAmount` for ERC1155Orders.
        uint128 orderAmount;
        // The remaining amount of the ERC721/ERC1155 asset
        // that can be filled for the order.
        uint128 remainingAmount;
    }

    // The type hash for sell orders, which is:
    // keccak256(abi.encodePacked(
    //    "NFTSellOrder(",
    //        "address maker,",
    //        "address taker,",
    //        "uint256 expiry,",
    //        "uint256 nonce,",
    //        "address erc20Token,",
    //        "uint256 erc20TokenAmount,",
    //        "Fee[] fees,",
    //        "address nft,",
    //        "uint256 nftId,",
    //        "uint256 hashNonce",
    //    ")",
    //    "Fee(",
    //        "address recipient,",
    //        "uint256 amount,",
    //        "bytes feeData",
    //    ")"
    // ))
    uint256 private constant _NFT_SELL_ORDER_TYPE_HASH = 0xed676c7f3e8232a311454799b1cf26e75b4abc90c9bf06c9f7e8e79fcc7fe14d;

    // The type hash for buy orders, which is:
    // keccak256(abi.encodePacked(
    //    "NFTBuyOrder(",
    //        "address maker,",
    //        "address taker,",
    //        "uint256 expiry,",
    //        "uint256 nonce,",
    //        "address erc20Token,",
    //        "uint256 erc20TokenAmount,",
    //        "Fee[] fees,",
    //        "address nft,",
    //        "uint256 nftId,",
    //        "Property[] nftProperties,",
    //        "uint256 hashNonce",
    //    ")",
    //    "Fee(",
    //        "address recipient,",
    //        "uint256 amount,",
    //        "bytes feeData",
    //    ")",
    //    "Property(",
    //        "address propertyValidator,",
    //        "bytes propertyData",
    //    ")"
    // ))
    uint256 private constant _NFT_BUY_ORDER_TYPE_HASH = 0xa525d336300f566329800fcbe82fd263226dc27d6c109f060d9a4a364281521c;

    // The type hash for ERC1155 sell orders, which is:
    // keccak256(abi.encodePacked(
    //    "ERC1155SellOrder(",
    //        "address maker,",
    //        "address taker,",
    //        "uint256 expiry,",
    //        "uint256 nonce,",
    //        "address erc20Token,",
    //        "uint256 erc20TokenAmount,",
    //        "Fee[] fees,",
    //        "address erc1155Token,",
    //        "uint256 erc1155TokenId,",
    //        "uint128 erc1155TokenAmount,",
    //        "uint256 hashNonce",
    //    ")",
    //    "Fee(",
    //        "address recipient,",
    //        "uint256 amount,",
    //        "bytes feeData",
    //    ")"
    // ))
    uint256 private constant _ERC_1155_SELL_ORDER_TYPE_HASH = 0x3529b5920cc48ecbceb24e9c51dccb50fefd8db2cf05d36e356aeb1754e19eda;

    // The type hash for ERC1155 buy orders, which is:
    // keccak256(abi.encodePacked(
    //    "ERC1155BuyOrder(",
    //        "address maker,",
    //        "address taker,",
    //        "uint256 expiry,",
    //        "uint256 nonce,",
    //        "address erc20Token,",
    //        "uint256 erc20TokenAmount,",
    //        "Fee[] fees,",
    //        "address erc1155Token,",
    //        "uint256 erc1155TokenId,",
    //        "Property[] erc1155TokenProperties,",
    //        "uint128 erc1155TokenAmount,",
    //        "uint256 hashNonce",
    //    ")",
    //    "Fee(",
    //        "address recipient,",
    //        "uint256 amount,",
    //        "bytes feeData",
    //    ")",
    //    "Property(",
    //        "address propertyValidator,",
    //        "bytes propertyData",
    //    ")"
    // ))
    uint256 private constant _ERC_1155_BUY_ORDER_TYPE_HASH = 0x1a6eaae1fbed341e0974212ec17f035a9d419cadc3bf5154841cbf7fd605ba48;

    // keccak256(abi.encodePacked(
    //    "Fee(",
    //        "address recipient,",
    //        "uint256 amount,",
    //        "bytes feeData",
    //    ")"
    // ))
    uint256 private constant _FEE_TYPE_HASH = 0xe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e94115;

    // keccak256(abi.encodePacked(
    //    "Property(",
    //        "address propertyValidator,",
    //        "bytes propertyData",
    //    ")"
    // ))
    uint256 private constant _PROPERTY_TYPE_HASH = 0x6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e8;

    // keccak256("");
    bytes32 private constant _EMPTY_ARRAY_KECCAK256 = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

    // keccak256(abi.encodePacked(keccak256(abi.encode(
    //    _PROPERTY_TYPE_HASH,
    //    address(0),
    //    keccak256("")
    // ))));
    bytes32 private constant _NULL_PROPERTY_STRUCT_HASH = 0x720ee400a9024f6a49768142c339bf09d2dd9056ab52d20fbe7165faba6e142d;

    uint256 private constant ADDRESS_MASK = (1 << 160) - 1;

    function asNFTSellOrder(NFTBuyOrder memory nftBuyOrder) internal pure returns (NFTSellOrder memory order) {
        assembly { order := nftBuyOrder }
    }

    function asNFTSellOrder(ERC1155SellOrder memory erc1155SellOrder) internal pure returns (NFTSellOrder memory order) {
        assembly { order := erc1155SellOrder }
    }

    function asNFTBuyOrder(ERC1155BuyOrder memory erc1155BuyOrder) internal pure returns (NFTBuyOrder memory order) {
        assembly { order := erc1155BuyOrder }
    }

    function asERC1155SellOrder(NFTSellOrder memory nftSellOrder) internal pure returns (ERC1155SellOrder memory order) {
        assembly { order := nftSellOrder }
    }

    function asERC1155BuyOrder(NFTBuyOrder memory nftBuyOrder) internal pure returns (ERC1155BuyOrder memory order) {
        assembly { order := nftBuyOrder }
    }

    // @dev Get the struct hash of an sell order.
    /// @param order The sell order.
    /// @return structHash The struct hash of the order.
    function getNFTSellOrderStructHash(NFTSellOrder memory order, uint256 hashNonce) internal pure returns (bytes32 structHash) {
        bytes32 feesHash = _feesHash(order.fees);

        // Hash in place, equivalent to:
        // return keccak256(abi.encode(
        //     _NFT_SELL_ORDER_TYPE_HASH,
        //     order.maker,
        //     order.taker,
        //     order.expiry,
        //     order.nonce,
        //     order.erc20Token,
        //     order.erc20TokenAmount,
        //     feesHash,
        //     order.nft,
        //     order.nftId,
        //     hashNonce
        // ));
        assembly {
            if lt(order, 32) { invalid() } // Don't underflow memory.

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 192) // order + (32 * 6)
            let hashNoncePos := add(order, 288) // order + (32 * 9)

            let typeHashMemBefore := mload(typeHashPos)
            let feeHashMemBefore := mload(feesHashPos)
            let hashNonceMemBefore := mload(hashNoncePos)

            mstore(typeHashPos, _NFT_SELL_ORDER_TYPE_HASH)
            mstore(feesHashPos, feesHash)
            mstore(hashNoncePos, hashNonce)
            structHash := keccak256(typeHashPos, 352 /* 32 * 11 */ )

            mstore(typeHashPos, typeHashMemBefore)
            mstore(feesHashPos, feeHashMemBefore)
            mstore(hashNoncePos, hashNonceMemBefore)
        }
        return structHash;
    }

    /// @dev Get the struct hash of an buy order.
    /// @param order The buy order.
    /// @return structHash The struct hash of the order.
    function getNFTBuyOrderStructHash(NFTBuyOrder memory order, uint256 hashNonce) internal pure returns (bytes32 structHash) {
        bytes32 propertiesHash = _propertiesHash(order.nftProperties);
        bytes32 feesHash = _feesHash(order.fees);

        // Hash in place, equivalent to:
        // return keccak256(abi.encode(
        //     _NFT_BUY_ORDER_TYPE_HASH,
        //     order.maker,
        //     order.taker,
        //     order.expiry,
        //     order.nonce,
        //     order.erc20Token,
        //     order.erc20TokenAmount,
        //     feesHash,
        //     order.nft,
        //     order.nftId,
        //     propertiesHash,
        //     hashNonce
        // ));
        assembly {
            if lt(order, 32) { invalid() } // Don't underflow memory.

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 192) // order + (32 * 6)
            let propertiesHashPos := add(order, 288) // order + (32 * 9)
            let hashNoncePos := add(order, 320) // order + (32 * 10)

            let typeHashMemBefore := mload(typeHashPos)
            let feeHashMemBefore := mload(feesHashPos)
            let propertiesHashMemBefore := mload(propertiesHashPos)
            let hashNonceMemBefore := mload(hashNoncePos)

            mstore(typeHashPos, _NFT_BUY_ORDER_TYPE_HASH)
            mstore(feesHashPos, feesHash)
            mstore(propertiesHashPos, propertiesHash)
            mstore(hashNoncePos, hashNonce)
            structHash := keccak256(typeHashPos, 384 /* 32 * 12 */ )

            mstore(typeHashPos, typeHashMemBefore)
            mstore(feesHashPos, feeHashMemBefore)
            mstore(propertiesHashPos, propertiesHashMemBefore)
            mstore(hashNoncePos, hashNonceMemBefore)
        }
        return structHash;
    }

    /// @dev Get the struct hash of an ERC1155 sell order.
    /// @param order The ERC1155 sell order.
    /// @return structHash The struct hash of the order.
    function getERC1155SellOrderStructHash(ERC1155SellOrder memory order, uint256 hashNonce) internal pure returns (bytes32 structHash) {
        bytes32 feesHash = _feesHash(order.fees);

        // Hash in place, equivalent to:
        // return keccak256(abi.encode(
        //     _ERC_1155_SELL_ORDER_TYPE_HASH,
        //     order.maker,
        //     order.taker,
        //     order.expiry,
        //     order.nonce,
        //     order.erc20Token,
        //     order.erc20TokenAmount,
        //     feesHash,
        //     order.erc1155Token,
        //     order.erc1155TokenId,
        //     order.erc1155TokenAmount,
        //     hashNonce
        // ));
        assembly {
            if lt(order, 32) { invalid() } // Don't underflow memory.

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 192) // order + (32 * 6)
            let hashNoncePos := add(order, 320) // order + (32 * 10)

            let typeHashMemBefore := mload(typeHashPos)
            let feesHashMemBefore := mload(feesHashPos)
            let hashNonceMemBefore := mload(hashNoncePos)

            mstore(typeHashPos, _ERC_1155_SELL_ORDER_TYPE_HASH)
            mstore(feesHashPos, feesHash)
            mstore(hashNoncePos, hashNonce)
            structHash := keccak256(typeHashPos, 384 /* 32 * 12 */ )

            mstore(typeHashPos, typeHashMemBefore)
            mstore(feesHashPos, feesHashMemBefore)
            mstore(hashNoncePos, hashNonceMemBefore)
        }
        return structHash;
    }

    /// @dev Get the struct hash of an ERC1155 buy order.
    /// @param order The ERC1155 buy order.
    /// @return structHash The struct hash of the order.
    function getERC1155BuyOrderStructHash(ERC1155BuyOrder memory order, uint256 hashNonce) internal pure returns (bytes32 structHash) {
        bytes32 propertiesHash = _propertiesHash(order.erc1155TokenProperties);
        bytes32 feesHash = _feesHash(order.fees);

        // Hash in place, equivalent to:
        // return keccak256(abi.encode(
        //     _ERC_1155_BUY_ORDER_TYPE_HASH,
        //     order.maker,
        //     order.taker,
        //     order.expiry,
        //     order.nonce,
        //     order.erc20Token,
        //     order.erc20TokenAmount,
        //     feesHash,
        //     order.erc1155Token,
        //     order.erc1155TokenId,
        //     propertiesHash,
        //     order.erc1155TokenAmount,
        //     hashNonce
        // ));
        assembly {
            if lt(order, 32) { invalid() } // Don't underflow memory.

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 192) // order + (32 * 6)
            let propertiesHashPos := add(order, 288) // order + (32 * 9)
            let hashNoncePos := add(order, 352) // order + (32 * 11)

            let typeHashMemBefore := mload(typeHashPos)
            let feesHashMemBefore := mload(feesHashPos)
            let propertiesHashMemBefore := mload(propertiesHashPos)
            let hashNonceMemBefore := mload(hashNoncePos)

            mstore(typeHashPos, _ERC_1155_BUY_ORDER_TYPE_HASH)
            mstore(feesHashPos, feesHash)
            mstore(propertiesHashPos, propertiesHash)
            mstore(hashNoncePos, hashNonce)
            structHash := keccak256(typeHashPos, 416 /* 32 * 13 */ )

            mstore(typeHashPos, typeHashMemBefore)
            mstore(feesHashPos, feesHashMemBefore)
            mstore(propertiesHashPos, propertiesHashMemBefore)
            mstore(hashNoncePos, hashNonceMemBefore)
        }
        return structHash;
    }

    // Hashes the `properties` array as part of computing the
    // EIP-712 hash of an `ERC721Order` or `ERC1155Order`.
    function _propertiesHash(Property[] memory properties) private pure returns (bytes32 propertiesHash) {
        uint256 numProperties = properties.length;
        // We give `properties.length == 0` and `properties.length == 1`
        // special treatment because we expect these to be the most common.
        if (numProperties == 0) {
            propertiesHash = _EMPTY_ARRAY_KECCAK256;
        } else if (numProperties == 1) {
            Property memory property = properties[0];
            if (address(property.propertyValidator) == address(0) && property.propertyData.length == 0) {
                propertiesHash = _NULL_PROPERTY_STRUCT_HASH;
            } else {
                // propertiesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
                //     _PROPERTY_TYPE_HASH,
                //     properties[0].propertyValidator,
                //     keccak256(properties[0].propertyData)
                // ))));
                bytes32 dataHash = keccak256(property.propertyData);
                assembly {
                    // Load free memory pointer
                    let mem := mload(64)
                    mstore(mem, _PROPERTY_TYPE_HASH)
                    // property.propertyValidator
                    mstore(add(mem, 32), and(ADDRESS_MASK, mload(property)))
                    // keccak256(property.propertyData)
                    mstore(add(mem, 64), dataHash)
                    mstore(mem, keccak256(mem, 96))
                    propertiesHash := keccak256(mem, 32)
                }
            }
        } else {
            bytes32[] memory propertyStructHashArray = new bytes32[](numProperties);
            for (uint256 i = 0; i < numProperties; i++) {
                propertyStructHashArray[i] = keccak256(abi.encode(
                        _PROPERTY_TYPE_HASH, properties[i].propertyValidator, keccak256(properties[i].propertyData)));
            }
            assembly {
                propertiesHash := keccak256(add(propertyStructHashArray, 32), mul(numProperties, 32))
            }
        }
    }

    // Hashes the `fees` array as part of computing the
    // EIP-712 hash of an `ERC721Order` or `ERC1155Order`.
    function _feesHash(Fee[] memory fees) private pure returns (bytes32 feesHash) {
        uint256 numFees = fees.length;
        // We give `fees.length == 0` and `fees.length == 1`
        // special treatment because we expect these to be the most common.
        if (numFees == 0) {
            feesHash = _EMPTY_ARRAY_KECCAK256;
        } else if (numFees == 1) {
            // feesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
            //     _FEE_TYPE_HASH,
            //     fees[0].recipient,
            //     fees[0].amount,
            //     keccak256(fees[0].feeData)
            // ))));
            Fee memory fee = fees[0];
            bytes32 dataHash = keccak256(fee.feeData);
            assembly {
                // Load free memory pointer
                let mem := mload(64)
                mstore(mem, _FEE_TYPE_HASH)
                // fee.recipient
                mstore(add(mem, 32), and(ADDRESS_MASK, mload(fee)))
                // fee.amount
                mstore(add(mem, 64), mload(add(fee, 32)))
                // keccak256(fee.feeData)
                mstore(add(mem, 96), dataHash)
                mstore(mem, keccak256(mem, 128))
                feesHash := keccak256(mem, 32)
            }
        } else {
            bytes32[] memory feeStructHashArray = new bytes32[](numFees);
            for (uint256 i = 0; i < numFees; i++) {
                feeStructHashArray[i] = keccak256(abi.encode(_FEE_TYPE_HASH, fees[i].recipient, fees[i].amount, keccak256(fees[i].feeData)));
            }
            assembly {
                feesHash := keccak256(add(feeStructHashArray, 32), mul(numFees, 32))
            }
        }
    }
}

File 10 of 17 : LibSignature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

/// @dev A library for validating signatures.
library LibSignature {

    /// @dev Allowed signature types.
    enum SignatureType {
        EIP712,
        PRESIGNED
    }

    /// @dev Encoded EC signature.
    struct Signature {
        // How to validate the signature.
        SignatureType signatureType;
        // EC Signature data.
        uint8 v;
        // EC Signature data.
        bytes32 r;
        // EC Signature data.
        bytes32 s;
    }
}

File 11 of 17 : IPropertyValidator.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


interface IPropertyValidator {

    /// @dev Checks that the given ERC721/ERC1155 asset satisfies the properties encoded in `propertyData`.
    ///      Should revert if the asset does not satisfy the specified properties.
    /// @param tokenAddress The ERC721/ERC1155 token contract address.
    /// @param tokenId The ERC721/ERC1155 tokenId of the asset to check.
    /// @param propertyData Encoded properties or auxiliary data needed to perform the check.
    function validateProperty(address tokenAddress, uint256 tokenId, bytes calldata propertyData) external view;
}

File 12 of 17 : FixinEIP712.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


/// @dev EIP712 helpers for features.
abstract contract FixinEIP712 {

    bytes32 private constant DOMAIN = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
    bytes32 private constant NAME = keccak256("ElementEx");
    bytes32 private constant VERSION = keccak256("1.0.0");
    uint256 private immutable CHAIN_ID;

    constructor() {
        uint256 chainId;
        assembly { chainId := chainid() }
        CHAIN_ID = chainId;
    }

    function _getEIP712Hash(bytes32 structHash) internal view returns (bytes32) {
        return keccak256(abi.encodePacked(hex"1901", keccak256(abi.encode(DOMAIN, NAME, VERSION, CHAIN_ID, address(this))), structHash));
    }
}

File 13 of 17 : FixinTokenSpender.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";


/// @dev Helpers for moving tokens around.
abstract contract FixinTokenSpender {

    // Mask of the lower 20 bytes of a bytes32.
    uint256 constant private ADDRESS_MASK = 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff;

    /// @dev Transfers ERC20 tokens from `owner` to `to`.
    /// @param token The token to spend.
    /// @param owner The owner of the tokens.
    /// @param to The recipient of the tokens.
    /// @param amount The amount of `token` to transfer.
    function _transferERC20TokensFrom(IERC20 token, address owner, address to, uint256 amount) internal {
        uint256 success;
        assembly {
            let ptr := mload(0x40) // free memory pointer

            // selector for transferFrom(address,address,uint256)
            mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK))
            mstore(add(ptr, 0x24), and(to, ADDRESS_MASK))
            mstore(add(ptr, 0x44), amount)

            success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x64, ptr, 32)

            let rdsize := returndatasize()

            // Check for ERC20 success. ERC20 tokens should return a boolean,
            // but some don't. We accept 0-length return data as success, or at
            // least 32 bytes that starts with a 32-byte boolean true.
            success := and(
                success,                             // call itself succeeded
                or(
                    iszero(rdsize),                  // no return data, or
                    and(
                        iszero(lt(rdsize, 32)),      // at least 32 bytes
                        eq(mload(ptr), 1)            // starts with uint256(1)
                    )
                )
            )
        }
        require(success != 0, "_transferERC20/TRANSFER_FAILED");
    }

    /// @dev Transfers ERC20 tokens from ourselves to `to`.
    /// @param token The token to spend.
    /// @param to The recipient of the tokens.
    /// @param amount The amount of `token` to transfer.
    function _transferERC20Tokens(IERC20 token, address to, uint256 amount) internal {
        uint256 success;
        assembly {
            let ptr := mload(0x40) // free memory pointer

            // selector for transfer(address,uint256)
            mstore(ptr, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 0x04), and(to, ADDRESS_MASK))
            mstore(add(ptr, 0x24), amount)

            success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x44, ptr, 32)

            let rdsize := returndatasize()

            // Check for ERC20 success. ERC20 tokens should return a boolean,
            // but some don't. We accept 0-length return data as success, or at
            // least 32 bytes that starts with a 32-byte boolean true.
            success := and(
                success,                             // call itself succeeded
                or(
                    iszero(rdsize),                  // no return data, or
                    and(
                        iszero(lt(rdsize, 32)),      // at least 32 bytes
                        eq(mload(ptr), 1)            // starts with uint256(1)
                    )
                )
            )
        }
        require(success != 0, "_transferERC20/TRANSFER_FAILED");
    }


    /// @dev Transfers some amount of ETH to the given recipient and
    ///      reverts if the transfer fails.
    /// @param recipient The recipient of the ETH.
    /// @param amount The amount of ETH to transfer.
    function _transferEth(address payable recipient, uint256 amount) internal {
        if (amount > 0) {
            (bool success,) = recipient.call{value: amount}("");
            require(success, "_transferEth/TRANSFER_FAILED");
        }
    }
}

File 14 of 17 : IEtherToken.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2022 Element.Market

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


interface IEtherToken is IERC20 {
    /// @dev Wrap ether.
    function deposit() external payable;

    /// @dev Unwrap ether.
    function withdraw(uint256 amount) external;
}

File 15 of 17 : IFeeRecipient.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


interface IFeeRecipient {

    /// @dev A callback function invoked in the ERC721Feature for each ERC721
    ///      order fee that get paid. Integrators can make use of this callback
    ///      to implement arbitrary fee-handling logic, e.g. splitting the fee
    ///      between multiple parties.
    /// @param tokenAddress The address of the token in which the received fee is
    ///        denominated. `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` indicates
    ///        that the fee was paid in the native token (e.g. ETH).
    /// @param amount The amount of the given token received.
    /// @param feeData Arbitrary data encoded in the `Fee` used by this callback.
    /// @return success The selector of this function (0x0190805e),
    ///         indicating that the callback succeeded.
    function receiveZeroExFeeCallback(address tokenAddress, uint256 amount, bytes calldata feeData) external returns (bytes4 success);
}

File 16 of 17 : ITakerCallback.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Modifications Copyright 2022 Element.Market
  Copyright 2021 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.8.13;


interface ITakerCallback {

    /// @dev A taker callback function invoked in ERC721OrdersFeature and
    ///      ERC1155OrdersFeature between the maker -> taker transfer and
    ///      the taker -> maker transfer.
    /// @param orderHash The hash of the order being filled when this
    ///        callback is invoked.
    /// @param data Arbitrary data used by this callback.
    /// @return success The selector of this function,
    ///         indicating that the callback succeeded.
    function zeroExTakerCallback(bytes32 orderHash, bytes calldata data) external returns (bytes4);
}

File 17 of 17 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IEtherToken","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"ERC721BuyOrderFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"expiry","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"indexed":false,"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"indexed":false,"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"name":"ERC721BuyOrderPreSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"ERC721OrderCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"ERC721SellOrderFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"expiry","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"indexed":false,"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721TokenId","type":"uint256"}],"name":"ERC721SellOrderPreSigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"uint256","name":"newHashNonce","type":"uint256"}],"name":"HashNonceIncremented","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder[]","name":"sellOrders","type":"tuple[]"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature[]","name":"signatures","type":"tuple[]"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"}],"name":"batchBuyERC721s","outputs":[{"internalType":"bool[]","name":"successes","type":"bool[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder[]","name":"sellOrders","type":"tuple[]"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature[]","name":"signatures","type":"tuple[]"},{"internalType":"address[]","name":"takers","type":"address[]"},{"internalType":"bytes[]","name":"callbackData","type":"bytes[]"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"}],"name":"batchBuyERC721sEx","outputs":[{"internalType":"bool[]","name":"successes","type":"bool[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"orderNonces","type":"uint256[]"}],"name":"batchCancelERC721Orders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder[]","name":"sellOrders","type":"tuple[]"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder[]","name":"buyOrders","type":"tuple[]"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature[]","name":"sellOrderSignatures","type":"tuple[]"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature[]","name":"buyOrderSignatures","type":"tuple[]"}],"name":"batchMatchERC721Orders","outputs":[{"internalType":"uint256[]","name":"profits","type":"uint256[]"},{"internalType":"bool[]","name":"successes","type":"bool[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"}],"name":"buyERC721","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"name":"buyERC721Ex","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"ethAvailable","type":"uint256"},{"internalType":"bytes","name":"takerCallbackData","type":"bytes"}],"name":"buyERC721ExFromProxy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"}],"name":"buyERC721FromProxy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderNonce","type":"uint256"}],"name":"cancelERC721Order","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"order","type":"tuple"}],"name":"getERC721BuyOrderHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"order","type":"tuple"}],"name":"getERC721BuyOrderStatus","outputs":[{"internalType":"enum LibNFTOrder.OrderStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint248","name":"nonceRange","type":"uint248"}],"name":"getERC721OrderStatusBitVector","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"order","type":"tuple"}],"name":"getERC721SellOrderHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"order","type":"tuple"}],"name":"getERC721SellOrderStatus","outputs":[{"internalType":"enum LibNFTOrder.OrderStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"}],"name":"getHashNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incrementHashNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"buyOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"sellOrderSignature","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"buyOrderSignature","type":"tuple"}],"name":"matchERC721Orders","outputs":[{"internalType":"uint256","name":"profit","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"success","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"order","type":"tuple"}],"name":"preSignERC721BuyOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"order","type":"tuple"}],"name":"preSignERC721SellOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"buyOrder","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"internalType":"bool","name":"unwrapNativeToken","type":"bool"},{"internalType":"bytes","name":"callbackData","type":"bytes"}],"name":"sellERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"nftProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.NFTBuyOrder","name":"order","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"}],"name":"validateERC721BuyOrderSignature","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"feeData","type":"bytes"}],"internalType":"struct LibNFTOrder.Fee[]","name":"fees","type":"tuple[]"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"internalType":"struct LibNFTOrder.NFTSellOrder","name":"order","type":"tuple"},{"components":[{"internalType":"enum LibSignature.SignatureType","name":"signatureType","type":"uint8"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct LibSignature.Signature","name":"signature","type":"tuple"}],"name":"validateERC721SellOrderSignature","outputs":[],"stateMutability":"view","type":"function"}]

60e06040523480156200001157600080fd5b5060405162005211380380620052118339810160408190526200003491620000a0565b46608052806001600160a01b038116620000895760405162461bcd60e51b81526020600482015260126024820152712ba2aa242fa0a2222922a9a9afa2a92927a960711b604482015260640160405180910390fd5b6001600160a01b031660a052503060c052620000d2565b600060208284031215620000b357600080fd5b81516001600160a01b0381168114620000cb57600080fd5b9392505050565b60805160a05160c051615091620001806000396000818161064801528181610fd3015281816111520152818161132701526116f6015260008181610bb501528181610bf701528181610c42015281816129350152818161297201528181612a0301528181612a8e01528181612ac801528181612b3f01528181612b8b01528181612bd701528181612c140152818161325d015281816132f101526133320152600061088801526150916000f3fe6080604052600436106101405760003560e01c806333ba623b116100b6578063a88094851161006f578063a8809485146103c5578063af3de155146103e5578063b18d619f14610405578063be167b9d14610418578063c67a891114610438578063d8d2ae771461045857600080fd5b806333ba623b146102f85780635e7251861461030b5780635f57685e146103445780636e74f68a1461035757806386219940146103775780638e3efd591461039757600080fd5b8063150b7a0211610108578063150b7a021461022c5780631fc34ffe14610265578063287846681461028557806328a96208146102a557806332766750146102c5578063332b024f146102d857600080fd5b8063030b273014610145578063050505d6146101a8578063053c23f1146101bf578063078e6b33146101df57806310a1ea2b146101ff575b600080fd5b34801561015157600080fd5b50610195610160366004613b85565b6001600160a01b03919091166000908152600560801b602090815260408083206001600160f81b039094168352929052205490565b6040519081526020015b60405180910390f35b3480156101b457600080fd5b506101bd61046b565b005b6101d26101cd36600461408b565b6104cf565b60405161019f91906141f4565b3480156101eb57600080fd5b506101956101fa3660046143af565b6107e1565b34801561020b57600080fd5b5061021f61021a3660046143eb565b610907565b60405161019f9190614435565b34801561023857600080fd5b5061024c61024736600461444f565b6109b0565b6040516001600160e01b0319909116815260200161019f565b34801561027157600080fd5b506101956102803660046144ed565b610a67565b34801561029157600080fd5b506101956102a03660046143eb565b610ea2565b3480156102b157600080fd5b506101bd6102c03660046143eb565b610ece565b6101bd6102d3366004614574565b610fd0565b3480156102e457600080fd5b506101bd6102f33660046143af565b611053565b6101bd610306366004614608565b61114f565b34801561031757600080fd5b50610195610326366004614656565b6001600160a01b03166000908152600160821b602052604090205490565b6101bd610352366004614608565b6111cc565b34801561036357600080fd5b506101bd610372366004614608565b6111fe565b34801561038357600080fd5b506101bd610392366004614673565b611213565b3480156103a357600080fd5b506103b76103b23660046146b4565b611251565b60405161019f9291906147cf565b3480156103d157600080fd5b506101bd6103e0366004614826565b6114ed565b3480156103f157600080fd5b5061021f6104003660046143af565b6114fc565b6101bd61041336600461489c565b61156c565b34801561042457600080fd5b506101bd610433366004614919565b61159c565b34801561044457600080fd5b506101bd610453366004614932565b6115dc565b6101d2610466366004614967565b6115e8565b336000908152600160821b602052604081208054829061048a906149f0565b918290555060408051338152602081018390529192507f4cf3e8a83c6bf8a510613208458629675b4ae99b8029e3ab6cb6a86e5f01fd3191015b60405180910390a150565b8551855160609190811480156104e457508085145b80156104f05750835181145b6105155760405162461bcd60e51b815260040161050c90614a09565b60405180910390fd5b806001600160401b0381111561052d5761052d613bca565b604051908082528060200260200182016040528015610556578160200160208202803683370190505b50915060006105653447614a38565b9050831561063b5760005b82811015610635576105ff8a828151811061058d5761058d614a4f565b60200260200101518a83815181106105a7576105a7614a4f565b60200260200101518a8a858181106105c1576105c1614a4f565b90506020020160208101906105d69190614656565b6105e08647614a38565b8a86815181106105f2576105f2614a4f565b6020026020010151611839565b600184828151811061061357610613614a4f565b911515602092830291909101909101528061062d816149f0565b915050610570565b506107c2565b60005b828110156107c0577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633276675060e01b8b838151811061068a5761068a614a4f565b60200260200101518b84815181106106a4576106a4614a4f565b60200260200101518b8b868181106106be576106be614a4f565b90506020020160208101906106d39190614656565b6106dd8747614a38565b8b87815181106106ef576106ef614a4f565b602002602001015160405160240161070b959493929190614c1f565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516107499190614c76565b600060405180830381855af49150503d8060008114610784576040519150601f19603f3d011682016040523d82523d6000602084013e610789565b606091505b505084828151811061079d5761079d614a4f565b6020026020010181151515158152505080806107b8906149f0565b91505061063e565b505b6107d5336107d08347614a38565b611948565b50509695505050505050565b80516001600160a01b03166000908152600160821b60205260408120546109019061080d9084906119f1565b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f27b14c20196091d9cd90ca9c473d3ad1523b00ddf487a9b7452a8a119a16b98c828401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608301527f000000000000000000000000000000000000000000000000000000000000000060808301523060a0808401919091528351808403909101815260c08301845280519082012061190160f01b60e084015260e28301526101028083019490945282518083039094018452610122909101909152815191012090565b92915050565b604081015160009067ffffffff00000000161561093c574260208360400151901c63ffffffff16111561093c57506000919050565b42826040015163ffffffff161161095557506003919050565b81516001600160a01b03166000908152600560801b6020818152604080842060608701805160081c86529252909220549151909190600160ff9091161b808216156109a557506002949350505050565b506001949350505050565b60008080806109c185870187614c92565b9250925092508260e001516001600160a01b0316336001600160a01b031614610a2c5760405162461bcd60e51b815260206004820152601b60248201527f4552433732315f544f4b454e5f4d49534d415443485f4552524f520000000000604482015260640161050c565b604080516000815260208101909152610a5090849084908a9085908e903090611a80565b50630a85bd0160e11b925050505b95945050505050565b60008360e001516001600160a01b03168560e001516001600160a01b031614610ad25760405162461bcd60e51b815260206004820152601b60248201527f4552433732315f544f4b454e5f4d49534d415443485f4552524f520000000000604482015260640161050c565b6000610add86611b35565b90506000610aea86611bf9565b9050610afc8786848960000151611c55565b610b128685838a600001518b6101000151611d4b565b604087015160fc1c600203610b3257610b32878760a00151600180611ebe565b610b428783600001516001611fcb565b610b57610b4e87611fdd565b82516001611fcb565b60008760a001518760a00151610b6d9190614a38565b60e0890151895189516101008c0151939450610b8893612024565b60808801516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148015610bed57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031687608001516001600160a01b0316145b15610d0657610c267f00000000000000000000000000000000000000000000000000000000000000008860000151308a60a001516120be565b60a0870151604051632e1a7d4d60e01b815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610c8e57600080fd5b505af1158015610ca2573d6000803e3d6000fd5b50505050610cb888600001518960a00151611948565b610cd0610cc488611fdd565b8851600180600061216c565b506000610ce28930600180600161216c565b9050610cee8183614a38565b94508415610d0057610d003386611948565b50610dd7565b86608001516001600160a01b031688608001516001600160a01b031614610d6f5760405162461bcd60e51b815260206004820152601a60248201527f45524332305f544f4b454e5f4d49534d415443485f4552524f52000000000000604482015260640161050c565b610d8b876080015188600001518a600001518b60a001516120be565b610d97610cc488611fdd565b506000610dad898960000151600180600061216c565b9050610db98183614a38565b94508415610dd557610dd58860800151896000015133886120be565b505b7f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac94886000015188600001518a608001518b60a001518c60e001518d61010001518960000151604051610e2f9796959493929190614ce7565b60405180910390a17fa24193d56ccdf64ce1df60c80ca683da965a1da3363efa67c14abf62b2d7d4938760000151896000015189608001518a60a001518b60e001518d61010001518860000151604051610e8f9796959493929190614ce7565b60405180910390a1505050949350505050565b80516001600160a01b03166000908152600160821b60205260408120546109019061080d90849061235e565b80516001600160a01b03163314610f145760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa6a0a5a2a960b11b604482015260640161050c565b80516001600160a01b03166000908152600160821b602052604081205490610f3b83610ea2565b9050610f48826001614d2a565b60008281526001600560801b01602090815260409182902092909255845191850151858201516060870151608088015160a089015160c08a015160e08b01516101008c015197517f29806076879d6116f3a8b8f81980ee6273d4ae8cb3ede88be4bb96f88787c26c99610fc399909897969594939291614d42565b60405180910390a1505050565b307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03160361103f5760405162461bcd60e51b81526020600482015260146024820152734d5553545f43414c4c5f46524f4d5f50524f585960601b604482015260640161050c565b61104c8585858585611839565b5050505050565b80516001600160a01b031633146110995760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa6a0a5a2a960b11b604482015260640161050c565b80516001600160a01b03166000908152600160821b6020526040812054906110c0836107e1565b90506110cd826001614d2a565b60008281526001600560801b01602090815260409182902092909255845191850151858201516060870151608088015160a089015160c08a015160e08b01516101008c01516101208d015198517f4c2669b38ff3018c301fbc65423ac87447906bcf66b95a5fe0d3c5bbd6bcb2979a610fc39a90999897969594939291614e05565b307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316036111be5760405162461bcd60e51b81526020600482015260146024820152734d5553545f43414c4c5f46524f4d5f50524f585960601b604482015260640161050c565b6111c882826123cc565b5050565b60006111d83447614a38565b90506111e483836123cc565b8047146111f9576111f9336107d08347614a38565b505050565b6111c861120a83610ea2565b8351839061242b565b60005b818110156111f95761123f83838381811061123357611233614a4f565b9050602002013561159c565b80611249816149f0565b915050611216565b835183516060918291811480156112685750845181145b80156112745750835181145b6112905760405162461bcd60e51b815260040161050c90614a09565b806001600160401b038111156112a8576112a8613bca565b6040519080825280602002602001820160405280156112d1578160200160208202803683370190505b509250806001600160401b038111156112ec576112ec613bca565b604051908082528060200260200182016040528015611315578160200160208202803683370190505b50915060005b818110156114e25760607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631fc34ffe60e01b8a848151811061136957611369614a4f565b60200260200101518a858151811061138357611383614a4f565b60200260200101518a868151811061139d5761139d614a4f565b60200260200101518a87815181106113b7576113b7614a4f565b60200260200101516040516024016113d29493929190614e80565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516114109190614c76565b600060405180830381855af49150503d806000811461144b576040519150601f19603f3d011682016040523d82523d6000602084013e611450565b606091505b5085848151811061146357611463614a4f565b602002602001018193508215151515815250505083828151811061148957611489614a4f565b6020026020010151156114cf576000818060200190518101906114ac9190614f75565b9050808684815181106114c1576114c1614a4f565b602002602001018181525050505b50806114da816149f0565b91505061131b565b505094509492505050565b61104c85858585333387611a80565b600081610100015160001415801561151a5750600082610120015151115b1561152757506000919050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031682608001516001600160a01b03160361156057506000919050565b61090161021a83611fdd565b60006115783447614a38565b90506115878585853486611839565b80471461104c5761104c336107d08347614a38565b6115a633826125a1565b60408051338152602081018390527fa015ad2dc32f266993958a0fd9884c746b971b254206f3478bc43e2f125c7b9e91016104c4565b6111c861120a836107e1565b8251825160609190811461160e5760405162461bcd60e51b815260040161050c90614a09565b806001600160401b0381111561162657611626613bca565b60405190808252806020026020018201604052801561164f578160200160208202803683370190505b509150600061165e3447614a38565b905083156116e95760005b828110156116e3576116ad87828151811061168657611686614a4f565b60200260200101518783815181106116a0576116a0614a4f565b60200260200101516123cc565b60018482815181106116c1576116c1614a4f565b91151560209283029190910190910152806116db816149f0565b915050611669565b50611822565b60005b82811015611820577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166333ba623b60e01b88838151811061173857611738614a4f565b602002602001015188848151811061175257611752614a4f565b602002602001015160405160240161176b929190614f8e565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516117a99190614c76565b600060405180830381855af49150503d80600081146117e4576040519150601f19603f3d011682016040523d82523d6000602084013e6117e9565b606091505b50508482815181106117fd576117fd614a4f565b602002602001018115151515815250508080611818906149f0565b9150506116ec565b505b611830336107d08347614a38565b50509392505050565b6001600160a01b03831661184f573392506118a7565b306001600160a01b038416036118a75760405162461bcd60e51b815260206004820152601b60248201527f5f62757937323145782f54414b45525f43414e4e4f545f53454c460000000000604482015260640161050c565b60006118e78686604051806080016040528060016001600160801b03168152602001878152602001886001600160a01b03168152602001868152506125e2565b8751608089015160a08a015160e08b01516101008c01516040519597507f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac949650611938958b94939291908990614ce7565b60405180910390a1505050505050565b80156111c8576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461199b576040519150601f19603f3d011682016040523d82523d6000602084013e6119a0565b606091505b50509050806111f95760405162461bcd60e51b815260206004820152601c60248201527f5f7472616e736665724574682f5452414e534645525f4641494c454400000000604482015260640161050c565b600080611a02846101200151612ce8565b90506000611a138560c00151612f2a565b90506020851015611a2057fe5b601f198501805160c087018051610120890180516101408b0180517fa525d336300f566329800fcbe82fd263226dc27d6c109f060d9a4a364281521c88529785529782528988526101808620949095529152919091529152905092915050565b6000611ad788886040518060c0016040528060016001600160801b031681526020018a81526020018915158152602001886001600160a01b03168152602001876001600160a01b0316815260200186815250613139565b895160808b015160a08c015160e08d01516040519496507fa24193d56ccdf64ce1df60c80ca683da965a1da3363efa67c14abf62b2d7d4939550611b23948a939291908d908990614ce7565b60405180910390a15050505050505050565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152611b8683610ea2565b8152611b9183610907565b81602001906003811115611ba757611ba761441f565b90816003811115611bba57611bba61441f565b90525060016040820181905281602001516003811115611bdc57611bdc61441f565b14611be8576000611beb565b60015b60ff16606082015292915050565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152611c4a836107e1565b8152611b91836114fc565b60208401516001600160a01b03161580611c845750806001600160a01b031684602001516001600160a01b0316145b611cd05760405162461bcd60e51b815260206004820152601960248201527f5f76616c69646174654f726465722f4f4e4c595f54414b455200000000000000604482015260640161050c565b600182602001516003811115611ce857611ce861441f565b14611d355760405162461bcd60e51b815260206004820152601d60248201527f5f76616c69646174654f726465722f4f524445525f4e4f545f46494c4c000000604482015260640161050c565b81518451611d459190859061242b565b50505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031685608001516001600160a01b031603611dc45760405162461bcd60e51b815260206004820181905260248201527f5f76616c69646174654275794f726465722f544f4b454e5f4d49534d41544348604482015260640161050c565b60208501516001600160a01b03161580611df35750816001600160a01b031685602001516001600160a01b0316145b611e3f5760405162461bcd60e51b815260206004820152601c60248201527f5f76616c69646174654275794f726465722f4f4e4c595f54414b455200000000604482015260640161050c565b600183602001516003811115611e5757611e5761441f565b14611ea45760405162461bcd60e51b815260206004820152601d60248201527f5f76616c69646174654f726465722f4f524445525f4e4f545f46494c4c000000604482015260640161050c565b611eae8582613556565b8251855161104c9190869061242b565b6000611ecf8560c0015184846136fe565b905060008560a0015182611ee39190614d2a565b9050808514611fc3576000611ef88287614a38565b905060008215611fa25760005b8860c0015151811015611fa0576000848a60c001518381518110611f2b57611f2b614a4f565b60200260200101516020015185611f429190614fb0565b611f4c9190614fcf565b9050808a60c001518381518110611f6557611f65614a4f565b6020026020010151602001818151611f7d9190614d2a565b905250611f8a8184614d2a565b9250508080611f98906149f0565b915050611f05565b505b611fac8183614a38565b8860a001818151611fbd9190614d2a565b90525050505b505050505050565b6111f9836000015184606001516125a1565b604080516101208101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c082015260e08101829052610100015290565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260008060648360006001600160a01b038b165af19150508060000361104c5760405162461bcd60e51b815260206004820152601f60248201527f5f7472616e736665724552433732312f5452414e534645525f4641494c454400604482015260640161050c565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260208160648360006001600160a01b038b165af191503d60018251146020821015168115178316925050508060000361104c5760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c45440000604482015260640161050c565b6000805b8660c00151518110156123545760008760c00151828151811061219557612195614a4f565b602002602001015190506000856001600160801b0316876001600160801b0316146121ec57856001600160801b0316876001600160801b031683602001516121dd9190614fb0565b6121e79190614fcf565b6121f2565b81602001515b9050841561220b5781516122069082611948565b612225565b8015612225576122258960800151898460000151846120be565b604082015151156123335781516000906001600160a01b03166330787dd187612252578b60800151612268565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b8486604001516040518463ffffffff1660e01b815260040161228c93929190614ff1565b6020604051808303816000875af11580156122ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cf9190615018565b90506001600160e01b031981166330787dd160e01b146123315760405162461bcd60e51b815260206004820152601860248201527f5f706179466565732f43414c4c4241434b5f4641494c45440000000000000000604482015260640161050c565b505b61233d8185614d2a565b93505050808061234c906149f0565b915050612170565b5095945050505050565b60008061236e8460c00151612f2a565b9050602084101561237b57fe5b601f198401805160c08601805161012090970180517fed676c7f3e8232a311454799b1cf26e75b4abc90c9bf06c9f7e8e79fcc7fe14d85529482529586526101608320919092529490529091525090565b60006123da838360016137bd565b8451608086015160a087015160e08801516101008901516040519597507f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac949650610fc3953394939291908990614ce7565b6001825160018111156124405761244061441f565b036124ce576001600160a01b0381166000908152600160821b602052604090205461246c906001614d2a565b60008481526001600560801b016020526040902054146111f95760405162461bcd60e51b815260206004820152601860248201527f5052455349474e45445f494e56414c49445f5349474e45520000000000000000604482015260640161050c565b6001600160a01b0381161580159061255e575060208083015160408085015160608087015183516000815295860180855289905260ff9094169285019290925290830152608082015260019060a0016020604051602081039080840390855afa15801561253f573d6000803e3d6000fd5b505050602060405103516001600160a01b0316816001600160a01b0316145b6111f95760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa9a4a3a722a92fa2a92927a960611b604482015260640161050c565b600160ff82161b80600560801b6001600160a01b0390941660009081526020948552604080822060089590951c825293909452919092208054909117905550565b60008060006125f086611b35565b9050806000015191506126098686838760400151611c55565b80606001516001600160801b031684600001516001600160801b0316111561267e5760405162461bcd60e51b815260206004820152602260248201527f5f6275794e465445782f455843454544535f52454d41494e494e475f414d4f55604482015261139560f21b606482015260840161050c565b8051845161268d918891611fcb565b604086015160fc1c6001036126bc5760408681015163ffffffff911c1680156126ba576126ba878261393f565b505b80604001516001600160801b031684600001516001600160801b0316146127155761271084600001516001600160801b03168760a001516126fd9190614fb0565b82604001516001600160801b0316613a8f565b61271b565b8560a001515b60e0870151875160408701516101008a01518851949750612744946001600160801b0316613ab2565b6020840151606085015151156128b257306001600160a01b031685604001516001600160a01b0316036127b95760405162461bcd60e51b815260206004820152601e60248201527f5f6275794e465445782f43414e4e4f545f43414c4c4241434b5f53454c460000604482015260640161050c565b60408086015183516060880151925163f2b45c6f60e01b815247936000936001600160a01b03169263f2b45c6f926127f49290600401615042565b6020604051808303816000875af1158015612813573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128379190615018565b90506128438247614a38565b61284d9084614d2a565b92506001600160e01b0319811663f2b45c6f60e01b146128af5760405162461bcd60e51b815260206004820152601960248201527f5f6275794e465445782f43414c4c4241434b5f4641494c454400000000000000604482015260640161050c565b50505b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031687608001516001600160a01b031603612a0157600061290e8860c0015187600001516001600160801b031685604001516001600160801b03166136fe565b6129189086614d2a565b9050808210156129d857600061292e8383614a38565b905061295c7f00000000000000000000000000000000000000000000000000000000000000003330846120be565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156129be57600080fd5b505af11580156129d2573d6000803e3d6000fd5b50505050505b87516129e49086611948565b6129fa883088600001518660400151600161216c565b5050612cde565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031687608001516001600160a01b031603612cb2576000612a698860c0015187600001516001600160801b031685604001516001600160801b03166136fe565b905080821115612b86576000612a7f8284614a38565b905085811015612ac357612abe7f00000000000000000000000000000000000000000000000000000000000000003330612ab9858b614a38565b6120be565b612ac6565b50845b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612b2157600080fd5b505af1158015612b35573d6000803e3d6000fd5b5050505050612b697f00000000000000000000000000000000000000000000000000000000000000008a6000015188613abe565b612b7f893089600001518760400151600161216c565b5050612cac565b612bb67f0000000000000000000000000000000000000000000000000000000000000000338a60000151886120be565b8115612c965780821015612c7a576000612bd08383614a38565b9050612bfe7f00000000000000000000000000000000000000000000000000000000000000003330846120be565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015612c6057600080fd5b505af1158015612c74573d6000803e3d6000fd5b50505050505b612c90883088600001518660400151600161216c565b50612cac565b6129fa883388600001518660400151600061216c565b50612cde565b612cc68760800151338960000151876120be565b612cdc873387600001518560400151600061216c565b505b5050935093915050565b8051600090808203612d1c577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709150612f24565b80600103612df257600083600081518110612d3957612d39614a4f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316148015612d6c5750602081015151155b15612d99577f720ee400a9024f6a49768142c339bf09d2dd9056ab52d20fbe7165faba6e142d9250612dec565b602080820151805190820120604080517f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e8815284516001600160a01b031681850152908101919091526060812081522092505b50612f24565b6000816001600160401b03811115612e0c57612e0c613bca565b604051908082528060200260200182016040528015612e35578160200160208202803683370190505b50905060005b82811015612f18577f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e8858281518110612e7657612e76614a4f565b602002602001015160000151868381518110612e9457612e94614a4f565b60200260200101516020015180519060200120604051602001612ed3939291909283526001600160a01b03919091166020830152604082015260600190565b60405160208183030381529060405280519060200120828281518110612efb57612efb614a4f565b602090810291909101015280612f10816149f0565b915050612e3b565b50602082810291012091505b50919050565b8051600090808203612f5e577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709150612f24565b80600103612fef57600083600081518110612f7b57612f7b614a4f565b60200260200101519050600081604001518051906020012090506040517fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e94115815282516001600160a01b0316602082015260208301516040820152816060820152608081208152602081209450505050612f24565b6000816001600160401b0381111561300957613009613bca565b604051908082528060200260200182016040528015613032578160200160208202803683370190505b50905060005b82811015612f18577fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e9411585828151811061307357613073614a4f565b60200260200101516000015186838151811061309157613091614a4f565b6020026020010151602001518784815181106130af576130af614a4f565b602002602001015160400151805190602001206040516020016130f494939291909384526001600160a01b039290921660208401526040830152606082015260800190565b6040516020818303038152906040528051906020012082828151811061311c5761311c614a4f565b602090810291909101015280613131816149f0565b915050613038565b600080600061314786611bf9565b90508060000151915061316586868387606001518860200151611d4b565b80606001516001600160801b031684600001516001600160801b031611156131d95760405162461bcd60e51b815260206004820152602160248201527f5f73656c6c4e46542f455843454544535f52454d41494e494e475f414d4f554e6044820152601560fa1b606482015260840161050c565b6131ee6131e587611fdd565b82518651611fcb565b80604001516001600160801b031684600001516001600160801b0316146132495780604001516001600160801b031684600001516001600160801b03168760a0015161323a9190614fb0565b6132449190614fcf565b61324f565b8560a001515b92508360400151156133a9577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031686608001516001600160a01b0316146132ec5760405162461bcd60e51b815260206004820152602360248201527f5f73656c6c4e46542f45524332305f544f4b454e5f4d49534d415443485f45526044820152622927a960e91b606482015260840161050c565b61331c7f0000000000000000000000000000000000000000000000000000000000000000876000015130866120be565b604051632e1a7d4d60e01b8152600481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561337e57600080fd5b505af1158015613392573d6000803e3d6000fd5b505050506133a4846060015184611948565b6133c1565b6133c1866080015187600001518660600151866120be565b60a0840151511561351057306001600160a01b031684606001516001600160a01b0316036134315760405162461bcd60e51b815260206004820152601d60248201527f5f73656c6c4e46542f43414e4e4f545f43414c4c4241434b5f53454c46000000604482015260640161050c565b6060840151815160a086015160405163f2b45c6f60e01b81526000936001600160a01b03169263f2b45c6f9261346992600401615042565b6020604051808303816000875af1158015613488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ac9190615018565b90506001600160e01b0319811663f2b45c6f60e01b1461350e5760405162461bcd60e51b815260206004820152601860248201527f5f73656c6c4e46542f43414c4c4241434b5f4641494c45440000000000000000604482015260640161050c565b505b61353a8660e0015185608001518860000151876020015188600001516001600160801b0316613ab2565b612cde61354687611fdd565b875186516040850151600061216c565b816101200151516000036135b85781610100015181146111c85760405162461bcd60e51b815260206004820181905260248201527f5f76616c696461746550726f706572746965732f544f4b454e5f49445f455252604482015260640161050c565b60005b826101200151518110156111f957600083610120015182815181106135e2576135e2614a4f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316146136eb57805160e08501516020830151604051631395c0f360e01b81526001600160a01b0390931692631395c0f392613646929091889190600401614ff1565b60006040518083038186803b15801561365e57600080fd5b505afa92505050801561366f575060015b6136eb573d80801561369d576040519150601f19603f3d011682016040523d82523d6000602084013e6136a2565b606091505b5060405162461bcd60e51b815260206004820152601a60248201527f50524f50455254595f56414c49444154494f4e5f4641494c4544000000000000604482015260640161050c565b50806136f6816149f0565b9150506135bb565b60008183036137565760005b84518110156137505784818151811061372557613725614a4f565b6020026020010151602001518261373c9190614d2a565b915080613748816149f0565b91505061370a565b506137b6565b60005b84518110156137b457828486838151811061377657613776614a4f565b60200260200101516020015161378c9190614fb0565b6137969190614fcf565b6137a09083614d2a565b9150806137ac816149f0565b915050613759565b505b9392505050565b60008060006137cb86611b35565b8051925090506137dd86868333611c55565b80606001516001600160801b0316846001600160801b031611156138435760405162461bcd60e51b815260206004820181905260248201527f5f6275794e46542f455843454544535f52454d41494e494e475f414d4f554e54604482015260640161050c565b61385286826000015186611fcb565b80604001516001600160801b0316846001600160801b0316146138905761388b846001600160801b03168760a001516126fd9190614fb0565b613896565b8560a001515b92506138bb8660e00151876000015133896101000151886001600160801b0316613ab2565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031686608001516001600160a01b0316036139105785516138f89084611948565b61390a8630868460400151600161216c565b50613936565b6139248660800151338860000151866120be565b612cde8633868460400151600061216c565b50935093915050565b6305f5e1008111156139875760405162461bcd60e51b8152602060048201526011602482015270434f554e545f4f55545f4f465f5349444560781b604482015260640161050c565b604082015163ffffffff602082901c8116916000916139a891849116614a38565b6139b6906305f5e100614fb0565b90506000836139c58442614a38565b6139cf9190614fb0565b60a0860151909150826139e28383614fb0565b6139ec9190614fcf565b6139f69082614a38565b60a087015260005b8660c0015151811015613a86578660c001518181518110613a2157613a21614a4f565b6020026020010151602001519150838383613a3c9190614fb0565b613a469190614fcf565b613a509083614a38565b8760c001518281518110613a6657613a66614a4f565b602090810291909101810151015280613a7e816149f0565b9150506139fe565b50505050505050565b6000816001613a9e8286614d2a565b613aa89190614a38565b6137b69190614fcf565b61104c85858585612024565b600060405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260208160448360006001600160a01b038a165af191503d600182511460208210151681151783169250505080600003611d455760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c45440000604482015260640161050c565b6001600160a01b0381168114613b7257600080fd5b50565b8035613b8081613b5d565b919050565b60008060408385031215613b9857600080fd5b8235613ba381613b5d565b915060208301356001600160f81b0381168114613bbf57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b0381118282101715613c0257613c02613bca565b60405290565b60405161012081016001600160401b0381118282101715613c0257613c02613bca565b604080519081016001600160401b0381118282101715613c0257613c02613bca565b60405161014081016001600160401b0381118282101715613c0257613c02613bca565b604051601f8201601f191681016001600160401b0381118282101715613c9857613c98613bca565b604052919050565b60006001600160401b03821115613cb957613cb9613bca565b5060051b60200190565b600082601f830112613cd457600080fd5b81356001600160401b03811115613ced57613ced613bca565b613d00601f8201601f1916602001613c70565b818152846020838601011115613d1557600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f830112613d4357600080fd5b81356020613d58613d5383613ca0565b613c70565b82815260059290921b84018101918181019086841115613d7757600080fd5b8286015b84811015613e0b5780356001600160401b0380821115613d9b5760008081fd5b908801906060828b03601f1901811315613db55760008081fd5b613dbd613be0565b87840135613dca81613b5d565b815260408481013589830152918401359183831115613de95760008081fd5b613df78d8a85880101613cc3565b908201528652505050918301918301613d7b565b509695505050505050565b60006101208284031215613e2957600080fd5b613e31613c08565b9050613e3c82613b75565b8152613e4a60208301613b75565b60208201526040820135604082015260608201356060820152613e6f60808301613b75565b608082015260a082013560a082015260c08201356001600160401b03811115613e9757600080fd5b613ea384828501613d32565b60c083015250613eb560e08301613b75565b60e082015261010080830135818301525092915050565b600082601f830112613edd57600080fd5b81356020613eed613d5383613ca0565b82815260059290921b84018101918181019086841115613f0c57600080fd5b8286015b84811015613e0b5780356001600160401b03811115613f2f5760008081fd5b613f3d8986838b0101613e16565b845250918301918301613f10565b600060808284031215613f5d57600080fd5b604051608081018181106001600160401b0382111715613f7f57613f7f613bca565b604052905080823560028110613f9457600080fd5b8152602083013560ff81168114613faa57600080fd5b8060208301525060408301356040820152606083013560608201525092915050565b600082601f830112613fdd57600080fd5b81356020613fed613d5383613ca0565b82815260079290921b8401810191818101908684111561400c57600080fd5b8286015b84811015613e0b576140228882613f4b565b835291830191608001614010565b60008083601f84011261404257600080fd5b5081356001600160401b0381111561405957600080fd5b6020830191508360208260051b850101111561407457600080fd5b9250929050565b80358015158114613b8057600080fd5b60008060008060008060a087890312156140a457600080fd5b6001600160401b0380883511156140ba57600080fd5b6140c78989358a01613ecc565b9650602080890135828111156140dc57600080fd5b6140e88b828c01613fcc565b9750506040890135828111156140fd57600080fd5b6141098b828c01614030565b90975095505060608901358281111561412157600080fd5b8901601f81018b1361413257600080fd5b8035614140613d5382613ca0565b81815260059190911b8201830190838101908d83111561415f57600080fd5b8484015b8381101561419557868135111561417957600080fd5b6141888f878335880101613cc3565b8352918501918501614163565b508097505050505050506141ab6080880161407b565b90509295509295509295565b600081518084526020808501945080840160005b838110156141e95781511515875295820195908201906001016141cb565b509495945050505050565b6020815260006137b660208301846141b7565b600082601f83011261421857600080fd5b81356020614228613d5383613ca0565b82815260059290921b8401810191818101908684111561424757600080fd5b8286015b84811015613e0b5780356001600160401b038082111561426b5760008081fd5b908801906040828b03601f19018113156142855760008081fd5b61428d613c2b565b8784013561429a81613b5d565b81529083013590828211156142af5760008081fd5b6142bd8c8984870101613cc3565b81890152865250505091830191830161424b565b600061014082840312156142e457600080fd5b6142ec613c4d565b90506142f782613b75565b815261430560208301613b75565b6020820152604082013560408201526060820135606082015261432a60808301613b75565b608082015260a082013560a082015260c08201356001600160401b038082111561435357600080fd5b61435f85838601613d32565b60c084015261437060e08501613b75565b60e084015261010084810135908401526101209150818401358181111561439657600080fd5b6143a286828701614207565b8385015250505092915050565b6000602082840312156143c157600080fd5b81356001600160401b038111156143d757600080fd5b6143e3848285016142d1565b949350505050565b6000602082840312156143fd57600080fd5b81356001600160401b0381111561441357600080fd5b6143e384828501613e16565b634e487b7160e01b600052602160045260246000fd5b60208101600483106144495761444961441f565b91905290565b60008060008060006080868803121561446757600080fd5b853561447281613b5d565b9450602086013561448281613b5d565b93506040860135925060608601356001600160401b03808211156144a557600080fd5b818801915088601f8301126144b957600080fd5b8135818111156144c857600080fd5b8960208285010111156144da57600080fd5b9699959850939650602001949392505050565b600080600080610140858703121561450457600080fd5b84356001600160401b038082111561451b57600080fd5b61452788838901613e16565b9550602087013591508082111561453d57600080fd5b5061454a878288016142d1565b93505061455a8660408701613f4b565b91506145698660c08701613f4b565b905092959194509250565b6000806000806000610100868803121561458d57600080fd5b85356001600160401b03808211156145a457600080fd5b6145b089838a01613e16565b96506145bf8960208a01613f4b565b955060a088013591506145d182613b5d565b90935060c0870135925060e087013590808211156145ee57600080fd5b506145fb88828901613cc3565b9150509295509295909350565b60008060a0838503121561461b57600080fd5b82356001600160401b0381111561463157600080fd5b61463d85828601613e16565b92505061464d8460208501613f4b565b90509250929050565b60006020828403121561466857600080fd5b81356137b681613b5d565b6000806020838503121561468657600080fd5b82356001600160401b0381111561469c57600080fd5b6146a885828601614030565b90969095509350505050565b600080600080608085870312156146ca57600080fd5b84356001600160401b03808211156146e157600080fd5b6146ed88838901613ecc565b955060209150818701358181111561470457600080fd5b8701601f8101891361471557600080fd5b8035614723613d5382613ca0565b81815260059190911b8201840190848101908b83111561474257600080fd5b8584015b8381101561477a5780358681111561475e5760008081fd5b61476c8e89838901016142d1565b845250918601918601614746565b509750505050604087013591508082111561479457600080fd5b6147a088838901613fcc565b935060608701359150808211156147b657600080fd5b506147c387828801613fcc565b91505092959194509250565b604080825283519082018190526000906020906060840190828701845b82811015614808578151845292840192908401906001016147ec565b5050508381038285015261481c81866141b7565b9695505050505050565b6000806000806000610100868803121561483f57600080fd5b85356001600160401b038082111561485657600080fd5b61486289838a016142d1565b96506148718960208a01613f4b565b955060a0880135945061488660c0890161407b565b935060e08801359150808211156145ee57600080fd5b60008060008060e085870312156148b257600080fd5b84356001600160401b03808211156148c957600080fd5b6148d588838901613e16565b95506148e48860208901613f4b565b945060a087013591506148f682613b5d565b90925060c0860135908082111561490c57600080fd5b506147c387828801613cc3565b60006020828403121561492b57600080fd5b5035919050565b60008060a0838503121561494557600080fd5b82356001600160401b0381111561495b57600080fd5b61463d858286016142d1565b60008060006060848603121561497c57600080fd5b83356001600160401b038082111561499357600080fd5b61499f87838801613ecc565b945060208601359150808211156149b557600080fd5b506149c286828701613fcc565b9250506149d16040850161407b565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b600060018201614a0257614a026149da565b5060010190565b602080825260159082015274082a4a482b2be988a9c8ea890be9a92a69a82a8869605b1b604082015260600190565b600082821015614a4a57614a4a6149da565b500390565b634e487b7160e01b600052603260045260246000fd5b60005b83811015614a80578181015183820152602001614a68565b83811115611d455750506000910152565b60008151808452614aa9816020860160208601614a65565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b85811015614b2e578284038952815180516001600160a01b031685528581015186860152604090810151606091860182905290614b1a81870183614a91565b9a87019a9550505090840190600101614adb565b5091979650505050505050565b600061012060018060a01b0383511684526020830151614b6660208601826001600160a01b03169052565b5060408301516040850152606083015160608501526080830151614b9560808601826001600160a01b03169052565b5060a083015160a085015260c08301518160c0860152614bb782860182614abd565b91505060e0830151614bd460e08601826001600160a01b03169052565b50610100928301519390920192909252919050565b805160028110614bfb57614bfb61441f565b825260208181015160ff169083015260408082015190830152606090810151910152565b6000610100808352614c3381840189614b3b565b9050614c426020840188614be9565b6001600160a01b03861660a084015260c0830185905282810360e0840152614c6a8185614a91565b98975050505050505050565b60008251614c88818460208701614a65565b9190910192915050565b600080600060c08486031215614ca757600080fd5b83356001600160401b03811115614cbd57600080fd5b614cc9868287016142d1565b935050614cd98560208601613f4b565b91506149d160a0850161407b565b6001600160a01b039788168152958716602087015293861660408601526060850192909252909316608083015260a082019290925260c081019190915260e00190565b60008219821115614d3d57614d3d6149da565b500190565b600061012060018060a01b03808d168452808c1660208501528a604085015289606085015280891660808501528760a08501528160c0850152614d8782850188614abd565b951660e084015250506101000152979650505050505050565b600081518084526020808501808196508360051b8101915082860160005b85811015614b2e578284038952815180516001600160a01b031685528501516040868601819052614df181870183614a91565b9a87019a9550505090840190600101614dbe565b600061014060018060a01b03808e168452808d1660208501528b60408501528a6060850152808a1660808501528860a08501528160c0850152614e4a82850189614abd565b915080871660e08501525084610100840152828103610120840152614e6f8185614da0565b9d9c50505050505050505050505050565b6000610140808352614e9481840188614b3b565b838103602085015286516001600160a01b031681526020870151614ec360208301826001600160a01b03169052565b5060408701516040820152606087015160608201526080870151614ef260808301826001600160a01b03169052565b5060a087015160a082015260c08701518260c0830152614f1483830182614abd565b92505060e0870151614f3160e08301826001600160a01b03169052565b5061010087810151908201526101208088015182840382840152614f558482614da0565b945050505050614f686040830185614be9565b610a5e60c0830184614be9565b600060208284031215614f8757600080fd5b5051919050565b60a081526000614fa160a0830185614b3b565b90506137b66020830184614be9565b6000816000190483118215151615614fca57614fca6149da565b500290565b600082614fec57634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b0384168152826020820152606060408201526000610a5e6060830184614a91565b60006020828403121561502a57600080fd5b81516001600160e01b0319811681146137b657600080fd5b8281526040602082015260006143e36040830184614a9156fea2646970667358221220cc8e30033a1a29c470c793e747e1dbda5f9de82cd1a4355083536980526619c264736f6c634300080d0033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x6080604052600436106101405760003560e01c806333ba623b116100b6578063a88094851161006f578063a8809485146103c5578063af3de155146103e5578063b18d619f14610405578063be167b9d14610418578063c67a891114610438578063d8d2ae771461045857600080fd5b806333ba623b146102f85780635e7251861461030b5780635f57685e146103445780636e74f68a1461035757806386219940146103775780638e3efd591461039757600080fd5b8063150b7a0211610108578063150b7a021461022c5780631fc34ffe14610265578063287846681461028557806328a96208146102a557806332766750146102c5578063332b024f146102d857600080fd5b8063030b273014610145578063050505d6146101a8578063053c23f1146101bf578063078e6b33146101df57806310a1ea2b146101ff575b600080fd5b34801561015157600080fd5b50610195610160366004613b85565b6001600160a01b03919091166000908152600560801b602090815260408083206001600160f81b039094168352929052205490565b6040519081526020015b60405180910390f35b3480156101b457600080fd5b506101bd61046b565b005b6101d26101cd36600461408b565b6104cf565b60405161019f91906141f4565b3480156101eb57600080fd5b506101956101fa3660046143af565b6107e1565b34801561020b57600080fd5b5061021f61021a3660046143eb565b610907565b60405161019f9190614435565b34801561023857600080fd5b5061024c61024736600461444f565b6109b0565b6040516001600160e01b0319909116815260200161019f565b34801561027157600080fd5b506101956102803660046144ed565b610a67565b34801561029157600080fd5b506101956102a03660046143eb565b610ea2565b3480156102b157600080fd5b506101bd6102c03660046143eb565b610ece565b6101bd6102d3366004614574565b610fd0565b3480156102e457600080fd5b506101bd6102f33660046143af565b611053565b6101bd610306366004614608565b61114f565b34801561031757600080fd5b50610195610326366004614656565b6001600160a01b03166000908152600160821b602052604090205490565b6101bd610352366004614608565b6111cc565b34801561036357600080fd5b506101bd610372366004614608565b6111fe565b34801561038357600080fd5b506101bd610392366004614673565b611213565b3480156103a357600080fd5b506103b76103b23660046146b4565b611251565b60405161019f9291906147cf565b3480156103d157600080fd5b506101bd6103e0366004614826565b6114ed565b3480156103f157600080fd5b5061021f6104003660046143af565b6114fc565b6101bd61041336600461489c565b61156c565b34801561042457600080fd5b506101bd610433366004614919565b61159c565b34801561044457600080fd5b506101bd610453366004614932565b6115dc565b6101d2610466366004614967565b6115e8565b336000908152600160821b602052604081208054829061048a906149f0565b918290555060408051338152602081018390529192507f4cf3e8a83c6bf8a510613208458629675b4ae99b8029e3ab6cb6a86e5f01fd3191015b60405180910390a150565b8551855160609190811480156104e457508085145b80156104f05750835181145b6105155760405162461bcd60e51b815260040161050c90614a09565b60405180910390fd5b806001600160401b0381111561052d5761052d613bca565b604051908082528060200260200182016040528015610556578160200160208202803683370190505b50915060006105653447614a38565b9050831561063b5760005b82811015610635576105ff8a828151811061058d5761058d614a4f565b60200260200101518a83815181106105a7576105a7614a4f565b60200260200101518a8a858181106105c1576105c1614a4f565b90506020020160208101906105d69190614656565b6105e08647614a38565b8a86815181106105f2576105f2614a4f565b6020026020010151611839565b600184828151811061061357610613614a4f565b911515602092830291909101909101528061062d816149f0565b915050610570565b506107c2565b60005b828110156107c0577f000000000000000000000000e4ac19434cef450ead2942fa9ab01ec8fc0cf1816001600160a01b0316633276675060e01b8b838151811061068a5761068a614a4f565b60200260200101518b84815181106106a4576106a4614a4f565b60200260200101518b8b868181106106be576106be614a4f565b90506020020160208101906106d39190614656565b6106dd8747614a38565b8b87815181106106ef576106ef614a4f565b602002602001015160405160240161070b959493929190614c1f565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516107499190614c76565b600060405180830381855af49150503d8060008114610784576040519150601f19603f3d011682016040523d82523d6000602084013e610789565b606091505b505084828151811061079d5761079d614a4f565b6020026020010181151515158152505080806107b8906149f0565b91505061063e565b505b6107d5336107d08347614a38565b611948565b50509695505050505050565b80516001600160a01b03166000908152600160821b60205260408120546109019061080d9084906119f1565b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f27b14c20196091d9cd90ca9c473d3ad1523b00ddf487a9b7452a8a119a16b98c828401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608301527f000000000000000000000000000000000000000000000000000000000000000160808301523060a0808401919091528351808403909101815260c08301845280519082012061190160f01b60e084015260e28301526101028083019490945282518083039094018452610122909101909152815191012090565b92915050565b604081015160009067ffffffff00000000161561093c574260208360400151901c63ffffffff16111561093c57506000919050565b42826040015163ffffffff161161095557506003919050565b81516001600160a01b03166000908152600560801b6020818152604080842060608701805160081c86529252909220549151909190600160ff9091161b808216156109a557506002949350505050565b506001949350505050565b60008080806109c185870187614c92565b9250925092508260e001516001600160a01b0316336001600160a01b031614610a2c5760405162461bcd60e51b815260206004820152601b60248201527f4552433732315f544f4b454e5f4d49534d415443485f4552524f520000000000604482015260640161050c565b604080516000815260208101909152610a5090849084908a9085908e903090611a80565b50630a85bd0160e11b925050505b95945050505050565b60008360e001516001600160a01b03168560e001516001600160a01b031614610ad25760405162461bcd60e51b815260206004820152601b60248201527f4552433732315f544f4b454e5f4d49534d415443485f4552524f520000000000604482015260640161050c565b6000610add86611b35565b90506000610aea86611bf9565b9050610afc8786848960000151611c55565b610b128685838a600001518b6101000151611d4b565b604087015160fc1c600203610b3257610b32878760a00151600180611ebe565b610b428783600001516001611fcb565b610b57610b4e87611fdd565b82516001611fcb565b60008760a001518760a00151610b6d9190614a38565b60e0890151895189516101008c0151939450610b8893612024565b60808801516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148015610bed57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031687608001516001600160a01b0316145b15610d0657610c267f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28860000151308a60a001516120be565b60a0870151604051632e1a7d4d60e01b815260048101919091527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610c8e57600080fd5b505af1158015610ca2573d6000803e3d6000fd5b50505050610cb888600001518960a00151611948565b610cd0610cc488611fdd565b8851600180600061216c565b506000610ce28930600180600161216c565b9050610cee8183614a38565b94508415610d0057610d003386611948565b50610dd7565b86608001516001600160a01b031688608001516001600160a01b031614610d6f5760405162461bcd60e51b815260206004820152601a60248201527f45524332305f544f4b454e5f4d49534d415443485f4552524f52000000000000604482015260640161050c565b610d8b876080015188600001518a600001518b60a001516120be565b610d97610cc488611fdd565b506000610dad898960000151600180600061216c565b9050610db98183614a38565b94508415610dd557610dd58860800151896000015133886120be565b505b7f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac94886000015188600001518a608001518b60a001518c60e001518d61010001518960000151604051610e2f9796959493929190614ce7565b60405180910390a17fa24193d56ccdf64ce1df60c80ca683da965a1da3363efa67c14abf62b2d7d4938760000151896000015189608001518a60a001518b60e001518d61010001518860000151604051610e8f9796959493929190614ce7565b60405180910390a1505050949350505050565b80516001600160a01b03166000908152600160821b60205260408120546109019061080d90849061235e565b80516001600160a01b03163314610f145760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa6a0a5a2a960b11b604482015260640161050c565b80516001600160a01b03166000908152600160821b602052604081205490610f3b83610ea2565b9050610f48826001614d2a565b60008281526001600560801b01602090815260409182902092909255845191850151858201516060870151608088015160a089015160c08a015160e08b01516101008c015197517f29806076879d6116f3a8b8f81980ee6273d4ae8cb3ede88be4bb96f88787c26c99610fc399909897969594939291614d42565b60405180910390a1505050565b307f000000000000000000000000e4ac19434cef450ead2942fa9ab01ec8fc0cf1816001600160a01b03160361103f5760405162461bcd60e51b81526020600482015260146024820152734d5553545f43414c4c5f46524f4d5f50524f585960601b604482015260640161050c565b61104c8585858585611839565b5050505050565b80516001600160a01b031633146110995760405162461bcd60e51b815260206004820152600a60248201526927a7262cafa6a0a5a2a960b11b604482015260640161050c565b80516001600160a01b03166000908152600160821b6020526040812054906110c0836107e1565b90506110cd826001614d2a565b60008281526001600560801b01602090815260409182902092909255845191850151858201516060870151608088015160a089015160c08a015160e08b01516101008c01516101208d015198517f4c2669b38ff3018c301fbc65423ac87447906bcf66b95a5fe0d3c5bbd6bcb2979a610fc39a90999897969594939291614e05565b307f000000000000000000000000e4ac19434cef450ead2942fa9ab01ec8fc0cf1816001600160a01b0316036111be5760405162461bcd60e51b81526020600482015260146024820152734d5553545f43414c4c5f46524f4d5f50524f585960601b604482015260640161050c565b6111c882826123cc565b5050565b60006111d83447614a38565b90506111e483836123cc565b8047146111f9576111f9336107d08347614a38565b505050565b6111c861120a83610ea2565b8351839061242b565b60005b818110156111f95761123f83838381811061123357611233614a4f565b9050602002013561159c565b80611249816149f0565b915050611216565b835183516060918291811480156112685750845181145b80156112745750835181145b6112905760405162461bcd60e51b815260040161050c90614a09565b806001600160401b038111156112a8576112a8613bca565b6040519080825280602002602001820160405280156112d1578160200160208202803683370190505b509250806001600160401b038111156112ec576112ec613bca565b604051908082528060200260200182016040528015611315578160200160208202803683370190505b50915060005b818110156114e25760607f000000000000000000000000e4ac19434cef450ead2942fa9ab01ec8fc0cf1816001600160a01b0316631fc34ffe60e01b8a848151811061136957611369614a4f565b60200260200101518a858151811061138357611383614a4f565b60200260200101518a868151811061139d5761139d614a4f565b60200260200101518a87815181106113b7576113b7614a4f565b60200260200101516040516024016113d29493929190614e80565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516114109190614c76565b600060405180830381855af49150503d806000811461144b576040519150601f19603f3d011682016040523d82523d6000602084013e611450565b606091505b5085848151811061146357611463614a4f565b602002602001018193508215151515815250505083828151811061148957611489614a4f565b6020026020010151156114cf576000818060200190518101906114ac9190614f75565b9050808684815181106114c1576114c1614a4f565b602002602001018181525050505b50806114da816149f0565b91505061131b565b505094509492505050565b61104c85858585333387611a80565b600081610100015160001415801561151a5750600082610120015151115b1561152757506000919050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031682608001516001600160a01b03160361156057506000919050565b61090161021a83611fdd565b60006115783447614a38565b90506115878585853486611839565b80471461104c5761104c336107d08347614a38565b6115a633826125a1565b60408051338152602081018390527fa015ad2dc32f266993958a0fd9884c746b971b254206f3478bc43e2f125c7b9e91016104c4565b6111c861120a836107e1565b8251825160609190811461160e5760405162461bcd60e51b815260040161050c90614a09565b806001600160401b0381111561162657611626613bca565b60405190808252806020026020018201604052801561164f578160200160208202803683370190505b509150600061165e3447614a38565b905083156116e95760005b828110156116e3576116ad87828151811061168657611686614a4f565b60200260200101518783815181106116a0576116a0614a4f565b60200260200101516123cc565b60018482815181106116c1576116c1614a4f565b91151560209283029190910190910152806116db816149f0565b915050611669565b50611822565b60005b82811015611820577f000000000000000000000000e4ac19434cef450ead2942fa9ab01ec8fc0cf1816001600160a01b03166333ba623b60e01b88838151811061173857611738614a4f565b602002602001015188848151811061175257611752614a4f565b602002602001015160405160240161176b929190614f8e565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516117a99190614c76565b600060405180830381855af49150503d80600081146117e4576040519150601f19603f3d011682016040523d82523d6000602084013e6117e9565b606091505b50508482815181106117fd576117fd614a4f565b602002602001018115151515815250508080611818906149f0565b9150506116ec565b505b611830336107d08347614a38565b50509392505050565b6001600160a01b03831661184f573392506118a7565b306001600160a01b038416036118a75760405162461bcd60e51b815260206004820152601b60248201527f5f62757937323145782f54414b45525f43414e4e4f545f53454c460000000000604482015260640161050c565b60006118e78686604051806080016040528060016001600160801b03168152602001878152602001886001600160a01b03168152602001868152506125e2565b8751608089015160a08a015160e08b01516101008c01516040519597507f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac949650611938958b94939291908990614ce7565b60405180910390a1505050505050565b80156111c8576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461199b576040519150601f19603f3d011682016040523d82523d6000602084013e6119a0565b606091505b50509050806111f95760405162461bcd60e51b815260206004820152601c60248201527f5f7472616e736665724574682f5452414e534645525f4641494c454400000000604482015260640161050c565b600080611a02846101200151612ce8565b90506000611a138560c00151612f2a565b90506020851015611a2057fe5b601f198501805160c087018051610120890180516101408b0180517fa525d336300f566329800fcbe82fd263226dc27d6c109f060d9a4a364281521c88529785529782528988526101808620949095529152919091529152905092915050565b6000611ad788886040518060c0016040528060016001600160801b031681526020018a81526020018915158152602001886001600160a01b03168152602001876001600160a01b0316815260200186815250613139565b895160808b015160a08c015160e08d01516040519496507fa24193d56ccdf64ce1df60c80ca683da965a1da3363efa67c14abf62b2d7d4939550611b23948a939291908d908990614ce7565b60405180910390a15050505050505050565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152611b8683610ea2565b8152611b9183610907565b81602001906003811115611ba757611ba761441f565b90816003811115611bba57611bba61441f565b90525060016040820181905281602001516003811115611bdc57611bdc61441f565b14611be8576000611beb565b60015b60ff16606082015292915050565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152611c4a836107e1565b8152611b91836114fc565b60208401516001600160a01b03161580611c845750806001600160a01b031684602001516001600160a01b0316145b611cd05760405162461bcd60e51b815260206004820152601960248201527f5f76616c69646174654f726465722f4f4e4c595f54414b455200000000000000604482015260640161050c565b600182602001516003811115611ce857611ce861441f565b14611d355760405162461bcd60e51b815260206004820152601d60248201527f5f76616c69646174654f726465722f4f524445525f4e4f545f46494c4c000000604482015260640161050c565b81518451611d459190859061242b565b50505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031685608001516001600160a01b031603611dc45760405162461bcd60e51b815260206004820181905260248201527f5f76616c69646174654275794f726465722f544f4b454e5f4d49534d41544348604482015260640161050c565b60208501516001600160a01b03161580611df35750816001600160a01b031685602001516001600160a01b0316145b611e3f5760405162461bcd60e51b815260206004820152601c60248201527f5f76616c69646174654275794f726465722f4f4e4c595f54414b455200000000604482015260640161050c565b600183602001516003811115611e5757611e5761441f565b14611ea45760405162461bcd60e51b815260206004820152601d60248201527f5f76616c69646174654f726465722f4f524445525f4e4f545f46494c4c000000604482015260640161050c565b611eae8582613556565b8251855161104c9190869061242b565b6000611ecf8560c0015184846136fe565b905060008560a0015182611ee39190614d2a565b9050808514611fc3576000611ef88287614a38565b905060008215611fa25760005b8860c0015151811015611fa0576000848a60c001518381518110611f2b57611f2b614a4f565b60200260200101516020015185611f429190614fb0565b611f4c9190614fcf565b9050808a60c001518381518110611f6557611f65614a4f565b6020026020010151602001818151611f7d9190614d2a565b905250611f8a8184614d2a565b9250508080611f98906149f0565b915050611f05565b505b611fac8183614a38565b8860a001818151611fbd9190614d2a565b90525050505b505050505050565b6111f9836000015184606001516125a1565b604080516101208101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c082015260e08101829052610100015290565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260008060648360006001600160a01b038b165af19150508060000361104c5760405162461bcd60e51b815260206004820152601f60248201527f5f7472616e736665724552433732312f5452414e534645525f4641494c454400604482015260640161050c565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260208160648360006001600160a01b038b165af191503d60018251146020821015168115178316925050508060000361104c5760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c45440000604482015260640161050c565b6000805b8660c00151518110156123545760008760c00151828151811061219557612195614a4f565b602002602001015190506000856001600160801b0316876001600160801b0316146121ec57856001600160801b0316876001600160801b031683602001516121dd9190614fb0565b6121e79190614fcf565b6121f2565b81602001515b9050841561220b5781516122069082611948565b612225565b8015612225576122258960800151898460000151846120be565b604082015151156123335781516000906001600160a01b03166330787dd187612252578b60800151612268565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b8486604001516040518463ffffffff1660e01b815260040161228c93929190614ff1565b6020604051808303816000875af11580156122ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cf9190615018565b90506001600160e01b031981166330787dd160e01b146123315760405162461bcd60e51b815260206004820152601860248201527f5f706179466565732f43414c4c4241434b5f4641494c45440000000000000000604482015260640161050c565b505b61233d8185614d2a565b93505050808061234c906149f0565b915050612170565b5095945050505050565b60008061236e8460c00151612f2a565b9050602084101561237b57fe5b601f198401805160c08601805161012090970180517fed676c7f3e8232a311454799b1cf26e75b4abc90c9bf06c9f7e8e79fcc7fe14d85529482529586526101608320919092529490529091525090565b60006123da838360016137bd565b8451608086015160a087015160e08801516101008901516040519597507f8a0f8e04e7a35efabdc150b7d106308198a4f965a5d11badf768c5b8b273ac949650610fc3953394939291908990614ce7565b6001825160018111156124405761244061441f565b036124ce576001600160a01b0381166000908152600160821b602052604090205461246c906001614d2a565b60008481526001600560801b016020526040902054146111f95760405162461bcd60e51b815260206004820152601860248201527f5052455349474e45445f494e56414c49445f5349474e45520000000000000000604482015260640161050c565b6001600160a01b0381161580159061255e575060208083015160408085015160608087015183516000815295860180855289905260ff9094169285019290925290830152608082015260019060a0016020604051602081039080840390855afa15801561253f573d6000803e3d6000fd5b505050602060405103516001600160a01b0316816001600160a01b0316145b6111f95760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa9a4a3a722a92fa2a92927a960611b604482015260640161050c565b600160ff82161b80600560801b6001600160a01b0390941660009081526020948552604080822060089590951c825293909452919092208054909117905550565b60008060006125f086611b35565b9050806000015191506126098686838760400151611c55565b80606001516001600160801b031684600001516001600160801b0316111561267e5760405162461bcd60e51b815260206004820152602260248201527f5f6275794e465445782f455843454544535f52454d41494e494e475f414d4f55604482015261139560f21b606482015260840161050c565b8051845161268d918891611fcb565b604086015160fc1c6001036126bc5760408681015163ffffffff911c1680156126ba576126ba878261393f565b505b80604001516001600160801b031684600001516001600160801b0316146127155761271084600001516001600160801b03168760a001516126fd9190614fb0565b82604001516001600160801b0316613a8f565b61271b565b8560a001515b60e0870151875160408701516101008a01518851949750612744946001600160801b0316613ab2565b6020840151606085015151156128b257306001600160a01b031685604001516001600160a01b0316036127b95760405162461bcd60e51b815260206004820152601e60248201527f5f6275794e465445782f43414e4e4f545f43414c4c4241434b5f53454c460000604482015260640161050c565b60408086015183516060880151925163f2b45c6f60e01b815247936000936001600160a01b03169263f2b45c6f926127f49290600401615042565b6020604051808303816000875af1158015612813573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128379190615018565b90506128438247614a38565b61284d9084614d2a565b92506001600160e01b0319811663f2b45c6f60e01b146128af5760405162461bcd60e51b815260206004820152601960248201527f5f6275794e465445782f43414c4c4241434b5f4641494c454400000000000000604482015260640161050c565b50505b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031687608001516001600160a01b031603612a0157600061290e8860c0015187600001516001600160801b031685604001516001600160801b03166136fe565b6129189086614d2a565b9050808210156129d857600061292e8383614a38565b905061295c7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23330846120be565b604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156129be57600080fd5b505af11580156129d2573d6000803e3d6000fd5b50505050505b87516129e49086611948565b6129fa883088600001518660400151600161216c565b5050612cde565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031687608001516001600160a01b031603612cb2576000612a698860c0015187600001516001600160801b031685604001516001600160801b03166136fe565b905080821115612b86576000612a7f8284614a38565b905085811015612ac357612abe7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23330612ab9858b614a38565b6120be565b612ac6565b50845b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612b2157600080fd5b505af1158015612b35573d6000803e3d6000fd5b5050505050612b697f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a6000015188613abe565b612b7f893089600001518760400151600161216c565b5050612cac565b612bb67f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2338a60000151886120be565b8115612c965780821015612c7a576000612bd08383614a38565b9050612bfe7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23330846120be565b604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015612c6057600080fd5b505af1158015612c74573d6000803e3d6000fd5b50505050505b612c90883088600001518660400151600161216c565b50612cac565b6129fa883388600001518660400151600061216c565b50612cde565b612cc68760800151338960000151876120be565b612cdc873387600001518560400151600061216c565b505b5050935093915050565b8051600090808203612d1c577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709150612f24565b80600103612df257600083600081518110612d3957612d39614a4f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316148015612d6c5750602081015151155b15612d99577f720ee400a9024f6a49768142c339bf09d2dd9056ab52d20fbe7165faba6e142d9250612dec565b602080820151805190820120604080517f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e8815284516001600160a01b031681850152908101919091526060812081522092505b50612f24565b6000816001600160401b03811115612e0c57612e0c613bca565b604051908082528060200260200182016040528015612e35578160200160208202803683370190505b50905060005b82811015612f18577f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e8858281518110612e7657612e76614a4f565b602002602001015160000151868381518110612e9457612e94614a4f565b60200260200101516020015180519060200120604051602001612ed3939291909283526001600160a01b03919091166020830152604082015260600190565b60405160208183030381529060405280519060200120828281518110612efb57612efb614a4f565b602090810291909101015280612f10816149f0565b915050612e3b565b50602082810291012091505b50919050565b8051600090808203612f5e577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709150612f24565b80600103612fef57600083600081518110612f7b57612f7b614a4f565b60200260200101519050600081604001518051906020012090506040517fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e94115815282516001600160a01b0316602082015260208301516040820152816060820152608081208152602081209450505050612f24565b6000816001600160401b0381111561300957613009613bca565b604051908082528060200260200182016040528015613032578160200160208202803683370190505b50905060005b82811015612f18577fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e9411585828151811061307357613073614a4f565b60200260200101516000015186838151811061309157613091614a4f565b6020026020010151602001518784815181106130af576130af614a4f565b602002602001015160400151805190602001206040516020016130f494939291909384526001600160a01b039290921660208401526040830152606082015260800190565b6040516020818303038152906040528051906020012082828151811061311c5761311c614a4f565b602090810291909101015280613131816149f0565b915050613038565b600080600061314786611bf9565b90508060000151915061316586868387606001518860200151611d4b565b80606001516001600160801b031684600001516001600160801b031611156131d95760405162461bcd60e51b815260206004820152602160248201527f5f73656c6c4e46542f455843454544535f52454d41494e494e475f414d4f554e6044820152601560fa1b606482015260840161050c565b6131ee6131e587611fdd565b82518651611fcb565b80604001516001600160801b031684600001516001600160801b0316146132495780604001516001600160801b031684600001516001600160801b03168760a0015161323a9190614fb0565b6132449190614fcf565b61324f565b8560a001515b92508360400151156133a9577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031686608001516001600160a01b0316146132ec5760405162461bcd60e51b815260206004820152602360248201527f5f73656c6c4e46542f45524332305f544f4b454e5f4d49534d415443485f45526044820152622927a960e91b606482015260840161050c565b61331c7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2876000015130866120be565b604051632e1a7d4d60e01b8152600481018490527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561337e57600080fd5b505af1158015613392573d6000803e3d6000fd5b505050506133a4846060015184611948565b6133c1565b6133c1866080015187600001518660600151866120be565b60a0840151511561351057306001600160a01b031684606001516001600160a01b0316036134315760405162461bcd60e51b815260206004820152601d60248201527f5f73656c6c4e46542f43414e4e4f545f43414c4c4241434b5f53454c46000000604482015260640161050c565b6060840151815160a086015160405163f2b45c6f60e01b81526000936001600160a01b03169263f2b45c6f9261346992600401615042565b6020604051808303816000875af1158015613488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ac9190615018565b90506001600160e01b0319811663f2b45c6f60e01b1461350e5760405162461bcd60e51b815260206004820152601860248201527f5f73656c6c4e46542f43414c4c4241434b5f4641494c45440000000000000000604482015260640161050c565b505b61353a8660e0015185608001518860000151876020015188600001516001600160801b0316613ab2565b612cde61354687611fdd565b875186516040850151600061216c565b816101200151516000036135b85781610100015181146111c85760405162461bcd60e51b815260206004820181905260248201527f5f76616c696461746550726f706572746965732f544f4b454e5f49445f455252604482015260640161050c565b60005b826101200151518110156111f957600083610120015182815181106135e2576135e2614a4f565b6020026020010151905060006001600160a01b031681600001516001600160a01b0316146136eb57805160e08501516020830151604051631395c0f360e01b81526001600160a01b0390931692631395c0f392613646929091889190600401614ff1565b60006040518083038186803b15801561365e57600080fd5b505afa92505050801561366f575060015b6136eb573d80801561369d576040519150601f19603f3d011682016040523d82523d6000602084013e6136a2565b606091505b5060405162461bcd60e51b815260206004820152601a60248201527f50524f50455254595f56414c49444154494f4e5f4641494c4544000000000000604482015260640161050c565b50806136f6816149f0565b9150506135bb565b60008183036137565760005b84518110156137505784818151811061372557613725614a4f565b6020026020010151602001518261373c9190614d2a565b915080613748816149f0565b91505061370a565b506137b6565b60005b84518110156137b457828486838151811061377657613776614a4f565b60200260200101516020015161378c9190614fb0565b6137969190614fcf565b6137a09083614d2a565b9150806137ac816149f0565b915050613759565b505b9392505050565b60008060006137cb86611b35565b8051925090506137dd86868333611c55565b80606001516001600160801b0316846001600160801b031611156138435760405162461bcd60e51b815260206004820181905260248201527f5f6275794e46542f455843454544535f52454d41494e494e475f414d4f554e54604482015260640161050c565b61385286826000015186611fcb565b80604001516001600160801b0316846001600160801b0316146138905761388b846001600160801b03168760a001516126fd9190614fb0565b613896565b8560a001515b92506138bb8660e00151876000015133896101000151886001600160801b0316613ab2565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031686608001516001600160a01b0316036139105785516138f89084611948565b61390a8630868460400151600161216c565b50613936565b6139248660800151338860000151866120be565b612cde8633868460400151600061216c565b50935093915050565b6305f5e1008111156139875760405162461bcd60e51b8152602060048201526011602482015270434f554e545f4f55545f4f465f5349444560781b604482015260640161050c565b604082015163ffffffff602082901c8116916000916139a891849116614a38565b6139b6906305f5e100614fb0565b90506000836139c58442614a38565b6139cf9190614fb0565b60a0860151909150826139e28383614fb0565b6139ec9190614fcf565b6139f69082614a38565b60a087015260005b8660c0015151811015613a86578660c001518181518110613a2157613a21614a4f565b6020026020010151602001519150838383613a3c9190614fb0565b613a469190614fcf565b613a509083614a38565b8760c001518281518110613a6657613a66614a4f565b602090810291909101810151015280613a7e816149f0565b9150506139fe565b50505050505050565b6000816001613a9e8286614d2a565b613aa89190614a38565b6137b69190614fcf565b61104c85858585612024565b600060405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260208160448360006001600160a01b038a165af191503d600182511460208210151681151783169250505080600003611d455760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c45440000604482015260640161050c565b6001600160a01b0381168114613b7257600080fd5b50565b8035613b8081613b5d565b919050565b60008060408385031215613b9857600080fd5b8235613ba381613b5d565b915060208301356001600160f81b0381168114613bbf57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b0381118282101715613c0257613c02613bca565b60405290565b60405161012081016001600160401b0381118282101715613c0257613c02613bca565b604080519081016001600160401b0381118282101715613c0257613c02613bca565b60405161014081016001600160401b0381118282101715613c0257613c02613bca565b604051601f8201601f191681016001600160401b0381118282101715613c9857613c98613bca565b604052919050565b60006001600160401b03821115613cb957613cb9613bca565b5060051b60200190565b600082601f830112613cd457600080fd5b81356001600160401b03811115613ced57613ced613bca565b613d00601f8201601f1916602001613c70565b818152846020838601011115613d1557600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f830112613d4357600080fd5b81356020613d58613d5383613ca0565b613c70565b82815260059290921b84018101918181019086841115613d7757600080fd5b8286015b84811015613e0b5780356001600160401b0380821115613d9b5760008081fd5b908801906060828b03601f1901811315613db55760008081fd5b613dbd613be0565b87840135613dca81613b5d565b815260408481013589830152918401359183831115613de95760008081fd5b613df78d8a85880101613cc3565b908201528652505050918301918301613d7b565b509695505050505050565b60006101208284031215613e2957600080fd5b613e31613c08565b9050613e3c82613b75565b8152613e4a60208301613b75565b60208201526040820135604082015260608201356060820152613e6f60808301613b75565b608082015260a082013560a082015260c08201356001600160401b03811115613e9757600080fd5b613ea384828501613d32565b60c083015250613eb560e08301613b75565b60e082015261010080830135818301525092915050565b600082601f830112613edd57600080fd5b81356020613eed613d5383613ca0565b82815260059290921b84018101918181019086841115613f0c57600080fd5b8286015b84811015613e0b5780356001600160401b03811115613f2f5760008081fd5b613f3d8986838b0101613e16565b845250918301918301613f10565b600060808284031215613f5d57600080fd5b604051608081018181106001600160401b0382111715613f7f57613f7f613bca565b604052905080823560028110613f9457600080fd5b8152602083013560ff81168114613faa57600080fd5b8060208301525060408301356040820152606083013560608201525092915050565b600082601f830112613fdd57600080fd5b81356020613fed613d5383613ca0565b82815260079290921b8401810191818101908684111561400c57600080fd5b8286015b84811015613e0b576140228882613f4b565b835291830191608001614010565b60008083601f84011261404257600080fd5b5081356001600160401b0381111561405957600080fd5b6020830191508360208260051b850101111561407457600080fd5b9250929050565b80358015158114613b8057600080fd5b60008060008060008060a087890312156140a457600080fd5b6001600160401b0380883511156140ba57600080fd5b6140c78989358a01613ecc565b9650602080890135828111156140dc57600080fd5b6140e88b828c01613fcc565b9750506040890135828111156140fd57600080fd5b6141098b828c01614030565b90975095505060608901358281111561412157600080fd5b8901601f81018b1361413257600080fd5b8035614140613d5382613ca0565b81815260059190911b8201830190838101908d83111561415f57600080fd5b8484015b8381101561419557868135111561417957600080fd5b6141888f878335880101613cc3565b8352918501918501614163565b508097505050505050506141ab6080880161407b565b90509295509295509295565b600081518084526020808501945080840160005b838110156141e95781511515875295820195908201906001016141cb565b509495945050505050565b6020815260006137b660208301846141b7565b600082601f83011261421857600080fd5b81356020614228613d5383613ca0565b82815260059290921b8401810191818101908684111561424757600080fd5b8286015b84811015613e0b5780356001600160401b038082111561426b5760008081fd5b908801906040828b03601f19018113156142855760008081fd5b61428d613c2b565b8784013561429a81613b5d565b81529083013590828211156142af5760008081fd5b6142bd8c8984870101613cc3565b81890152865250505091830191830161424b565b600061014082840312156142e457600080fd5b6142ec613c4d565b90506142f782613b75565b815261430560208301613b75565b6020820152604082013560408201526060820135606082015261432a60808301613b75565b608082015260a082013560a082015260c08201356001600160401b038082111561435357600080fd5b61435f85838601613d32565b60c084015261437060e08501613b75565b60e084015261010084810135908401526101209150818401358181111561439657600080fd5b6143a286828701614207565b8385015250505092915050565b6000602082840312156143c157600080fd5b81356001600160401b038111156143d757600080fd5b6143e3848285016142d1565b949350505050565b6000602082840312156143fd57600080fd5b81356001600160401b0381111561441357600080fd5b6143e384828501613e16565b634e487b7160e01b600052602160045260246000fd5b60208101600483106144495761444961441f565b91905290565b60008060008060006080868803121561446757600080fd5b853561447281613b5d565b9450602086013561448281613b5d565b93506040860135925060608601356001600160401b03808211156144a557600080fd5b818801915088601f8301126144b957600080fd5b8135818111156144c857600080fd5b8960208285010111156144da57600080fd5b9699959850939650602001949392505050565b600080600080610140858703121561450457600080fd5b84356001600160401b038082111561451b57600080fd5b61452788838901613e16565b9550602087013591508082111561453d57600080fd5b5061454a878288016142d1565b93505061455a8660408701613f4b565b91506145698660c08701613f4b565b905092959194509250565b6000806000806000610100868803121561458d57600080fd5b85356001600160401b03808211156145a457600080fd5b6145b089838a01613e16565b96506145bf8960208a01613f4b565b955060a088013591506145d182613b5d565b90935060c0870135925060e087013590808211156145ee57600080fd5b506145fb88828901613cc3565b9150509295509295909350565b60008060a0838503121561461b57600080fd5b82356001600160401b0381111561463157600080fd5b61463d85828601613e16565b92505061464d8460208501613f4b565b90509250929050565b60006020828403121561466857600080fd5b81356137b681613b5d565b6000806020838503121561468657600080fd5b82356001600160401b0381111561469c57600080fd5b6146a885828601614030565b90969095509350505050565b600080600080608085870312156146ca57600080fd5b84356001600160401b03808211156146e157600080fd5b6146ed88838901613ecc565b955060209150818701358181111561470457600080fd5b8701601f8101891361471557600080fd5b8035614723613d5382613ca0565b81815260059190911b8201840190848101908b83111561474257600080fd5b8584015b8381101561477a5780358681111561475e5760008081fd5b61476c8e89838901016142d1565b845250918601918601614746565b509750505050604087013591508082111561479457600080fd5b6147a088838901613fcc565b935060608701359150808211156147b657600080fd5b506147c387828801613fcc565b91505092959194509250565b604080825283519082018190526000906020906060840190828701845b82811015614808578151845292840192908401906001016147ec565b5050508381038285015261481c81866141b7565b9695505050505050565b6000806000806000610100868803121561483f57600080fd5b85356001600160401b038082111561485657600080fd5b61486289838a016142d1565b96506148718960208a01613f4b565b955060a0880135945061488660c0890161407b565b935060e08801359150808211156145ee57600080fd5b60008060008060e085870312156148b257600080fd5b84356001600160401b03808211156148c957600080fd5b6148d588838901613e16565b95506148e48860208901613f4b565b945060a087013591506148f682613b5d565b90925060c0860135908082111561490c57600080fd5b506147c387828801613cc3565b60006020828403121561492b57600080fd5b5035919050565b60008060a0838503121561494557600080fd5b82356001600160401b0381111561495b57600080fd5b61463d858286016142d1565b60008060006060848603121561497c57600080fd5b83356001600160401b038082111561499357600080fd5b61499f87838801613ecc565b945060208601359150808211156149b557600080fd5b506149c286828701613fcc565b9250506149d16040850161407b565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b600060018201614a0257614a026149da565b5060010190565b602080825260159082015274082a4a482b2be988a9c8ea890be9a92a69a82a8869605b1b604082015260600190565b600082821015614a4a57614a4a6149da565b500390565b634e487b7160e01b600052603260045260246000fd5b60005b83811015614a80578181015183820152602001614a68565b83811115611d455750506000910152565b60008151808452614aa9816020860160208601614a65565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b85811015614b2e578284038952815180516001600160a01b031685528581015186860152604090810151606091860182905290614b1a81870183614a91565b9a87019a9550505090840190600101614adb565b5091979650505050505050565b600061012060018060a01b0383511684526020830151614b6660208601826001600160a01b03169052565b5060408301516040850152606083015160608501526080830151614b9560808601826001600160a01b03169052565b5060a083015160a085015260c08301518160c0860152614bb782860182614abd565b91505060e0830151614bd460e08601826001600160a01b03169052565b50610100928301519390920192909252919050565b805160028110614bfb57614bfb61441f565b825260208181015160ff169083015260408082015190830152606090810151910152565b6000610100808352614c3381840189614b3b565b9050614c426020840188614be9565b6001600160a01b03861660a084015260c0830185905282810360e0840152614c6a8185614a91565b98975050505050505050565b60008251614c88818460208701614a65565b9190910192915050565b600080600060c08486031215614ca757600080fd5b83356001600160401b03811115614cbd57600080fd5b614cc9868287016142d1565b935050614cd98560208601613f4b565b91506149d160a0850161407b565b6001600160a01b039788168152958716602087015293861660408601526060850192909252909316608083015260a082019290925260c081019190915260e00190565b60008219821115614d3d57614d3d6149da565b500190565b600061012060018060a01b03808d168452808c1660208501528a604085015289606085015280891660808501528760a08501528160c0850152614d8782850188614abd565b951660e084015250506101000152979650505050505050565b600081518084526020808501808196508360051b8101915082860160005b85811015614b2e578284038952815180516001600160a01b031685528501516040868601819052614df181870183614a91565b9a87019a9550505090840190600101614dbe565b600061014060018060a01b03808e168452808d1660208501528b60408501528a6060850152808a1660808501528860a08501528160c0850152614e4a82850189614abd565b915080871660e08501525084610100840152828103610120840152614e6f8185614da0565b9d9c50505050505050505050505050565b6000610140808352614e9481840188614b3b565b838103602085015286516001600160a01b031681526020870151614ec360208301826001600160a01b03169052565b5060408701516040820152606087015160608201526080870151614ef260808301826001600160a01b03169052565b5060a087015160a082015260c08701518260c0830152614f1483830182614abd565b92505060e0870151614f3160e08301826001600160a01b03169052565b5061010087810151908201526101208088015182840382840152614f558482614da0565b945050505050614f686040830185614be9565b610a5e60c0830184614be9565b600060208284031215614f8757600080fd5b5051919050565b60a081526000614fa160a0830185614b3b565b90506137b66020830184614be9565b6000816000190483118215151615614fca57614fca6149da565b500290565b600082614fec57634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b0384168152826020820152606060408201526000610a5e6060830184614a91565b60006020828403121561502a57600080fd5b81516001600160e01b0319811681146137b657600080fd5b8281526040602082015260006143e36040830184614a9156fea2646970667358221220cc8e30033a1a29c470c793e747e1dbda5f9de82cd1a4355083536980526619c264736f6c634300080d0033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Decoded View---------------
Arg [0] : weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

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


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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