ETH Price: $2,979.39 (-1.11%)
Gas: 5 Gwei

Contract

0x4aF649FFde640CEb34b1AfaBa3e0Bb8e9698cb01
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x61010060142582052022-02-22 21:14:40866 days ago1645564480IN
 Create: ERC721OrdersFeature
0 ETH0.47795721100.607258

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.6.12+commit.27d51765

Optimization Enabled:
Yes with 1000000 runs

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

  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.6;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../../fixins/FixinERC721Spender.sol";
import "../../migrations/LibMigrate.sol";
import "../../storage/LibERC721OrdersStorage.sol";
import "../interfaces/IFeature.sol";
import "../interfaces/IERC721OrdersFeature.sol";
import "../libs/LibNFTOrder.sol";
import "../libs/LibSignature.sol";
import "./NFTOrders.sol";


/// @dev Feature for interacting with ERC721 orders.
contract ERC721OrdersFeature is
    IFeature,
    IERC721OrdersFeature,
    FixinERC721Spender,
    NFTOrders
{
    using LibSafeMathV06 for uint256;
    using LibNFTOrder for LibNFTOrder.ERC721Order;
    using LibNFTOrder for LibNFTOrder.NFTOrder;

    /// @dev Name of this feature.
    string public constant override FEATURE_NAME = "ERC721Orders";
    /// @dev Version of this feature.
    uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 0);

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


    constructor(address zeroExAddress, IEtherTokenV06 weth)
        public
        NFTOrders(zeroExAddress, weth)
    {}

    /// @dev Initialize and register this feature.
    ///      Should be delegatecalled by `Migrate.migrate()`.
    /// @return success `LibMigrate.SUCCESS` on success.
    function migrate()
        external
        returns (bytes4 success)
    {
        _registerFeatureFunction(this.sellERC721.selector);
        _registerFeatureFunction(this.buyERC721.selector);
        _registerFeatureFunction(this.cancelERC721Order.selector);
        _registerFeatureFunction(this.batchBuyERC721s.selector);
        _registerFeatureFunction(this.matchERC721Orders.selector);
        _registerFeatureFunction(this.batchMatchERC721Orders.selector);
        _registerFeatureFunction(this.onERC721Received.selector);
        _registerFeatureFunction(this.preSignERC721Order.selector);
        _registerFeatureFunction(this.validateERC721OrderSignature.selector);
        _registerFeatureFunction(this.validateERC721OrderProperties.selector);
        _registerFeatureFunction(this.getERC721OrderStatus.selector);
        _registerFeatureFunction(this.getERC721OrderHash.selector);
        _registerFeatureFunction(this.getERC721OrderStatusBitVector.selector);
        return LibMigrate.MIGRATE_SUCCESS;
    }

    /// @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.ERC721Order memory buyOrder,
        LibSignature.Signature memory signature,
        uint256 erc721TokenId,
        bool unwrapNativeToken,
        bytes memory callbackData
    )
        public
        override
    {
        _sellERC721(
            buyOrder,
            signature,
            erc721TokenId,
            unwrapNativeToken,
            msg.sender, // taker
            msg.sender, // owner
            callbackData
        );
    }

    /// @dev Buys an ERC721 asset by filling the given order.
    /// @param sellOrder The ERC721 sell order.
    /// @param signature The order signature.
    /// @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 buyERC721(
        LibNFTOrder.ERC721Order memory sellOrder,
        LibSignature.Signature memory signature,
        bytes memory callbackData
    )
        public
        override
        payable
    {
        uint256 ethBalanceBefore = address(this).balance
            .safeSub(msg.value);
        _buyERC721(
            sellOrder,
            signature,
            msg.value,
            callbackData
        );
        uint256 ethBalanceAfter = address(this).balance;
        // Cannot use pre-existing ETH balance
        if (ethBalanceAfter < ethBalanceBefore) {
            LibNFTOrdersRichErrors.OverspentEthError(
                msg.value + (ethBalanceBefore - ethBalanceAfter),
                msg.value
            ).rrevert();
        }
        // Refund
        _transferEth(msg.sender, ethBalanceAfter - 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.
    /// @param callbackData The data (if any) to pass to the taker
    ///        callback for each order. Refer to the `callbackData`
    ///        parameter to for `buyERC721`.
    /// @return successes An array of booleans corresponding to whether
    ///         each order in `orders` was successfully filled.
    function batchBuyERC721s(
        LibNFTOrder.ERC721Order[] memory sellOrders,
        LibSignature.Signature[] memory signatures,
        bytes[] memory callbackData,
        bool revertIfIncomplete
    )
        public
        override
        payable
        returns (bool[] memory successes)
    {
        require(
            sellOrders.length == signatures.length &&
            sellOrders.length == callbackData.length,
            "ERC721OrdersFeature::batchBuyERC721s/ARRAY_LENGTH_MISMATCH"
        );
        successes = new bool[](sellOrders.length);

        uint256 ethBalanceBefore = address(this).balance
            .safeSub(msg.value);
        if (revertIfIncomplete) {
            for (uint256 i = 0; i < sellOrders.length; i++) {
                // Will revert if _buyERC721 reverts.
                _buyERC721(
                    sellOrders[i],
                    signatures[i],
                    address(this).balance.safeSub(ethBalanceBefore),
                    callbackData[i]
                );
                successes[i] = true;
            }
        } else {
            for (uint256 i = 0; i < sellOrders.length; i++) {
                // Delegatecall `_buyERC721` to swallow reverts while
                // preserving execution context.
                // Note that `_buyERC721` is a public function but should _not_
                // be registered in the Exchange Proxy.
                (successes[i], ) = _implementation.delegatecall(
                    abi.encodeWithSelector(
                        this._buyERC721.selector,
                        sellOrders[i],
                        signatures[i],
                        address(this).balance.safeSub(ethBalanceBefore), // Remaining ETH available
                        callbackData[i]
                    )
                );
            }
        }

        // Cannot use pre-existing ETH balance
        uint256 ethBalanceAfter = address(this).balance;
        if (ethBalanceAfter < ethBalanceBefore) {
            LibNFTOrdersRichErrors.OverspentEthError(
                msg.value + (ethBalanceBefore - ethBalanceAfter),
                msg.value
            ).rrevert();
        }

        // Refund
        _transferEth(msg.sender, ethBalanceAfter - ethBalanceBefore);
    }

    /// @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.ERC721Order memory sellOrder,
        LibNFTOrder.ERC721Order memory buyOrder,
        LibSignature.Signature memory sellOrderSignature,
        LibSignature.Signature memory buyOrderSignature
    )
        public
        override
        returns (uint256 profit)
    {
        // The ERC721 tokens must match
        if (sellOrder.erc721Token != buyOrder.erc721Token) {
            LibNFTOrdersRichErrors.ERC721TokenMismatchError(
                address(sellOrder.erc721Token),
                address(buyOrder.erc721Token)
            ).rrevert();
        }

        LibNFTOrder.NFTOrder memory sellNFTOrder = sellOrder.asNFTOrder();
        LibNFTOrder.NFTOrder memory buyNFTOrder = buyOrder.asNFTOrder();

        {
            LibNFTOrder.OrderInfo memory sellOrderInfo = _getOrderInfo(sellNFTOrder);
            LibNFTOrder.OrderInfo memory buyOrderInfo = _getOrderInfo(buyNFTOrder);

            _validateSellOrder(
                sellNFTOrder,
                sellOrderSignature,
                sellOrderInfo,
                buyOrder.maker
            );
            _validateBuyOrder(
                buyNFTOrder,
                buyOrderSignature,
                buyOrderInfo,
                sellOrder.maker,
                sellOrder.erc721TokenId
            );

            // Mark both orders as filled.
            _updateOrderState(sellNFTOrder, sellOrderInfo.orderHash, 1);
            _updateOrderState(buyNFTOrder, buyOrderInfo.orderHash, 1);
        }

        // The buyer must be willing to pay at least the amount that the
        // seller is asking.
        if (buyOrder.erc20TokenAmount < sellOrder.erc20TokenAmount) {
            LibNFTOrdersRichErrors.NegativeSpreadError(
                sellOrder.erc20TokenAmount,
                buyOrder.erc20TokenAmount
            ).rrevert();
        }

        // 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.erc721Token,
            sellOrder.maker,
            buyOrder.maker,
            sellOrder.erc721TokenId
        );

        // 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(
                buyNFTOrder,
                buyOrder.maker, // payer
                1,              // fillAmount
                1,              // orderAmount
                false           // useNativeToken
            );

            // 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(
                sellNFTOrder,
                address(this), // payer
                1,             // fillAmount
                1,             // orderAmount
                true           // useNativeToken
            );

            // Step 6: The spread must be enough to cover the sell order fees.
            //         If not, either `_payFees` will have reverted, or we
            //         have spent ETH that was in the EP before this
            //         `matchERC721Orders` call, which we disallow.
            if (spread < sellOrderFees) {
                LibNFTOrdersRichErrors.SellOrderFeesExceedSpreadError(
                    sellOrderFees,
                    spread
                ).rrevert();
            }
            // Step 7: 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(msg.sender, profit);
            }
        } else {
            // ERC20 tokens must match
            if (sellOrder.erc20Token != buyOrder.erc20Token) {
                LibNFTOrdersRichErrors.ERC20TokenMismatchError(
                    address(sellOrder.erc20Token),
                    address(buyOrder.erc20Token)
                ).rrevert();
            }

            // 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(
                buyNFTOrder,
                buyOrder.maker, // payer
                1,              // fillAmount
                1,              // orderAmount
                false           // useNativeToken
            );

            // 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(
                sellNFTOrder,
                buyOrder.maker, // payer
                1,              // fillAmount
                1,              // orderAmount
                false           // useNativeToken
            );

            // Step 4: The spread must be enough to cover the sell order fees.
            //         If not, `_payFees` will have taken more tokens from the
            //         buyer than they had agreed to in the buy order, in which
            //         case we revert here.
            if (spread < sellOrderFees) {
                LibNFTOrdersRichErrors.SellOrderFeesExceedSpreadError(
                    sellOrderFees,
                    spread
                ).rrevert();
            }

            // Step 5: 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 ERC721OrderFilled(
            sellOrder.direction,
            sellOrder.maker,
            buyOrder.maker, // taker
            sellOrder.nonce,
            sellOrder.erc20Token,
            sellOrder.erc20TokenAmount,
            sellOrder.erc721Token,
            sellOrder.erc721TokenId,
            msg.sender
        );

        emit ERC721OrderFilled(
            buyOrder.direction,
            buyOrder.maker,
            sellOrder.maker, // taker
            buyOrder.nonce,
            buyOrder.erc20Token,
            buyOrder.erc20TokenAmount,
            buyOrder.erc721Token,
            sellOrder.erc721TokenId,
            msg.sender
        );
    }

    /// @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.ERC721Order[] memory sellOrders,
        LibNFTOrder.ERC721Order[] memory buyOrders,
        LibSignature.Signature[] memory sellOrderSignatures,
        LibSignature.Signature[] memory buyOrderSignatures
    )
        public
        override
        returns (uint256[] memory profits, bool[] memory successes)
    {
        require(
            sellOrders.length == buyOrders.length &&
            sellOrderSignatures.length == buyOrderSignatures.length &&
            sellOrders.length == sellOrderSignatures.length,
            "ERC721OrdersFeature::batchMatchERC721Orders/ARRAY_LENGTH_MISMATCH"
        );
        profits = new uint256[](sellOrders.length);
        successes = new bool[](sellOrders.length);

        for (uint256 i = 0; i < sellOrders.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.ERC721Order memory buyOrder,
            LibSignature.Signature memory signature,
            bool unwrapNativeToken
        ) = abi.decode(
            data,
            (LibNFTOrder.ERC721Order, LibSignature.Signature, bool)
        );

        // `onERC721Received` is called by the ERC721 token contract.
        // Check that it matches the ERC721 token in the order.
        if (msg.sender != address(buyOrder.erc721Token)) {
            LibNFTOrdersRichErrors.ERC721TokenMismatchError(
                msg.sender,
                address(buyOrder.erc721Token)
            ).rrevert();
        }

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

        return ERC721_RECEIVED_MAGIC_BYTES;
    }

    /// @dev Approves an ERC721 order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 order.
    function preSignERC721Order(LibNFTOrder.ERC721Order memory order)
        public
        override
    {
        require(
            order.maker == msg.sender,
            "ERC721OrdersFeature::preSignERC721Order/ONLY_MAKER"
        );
        bytes32 orderHash = getERC721OrderHash(order);
        LibERC721OrdersStorage.getStorage().preSigned[orderHash] = true;

        emit ERC721OrderPreSigned(
            order.direction,
            order.maker,
            order.taker,
            order.expiry,
            order.nonce,
            order.erc20Token,
            order.erc20TokenAmount,
            order.fees,
            order.erc721Token,
            order.erc721TokenId,
            order.erc721TokenProperties
        );
    }

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

        emit ERC721OrderFilled(
            buyOrder.direction,
            buyOrder.maker,
            taker,
            buyOrder.nonce,
            buyOrder.erc20Token,
            buyOrder.erc20TokenAmount,
            buyOrder.erc721Token,
            erc721TokenId,
            address(0)
        );
    }

    // Core settlement logic for buying an ERC721 asset.
    // Used by `buyERC721` and `batchBuyERC721s`.
    function _buyERC721(
        LibNFTOrder.ERC721Order memory sellOrder,
        LibSignature.Signature memory signature,
        uint256 ethAvailable,
        bytes memory takerCallbackData
    )
        public
        payable
    {
        _buyNFT(
            sellOrder.asNFTOrder(),
            signature,
            BuyParams(
                1, // buy amount
                ethAvailable,
                takerCallbackData
            )
        );

        emit ERC721OrderFilled(
            sellOrder.direction,
            sellOrder.maker,
            msg.sender,
            sellOrder.nonce,
            sellOrder.erc20Token,
            sellOrder.erc20TokenAmount,
            sellOrder.erc721Token,
            sellOrder.erc721TokenId,
            address(0)
        );
    }


    /// @dev Checks whether the given signature is valid for the
    ///      the given ERC721 order. Reverts if not.
    /// @param order The ERC721 order.
    /// @param signature The signature to validate.
    function validateERC721OrderSignature(
        LibNFTOrder.ERC721Order memory order,
        LibSignature.Signature memory signature
    )
        public
        override
        view
    {
        bytes32 orderHash = getERC721OrderHash(order);
        _validateOrderSignature(orderHash, 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) {
            // Check if order hash has been pre-signed by the maker.
            bool isPreSigned = LibERC721OrdersStorage.getStorage().preSigned[orderHash];
            if (!isPreSigned) {
                LibNFTOrdersRichErrors.InvalidSignerError(maker, address(0)).rrevert();
            }
        } else {
            address signer = LibSignature.getSignerOfHash(orderHash, signature);
            if (signer != maker) {
                LibNFTOrdersRichErrors.InvalidSignerError(maker, signer).rrevert();
            }
        }
    }

    /// @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
        override
    {
        assert(amount == 1);
        _transferERC721AssetFrom(IERC721Token(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.
    /// @param fillAmount The amount (denominated in the NFT asset)
    ///        that the order has been filled by.
    function _updateOrderState(
        LibNFTOrder.NFTOrder memory order,
        bytes32 /* orderHash */,
        uint128 fillAmount
    )
        internal
        override
    {
        assert(fillAmount == 1);
        _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 If the given order is buying an ERC721 asset, checks
    ///      whether or not the given token ID satisfies the required
    ///      properties specified in the order. If the order does not
    ///      specify any properties, this function instead checks
    ///      whether the given token ID matches the ID in the order.
    ///      Reverts if any checks fail, or if the order is selling
    ///      an ERC721 asset.
    /// @param order The ERC721 order.
    /// @param erc721TokenId The ID of the ERC721 asset.
    function validateERC721OrderProperties(
        LibNFTOrder.ERC721Order memory order,
        uint256 erc721TokenId
    )
        public
        override
        view
    {
        _validateOrderProperties(
            order.asNFTOrder(),
            erc721TokenId
        );
    }

    /// @dev Get the current status of an ERC721 order.
    /// @param order The ERC721 order.
    /// @return status The status of the order.
    function getERC721OrderStatus(LibNFTOrder.ERC721Order memory order)
        public
        override
        view
        returns (LibNFTOrder.OrderStatus status)
    {
        // Only buy orders with `erc721TokenId` == 0 can be property
        // orders.
        if (order.erc721TokenProperties.length > 0 &&
                (order.direction != LibNFTOrder.TradeDirection.BUY_NFT ||
                 order.erc721TokenId != 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 (order.direction == LibNFTOrder.TradeDirection.BUY_NFT &&
            address(order.erc20Token) == NATIVE_TOKEN_ADDRESS)
        {
            return LibNFTOrder.OrderStatus.INVALID;
        }

        // Check for expiry.
        if (order.expiry <= 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 order info for an NFT order.
    /// @param order The NFT order.
    /// @return orderInfo Info about the order.
    function _getOrderInfo(LibNFTOrder.NFTOrder memory order)
        internal
        override
        view
        returns (LibNFTOrder.OrderInfo memory orderInfo)
    {
        LibNFTOrder.ERC721Order memory erc721Order = order.asERC721Order();
        orderInfo.orderHash = getERC721OrderHash(erc721Order);
        orderInfo.status = getERC721OrderStatus(erc721Order);
        orderInfo.orderAmount = 1;
        orderInfo.remainingAmount = orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE ? 1 : 0;
    }

    /// @dev Get the EIP-712 hash of an ERC721 order.
    /// @param order The ERC721 order.
    /// @return orderHash The order hash.
    function getERC721OrderHash(LibNFTOrder.ERC721Order memory order)
        public
        override
        view
        returns (bytes32 orderHash)
    {
        return _getEIP712Hash(LibNFTOrder.getERC721OrderStructHash(order));
    }

    /// @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 bitVector)
    {
        LibERC721OrdersStorage.Storage storage stor =
            LibERC721OrdersStorage.getStorage();
        return stor.orderStatusByMaker[maker][nonceRange];
    }
}

File 2 of 32 : IEtherTokenV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;

import "./IERC20TokenV06.sol";


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

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

File 3 of 32 : IERC20TokenV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


interface IERC20TokenV06 {

    // solhint-disable no-simple-event-func-name
    event Transfer(
        address indexed from,
        address indexed to,
        uint256 value
    );

    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    /// @dev send `value` token to `to` from `msg.sender`
    /// @param to The address of the recipient
    /// @param value The amount of token to be transferred
    /// @return True if transfer was successful
    function transfer(address to, uint256 value)
        external
        returns (bool);

    /// @dev send `value` token to `to` from `from` on the condition it is approved by `from`
    /// @param from The address of the sender
    /// @param to The address of the recipient
    /// @param value The amount of token to be transferred
    /// @return True if transfer was successful
    function transferFrom(
        address from,
        address to,
        uint256 value
    )
        external
        returns (bool);

    /// @dev `msg.sender` approves `spender` to spend `value` tokens
    /// @param spender The address of the account able to transfer the tokens
    /// @param value The amount of wei to be approved for transfer
    /// @return Always true if the call has enough gas to complete execution
    function approve(address spender, uint256 value)
        external
        returns (bool);

    /// @dev Query total supply of token
    /// @return Total supply of token
    function totalSupply()
        external
        view
        returns (uint256);

    /// @dev Get the balance of `owner`.
    /// @param owner The address from which the balance will be retrieved
    /// @return Balance of owner
    function balanceOf(address owner)
        external
        view
        returns (uint256);

    /// @dev Get the allowance for `spender` to spend from `owner`.
    /// @param owner The address of the account owning tokens
    /// @param spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    /// @dev Get the number of decimals this token has.
    function decimals()
        external
        view
        returns (uint8);
}

File 4 of 32 : LibSafeMathV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;

import "./errors/LibRichErrorsV06.sol";
import "./errors/LibSafeMathRichErrorsV06.sol";


library LibSafeMathV06 {

    function safeMul(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        if (c / a != b) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function safeDiv(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        if (b == 0) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.DIVISION_BY_ZERO,
                a,
                b
            ));
        }
        uint256 c = a / b;
        return c;
    }

    function safeSub(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        if (b > a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
                a,
                b
            ));
        }
        return a - b;
    }

    function safeAdd(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        uint256 c = a + b;
        if (c < a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.ADDITION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function max256(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        return a >= b ? a : b;
    }

    function min256(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        return a < b ? a : b;
    }

    function safeMul128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (a == 0) {
            return 0;
        }
        uint128 c = a * b;
        if (c / a != b) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function safeDiv128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (b == 0) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.DIVISION_BY_ZERO,
                a,
                b
            ));
        }
        uint128 c = a / b;
        return c;
    }

    function safeSub128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (b > a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
                a,
                b
            ));
        }
        return a - b;
    }

    function safeAdd128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        uint128 c = a + b;
        if (c < a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.ADDITION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function max128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        return a >= b ? a : b;
    }

    function min128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        return a < b ? a : b;
    }

    function safeDowncastToUint128(uint256 a)
        internal
        pure
        returns (uint128)
    {
        if (a > type(uint128).max) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256DowncastError(
                LibSafeMathRichErrorsV06.DowncastErrorCodes.VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT128,
                a
            ));
        }
        return uint128(a);
    }
}

File 5 of 32 : LibRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibRichErrorsV06 {

    // bytes4(keccak256("Error(string)"))
    bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0;

    // solhint-disable func-name-mixedcase
    /// @dev ABI encode a standard, string revert error payload.
    ///      This is the same payload that would be included by a `revert(string)`
    ///      solidity statement. It has the function signature `Error(string)`.
    /// @param message The error string.
    /// @return The ABI encoded error.
    function StandardError(string memory message)
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            STANDARD_ERROR_SELECTOR,
            bytes(message)
        );
    }
    // solhint-enable func-name-mixedcase

    /// @dev Reverts an encoded rich revert reason `errorData`.
    /// @param errorData ABI encoded error data.
    function rrevert(bytes memory errorData)
        internal
        pure
    {
        assembly {
            revert(add(errorData, 0x20), mload(errorData))
        }
    }
}

File 6 of 32 : LibSafeMathRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibSafeMathRichErrorsV06 {

    // bytes4(keccak256("Uint256BinOpError(uint8,uint256,uint256)"))
    bytes4 internal constant UINT256_BINOP_ERROR_SELECTOR =
        0xe946c1bb;

    // bytes4(keccak256("Uint256DowncastError(uint8,uint256)"))
    bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR =
        0xc996af7b;

    enum BinOpErrorCodes {
        ADDITION_OVERFLOW,
        MULTIPLICATION_OVERFLOW,
        SUBTRACTION_UNDERFLOW,
        DIVISION_BY_ZERO
    }

    enum DowncastErrorCodes {
        VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT32,
        VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT64,
        VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT96,
        VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT128
    }

    // solhint-disable func-name-mixedcase
    function Uint256BinOpError(
        BinOpErrorCodes errorCode,
        uint256 a,
        uint256 b
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            UINT256_BINOP_ERROR_SELECTOR,
            errorCode,
            a,
            b
        );
    }

    function Uint256DowncastError(
        DowncastErrorCodes errorCode,
        uint256 a
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            UINT256_DOWNCAST_ERROR_SELECTOR,
            errorCode,
            a
        );
    }
}

File 7 of 32 : FixinERC721Spender.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../vendor/IERC721Token.sol";


/// @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(
        IERC721Token token,
        address owner,
        address to,
        uint256 tokenId
    )
        internal
    {
        require(address(token) != address(this), "FixinERC721Spender/CANNOT_INVOKE_SELF");

        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)

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

            if iszero(success) {
                let rdsize := returndatasize()
                returndatacopy(ptr, 0, rdsize)
                revert(ptr, rdsize)
            }
        }
    }
}

File 8 of 32 : IERC721Token.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;


interface IERC721Token {

    /// @dev This emits when ownership of any NFT changes by any mechanism.
    ///      This event emits when NFTs are created (`from` == 0) and destroyed
    ///      (`to` == 0). Exception: during contract creation, any number of NFTs
    ///      may be created and assigned without emitting Transfer. At the time of
    ///      any transfer, the approved address for that NFT (if any) is reset to none.
    event Transfer(
        address indexed _from,
        address indexed _to,
        uint256 indexed _tokenId
    );

    /// @dev This emits when the approved address for an NFT is changed or
    ///      reaffirmed. The zero address indicates there is no approved address.
    ///      When a Transfer event emits, this also indicates that the approved
    ///      address for that NFT (if any) is reset to none.
    event Approval(
        address indexed _owner,
        address indexed _approved,
        uint256 indexed _tokenId
    );

    /// @dev This emits when an operator is enabled or disabled for an owner.
    ///      The operator can manage all NFTs of the owner.
    event ApprovalForAll(
        address indexed _owner,
        address indexed _operator,
        bool _approved
    );

    /// @notice Transfers the ownership of an NFT from one address to another address
    /// @dev Throws unless `msg.sender` is the current owner, an authorized
    ///      perator, or the approved address for this NFT. Throws if `_from` is
    ///      not the current owner. Throws if `_to` is the zero address. Throws if
    ///      `_tokenId` is not a valid NFT. When transfer is complete, this function
    ///      checks if `_to` is a smart contract (code size > 0). If so, it calls
    ///      `onERC721Received` on `_to` and throws if the return value is not
    ///      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    /// @param _data Additional data with no specified format, sent in call to `_to`
    function safeTransferFrom(
        address _from,
        address _to,
        uint256 _tokenId,
        bytes calldata _data
    )
        external;

    /// @notice Transfers the ownership of an NFT from one address to another address
    /// @dev This works identically to the other function with an extra data parameter,
    ///      except this function just sets data to "".
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    function safeTransferFrom(
        address _from,
        address _to,
        uint256 _tokenId
    )
        external;

    /// @notice Change or reaffirm the approved address for an NFT
    /// @dev The zero address indicates there is no approved address.
    ///      Throws unless `msg.sender` is the current NFT owner, or an authorized
    ///      operator of the current owner.
    /// @param _approved The new approved NFT controller
    /// @param _tokenId The NFT to approve
    function approve(address _approved, uint256 _tokenId)
        external;

    /// @notice Enable or disable approval for a third party ("operator") to manage
    ///         all of `msg.sender`'s assets
    /// @dev Emits the ApprovalForAll event. The contract MUST allow
    ///      multiple operators per owner.
    /// @param _operator Address to add to the set of authorized operators
    /// @param _approved True if the operator is approved, false to revoke approval
    function setApprovalForAll(address _operator, bool _approved)
        external;

    /// @notice Count all NFTs assigned to an owner
    /// @dev NFTs assigned to the zero address are considered invalid, and this
    ///      function throws for queries about the zero address.
    /// @param _owner An address for whom to query the balance
    /// @return The number of NFTs owned by `_owner`, possibly zero
    function balanceOf(address _owner)
        external
        view
        returns (uint256);

    /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
    ///         TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
    ///         THEY MAY BE PERMANENTLY LOST
    /// @dev Throws unless `msg.sender` is the current owner, an authorized
    ///      operator, or the approved address for this NFT. Throws if `_from` is
    ///      not the current owner. Throws if `_to` is the zero address. Throws if
    ///      `_tokenId` is not a valid NFT.
    /// @param _from The current owner of the NFT
    /// @param _to The new owner
    /// @param _tokenId The NFT to transfer
    function transferFrom(
        address _from,
        address _to,
        uint256 _tokenId
    )
        external;

    /// @notice Find the owner of an NFT
    /// @dev NFTs assigned to zero address are considered invalid, and queries
    ///      about them do throw.
    /// @param _tokenId The identifier for an NFT
    /// @return The address of the owner of the NFT
    function ownerOf(uint256 _tokenId)
        external
        view
        returns (address);

    /// @notice Get the approved address for a single NFT
    /// @dev Throws if `_tokenId` is not a valid NFT.
    /// @param _tokenId The NFT to find the approved address for
    /// @return The approved address for this NFT, or the zero address if there is none
    function getApproved(uint256 _tokenId)
        external
        view
        returns (address);

    /// @notice Query if an address is an authorized operator for another address
    /// @param _owner The address that owns the NFTs
    /// @param _operator The address that acts on behalf of the owner
    /// @return True if `_operator` is an approved operator for `_owner`, false otherwise
    function isApprovedForAll(address _owner, address _operator)
        external
        view
        returns (bool);
}

File 9 of 32 : LibMigrate.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "../errors/LibOwnableRichErrors.sol";


library LibMigrate {

    /// @dev Magic bytes returned by a migrator to indicate success.
    ///      This is `keccack('MIGRATE_SUCCESS')`.
    bytes4 internal constant MIGRATE_SUCCESS = 0x2c64c5ef;

    using LibRichErrorsV06 for bytes;

    /// @dev Perform a delegatecall and ensure it returns the magic bytes.
    /// @param target The call target.
    /// @param data The call data.
    function delegatecallMigrateFunction(
        address target,
        bytes memory data
    )
        internal
    {
        (bool success, bytes memory resultData) = target.delegatecall(data);
        if (!success ||
            resultData.length != 32 ||
            abi.decode(resultData, (bytes4)) != MIGRATE_SUCCESS)
        {
            LibOwnableRichErrors.MigrateCallFailedError(target, resultData).rrevert();
        }
    }
}

File 10 of 32 : LibOwnableRichErrors.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibOwnableRichErrors {

    // solhint-disable func-name-mixedcase

    function OnlyOwnerError(
        address sender,
        address owner
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OnlyOwnerError(address,address)")),
            sender,
            owner
        );
    }

    function TransferOwnerToZeroError()
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("TransferOwnerToZeroError()"))
        );
    }

    function MigrateCallFailedError(address target, bytes memory resultData)
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MigrateCallFailedError(address,bytes)")),
            target,
            resultData
        );
    }
}

File 11 of 32 : LibERC721OrdersStorage.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;

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 => isSigned
        mapping(bytes32 => bool) preSigned;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        uint256 storageSlot = LibStorage.getStorageSlot(
            LibStorage.StorageId.ERC721Orders
        );
        // 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 12 of 32 : LibStorage.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;


/// @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 private constant STORAGE_SLOT_EXP = 128;

    /// @dev Storage IDs for feature storage buckets.
    ///      WARNING: APPEND-ONLY.
    enum StorageId {
        Proxy,
        SimpleFunctionRegistry,
        Ownable,
        TokenSpender,
        TransformERC20,
        MetaTransactions,
        ReentrancyGuard,
        NativeOrders,
        OtcOrders,
        ERC721Orders,
        ERC1155Orders
    }

    /// @dev Get the storage slot given a storage ID. We assign unique, well-spaced
    ///     slots to storage bucket variables to ensure they do not overlap.
    ///     See: https://solidity.readthedocs.io/en/v0.6.6/assembly.html#access-to-external-variables-functions-and-libraries
    /// @param storageId An entry in `StorageId`
    /// @return slot The storage slot.
    function getStorageSlot(StorageId storageId)
        internal
        pure
        returns (uint256 slot)
    {
        // This should never overflow with a reasonable `STORAGE_SLOT_EXP`
        // because Solidity will do a range check on `storageId` during the cast.
        return (uint256(storageId) + 1) << STORAGE_SLOT_EXP;
    }
}

File 13 of 32 : IFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;


/// @dev Basic interface for a feature contract.
interface IFeature {

    // solhint-disable func-name-mixedcase

    /// @dev The name of this feature set.
    function FEATURE_NAME() external view returns (string memory name);

    /// @dev The version of this feature set.
    function FEATURE_VERSION() external view returns (uint256 version);
}

File 14 of 32 : IERC721OrdersFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../libs/LibNFTOrder.sol";
import "../libs/LibSignature.sol";
import "../../vendor/IERC721Token.sol";


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

    /// @dev Emitted whenever an `ERC721Order` is filled.
    /// @param direction Whether the order is selling or
    ///        buying the ERC721 token.
    /// @param maker The maker of the order.
    /// @param taker The taker of the order.
    /// @param nonce The unique maker nonce in the order.
    /// @param erc20Token The address of the ERC20 token.
    /// @param erc20TokenAmount The amount of ERC20 token
    ///        to sell or buy.
    /// @param erc721Token The address of the ERC721 token.
    /// @param erc721TokenId The ID of the ERC721 asset.
    /// @param matcher If this order was matched with another using `matchERC721Orders()`,
    ///                this will be the address of the caller. If not, this will be `address(0)`.
    event ERC721OrderFilled(
        LibNFTOrder.TradeDirection direction,
        address maker,
        address taker,
        uint256 nonce,
        IERC20TokenV06 erc20Token,
        uint256 erc20TokenAmount,
        IERC721Token erc721Token,
        uint256 erc721TokenId,
        address matcher
    );

    /// @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 when an `ERC721Order` is pre-signed.
    ///      Contains all the fields of the order.
    event ERC721OrderPreSigned(
        LibNFTOrder.TradeDirection direction,
        address maker,
        address taker,
        uint256 expiry,
        uint256 nonce,
        IERC20TokenV06 erc20Token,
        uint256 erc20TokenAmount,
        LibNFTOrder.Fee[] fees,
        IERC721Token erc721Token,
        uint256 erc721TokenId,
        LibNFTOrder.Property[] erc721TokenProperties
    );

    /// @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.ERC721Order 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.
    /// @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 buyERC721(
        LibNFTOrder.ERC721Order calldata sellOrder,
        LibSignature.Signature calldata signature,
        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 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 batchBuyERC721s(
        LibNFTOrder.ERC721Order[] calldata sellOrders,
        LibSignature.Signature[] calldata signatures,
        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.ERC721Order calldata sellOrder,
        LibNFTOrder.ERC721Order 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.ERC721Order[] calldata sellOrders,
        LibNFTOrder.ERC721Order[] 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 order on-chain. After pre-signing
    ///      the order, the `PRESIGNED` signature type will become
    ///      valid for that order and signer.
    /// @param order An ERC721 order.
    function preSignERC721Order(LibNFTOrder.ERC721Order calldata order)
        external;

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

    /// @dev If the given order is buying an ERC721 asset, checks
    ///      whether or not the given token ID satisfies the required
    ///      properties specified in the order. If the order does not
    ///      specify any properties, this function instead checks
    ///      whether the given token ID matches the ID in the order.
    ///      Reverts if any checks fail, or if the order is selling
    ///      an ERC721 asset.
    /// @param order The ERC721 order.
    /// @param erc721TokenId The ID of the ERC721 asset.
    function validateERC721OrderProperties(
        LibNFTOrder.ERC721Order calldata order,
        uint256 erc721TokenId
    )
        external
        view;

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

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

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

File 15 of 32 : LibNFTOrder.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../../vendor/IERC1155Token.sol";
import "../../vendor/IERC721Token.sol";
import "../../vendor/IPropertyValidator.sol";


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

    enum OrderStatus {
        INVALID,
        FILLABLE,
        UNFILLABLE,
        EXPIRED
    }

    enum TradeDirection {
        SELL_NFT,
        BUY_NFT
    }

    struct Property {
        IPropertyValidator propertyValidator;
        bytes propertyData;
    }

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

    // "Base struct" for ERC721Order and ERC1155, used
    // by the abstract contract `NFTOrders`.
    struct NFTOrder {
        TradeDirection direction;
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20TokenV06 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        address nft;
        uint256 nftId;
        Property[] nftProperties;
    }

    // All fields align with those of NFTOrder
    struct ERC721Order {
        TradeDirection direction;
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20TokenV06 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        IERC721Token erc721Token;
        uint256 erc721TokenId;
        Property[] erc721TokenProperties;
    }

    // All fields except `erc1155TokenAmount` align
    // with those of NFTOrder
    struct ERC1155Order {
        TradeDirection direction;
        address maker;
        address taker;
        uint256 expiry;
        uint256 nonce;
        IERC20TokenV06 erc20Token;
        uint256 erc20TokenAmount;
        Fee[] fees;
        IERC1155Token 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 ERC721 orders, which is:
    // keccak256(abi.encodePacked(
    //     "ERC721Order(",
    //       "uint8 direction,",
    //       "address maker,",
    //       "address taker,",
    //       "uint256 expiry,",
    //       "uint256 nonce,",
    //       "address erc20Token,",
    //       "uint256 erc20TokenAmount,",
    //       "Fee[] fees,",
    //       "address erc721Token,",
    //       "uint256 erc721TokenId,",
    //       "Property[] erc721TokenProperties",
    //     ")",
    //     "Fee(",
    //       "address recipient,",
    //       "uint256 amount,",
    //       "bytes feeData",
    //     ")",
    //     "Property(",
    //       "address propertyValidator,",
    //       "bytes propertyData",
    //     ")"
    // ))
    uint256 private constant _ERC_721_ORDER_TYPEHASH =
        0x2de32b2b090da7d8ab83ca4c85ba2eb6957bc7f6c50cb4ae1995e87560d808ed;

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

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

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

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

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

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

    // ERC721Order and NFTOrder fields are aligned, so
    // we can safely cast an ERC721Order to an NFTOrder.
    function asNFTOrder(ERC721Order memory erc721Order)
        internal
        pure
        returns (NFTOrder memory nftOrder)
    {
        assembly {
            nftOrder := erc721Order
        }
    }

    // ERC1155Order and NFTOrder fields are aligned with
    // the exception of the last field `erc1155TokenAmount`
    // in ERC1155Order, so we can safely cast an ERC1155Order
    // to an NFTOrder.
    function asNFTOrder(ERC1155Order memory erc1155Order)
        internal
        pure
        returns (NFTOrder memory nftOrder)
    {
        assembly {
            nftOrder := erc1155Order
        }
    }

    // ERC721Order and NFTOrder fields are aligned, so
    // we can safely cast an MFTOrder to an ERC721Order.
    function asERC721Order(NFTOrder memory nftOrder)
        internal
        pure
        returns (ERC721Order memory erc721Order)
    {
        assembly {
            erc721Order := nftOrder
        }
    }

    // NOTE: This is only safe if `nftOrder` was previously
    // cast from an `ERC1155Order` and the original
    // `erc1155TokenAmount` memory word has not been corrupted!
    function asERC1155Order(
        NFTOrder memory nftOrder
    )
        internal
        pure
        returns (ERC1155Order memory erc1155Order)
    {
        assembly {
            erc1155Order := nftOrder
        }
    }

    /// @dev Get the struct hash of an ERC721 order.
    /// @param order The ERC721 order.
    /// @return structHash The struct hash of the order.
    function getERC721OrderStructHash(ERC721Order memory order)
        internal
        pure
        returns (bytes32 structHash)
    {
        bytes32 propertiesHash = _propertiesHash(order.erc721TokenProperties);
        bytes32 feesHash = _feesHash(order.fees);

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

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 224) // order + (32 * 7)
            let propertiesHashPos := add(order, 320) // order + (32 * 10)

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

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

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

    /// @dev Get the struct hash of an ERC1155 order.
    /// @param order The ERC1155 order.
    /// @return structHash The struct hash of the order.
    function getERC1155OrderStructHash(ERC1155Order memory order)
        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_ORDER_TYPEHASH,
        //     order.direction,
        //     order.maker,
        //     order.taker,
        //     order.expiry,
        //     order.nonce,
        //     order.erc20Token,
        //     order.erc20TokenAmount,
        //     feesHash,
        //     order.erc1155Token,
        //     order.erc1155TokenId,
        //     propertiesHash,
        //     order.erc1155TokenAmount
        // ));
        assembly {
            if lt(order, 32) { invalid() } // Don't underflow memory.

            let typeHashPos := sub(order, 32) // order - 32
            let feesHashPos := add(order, 224) // order + (32 * 7)
            let propertiesHashPos := add(order, 320) // order + (32 * 10)

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

            mstore(typeHashPos, _ERC_1155_ORDER_TYPEHASH)
            mstore(feesHashPos, feesHash)
            mstore(propertiesHashPos, propertiesHash)
            structHash := keccak256(typeHashPos, 416 /* 32 * 12 */ )

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

    // Hashes the `properties` arrayB 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_TYPEHASH,
                //     properties[0].propertyValidator,
                //     keccak256(properties[0].propertyData)
                // ))));
                bytes32 dataHash = keccak256(property.propertyData);
                assembly {
                    // Load free memory pointer
                    let mem := mload(64)
                    mstore(mem, _PROPERTY_TYPEHASH)
                    // 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_TYPEHASH,
                    properties[i].propertyValidator,
                    keccak256(properties[i].propertyData)
                ));
            }
            assembly {
                propertiesHash := keccak256(add(propertyStructHashArray, 32), mul(numProperties, 32))
            }
        }
    }

    // Hashes the `fees` arrayB 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_TYPEHASH,
            //     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_TYPEHASH)
                // 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_TYPEHASH,
                    fees[i].recipient,
                    fees[i].amount,
                    keccak256(fees[i].feeData)
                ));
            }
            assembly {
                feesHash := keccak256(add(feeStructHashArray, 32), mul(numFees, 32))
            }
        }
    }
}

File 16 of 32 : IERC1155Token.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2022 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.6;
pragma experimental ABIEncoderV2;


interface IERC1155Token {

    /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred,
    ///      including zero value transfers as well as minting or burning.
    /// Operator will always be msg.sender.
    /// Either event from address `0x0` signifies a minting operation.
    /// An event to address `0x0` signifies a burning or melting operation.
    /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may
    /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID.
    /// To define a token ID with no initial balance, the contract SHOULD emit the TransferSingle event
    /// from `0x0` to `0x0`, with the token creator as `_operator`.
    event TransferSingle(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256 id,
        uint256 value
    );

    /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred,
    ///      including zero value transfers as well as minting or burning.
    ///Operator will always be msg.sender.
    /// Either event from address `0x0` signifies a minting operation.
    /// An event to address `0x0` signifies a burning or melting operation.
    /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may
    /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID.
    /// To define multiple token IDs with no initial balance, this SHOULD emit the TransferBatch event
    /// from `0x0` to `0x0`, with the token creator as `_operator`.
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /// @dev MUST emit when an approval is updated.
    event ApprovalForAll(
        address indexed owner,
        address indexed operator,
        bool approved
    );

    /// @dev MUST emit when the URI is updated for a token ID.
    /// URIs are defined in RFC 3986.
    /// The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata JSON Schema".
    event URI(
        string value,
        uint256 indexed id
    );

    /// @notice Transfers value amount of an _id from the _from address to the _to address specified.
    /// @dev MUST emit TransferSingle event on success.
    /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll).
    /// MUST throw if `_to` is the zero address.
    /// MUST throw if balance of sender for token `_id` is lower than the `_value` sent.
    /// MUST throw on any other error.
    /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0).
    /// If so, it MUST call `onERC1155Received` on `_to` and revert if the return value
    /// is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`.
    /// @param from    Source address
    /// @param to      Target address
    /// @param id      ID of the token type
    /// @param value   Transfer amount
    /// @param data    Additional data with no specified format, sent in call to `_to`
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 value,
        bytes calldata data
    )
        external;

    /// @notice Send multiple types of Tokens from a 3rd party in one transfer (with safety call).
    /// @dev MUST emit TransferBatch event on success.
    /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll).
    /// MUST throw if `_to` is the zero address.
    /// MUST throw if length of `_ids` is not the same as length of `_values`.
    ///  MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent.
    /// MUST throw on any other error.
    /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0).
    /// If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value
    /// is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`.
    /// @param from    Source addresses
    /// @param to      Target addresses
    /// @param ids     IDs of each token type
    /// @param values  Transfer amounts per token type
    /// @param data    Additional data with no specified format, sent in call to `_to`
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    )
        external;

    /// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
    /// @dev MUST emit the ApprovalForAll event on success.
    /// @param operator  Address to add to the set of authorized operators
    /// @param approved  True if the operator is approved, false to revoke approval
    function setApprovalForAll(address operator, bool approved) external;

    /// @notice Queries the approval status of an operator for a given owner.
    /// @param owner        The owner of the Tokens
    /// @param operator     Address of authorized operator
    /// @return isApproved  True if the operator is approved, false if not
    function isApprovedForAll(address owner, address operator) external view returns (bool isApproved);

    /// @notice Get the balance of an account's Tokens.
    /// @param owner     The address of the token holder
    /// @param id        ID of the Token
    /// @return balance  The _owner's balance of the Token type requested
    function balanceOf(address owner, uint256 id) external view returns (uint256 balance);

    /// @notice Get the balance of multiple account/token pairs
    /// @param owners      The addresses of the token holders
    /// @param ids         ID of the Tokens
    /// @return balances_  The _owner's balance of the Token types requested
    function balanceOfBatch(
        address[] calldata owners,
        uint256[] calldata ids
    )
        external
        view
        returns (uint256[] memory balances_);
}

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

  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.6;
pragma experimental ABIEncoderV2;


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 18 of 32 : LibSignature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "../../errors/LibSignatureRichErrors.sol";


/// @dev A library for validating signatures.
library LibSignature {
    using LibRichErrorsV06 for bytes;

    // '\x19Ethereum Signed Message:\n32\x00\x00\x00\x00' in a word.
    uint256 private constant ETH_SIGN_HASH_PREFIX =
        0x19457468657265756d205369676e6564204d6573736167653a0a333200000000;
    /// @dev Exclusive upper limit on ECDSA signatures 'R' values.
    ///      The valid range is given by fig (282) of the yellow paper.
    uint256 private constant ECDSA_SIGNATURE_R_LIMIT =
        uint256(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141);
    /// @dev Exclusive upper limit on ECDSA signatures 'S' values.
    ///      The valid range is given by fig (283) of the yellow paper.
    uint256 private constant ECDSA_SIGNATURE_S_LIMIT = ECDSA_SIGNATURE_R_LIMIT / 2 + 1;

    /// @dev Allowed signature types.
    enum SignatureType {
        ILLEGAL,
        INVALID,
        EIP712,
        ETHSIGN,
        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;
    }

    /// @dev Retrieve the signer of a signature.
    ///      Throws if the signature can't be validated.
    /// @param hash The hash that was signed.
    /// @param signature The signature.
    /// @return recovered The recovered signer address.
    function getSignerOfHash(
        bytes32 hash,
        Signature memory signature
    )
        internal
        pure
        returns (address recovered)
    {
        // Ensure this is a signature type that can be validated against a hash.
        _validateHashCompatibleSignature(hash, signature);

        if (signature.signatureType == SignatureType.EIP712) {
            // Signed using EIP712
            recovered = ecrecover(
                hash,
                signature.v,
                signature.r,
                signature.s
            );
        } else if (signature.signatureType == SignatureType.ETHSIGN) {
            // Signed using `eth_sign`
            // Need to hash `hash` with "\x19Ethereum Signed Message:\n32" prefix
            // in packed encoding.
            bytes32 ethSignHash;
            assembly {
                // Use scratch space
                mstore(0, ETH_SIGN_HASH_PREFIX) // length of 28 bytes
                mstore(28, hash) // length of 32 bytes
                ethSignHash := keccak256(0, 60)
            }
            recovered = ecrecover(
                ethSignHash,
                signature.v,
                signature.r,
                signature.s
            );
        }
        // `recovered` can be null if the signature values are out of range.
        if (recovered == address(0)) {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.BAD_SIGNATURE_DATA,
                hash
            ).rrevert();
        }
    }

    /// @dev Validates that a signature is compatible with a hash signee.
    /// @param hash The hash that was signed.
    /// @param signature The signature.
    function _validateHashCompatibleSignature(
        bytes32 hash,
        Signature memory signature
    )
        private
        pure
    {
        // Ensure the r and s are within malleability limits.
        if (uint256(signature.r) >= ECDSA_SIGNATURE_R_LIMIT ||
            uint256(signature.s) >= ECDSA_SIGNATURE_S_LIMIT)
        {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.BAD_SIGNATURE_DATA,
                hash
            ).rrevert();
        }

        // Always illegal signature.
        if (signature.signatureType == SignatureType.ILLEGAL) {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.ILLEGAL,
                hash
            ).rrevert();
        }

        // Always invalid.
        if (signature.signatureType == SignatureType.INVALID) {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.ALWAYS_INVALID,
                hash
            ).rrevert();
        }

        // If a feature supports pre-signing, it wouldn't use 
        // `getSignerOfHash` on a pre-signed order.
        if (signature.signatureType == SignatureType.PRESIGNED) {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.UNSUPPORTED,
                hash
            ).rrevert();
        }

        // Solidity should check that the signature type is within enum range for us
        // when abi-decoding.
    }
}

File 19 of 32 : LibSignatureRichErrors.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibSignatureRichErrors {

    enum SignatureValidationErrorCodes {
        ALWAYS_INVALID,
        INVALID_LENGTH,
        UNSUPPORTED,
        ILLEGAL,
        WRONG_SIGNER,
        BAD_SIGNATURE_DATA
    }

    // solhint-disable func-name-mixedcase

    function SignatureValidationError(
        SignatureValidationErrorCodes code,
        bytes32 hash,
        address signerAddress,
        bytes memory signature
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("SignatureValidationError(uint8,bytes32,address,bytes)")),
            code,
            hash,
            signerAddress,
            signature
        );
    }

    function SignatureValidationError(
        SignatureValidationErrorCodes code,
        bytes32 hash
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("SignatureValidationError(uint8,bytes32)")),
            code,
            hash
        );
    }
}

File 20 of 32 : NFTOrders.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../../errors/LibNFTOrdersRichErrors.sol";
import "../../fixins/FixinCommon.sol";
import "../../fixins/FixinEIP712.sol";
import "../../fixins/FixinTokenSpender.sol";
import "../../migrations/LibMigrate.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
    FixinCommon,
    FixinEIP712,
    FixinTokenSpender
{
    using LibSafeMathV06 for uint256;

    /// @dev Native token pseudo-address.
    address constant internal NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    /// @dev The WETH token contract.
    IEtherTokenV06 internal immutable WETH;

    /// @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(address zeroExAddress, IEtherTokenV06 weth)
        public
        FixinEIP712(zeroExAddress)
    {
        WETH = weth;
    }

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

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

    // Core settlement logic for selling an NFT asset.
    function _sellNFT(
        LibNFTOrder.NFTOrder memory buyOrder,
        LibSignature.Signature memory signature,
        SellParams memory params
    )
        internal
        returns (uint256 erc20FillAmount)
    {
        LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(buyOrder);
        // Check that the order can be filled.
        _validateBuyOrder(
            buyOrder,
            signature,
            orderInfo,
            params.taker,
            params.tokenId
        );

        if (params.sellAmount > orderInfo.remainingAmount) {
            LibNFTOrdersRichErrors.ExceedsRemainingOrderAmount(
                orderInfo.remainingAmount,
                params.sellAmount
            ).rrevert();
        }

        _updateOrderState(buyOrder, orderInfo.orderHash, params.sellAmount);

        if (params.sellAmount == orderInfo.orderAmount) {
            erc20FillAmount = buyOrder.erc20TokenAmount;
        } else {
            // Rounding favors the order maker.
            erc20FillAmount = LibMathV06.getPartialAmountFloor(
                params.sellAmount,
                orderInfo.orderAmount,
                buyOrder.erc20TokenAmount
            );
        }

        if (params.unwrapNativeToken) {
            // The ERC20 token must be WETH for it to be unwrapped.
            if (buyOrder.erc20Token != WETH) {
                LibNFTOrdersRichErrors.ERC20TokenMismatchError(
                    address(buyOrder.erc20Token),
                    address(WETH)
                ).rrevert();
            }
            // 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),
                "NFTOrders::_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,
                "NFTOrders::_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,
            buyOrder.maker,
            params.sellAmount,
            orderInfo.orderAmount,
            false
        );
    }

    // Core settlement logic for buying an NFT asset.
    function _buyNFT(
        LibNFTOrder.NFTOrder memory sellOrder,
        LibSignature.Signature memory signature,
        BuyParams memory params
    )
        internal
        returns (uint256 erc20FillAmount)
    {
        LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(sellOrder);
        // Check that the order can be filled.
        _validateSellOrder(
            sellOrder,
            signature,
            orderInfo,
            msg.sender
        );

        if (params.buyAmount > orderInfo.remainingAmount) {
            LibNFTOrdersRichErrors.ExceedsRemainingOrderAmount(
                orderInfo.remainingAmount,
                params.buyAmount
            ).rrevert();
        }

        _updateOrderState(sellOrder, orderInfo.orderHash, params.buyAmount);

        if (params.buyAmount == orderInfo.orderAmount) {
            erc20FillAmount = sellOrder.erc20TokenAmount;
        } else {
            // Rounding favors the order maker.
            erc20FillAmount = LibMathV06.getPartialAmountCeil(
                params.buyAmount,
                orderInfo.orderAmount,
                sellOrder.erc20TokenAmount
            );
        }

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

        uint256 ethAvailable = params.ethAvailable;
        if (params.takerCallbackData.length > 0) {
            require(
                msg.sender != address(this),
                "NFTOrders::_buyNFT/CANNOT_CALLBACK_SELF"
            );
            uint256 ethBalanceBeforeCallback = address(this).balance;
            // Invoke the callback
            bytes4 callbackResult = ITakerCallback(msg.sender)
                .zeroExTakerCallback(orderInfo.orderHash, params.takerCallbackData);
            // Update `ethAvailable` with amount acquired during
            // the callback
            ethAvailable = ethAvailable.safeAdd(
                address(this).balance.safeSub(ethBalanceBeforeCallback)
            );
            // Check for the magic success bytes
            require(
                callbackResult == TAKER_CALLBACK_MAGIC_BYTES,
                "NFTOrders::_buyNFT/CALLBACK_FAILED"
            );
        }

        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.
            _payEthFees(
                sellOrder,
                params.buyAmount,
                orderInfo.orderAmount,
                erc20FillAmount,
                ethAvailable
            );
        } else if (sellOrder.erc20Token == WETH) {
            // If there is enough ETH available, fill the WETH order
            // (including fees) using that ETH.
            // Otherwise, transfer WETH from the taker.
            if (ethAvailable >= erc20FillAmount) {
                // Wrap ETH.
                WETH.deposit{value: erc20FillAmount}();
                // TODO: Probably safe to just use WETH.transfer for some
                //       small gas savings
                // Transfer WETH to the seller.
                _transferERC20Tokens(
                    WETH,
                    sellOrder.maker,
                    erc20FillAmount
                );
                // Fees are paid from the EP's current balance of ETH.
                _payEthFees(
                    sellOrder,
                    params.buyAmount,
                    orderInfo.orderAmount,
                    erc20FillAmount,
                    ethAvailable
                );
            } else {
                // Transfer WETH from the buyer to the seller.
                _transferERC20TokensFrom(
                    sellOrder.erc20Token,
                    msg.sender,
                    sellOrder.maker,
                    erc20FillAmount
                );
                // 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.NFTOrder memory sellOrder,
        LibSignature.Signature memory signature,
        LibNFTOrder.OrderInfo memory orderInfo,
        address taker
    )
        internal
        view
    {
        // Order must be selling the NFT asset.
        require(
            sellOrder.direction == LibNFTOrder.TradeDirection.SELL_NFT,
            "NFTOrders::_validateSellOrder/WRONG_TRADE_DIRECTION"
        );
        // Taker must match the order taker, if one is specified.
        if (sellOrder.taker != address(0) && sellOrder.taker != taker) {
            LibNFTOrdersRichErrors.OnlyTakerError(taker, sellOrder.taker).rrevert();
        }
        // Check that the order is valid and has not expired, been cancelled,
        // or been filled.
        if (orderInfo.status != LibNFTOrder.OrderStatus.FILLABLE) {
            LibNFTOrdersRichErrors.OrderNotFillableError(
                sellOrder.maker,
                sellOrder.nonce,
                uint8(orderInfo.status)
            ).rrevert();
        }

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

    function _validateBuyOrder(
        LibNFTOrder.NFTOrder memory buyOrder,
        LibSignature.Signature memory signature,
        LibNFTOrder.OrderInfo memory orderInfo,
        address taker,
        uint256 tokenId
    )
        internal
        view
    {
        // Order must be buying the NFT asset.
        require(
            buyOrder.direction == LibNFTOrder.TradeDirection.BUY_NFT,
            "NFTOrders::_validateBuyOrder/WRONG_TRADE_DIRECTION"
        );
        // The ERC20 token cannot be ETH.
        require(
            address(buyOrder.erc20Token) != NATIVE_TOKEN_ADDRESS,
            "NFTOrders::_validateBuyOrder/NATIVE_TOKEN_NOT_ALLOWED"
        );
        // Taker must match the order taker, if one is specified.
        if (buyOrder.taker != address(0) && buyOrder.taker != taker) {
            LibNFTOrdersRichErrors.OnlyTakerError(taker, buyOrder.taker).rrevert();
        }
        // Check that the order is valid and has not expired, been cancelled,
        // or been filled.
        if (orderInfo.status != LibNFTOrder.OrderStatus.FILLABLE) {
            LibNFTOrdersRichErrors.OrderNotFillableError(
                buyOrder.maker,
                buyOrder.nonce,
                uint8(orderInfo.status)
            ).rrevert();
        }
        // 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 _payEthFees(
        LibNFTOrder.NFTOrder memory order,
        uint128 fillAmount,
        uint128 orderAmount,
        uint256 ethSpent,
        uint256 ethAvailable
    )
        private
    {
        // Pay fees using ETH.
        uint256 ethFees = _payFees(
            order,
            address(this),
            fillAmount,
            orderAmount,
            true
        );
        // Update amount of ETH spent.
        ethSpent = ethSpent.safeAdd(ethFees);
        if (ethSpent > ethAvailable) {
            LibNFTOrdersRichErrors.OverspentEthError(
                ethSpent,
                ethAvailable
            ).rrevert();
        }
    }

    function _payFees(
        LibNFTOrder.NFTOrder memory order,
        address payer,
        uint128 fillAmount,
        uint128 orderAmount,
        bool useNativeToken
    )
        internal
        returns (uint256 totalFeesPaid)
    {
        // Make assertions about ETH case
        if (useNativeToken) {
            assert(payer == address(this));
            assert(
                order.erc20Token == WETH ||
                address(order.erc20Token) == NATIVE_TOKEN_ADDRESS
            );
        }

        for (uint256 i = 0; i < order.fees.length; i++) {
            LibNFTOrder.Fee memory fee = order.fees[i];

            require(
                fee.recipient != address(this),
                "NFTOrders::_payFees/RECIPIENT_CANNOT_BE_EXCHANGE_PROXY"
            );

            uint256 feeFillAmount;
            if (fillAmount == orderAmount) {
                feeFillAmount = fee.amount;
            } else {
                // Round against the fee recipient
                feeFillAmount = LibMathV06.getPartialAmountFloor(
                    fillAmount,
                    orderAmount,
                    fee.amount
                );
            }
            if (feeFillAmount == 0) {
                continue;
            }

            if (useNativeToken) {
                // Transfer ETH to the fee recipient.
                _transferEth(payable(fee.recipient), feeFillAmount);
            } else {
                // 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,
                    "NFTOrders::_payFees/CALLBACK_FAILED"
                );
            }
            // Sum the fees paid
            totalFeesPaid = totalFeesPaid.safeAdd(feeFillAmount);
        }
    }

    /// @dev If the given order is buying an NFT asset, checks
    ///      whether or not the given token ID satisfies the required
    ///      properties specified in the order. If the order does not
    ///      specify any properties, this function instead checks
    ///      whether the given token ID matches the ID in the order.
    ///      Reverts if any checks fail, or if the order is selling
    ///      an NFT asset.
    /// @param order The NFT order.
    /// @param tokenId The ID of the NFT asset.
    function _validateOrderProperties(
        LibNFTOrder.NFTOrder memory order,
        uint256 tokenId
    )
        internal
        view
    {
        // Order must be buying an NFT asset to have properties.
        require(
            order.direction == LibNFTOrder.TradeDirection.BUY_NFT,
            "NFTOrders::_validateOrderProperties/WRONG_TRADE_DIRECTION"
        );

        // If no properties are specified, check that the given
        // `tokenId` matches the one specified in the order.
        if (order.nftProperties.length == 0) {
            if (tokenId != order.nftId) {
                LibNFTOrdersRichErrors.TokenIdMismatchError(
                    tokenId,
                    order.nftId
                ).rrevert();
            }
        } 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)) {
                    continue;
                }

                // 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 errorData) {
                    LibNFTOrdersRichErrors.PropertyValidationFailedError(
                        address(property.propertyValidator),
                        order.nft,
                        tokenId,
                        property.propertyData,
                        errorData
                    ).rrevert();
                }
            }
        }
    }

    /// @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.NFTOrder memory order,
        bytes32 orderHash,
        uint128 fillAmount
    )
        internal
        virtual;

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

File 21 of 32 : LibMathV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2019 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.6.5;

import "./LibSafeMathV06.sol";
import "./errors/LibRichErrorsV06.sol";
import "./errors/LibMathRichErrorsV06.sol";


library LibMathV06 {

    using LibSafeMathV06 for uint256;

    /// @dev Calculates partial value given a numerator and denominator rounded down.
    ///      Reverts if rounding error is >= 0.1%
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to calculate partial of.
    /// @return partialAmount Partial value of target rounded down.
    function safeGetPartialAmountFloor(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (uint256 partialAmount)
    {
        if (isRoundingErrorFloor(
                numerator,
                denominator,
                target
        )) {
            LibRichErrorsV06.rrevert(LibMathRichErrorsV06.RoundingError(
                numerator,
                denominator,
                target
            ));
        }

        partialAmount = numerator.safeMul(target).safeDiv(denominator);
        return partialAmount;
    }

    /// @dev Calculates partial value given a numerator and denominator rounded down.
    ///      Reverts if rounding error is >= 0.1%
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to calculate partial of.
    /// @return partialAmount Partial value of target rounded up.
    function safeGetPartialAmountCeil(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (uint256 partialAmount)
    {
        if (isRoundingErrorCeil(
                numerator,
                denominator,
                target
        )) {
            LibRichErrorsV06.rrevert(LibMathRichErrorsV06.RoundingError(
                numerator,
                denominator,
                target
            ));
        }

        // safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
        //       ceil(a / b) = floor((a + b - 1) / b)
        // To implement `ceil(a / b)` using safeDiv.
        partialAmount = numerator.safeMul(target)
            .safeAdd(denominator.safeSub(1))
            .safeDiv(denominator);

        return partialAmount;
    }

    /// @dev Calculates partial value given a numerator and denominator rounded down.
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to calculate partial of.
    /// @return partialAmount Partial value of target rounded down.
    function getPartialAmountFloor(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (uint256 partialAmount)
    {
        partialAmount = numerator.safeMul(target).safeDiv(denominator);
        return partialAmount;
    }

    /// @dev Calculates partial value given a numerator and denominator rounded down.
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to calculate partial of.
    /// @return partialAmount Partial value of target rounded up.
    function getPartialAmountCeil(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (uint256 partialAmount)
    {
        // safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
        //       ceil(a / b) = floor((a + b - 1) / b)
        // To implement `ceil(a / b)` using safeDiv.
        partialAmount = numerator.safeMul(target)
            .safeAdd(denominator.safeSub(1))
            .safeDiv(denominator);

        return partialAmount;
    }

    /// @dev Checks if rounding error >= 0.1% when rounding down.
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to multiply with numerator/denominator.
    /// @return isError Rounding error is present.
    function isRoundingErrorFloor(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (bool isError)
    {
        if (denominator == 0) {
            LibRichErrorsV06.rrevert(LibMathRichErrorsV06.DivisionByZeroError());
        }

        // The absolute rounding error is the difference between the rounded
        // value and the ideal value. The relative rounding error is the
        // absolute rounding error divided by the absolute value of the
        // ideal value. This is undefined when the ideal value is zero.
        //
        // The ideal value is `numerator * target / denominator`.
        // Let's call `numerator * target % denominator` the remainder.
        // The absolute error is `remainder / denominator`.
        //
        // When the ideal value is zero, we require the absolute error to
        // be zero. Fortunately, this is always the case. The ideal value is
        // zero iff `numerator == 0` and/or `target == 0`. In this case the
        // remainder and absolute error are also zero.
        if (target == 0 || numerator == 0) {
            return false;
        }

        // Otherwise, we want the relative rounding error to be strictly
        // less than 0.1%.
        // The relative error is `remainder / (numerator * target)`.
        // We want the relative error less than 1 / 1000:
        //        remainder / (numerator * denominator)  <  1 / 1000
        // or equivalently:
        //        1000 * remainder  <  numerator * target
        // so we have a rounding error iff:
        //        1000 * remainder  >=  numerator * target
        uint256 remainder = mulmod(
            target,
            numerator,
            denominator
        );
        isError = remainder.safeMul(1000) >= numerator.safeMul(target);
        return isError;
    }

    /// @dev Checks if rounding error >= 0.1% when rounding up.
    /// @param numerator Numerator.
    /// @param denominator Denominator.
    /// @param target Value to multiply with numerator/denominator.
    /// @return isError Rounding error is present.
    function isRoundingErrorCeil(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (bool isError)
    {
        if (denominator == 0) {
            LibRichErrorsV06.rrevert(LibMathRichErrorsV06.DivisionByZeroError());
        }

        // See the comments in `isRoundingError`.
        if (target == 0 || numerator == 0) {
            // When either is zero, the ideal value and rounded value are zero
            // and there is no rounding error. (Although the relative error
            // is undefined.)
            return false;
        }
        // Compute remainder as before
        uint256 remainder = mulmod(
            target,
            numerator,
            denominator
        );
        remainder = denominator.safeSub(remainder) % denominator;
        isError = remainder.safeMul(1000) >= numerator.safeMul(target);
        return isError;
    }
}

File 22 of 32 : LibMathRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibMathRichErrorsV06 {

    // bytes4(keccak256("DivisionByZeroError()"))
    bytes internal constant DIVISION_BY_ZERO_ERROR =
        hex"a791837c";

    // bytes4(keccak256("RoundingError(uint256,uint256,uint256)"))
    bytes4 internal constant ROUNDING_ERROR_SELECTOR =
        0x339f3de2;

    // solhint-disable func-name-mixedcase
    function DivisionByZeroError()
        internal
        pure
        returns (bytes memory)
    {
        return DIVISION_BY_ZERO_ERROR;
    }

    function RoundingError(
        uint256 numerator,
        uint256 denominator,
        uint256 target
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            ROUNDING_ERROR_SELECTOR,
            numerator,
            denominator,
            target
        );
    }
}

File 23 of 32 : LibNFTOrdersRichErrors.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibNFTOrdersRichErrors {

    // solhint-disable func-name-mixedcase

    function OverspentEthError(
        uint256 ethSpent,
        uint256 ethAvailable
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OverspentEthError(uint256,uint256)")),
            ethSpent,
            ethAvailable
        );
    }

    function InsufficientEthError(
        uint256 ethAvailable,
        uint256 orderAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("InsufficientEthError(uint256,uint256)")),
            ethAvailable,
            orderAmount
        );
    }

    function ERC721TokenMismatchError(
        address token1,
        address token2
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("ERC721TokenMismatchError(address,address)")),
            token1,
            token2
        );
    }

    function ERC1155TokenMismatchError(
        address token1,
        address token2
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("ERC1155TokenMismatchError(address,address)")),
            token1,
            token2
        );
    }

    function ERC20TokenMismatchError(
        address token1,
        address token2
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("ERC20TokenMismatchError(address,address)")),
            token1,
            token2
        );
    }

    function NegativeSpreadError(
        uint256 sellOrderAmount,
        uint256 buyOrderAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("NegativeSpreadError(uint256,uint256)")),
            sellOrderAmount,
            buyOrderAmount
        );
    }

    function SellOrderFeesExceedSpreadError(
        uint256 sellOrderFees,
        uint256 spread
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("SellOrderFeesExceedSpreadError(uint256,uint256)")),
            sellOrderFees,
            spread
        );
    }

    function OnlyTakerError(
        address sender,
        address taker
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OnlyTakerError(address,address)")),
            sender,
            taker
        );
    }

    function InvalidSignerError(
        address maker,
        address signer
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("InvalidSignerError(address,address)")),
            maker,
            signer
        );
    }

    function OrderNotFillableError(
        address maker,
        uint256 nonce,
        uint8 orderStatus
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OrderNotFillableError(address,uint256,uint8)")),
            maker,
            nonce,
            orderStatus
        );
    }

    function TokenIdMismatchError(
        uint256 tokenId,
        uint256 orderTokenId
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("TokenIdMismatchError(uint256,uint256)")),
            tokenId,
            orderTokenId
        );
    }

    function PropertyValidationFailedError(
        address propertyValidator,
        address token,
        uint256 tokenId,
        bytes memory propertyData,
        bytes memory errorData
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("PropertyValidationFailedError(address,address,uint256,bytes,bytes)")),
            propertyValidator,
            token,
            tokenId,
            propertyData,
            errorData
        );
    }

    function ExceedsRemainingOrderAmount(
        uint128 remainingOrderAmount,
        uint128 fillAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("ExceedsRemainingOrderAmount(uint128,uint128)")),
            remainingOrderAmount,
            fillAmount
        );
    }
}

File 24 of 32 : FixinCommon.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "../errors/LibCommonRichErrors.sol";
import "../errors/LibOwnableRichErrors.sol";
import "../features/interfaces/IOwnableFeature.sol";
import "../features/interfaces/ISimpleFunctionRegistryFeature.sol";


/// @dev Common feature utilities.
abstract contract FixinCommon {

    using LibRichErrorsV06 for bytes;

    /// @dev The implementation address of this feature.
    address internal immutable _implementation;

    /// @dev The caller must be this contract.
    modifier onlySelf() virtual {
        if (msg.sender != address(this)) {
            LibCommonRichErrors.OnlyCallableBySelfError(msg.sender).rrevert();
        }
        _;
    }

    /// @dev The caller of this function must be the owner.
    modifier onlyOwner() virtual {
        {
            address owner = IOwnableFeature(address(this)).owner();
            if (msg.sender != owner) {
                LibOwnableRichErrors.OnlyOwnerError(
                    msg.sender,
                    owner
                ).rrevert();
            }
        }
        _;
    }

    constructor() internal {
        // Remember this feature's original address.
        _implementation = address(this);
    }

    /// @dev Registers a function implemented by this feature at `_implementation`.
    ///      Can and should only be called within a `migrate()`.
    /// @param selector The selector of the function whose implementation
    ///        is at `_implementation`.
    function _registerFeatureFunction(bytes4 selector)
        internal
    {
        ISimpleFunctionRegistryFeature(address(this)).extend(selector, _implementation);
    }

    /// @dev Encode a feature version as a `uint256`.
    /// @param major The major version number of the feature.
    /// @param minor The minor version number of the feature.
    /// @param revision The revision number of the feature.
    /// @return encodedVersion The encoded version number.
    function _encodeVersion(uint32 major, uint32 minor, uint32 revision)
        internal
        pure
        returns (uint256 encodedVersion)
    {
        return (uint256(major) << 64) | (uint256(minor) << 32) | uint256(revision);
    }
}

File 25 of 32 : LibCommonRichErrors.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


library LibCommonRichErrors {

    // solhint-disable func-name-mixedcase

    function OnlyCallableBySelfError(address sender)
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OnlyCallableBySelfError(address)")),
            sender
        );
    }

    function IllegalReentrancyError(bytes4 selector, uint256 reentrancyFlags)
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("IllegalReentrancyError(bytes4,uint256)")),
            selector,
            reentrancyFlags
        );
    }
}

File 26 of 32 : IOwnableFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/interfaces/IOwnableV06.sol";


// solhint-disable no-empty-blocks
/// @dev Owner management and migration features.
interface IOwnableFeature is
    IOwnableV06
{
    /// @dev Emitted when `migrate()` is called.
    /// @param caller The caller of `migrate()`.
    /// @param migrator The migration contract.
    /// @param newOwner The address of the new owner.
    event Migrated(address caller, address migrator, address newOwner);

    /// @dev Execute a migration function in the context of the ZeroEx contract.
    ///      The result of the function being called should be the magic bytes
    ///      0x2c64c5ef (`keccack('MIGRATE_SUCCESS')`). Only callable by the owner.
    ///      The owner will be temporarily set to `address(this)` inside the call.
    ///      Before returning, the owner will be set to `newOwner`.
    /// @param target The migrator contract address.
    /// @param newOwner The address of the new owner.
    /// @param data The call data.
    function migrate(address target, bytes calldata data, address newOwner) external;
}

File 27 of 32 : IOwnableV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;


interface IOwnableV06 {

    /// @dev Emitted by Ownable when ownership is transferred.
    /// @param previousOwner The previous owner of the contract.
    /// @param newOwner The new owner of the contract.
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /// @dev Transfers ownership of the contract to a new address.
    /// @param newOwner The address that will become the owner.
    function transferOwnership(address newOwner) external;

    /// @dev The owner of this contract.
    /// @return ownerAddress The owner address.
    function owner() external view returns (address ownerAddress);
}

File 28 of 32 : ISimpleFunctionRegistryFeature.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;


/// @dev Basic registry management features.
interface ISimpleFunctionRegistryFeature {

    /// @dev A function implementation was updated via `extend()` or `rollback()`.
    /// @param selector The function selector.
    /// @param oldImpl The implementation contract address being replaced.
    /// @param newImpl The replacement implementation contract address.
    event ProxyFunctionUpdated(bytes4 indexed selector, address oldImpl, address newImpl);

    /// @dev Roll back to a prior implementation of a function.
    /// @param selector The function selector.
    /// @param targetImpl The address of an older implementation of the function.
    function rollback(bytes4 selector, address targetImpl) external;

    /// @dev Register or replace a function.
    /// @param selector The function selector.
    /// @param impl The implementation contract for the function.
    function extend(bytes4 selector, address impl) external;

    /// @dev Retrieve the length of the rollback history for a function.
    /// @param selector The function selector.
    /// @return rollbackLength The number of items in the rollback history for
    ///         the function.
    function getRollbackLength(bytes4 selector)
        external
        view
        returns (uint256 rollbackLength);

    /// @dev Retrieve an entry in the rollback history for a function.
    /// @param selector The function selector.
    /// @param idx The index in the rollback history.
    /// @return impl An implementation address for the function at
    ///         index `idx`.
    function getRollbackEntryAtIndex(bytes4 selector, uint256 idx)
        external
        view
        returns (address impl);
}

File 29 of 32 : FixinEIP712.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "../errors/LibCommonRichErrors.sol";
import "../errors/LibOwnableRichErrors.sol";


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

    /// @dev The domain hash separator for the entire exchange proxy.
    bytes32 public immutable EIP712_DOMAIN_SEPARATOR;

    constructor(address zeroExAddress) internal {
        // Compute `EIP712_DOMAIN_SEPARATOR`
        {
            uint256 chainId;
            assembly { chainId := chainid() }
            EIP712_DOMAIN_SEPARATOR = keccak256(
                abi.encode(
                    keccak256(
                        "EIP712Domain("
                            "string name,"
                            "string version,"
                            "uint256 chainId,"
                            "address verifyingContract"
                        ")"
                    ),
                    keccak256("ZeroEx"),
                    keccak256("1.0.0"),
                    chainId,
                    zeroExAddress
                )
            );
        }
    }

    function _getEIP712Hash(bytes32 structHash)
        internal
        view
        returns (bytes32 eip712Hash)
    {
        return keccak256(abi.encodePacked(
            hex"1901",
            EIP712_DOMAIN_SEPARATOR,
            structHash
        ));
    }
}

File 30 of 32 : FixinTokenSpender.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6.5;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.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(
        IERC20TokenV06 token,
        address owner,
        address to,
        uint256 amount
    )
        internal
    {
        require(address(token) != address(this), "FixinTokenSpender/CANNOT_INVOKE_SELF");

        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)

            let 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)
                    )
                )
            )

            if iszero(success) {
                returndatacopy(ptr, 0, rdsize)
                revert(ptr, rdsize)
            }
        }
    }

    /// @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(
        IERC20TokenV06 token,
        address to,
        uint256 amount
    )
        internal
    {
        require(address(token) != address(this), "FixinTokenSpender/CANNOT_INVOKE_SELF");

        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)

            let 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)
                    )
                )
            )

            if iszero(success) {
                returndatacopy(ptr, 0, rdsize)
                revert(ptr, rdsize)
            }
        }
    }


    /// @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, "FixinTokenSpender::_transferEth/TRANSFER_FAILED");
        }
    }

    /// @dev Gets the maximum amount of an ERC20 token `token` that can be
    ///      pulled from `owner` by this address.
    /// @param token The token to spend.
    /// @param owner The owner of the tokens.
    /// @return amount The amount of tokens that can be pulled.
    function _getSpendableERC20BalanceOf(
        IERC20TokenV06 token,
        address owner
    )
        internal
        view
        returns (uint256)
    {
        return LibSafeMathV06.min256(
            token.allowance(owner, address(this)),
            token.balanceOf(owner)
        );
    }
}

File 31 of 32 : IFeeRecipient.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;


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 32 of 32 : ITakerCallback.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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.6;
pragma experimental ABIEncoderV2;


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 callbackData Arbitrary data used by this callback.
    /// @return success The selector of this function,
    ///         indicating that the callback succeeded.
    function zeroExTakerCallback(
        bytes32 orderHash,
        bytes calldata callbackData
    )
        external
        returns (bytes4 success);
}

Settings
{
  "remappings": [
    "@0x/contracts-utils=/Users/michaelzhu/protocol/node_modules/@0x/contracts-utils",
    "@0x/contracts-erc20=/Users/michaelzhu/protocol/contracts/zero-ex/node_modules/@0x/contracts-erc20"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000,
    "details": {
      "yul": true,
      "deduplicate": true,
      "cse": true,
      "constantOptimizer": true
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "istanbul"
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"zeroExAddress","type":"address"},{"internalType":"contract IEtherTokenV06","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"indexed":false,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"contract IERC20TokenV06","name":"erc20Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20TokenAmount","type":"uint256"},{"indexed":false,"internalType":"contract IERC721Token","name":"erc721Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"matcher","type":"address"}],"name":"ERC721OrderFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","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":"erc721TokenProperties","type":"tuple[]"}],"name":"ERC721OrderPreSigned","type":"event"},{"inputs":[],"name":"EIP712_DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEATURE_NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEATURE_VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","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":"uint256","name":"ethAvailable","type":"uint256"},{"internalType":"bytes","name":"takerCallbackData","type":"bytes"}],"name":"_buyERC721","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order[]","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":"bytes[]","name":"callbackData","type":"bytes[]"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"}],"name":"batchBuyERC721s","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":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order[]","name":"sellOrders","type":"tuple[]"},{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order[]","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":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","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":"bytes","name":"callbackData","type":"bytes"}],"name":"buyERC721","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderNonce","type":"uint256"}],"name":"cancelERC721Order","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","name":"order","type":"tuple"}],"name":"getERC721OrderHash","outputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","name":"order","type":"tuple"}],"name":"getERC721OrderStatus","outputs":[{"internalType":"enum LibNFTOrder.OrderStatus","name":"status","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":"bitVector","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","name":"sellOrder","type":"tuple"},{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","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":[],"name":"migrate","outputs":[{"internalType":"bytes4","name":"success","type":"bytes4"}],"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":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","name":"order","type":"tuple"}],"name":"preSignERC721Order","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","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":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","name":"order","type":"tuple"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"}],"name":"validateERC721OrderProperties","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum LibNFTOrder.TradeDirection","name":"direction","type":"uint8"},{"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 IERC20TokenV06","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":"contract IERC721Token","name":"erc721Token","type":"address"},{"internalType":"uint256","name":"erc721TokenId","type":"uint256"},{"components":[{"internalType":"contract IPropertyValidator","name":"propertyValidator","type":"address"},{"internalType":"bytes","name":"propertyData","type":"bytes"}],"internalType":"struct LibNFTOrder.Property[]","name":"erc721TokenProperties","type":"tuple[]"}],"internalType":"struct LibNFTOrder.ERC721Order","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":"validateERC721OrderSignature","outputs":[],"stateMutability":"view","type":"function"}]

61010060405262000014600160008062000108565b60e0523480156200002457600080fd5b50604051620057813803806200578183398101604081905262000047916200013a565b3060601b6080526040518290829082904690620000d1907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907f9e5dae0addaf20578aeb5d70341d092b53b4e14480ac5726438fd436df7ba427907f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c908590879060200162000178565b60408051808303601f19018152919052805160209091012060a052505060601b6001600160601b03191660c05250620001bd915050565b6bffffffff0000000000000000604084901b1667ffffffff00000000602084901b161763ffffffff8216179392505050565b600080604083850312156200014d578182fd5b82516200015a81620001a4565b60208401519092506200016d81620001a4565b809150509250929050565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6001600160a01b0381168114620001ba57600080fd5b50565b60805160601c60a05160c05160601c60e0516155476200023a600039806104165250806105b3528061060f52806106805280611d3f528061269f52806126fe52806127825280612d465280612da85280612dd15280612e395250806111c85280612958525080610cdb528061132a528061286152506155476000f3fe6080604052600436106101445760003560e01c806386219940116100c0578063d1ca183b11610074578063eae93ee711610059578063eae93ee714610350578063fbc4a51814610370578063fbee349d1461039d57610144565b8063d1ca183b1461031b578063dab400f31461033b57610144565b8063afde1b3c116100a5578063afde1b3c146102bb578063b73a6027146102db578063be167b9d146102fb57610144565b806386219940146102865780638fd3ab80146102a657610144565b8063462103af1161011757806360018b41116100fc57806360018b41146102235780636ae4b4f7146102365780637da9e2cf1461025857610144565b8063462103af146101e15780634a13d7971461020357610144565b8063030b273014610149578063031b905c1461017f5780630d8261eb14610194578063150b7a02146101b4575b600080fd5b34801561015557600080fd5b5061016961016436600461409f565b6103b0565b6040516101769190614ad7565b60405180910390f35b34801561018b57600080fd5b50610169610414565b3480156101a057600080fd5b506101696101af366004614369565b610438565b3480156101c057600080fd5b506101d46101cf366004614005565b6108f9565b6040516101769190614b17565b3480156101ed57600080fd5b506102016101fc366004614336565b6109bd565b005b34801561020f57600080fd5b5061020161021e366004614605565b610aed565b610201610231366004614595565b610b03565b34801561024257600080fd5b5061024b610bb0565b6040516101769190614d42565b34801561026457600080fd5b506102786102733660046140fa565b610be9565b604051610176929190614a8a565b34801561029257600080fd5b506102016102a1366004614287565b610ec4565b3480156102b257600080fd5b506101d4610ef7565b3480156102c757600080fd5b506102016102d6366004614503565b611133565b3480156102e757600080fd5b506101696102f6366004614336565b611149565b34801561030757600080fd5b50610201610316366004614648565b611164565b34801561032757600080fd5b506102016103363660046143e3565b6111aa565b34801561034757600080fd5b506101696111c6565b61036361035e3660046141a2565b6111ea565b6040516101769190614a77565b34801561037c57600080fd5b5061039061038b366004614336565b6114ea565b6040516101769190614bad565b6102016103ab366004614491565b611602565b6000806103bb611642565b73ffffffffffffffffffffffffffffffffffffffff85166000908152602091825260408082207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8716835290925220549150505b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600083610100015173ffffffffffffffffffffffffffffffffffffffff1685610100015173ffffffffffffffffffffffffffffffffffffffff16146104935761049361048e86610100015186610100015161164f565b61170a565b61049b613a30565b6104a486611712565b90506104ae613a30565b6104b786611712565b90506104c1613ae3565b6104ca8361171e565b90506104d4613ae3565b6104dd8361171e565b90506104ef8488848b602001516117a3565b6105058387838c602001518d61012001516118ad565b6105158483600001516001611a1e565b6105258382600001516001611a1e565b50508660c001518660c00151101561054c5761054c61048e8860c001518860c00151611a4c565b60008760c001518760c00151039050610579886101000151896020015189602001518b6101200151611a82565b60a088015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14801561060557507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168760a0015173ffffffffffffffffffffffffffffffffffffffff16145b1561074f5761063e7f00000000000000000000000000000000000000000000000000000000000000008860200151308a60c00151611b6e565b60c08701516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691632e1a7d4d916106b49190600401614ad7565b600060405180830381600087803b1580156106ce57600080fd5b505af11580156106e2573d6000803e3d6000fd5b505050506106f888602001518960c00151611c6d565b61070b8288602001516001806000611d16565b50600061071d84306001806001611d16565b9050808210156107345761073461048e8284612076565b80820394508415610749576107493386611c6d565b5061081c565b8660a0015173ffffffffffffffffffffffffffffffffffffffff168860a0015173ffffffffffffffffffffffffffffffffffffffff161461079f5761079f61048e8960a001518960a001516120ac565b6107bb8760a0015188602001518a602001518b60c00151611b6e565b6107ce8288602001516001806000611d16565b5060006107e48489602001516001806000611d16565b9050808210156107fb576107fb61048e8284612076565b8082039450841561081a5761081a8860a0015189602001513388611b6e565b505b7f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af8860000151896020015189602001518b608001518c60a001518d60c001518e61010001518f61012001513360405161087d99989796959493929190614c42565b60405180910390a17f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af876000015188602001518a602001518a608001518b60a001518c60c001518d61010001518f6101200151336040516108e699989796959493929190614c42565b60405180910390a1505050949350505050565b6000610903613a30565b61090b613b0c565b600061091985870187614430565b92509250925082610100015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109695761096961048e3385610100015161164f565b60408051600081526020810190915261098d90849084908a9085908e9030906120e2565b507f150b7a0200000000000000000000000000000000000000000000000000000000925050505b95945050505050565b602081015173ffffffffffffffffffffffffffffffffffffffff163314610a19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614eef565b60405180910390fd5b6000610a2482611149565b90506001610a30611642565b6000838152600191909101602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001693151593909317909255835191840151848201516060860151608087015160a088015160c089015160e08a01516101008b01516101208c01516101408d015199517f8c5d0c41fb16a7317a6c55ff7ba93d9d74f79e434fefa694e50d6028afbfa3f09b610ae19b909a999897969594939291614caa565b60405180910390a15050565b610aff610af983611712565b826121cd565b5050565b610b43610b0f85611712565b84604051806060016040528060016fffffffffffffffffffffffffffffffff1681526020018681526020018581525061239d565b507f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af846000015185602001513387608001518860a001518960c001518a61010001518b61012001516000604051610ba299989796959493929190614bd8565b60405180910390a150505050565b6040518060400160405280600c81526020017f4552433732314f7264657273000000000000000000000000000000000000000081525081565b60608084518651148015610bfe575082518451145b8015610c0b575083518651145b610c41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614e0f565b855167ffffffffffffffff81118015610c5957600080fd5b50604051908082528060200260200182016040528015610c83578160200160208202803683370190505b509150855167ffffffffffffffff81118015610c9e57600080fd5b50604051908082528060200260200182016040528015610cc8578160200160208202803683370190505b50905060005b8651811015610eba5760607f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630d8261eb60e01b898481518110610d2457fe5b6020026020010151898581518110610d3857fe5b6020026020010151898681518110610d4c57fe5b6020026020010151898781518110610d6057fe5b6020026020010151604051602401610d7b949392919061534b565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610e049190614912565b600060405180830381855af49150503d8060008114610e3f576040519150601f19603f3d011682016040523d82523d6000602084013e610e44565b606091505b50848481518110610e5157fe5b6020026020010181935082151515158152505050828281518110610e7157fe5b602002602001015115610eb157600081806020019051810190610e949190614660565b905080858481518110610ea357fe5b602002602001018181525050505b50600101610cce565b5094509492505050565b60005b81811015610ef257610eea838383818110610ede57fe5b90506020020135611164565b600101610ec7565b505050565b6000610f227fafde1b3c0000000000000000000000000000000000000000000000000000000061282b565b610f4b7ffbee349d0000000000000000000000000000000000000000000000000000000061282b565b610f747fbe167b9d0000000000000000000000000000000000000000000000000000000061282b565b610f9d7feae93ee70000000000000000000000000000000000000000000000000000000061282b565b610fc67f0d8261eb0000000000000000000000000000000000000000000000000000000061282b565b610fef7f7da9e2cf0000000000000000000000000000000000000000000000000000000061282b565b6110187f150b7a020000000000000000000000000000000000000000000000000000000061282b565b6110417f462103af0000000000000000000000000000000000000000000000000000000061282b565b61106a7fd1ca183b0000000000000000000000000000000000000000000000000000000061282b565b6110937f4a13d7970000000000000000000000000000000000000000000000000000000061282b565b6110bc7ffbc4a5180000000000000000000000000000000000000000000000000000000061282b565b6110e57fb73a60270000000000000000000000000000000000000000000000000000000061282b565b61110e7f030b27300000000000000000000000000000000000000000000000000000000061282b565b507f2c64c5ef0000000000000000000000000000000000000000000000000000000090565b611142858585853333876120e2565b5050505050565b600061115c611157836128b7565b612954565b90505b919050565b61116e33826129a6565b7fa015ad2dc32f266993958a0fd9884c746b971b254206f3478bc43e2f125c7b9e338260405161119f929190614967565b60405180910390a150565b60006111b583611149565b9050610ef2818385602001516129f7565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060835185511480156111fe575082518551145b611234576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614d55565b845167ffffffffffffffff8111801561124c57600080fd5b50604051908082528060200260200182016040528015611276578160200160208202803683370190505b50905060006112854734612a95565b9050821561131c5760005b8651811015611316576112f08782815181106112a857fe5b60200260200101518783815181106112bc57fe5b60200260200101516112d78547612a9590919063ffffffff16565b8885815181106112e357fe5b6020026020010151610b03565b60018382815181106112fe57fe5b91151560209283029190910190910152600101611290565b506114ba565b60005b86518110156114b8577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166360018b4160e01b88838151811061137357fe5b602002602001015188848151811061138757fe5b60200260200101516113a28647612a9590919063ffffffff16565b8986815181106113ae57fe5b60200260200101516040516024016113c99493929190615390565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516114529190614912565b600060405180830381855af49150503d806000811461148d576040519150601f19603f3d011682016040523d82523d6000602084013e611492565b606091505b50508382815181106114a057fe5b9115156020928302919091019091015260010161131f565b505b47818110156114d4576114d461048e828403340134612ab4565b6114e033838303611c6d565b5050949350505050565b6000808261014001515111801561151c575060018251600181111561150b57fe5b14158061151c575061012082015115155b156115295750600061115f565b60018251600181111561153857fe5b148015611572575060a082015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b1561157f5750600061115f565b428260600151116115925750600361115f565b600061159c611642565b60208085015173ffffffffffffffffffffffffffffffffffffffff166000908152828252604080822060808801805160081c84529352902054905191925090600160ff9091161b808216156115f7576002935050505061115f565b506001949350505050565b600061160e4734612a95565b905061161c84843485610b03565b47818110156116365761163661048e828403340134612ab4565b61114233838303611c6d565b60008061040e6009612aea565b60607f21916d9c05d4d89fb4c8db2934603a48c5480a95f94dfd3a2cd9ac40b8615d15838360405160240161168592919061498d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b805160208201fd5b61171a613a30565b5090565b611726613ae3565b61172e613a30565b61173783611712565b905061174281611149565b825261174d816114ea565b8260200190600381111561175d57fe5b9081600381111561176a57fe5b9052506001604083018190528260200151600381111561178657fe5b14611792576000611795565b60015b60ff16606083015250919050565b6000845160018111156117b257fe5b146117e9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a109061517a565b604084015173ffffffffffffffffffffffffffffffffffffffff161580159061184257508073ffffffffffffffffffffffffffffffffffffffff16846040015173ffffffffffffffffffffffffffffffffffffffff1614155b156118585761185861048e828660400151612b05565b60018260200151600381111561186a57fe5b146118945761189461048e856020015186608001518560200151600381111561188f57fe5b612b3b565b6118a782600001518486602001516129f7565b50505050565b6001855160018111156118bc57fe5b146118f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614fa9565b60a085015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561195b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614e92565b604085015173ffffffffffffffffffffffffffffffffffffffff16158015906119b457508173ffffffffffffffffffffffffffffffffffffffff16856040015173ffffffffffffffffffffffffffffffffffffffff1614155b156119ca576119ca61048e838760400151612b05565b6001836020015160038111156119dc57fe5b14611a0157611a0161048e866020015187608001518660200151600381111561188f57fe5b611a0b85826121cd565b61114283600001518587602001516129f7565b806fffffffffffffffffffffffffffffffff16600114611a3a57fe5b610ef2836020015184608001516129a6565b60607f2c837d7451f39ae9868ea7dacec7847412534d287da737ffde01c3c8b2f61c0a8383604051602401611685929190615453565b73ffffffffffffffffffffffffffffffffffffffff8416301415611ad2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906152ee565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152600080606483600073ffffffffffffffffffffffffffffffffffffffff8a165af180611b66573d806000843e8083fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416301415611bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615291565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152602081606483600073ffffffffffffffffffffffffffffffffffffffff8a165af13d60018351146020821015168115178216915081611c6457806000843e8083fd5b50505050505050565b8015610aff5760008273ffffffffffffffffffffffffffffffffffffffff1682604051611c9990614964565b60006040518083038185875af1925050503d8060008114611cd6576040519150601f19603f3d011682016040523d82523d6000602084013e611cdb565b606091505b5050905080610ef2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906150c0565b60008115611dce5773ffffffffffffffffffffffffffffffffffffffff85163014611d3d57fe5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168660a0015173ffffffffffffffffffffffffffffffffffffffff161480611dc8575060a086015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b611dce57fe5b60005b8660e001515181101561206c57611de6613b35565b8760e001518281518110611df657fe5b602002602001015190503073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a109061511d565b6000856fffffffffffffffffffffffffffffffff16876fffffffffffffffffffffffffffffffff161415611ea357506020810151611ed9565b611ed6876fffffffffffffffffffffffffffffffff16876fffffffffffffffffffffffffffffffff168460200151612bf9565b90505b80611ee5575050612064565b8415611efc578151611ef79082611c6d565b611f10565b611f108960a0015189846000015184611b6e565b6040820151511561205557815160009073ffffffffffffffffffffffffffffffffffffffff166330787dd187611f4a578b60a00151611f60565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b8486604001516040518463ffffffff1660e01b8152600401611f8493929190614a11565b602060405180830381600087803b158015611f9e57600080fd5b505af1158015611fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd691906142f6565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f30787dd10000000000000000000000000000000000000000000000000000000014612053576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614f4c565b505b61205f8482612c17565b935050505b600101611dd1565b5095945050505050565b60607fcc7617254e6a41fba90a903927c0528c50be1de6f67462ac6cad28a99b1fdf728383604051602401611685929190615453565b60607f035a4cad8d6eddf7c418e1bf06082335925e99c1e1c08596b45ea79896833d73838360405160240161168592919061498d565b6121626120ee88611712565b876040518060c0016040528060016fffffffffffffffffffffffffffffffff16815260200189815260200188151581526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff16815260200185815250612c3a565b507f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af87600001518860200151858a608001518b60a001518c60c001518d61010001518c60006040516121bc99989796959493929190614c42565b60405180910390a150505050505050565b6001825160018111156121dc57fe5b14612213576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615063565b6101408201515161224157816101200151811461223c5761223c61048e828461012001516130a7565b610aff565b60005b82610140015151811015610ef25761225a613b6c565b836101400151828151811061226b57fe5b60200260200101519050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614156122b45750612395565b805161010085015160208301516040517f1395c0f300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90931692631395c0f392612317929091889190600401614a11565b60006040518083038186803b15801561232f57600080fd5b505afa925050508015612340575060015b612393573d80801561236e576040519150601f19603f3d011682016040523d82523d6000602084013e612373565b606091505b5061239161048e8360000151876101000151878660200151866130dd565b505b505b600101612244565b60006123a7613ae3565b6123b08561171e565b90506123be858583336117a3565b80606001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff1611156124075761240761048e826060015185600001516131a1565b80518351612416918791611a1e565b80604001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161415612456578460c001519150612494565b61249183600001516fffffffffffffffffffffffffffffffff1682604001516fffffffffffffffffffffffffffffffff168760c001516131d7565b91505b6124c585610100015186602001513388610120015187600001516fffffffffffffffffffffffffffffffff166131fb565b60208301516040840151511561263f573330141561250f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615234565b815160408086015190517ff2b45c6f0000000000000000000000000000000000000000000000000000000081524792600092339263f2b45c6f92612557929091600401614ae0565b602060405180830381600087803b15801561257157600080fd5b505af1158015612585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a991906142f6565b90506125bf6125b84784612a95565b8490612c17565b92507fffffffff0000000000000000000000000000000000000000000000000000000081167ff2b45c6f000000000000000000000000000000000000000000000000000000001461263c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614db2565b50505b60a086015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561269d57612683866020015184611c6d565b61269886856000015184604001518685613211565b612822565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168660a0015173ffffffffffffffffffffffffffffffffffffffff1614156127f6578281106127c6577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561276457600080fd5b505af1158015612778573d6000803e3d6000fd5b50505050506127ac7f0000000000000000000000000000000000000000000000000000000000000000876020015185613244565b6127c186856000015184604001518685613211565b612698565b6127da8660a0015133886020015186611b6e565b6127f08633866000015185604001516000611d16565b50612822565b61280a8660a0015133886020015186611b6e565b6128208633866000015185604001516000611d16565b505b50509392505050565b6040517f6eb224cb0000000000000000000000000000000000000000000000000000000081523090636eb224cb906128899084907f000000000000000000000000000000000000000000000000000000000000000090600401614b44565b600060405180830381600087803b1580156128a357600080fd5b505af1158015611142573d6000803e3d6000fd5b6000806128c883610140015161331e565b905060006128d98460e00151613550565b905060208410156128e657fe5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08401805160e08601805161014090970180517f2de32b2b090da7d8ab83ca4c85ba2eb6957bc7f6c50cb4ae1995e87560d808ed855294825294855261018083209190925294905290525090565b60007f00000000000000000000000000000000000000000000000000000000000000008260405160200161298992919061492e565b604051602081830303815290604052805190602001209050919050565b600160ff82161b806129b6611642565b73ffffffffffffffffffffffffffffffffffffffff90941660009081526020948552604080822060089590951c825293909452919092208054909117905550565b600482516004811115612a0657fe5b1415612a47576000612a16611642565b6000858152600191909101602052604090205460ff16905080612a4157612a4161048e83600061372a565b50610ef2565b6000612a538484613760565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146118a7576118a761048e838361372a565b600082821115612aae57612aae61048e600285856138b1565b50900390565b60607ff066156ec319f3a42c58bb7c010e11f5c3620c829e5770398578cb4afa69970f8383604051602401611685929190615453565b6000608082600a811115612afa57fe5b600101901b92915050565b60607f95d9ecc19fc066a15ea87d62b14d6e6f74032bbb37cecf6f42cb5ae9e2b29820838360405160240161168592919061498d565b60607f03174b9cc303cd904c8eab3eb42c9a7f59293ef5eceb9fe1c27da0778ad16138848484604051602401612b7393929190614a46565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b6000612c0f83612c0986856138d0565b90613901565b949350505050565b600082820183811015612c3357612c3361048e600086866138b1565b9392505050565b6000612c44613ae3565b612c4d8561171e565b9050612c64858583866060015187602001516118ad565b80606001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161115612cad57612cad61048e826060015185600001516131a1565b80518351612cbc918791611a1e565b80604001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161415612cfc578460c001519150612d3a565b612d3783600001516fffffffffffffffffffffffffffffffff1682604001516fffffffffffffffffffffffffffffffff168760c00151612bf9565b91505b826040015115612eb3577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168560a0015173ffffffffffffffffffffffffffffffffffffffff1614612dcc57612dcc61048e8660a001517f00000000000000000000000000000000000000000000000000000000000000006120ac565b612dfc7f000000000000000000000000000000000000000000000000000000000000000086602001513085611b6e565b6040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90612e6e908590600401614ad7565b600060405180830381600087803b158015612e8857600080fd5b505af1158015612e9c573d6000803e3d6000fd5b50505050612eae836060015183611c6d565b612ecb565b612ecb8560a001518660200151856060015185611b6e565b60a0830151511561305957606083015173ffffffffffffffffffffffffffffffffffffffff16301415612f2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906151d7565b6060830151815160a08501516040517ff2b45c6f00000000000000000000000000000000000000000000000000000000815260009373ffffffffffffffffffffffffffffffffffffffff169263f2b45c6f92612f8892600401614ae0565b602060405180830381600087803b158015612fa257600080fd5b505af1158015612fb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fda91906142f6565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167ff2b45c6f0000000000000000000000000000000000000000000000000000000014613057576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615006565b505b61308d85610100015184608001518760200151866020015187600001516fffffffffffffffffffffffffffffffff166131fb565b612822858660200151856000015184604001516000611d16565b60607f3a0e82ab33a6ded59a82e996d14f78373afacfa934ad72bb76427beb2c8abd408383604051602401611685929190615453565b60607f409690f4d9f5014a9e8b0bc8995bfa0621e9da9daa9cd07a7c17d83cd3c4b59686868686866040516024016131199594939291906149b4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905095945050505050565b60607f4a5879850ad3b01848624d9559668b5a30a921c62ed2e7c3301591f9e7899a7683836040516024016116859291906153d3565b6000612c0f83612c096131eb826001612a95565b6131f588876138d0565b90612c17565b8060011461320557fe5b61114285858585611a82565b6000613221863087876001611d16565b905061322d8382612c17565b925081831115611b6657611b6661048e8484612ab4565b73ffffffffffffffffffffffffffffffffffffffff8316301415613294576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615291565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152816024820152602081604483600073ffffffffffffffffffffffffffffffffffffffff89165af13d60018351146020821015168115178216915081611b6657806000843e8083fd5b805160009080613350577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470915061354a565b806001141561344e57613361613b6c565b8360008151811061336e57fe5b60200260200101519050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161480156133bb5750602081015151155b156133e8577f720ee400a9024f6a49768142c339bf09d2dd9056ab52d20fbe7165faba6e142d9250613448565b602080820151805190820120604080517f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e88152845173ffffffffffffffffffffffffffffffffffffffff1681850152908101919091526060812081522092505b5061354a565b60608167ffffffffffffffff8111801561346757600080fd5b50604051908082528060200260200182016040528015613491578160200160208202803683370190505b50905060005b8281101561353e577f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e88582815181106134cc57fe5b6020026020010151600001518683815181106134e457fe5b6020026020010151602001518051906020012060405160200161350993929190615427565b6040516020818303038152906040528051906020012082828151811061352b57fe5b6020908102919091010152600101613497565b50602082810291012091505b50919050565b805160009080613582577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470915061354a565b806001141561362157613593613b35565b836000815181106135a057fe5b60200260200101519050600081604001518051906020012090506040517fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e941158152825173ffffffffffffffffffffffffffffffffffffffff1660208201526020830151604082015281606082015260808120815260208120945050505061354a565b60608167ffffffffffffffff8111801561363a57600080fd5b50604051908082528060200260200182016040528015613664578160200160208202803683370190505b50905060005b8281101561353e577fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e9411585828151811061369f57fe5b6020026020010151600001518683815181106136b757fe5b6020026020010151602001518784815181106136cf57fe5b602002602001015160400151805190602001206040516020016136f594939291906153f6565b6040516020818303038152906040528051906020012082828151811061371757fe5b602090810291909101015260010161366a565b60607f84356db366796dc6e2aeb1ad74b631fe4e5ec6a650464da6059e9f95c8810a10838360405160240161168592919061498d565b600061376c838361392b565b60028251600481111561377b57fe5b14156137e357600183836020015184604001518560600151604051600081526020016040526040516137b09493929190614af9565b6020604051602081039080840390855afa1580156137d2573d6000803e3d6000fd5b505050602060405103519050613888565b6003825160048111156137f257fe5b14156138885760007f19457468657265756d205369676e6564204d6573736167653a0a33320000000060005283601c52603c6000209050600181846020015185604001518660600151604051600081526020016040526040516138589493929190614af9565b6020604051602081039080840390855afa15801561387a573d6000803e3d6000fd5b505050602060405103519150505b73ffffffffffffffffffffffffffffffffffffffff811661040e5761040e61048e6005856139fa565b606063e946c1bb60e01b848484604051602401612b7393929190614b8c565b6000826138df5750600061040e565b828202828482816138ec57fe5b0414612c3357612c3361048e600186866138b1565b6000816139175761391761048e600385856138b1565b600082848161392257fe5b04949350505050565b60408101517ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141111580613982575060608101517f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a111155b156139955761399561048e6005846139fa565b6000815160048111156139a457fe5b14156139b8576139b861048e6003846139fa565b6001815160048111156139c757fe5b14156139db576139db61048e6000846139fa565b6004815160048111156139ea57fe5b1415610aff57610aff61048e6002845b60607ff18f11f3027e735c758137924b262d4d3aff0037dcd785aca3c699fa05d960bd8383604051602401611685929190614bc0565b6040805161016081019091528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160608152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b604080516080810190915260008082526020820190815260006020820181905260409091015290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b60408051808201909152600081526060602082015290565b803561040e816154e1565b600082601f830112613b9f578081fd5b8135613bb2613bad82615488565b615461565b818152915060208083019084810160005b84811015613bec57613bda888484358a0101613ea6565b84529282019290820190600101613bc3565b505050505092915050565b600082601f830112613c07578081fd5b8135613c15613bad82615488565b818152915060208083019084810160005b84811015613bec57813587016060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215613c6557600080fd5b613c6e81615461565b613c7a8b878501613b84565b815260408381013587830152918301359167ffffffffffffffff831115613ca057600080fd5b613cae8c8885870101613e10565b90820152865250509282019290820190600101613c26565b600082601f830112613cd6578081fd5b8135613ce4613bad82615488565b818152915060208083019084810160005b84811015613bec57813587016040807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215613d3457600080fd5b613d3d81615461565b85830135613d4a816154e1565b8152908201359067ffffffffffffffff821115613d6657600080fd5b613d748b8784860101613e10565b81870152865250509282019290820190600101613cf5565b600082601f830112613d9c578081fd5b8135613daa613bad82615488565b8181529150602080830190848101608080850287018301881015613dcd57600080fd5b60005b85811015613df457613de28984613fa2565b85529383019391810191600101613dd0565b50505050505092915050565b8035801515811461040e57600080fd5b600082601f830112613e20578081fd5b813567ffffffffffffffff811115613e36578182fd5b613e6760207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601615461565b9150808252836020828501011115613e7e57600080fd5b8060208401602084013760009082016020015292915050565b80356002811061040e57600080fd5b6000610160808385031215613eb9578182fd5b613ec281615461565b915050613ecf8383613e97565b8152613ede8360208401613b84565b6020820152613ef08360408401613b84565b60408201526060820135606082015260808201356080820152613f168360a08401613b84565b60a082015260c082013560c082015260e082013567ffffffffffffffff80821115613f4057600080fd5b613f4c85838601613bf7565b60e08401526101009150613f6285838601613b84565b828401526101209150818401358284015261014091508184013581811115613f8957600080fd5b613f9586828701613cc6565b8385015250505092915050565b600060808284031215613fb3578081fd5b613fbd6080615461565b9050813560058110613fce57600080fd5b8152602082013560ff81168114613fe457600080fd5b80602083015250604082013560408201526060820135606082015292915050565b60008060008060006080868803121561401c578081fd5b8535614027816154e1565b94506020860135614037816154e1565b935060408601359250606086013567ffffffffffffffff8082111561405a578283fd5b818801915088601f83011261406d578283fd5b81358181111561407b578384fd5b89602082850101111561408c578384fd5b9699959850939650602001949392505050565b600080604083850312156140b1578182fd5b82356140bc816154e1565b915060208301357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146140ef578182fd5b809150509250929050565b6000806000806080858703121561410f578182fd5b843567ffffffffffffffff80821115614126578384fd5b61413288838901613b8f565b95506020870135915080821115614147578384fd5b61415388838901613b8f565b94506040870135915080821115614168578384fd5b61417488838901613d8c565b93506060870135915080821115614189578283fd5b5061419687828801613d8c565b91505092959194509250565b600080600080608085870312156141b7578182fd5b843567ffffffffffffffff808211156141ce578384fd5b6141da88838901613b8f565b95506020915081870135818111156141f0578485fd5b6141fc89828a01613d8c565b955050604087013581811115614210578485fd5b87019050601f81018813614222578384fd5b8035614230613bad82615488565b81815283810190838501875b84811015614265576142538d888435890101613e10565b8452928601929086019060010161423c565b5050809650505050505061427c8660608701613e00565b905092959194509250565b60008060208385031215614299578182fd5b823567ffffffffffffffff808211156142b0578384fd5b818501915085601f8301126142c3578384fd5b8135818111156142d1578485fd5b86602080830285010111156142e4578485fd5b60209290920196919550909350505050565b600060208284031215614307578081fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114612c33578182fd5b600060208284031215614347578081fd5b813567ffffffffffffffff81111561435d578182fd5b612c0f84828501613ea6565b600080600080610140858703121561437f578182fd5b843567ffffffffffffffff80821115614396578384fd5b6143a288838901613ea6565b955060208701359150808211156143b7578384fd5b506143c487828801613ea6565b9350506143d48660408701613fa2565b915061427c8660c08701613fa2565b60008060a083850312156143f5578182fd5b823567ffffffffffffffff81111561440b578283fd5b61441785828601613ea6565b9250506144278460208501613fa2565b90509250929050565b600080600060c08486031215614444578081fd5b833567ffffffffffffffff81111561445a578182fd5b61446686828701613ea6565b9350506144768560208601613fa2565b915060a084013561448681615503565b809150509250925092565b600080600060c084860312156144a5578081fd5b833567ffffffffffffffff808211156144bc578283fd5b6144c887838801613ea6565b94506144d78760208801613fa2565b935060a08601359150808211156144ec578283fd5b506144f986828701613e10565b9150509250925092565b6000806000806000610100868803121561451b578283fd5b853567ffffffffffffffff80821115614532578485fd5b61453e89838a01613ea6565b965061454d8960208a01613fa2565b955060a0880135945060c0880135915061456682615503565b90925060e0870135908082111561457b578283fd5b5061458888828901613e10565b9150509295509295909350565b60008060008060e085870312156145aa578182fd5b843567ffffffffffffffff808211156145c1578384fd5b6145cd88838901613ea6565b95506145dc8860208901613fa2565b945060a0870135935060c08701359150808211156145f8578283fd5b5061419687828801613e10565b60008060408385031215614617578182fd5b823567ffffffffffffffff81111561462d578283fd5b61463985828601613ea6565b95602094909401359450505050565b600060208284031215614659578081fd5b5035919050565b600060208284031215614671578081fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208085019450808401835b838110156146c35781511515875295820195908201906001016146a5565b509495945050505050565b6000815180845260208085018081965082840281019150828601855b8581101561474a5782840389528151805173ffffffffffffffffffffffffffffffffffffffff1685528581015186860152604090810151606091860182905290614736818701836147c7565b9a87019a95505050908401906001016146ea565b5091979650505050505050565b6000815180845260208085018081965082840281019150828601855b8581101561474a5782840389528151805173ffffffffffffffffffffffffffffffffffffffff16855285015160408686018190526147b3818701836147c7565b9a87019a9550505090840190600101614773565b600081518084526147df8160208601602086016154a8565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6002811061481b57fe5b9052565b600061016061482f848451614811565b60208301516148416020860182614678565b5060408301516148546040860182614678565b50606083015160608501526080830151608085015260a083015161487b60a0860182614678565b5060c083015160c085015260e08301518160e086015261489d828601826146ce565b915050610100808401516148b382870182614678565b5050610120838101519085015261014080840151858303828701526148d88382614757565b9695505050505050565b8051600581106148ee57fe5b825260208181015160ff169083015260408082015190830152606090810151910152565b600082516149248184602087016154a8565b9190910192915050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b90565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015260a060608301526149f360a08301856147c7565b8281036080840152614a0581856147c7565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff85168252836020830152606060408301526109b460608301846147c7565b73ffffffffffffffffffffffffffffffffffffffff939093168352602083019190915260ff16604082015260600190565b600060208252612c336020830184614692565b604080825283519082018190526000906020906060840190828701845b82811015614ac357815184529284019290840190600101614aa7565b505050838103828501526148d88186614692565b90815260200190565b600083825260406020830152612c0f60408301846147c7565b93845260ff9290921660208401526040830152606082015260800190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000092909216825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60608101614b99856154d4565b938152602081019290925260409091015290565b60208101614bba836154d4565b91905290565b6040810160068410614bce57fe5b9281526020015290565b6101208101614be7828c614811565b73ffffffffffffffffffffffffffffffffffffffff998a16602083015297891660408201526060810196909652938716608086015260a0850192909252851660c084015260e083015290921661010090920191909152919050565b610120810160028b10614c5157fe5b99815273ffffffffffffffffffffffffffffffffffffffff988916602082015296881660408801526060870195909552928616608086015260a0850191909152841660c084015260e08301529091166101009091015290565b6000610160614cb9838f614811565b73ffffffffffffffffffffffffffffffffffffffff808e166020850152808d1660408501528b60608501528a6080850152808a1660a08501528860c08501528160e0850152614d0a828501896146ce565b91508087166101008501525084610120840152828103610140840152614d308185614757565b9e9d5050505050505050505050505050565b600060208252612c3360208301846147c7565b6020808252603a908201527f4552433732314f7264657273466561747572653a3a626174636842757945524360408201527f373231732f41525241595f4c454e4754485f4d49534d41544348000000000000606082015260800190565b60208082526022908201527f4e46544f72646572733a3a5f6275794e46542f43414c4c4241434b5f4641494c60408201527f4544000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526041908201527f4552433732314f7264657273466561747572653a3a62617463684d617463684560408201527f52433732314f72646572732f41525241595f4c454e4754485f4d49534d41544360608201527f4800000000000000000000000000000000000000000000000000000000000000608082015260a00190565b60208082526035908201527f4e46544f72646572733a3a5f76616c69646174654275794f726465722f4e415460408201527f4956455f544f4b454e5f4e4f545f414c4c4f5745440000000000000000000000606082015260800190565b60208082526032908201527f4552433732314f7264657273466561747572653a3a7072655369676e4552433760408201527f32314f726465722f4f4e4c595f4d414b45520000000000000000000000000000606082015260800190565b60208082526023908201527f4e46544f72646572733a3a5f706179466565732f43414c4c4241434b5f46414960408201527f4c45440000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f4e46544f72646572733a3a5f76616c69646174654275794f726465722f57524f60408201527f4e475f54524144455f444952454354494f4e0000000000000000000000000000606082015260800190565b60208082526023908201527f4e46544f72646572733a3a5f73656c6c4e46542f43414c4c4241434b5f46414960408201527f4c45440000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526039908201527f4e46544f72646572733a3a5f76616c69646174654f7264657250726f7065727460408201527f6965732f57524f4e475f54524144455f444952454354494f4e00000000000000606082015260800190565b6020808252602f908201527f466978696e546f6b656e5370656e6465723a3a5f7472616e736665724574682f60408201527f5452414e534645525f4641494c45440000000000000000000000000000000000606082015260800190565b60208082526036908201527f4e46544f72646572733a3a5f706179466565732f524543495049454e545f434160408201527f4e4e4f545f42455f45584348414e47455f50524f585900000000000000000000606082015260800190565b60208082526033908201527f4e46544f72646572733a3a5f76616c696461746553656c6c4f726465722f575260408201527f4f4e475f54524144455f444952454354494f4e00000000000000000000000000606082015260800190565b60208082526028908201527f4e46544f72646572733a3a5f73656c6c4e46542f43414e4e4f545f43414c4c4260408201527f41434b5f53454c46000000000000000000000000000000000000000000000000606082015260800190565b60208082526027908201527f4e46544f72646572733a3a5f6275794e46542f43414e4e4f545f43414c4c424160408201527f434b5f53454c4600000000000000000000000000000000000000000000000000606082015260800190565b60208082526024908201527f466978696e546f6b656e5370656e6465722f43414e4e4f545f494e564f4b455f60408201527f53454c4600000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f466978696e4552433732315370656e6465722f43414e4e4f545f494e564f4b4560408201527f5f53454c46000000000000000000000000000000000000000000000000000000606082015260800190565b600061014080835261535f8184018861481f565b90508281036020840152615373818761481f565b91505061538360408301856148e2565b6109b460c08301846148e2565b600060e082526153a360e083018761481f565b6153b060208401876148e2565b8460a084015282810360c08401526153c881856147c7565b979650505050505050565b6fffffffffffffffffffffffffffffffff92831681529116602082015260400190565b93845273ffffffffffffffffffffffffffffffffffffffff9290921660208401526040830152606082015260800190565b92835273ffffffffffffffffffffffffffffffffffffffff919091166020830152604082015260600190565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561548057600080fd5b604052919050565b600067ffffffffffffffff82111561549e578081fd5b5060209081020190565b60005b838110156154c35781810151838201526020016154ab565b838111156118a75750506000910152565b600481106154de57fe5b50565b73ffffffffffffffffffffffffffffffffffffffff811681146154de57600080fd5b80151581146154de57600080fdfea264697066735822122099f8a2da1f8a86b0d4dfa29321d8a27a9886210b24f5b5550c75c2429215ca3364736f6c634300060c0033000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x6080604052600436106101445760003560e01c806386219940116100c0578063d1ca183b11610074578063eae93ee711610059578063eae93ee714610350578063fbc4a51814610370578063fbee349d1461039d57610144565b8063d1ca183b1461031b578063dab400f31461033b57610144565b8063afde1b3c116100a5578063afde1b3c146102bb578063b73a6027146102db578063be167b9d146102fb57610144565b806386219940146102865780638fd3ab80146102a657610144565b8063462103af1161011757806360018b41116100fc57806360018b41146102235780636ae4b4f7146102365780637da9e2cf1461025857610144565b8063462103af146101e15780634a13d7971461020357610144565b8063030b273014610149578063031b905c1461017f5780630d8261eb14610194578063150b7a02146101b4575b600080fd5b34801561015557600080fd5b5061016961016436600461409f565b6103b0565b6040516101769190614ad7565b60405180910390f35b34801561018b57600080fd5b50610169610414565b3480156101a057600080fd5b506101696101af366004614369565b610438565b3480156101c057600080fd5b506101d46101cf366004614005565b6108f9565b6040516101769190614b17565b3480156101ed57600080fd5b506102016101fc366004614336565b6109bd565b005b34801561020f57600080fd5b5061020161021e366004614605565b610aed565b610201610231366004614595565b610b03565b34801561024257600080fd5b5061024b610bb0565b6040516101769190614d42565b34801561026457600080fd5b506102786102733660046140fa565b610be9565b604051610176929190614a8a565b34801561029257600080fd5b506102016102a1366004614287565b610ec4565b3480156102b257600080fd5b506101d4610ef7565b3480156102c757600080fd5b506102016102d6366004614503565b611133565b3480156102e757600080fd5b506101696102f6366004614336565b611149565b34801561030757600080fd5b50610201610316366004614648565b611164565b34801561032757600080fd5b506102016103363660046143e3565b6111aa565b34801561034757600080fd5b506101696111c6565b61036361035e3660046141a2565b6111ea565b6040516101769190614a77565b34801561037c57600080fd5b5061039061038b366004614336565b6114ea565b6040516101769190614bad565b6102016103ab366004614491565b611602565b6000806103bb611642565b73ffffffffffffffffffffffffffffffffffffffff85166000908152602091825260408082207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8716835290925220549150505b92915050565b7f000000000000000000000000000000000000000000000001000000000000000081565b600083610100015173ffffffffffffffffffffffffffffffffffffffff1685610100015173ffffffffffffffffffffffffffffffffffffffff16146104935761049361048e86610100015186610100015161164f565b61170a565b61049b613a30565b6104a486611712565b90506104ae613a30565b6104b786611712565b90506104c1613ae3565b6104ca8361171e565b90506104d4613ae3565b6104dd8361171e565b90506104ef8488848b602001516117a3565b6105058387838c602001518d61012001516118ad565b6105158483600001516001611a1e565b6105258382600001516001611a1e565b50508660c001518660c00151101561054c5761054c61048e8860c001518860c00151611a4c565b60008760c001518760c00151039050610579886101000151896020015189602001518b6101200151611a82565b60a088015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14801561060557507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168760a0015173ffffffffffffffffffffffffffffffffffffffff16145b1561074f5761063e7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28860200151308a60c00151611b6e565b60c08701516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21691632e1a7d4d916106b49190600401614ad7565b600060405180830381600087803b1580156106ce57600080fd5b505af11580156106e2573d6000803e3d6000fd5b505050506106f888602001518960c00151611c6d565b61070b8288602001516001806000611d16565b50600061071d84306001806001611d16565b9050808210156107345761073461048e8284612076565b80820394508415610749576107493386611c6d565b5061081c565b8660a0015173ffffffffffffffffffffffffffffffffffffffff168860a0015173ffffffffffffffffffffffffffffffffffffffff161461079f5761079f61048e8960a001518960a001516120ac565b6107bb8760a0015188602001518a602001518b60c00151611b6e565b6107ce8288602001516001806000611d16565b5060006107e48489602001516001806000611d16565b9050808210156107fb576107fb61048e8284612076565b8082039450841561081a5761081a8860a0015189602001513388611b6e565b505b7f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af8860000151896020015189602001518b608001518c60a001518d60c001518e61010001518f61012001513360405161087d99989796959493929190614c42565b60405180910390a17f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af876000015188602001518a602001518a608001518b60a001518c60c001518d61010001518f6101200151336040516108e699989796959493929190614c42565b60405180910390a1505050949350505050565b6000610903613a30565b61090b613b0c565b600061091985870187614430565b92509250925082610100015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109695761096961048e3385610100015161164f565b60408051600081526020810190915261098d90849084908a9085908e9030906120e2565b507f150b7a0200000000000000000000000000000000000000000000000000000000925050505b95945050505050565b602081015173ffffffffffffffffffffffffffffffffffffffff163314610a19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614eef565b60405180910390fd5b6000610a2482611149565b90506001610a30611642565b6000838152600191909101602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001693151593909317909255835191840151848201516060860151608087015160a088015160c089015160e08a01516101008b01516101208c01516101408d015199517f8c5d0c41fb16a7317a6c55ff7ba93d9d74f79e434fefa694e50d6028afbfa3f09b610ae19b909a999897969594939291614caa565b60405180910390a15050565b610aff610af983611712565b826121cd565b5050565b610b43610b0f85611712565b84604051806060016040528060016fffffffffffffffffffffffffffffffff1681526020018681526020018581525061239d565b507f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af846000015185602001513387608001518860a001518960c001518a61010001518b61012001516000604051610ba299989796959493929190614bd8565b60405180910390a150505050565b6040518060400160405280600c81526020017f4552433732314f7264657273000000000000000000000000000000000000000081525081565b60608084518651148015610bfe575082518451145b8015610c0b575083518651145b610c41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614e0f565b855167ffffffffffffffff81118015610c5957600080fd5b50604051908082528060200260200182016040528015610c83578160200160208202803683370190505b509150855167ffffffffffffffff81118015610c9e57600080fd5b50604051908082528060200260200182016040528015610cc8578160200160208202803683370190505b50905060005b8651811015610eba5760607f0000000000000000000000004af649ffde640ceb34b1afaba3e0bb8e9698cb0173ffffffffffffffffffffffffffffffffffffffff16630d8261eb60e01b898481518110610d2457fe5b6020026020010151898581518110610d3857fe5b6020026020010151898681518110610d4c57fe5b6020026020010151898781518110610d6057fe5b6020026020010151604051602401610d7b949392919061534b565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610e049190614912565b600060405180830381855af49150503d8060008114610e3f576040519150601f19603f3d011682016040523d82523d6000602084013e610e44565b606091505b50848481518110610e5157fe5b6020026020010181935082151515158152505050828281518110610e7157fe5b602002602001015115610eb157600081806020019051810190610e949190614660565b905080858481518110610ea357fe5b602002602001018181525050505b50600101610cce565b5094509492505050565b60005b81811015610ef257610eea838383818110610ede57fe5b90506020020135611164565b600101610ec7565b505050565b6000610f227fafde1b3c0000000000000000000000000000000000000000000000000000000061282b565b610f4b7ffbee349d0000000000000000000000000000000000000000000000000000000061282b565b610f747fbe167b9d0000000000000000000000000000000000000000000000000000000061282b565b610f9d7feae93ee70000000000000000000000000000000000000000000000000000000061282b565b610fc67f0d8261eb0000000000000000000000000000000000000000000000000000000061282b565b610fef7f7da9e2cf0000000000000000000000000000000000000000000000000000000061282b565b6110187f150b7a020000000000000000000000000000000000000000000000000000000061282b565b6110417f462103af0000000000000000000000000000000000000000000000000000000061282b565b61106a7fd1ca183b0000000000000000000000000000000000000000000000000000000061282b565b6110937f4a13d7970000000000000000000000000000000000000000000000000000000061282b565b6110bc7ffbc4a5180000000000000000000000000000000000000000000000000000000061282b565b6110e57fb73a60270000000000000000000000000000000000000000000000000000000061282b565b61110e7f030b27300000000000000000000000000000000000000000000000000000000061282b565b507f2c64c5ef0000000000000000000000000000000000000000000000000000000090565b611142858585853333876120e2565b5050505050565b600061115c611157836128b7565b612954565b90505b919050565b61116e33826129a6565b7fa015ad2dc32f266993958a0fd9884c746b971b254206f3478bc43e2f125c7b9e338260405161119f929190614967565b60405180910390a150565b60006111b583611149565b9050610ef2818385602001516129f7565b7ffe3a8808ff7909b8c36164e6e9a076597c21c3fc2ec6f2c8ac04529c41ce507e81565b6060835185511480156111fe575082518551145b611234576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614d55565b845167ffffffffffffffff8111801561124c57600080fd5b50604051908082528060200260200182016040528015611276578160200160208202803683370190505b50905060006112854734612a95565b9050821561131c5760005b8651811015611316576112f08782815181106112a857fe5b60200260200101518783815181106112bc57fe5b60200260200101516112d78547612a9590919063ffffffff16565b8885815181106112e357fe5b6020026020010151610b03565b60018382815181106112fe57fe5b91151560209283029190910190910152600101611290565b506114ba565b60005b86518110156114b8577f0000000000000000000000004af649ffde640ceb34b1afaba3e0bb8e9698cb0173ffffffffffffffffffffffffffffffffffffffff166360018b4160e01b88838151811061137357fe5b602002602001015188848151811061138757fe5b60200260200101516113a28647612a9590919063ffffffff16565b8986815181106113ae57fe5b60200260200101516040516024016113c99493929190615390565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516114529190614912565b600060405180830381855af49150503d806000811461148d576040519150601f19603f3d011682016040523d82523d6000602084013e611492565b606091505b50508382815181106114a057fe5b9115156020928302919091019091015260010161131f565b505b47818110156114d4576114d461048e828403340134612ab4565b6114e033838303611c6d565b5050949350505050565b6000808261014001515111801561151c575060018251600181111561150b57fe5b14158061151c575061012082015115155b156115295750600061115f565b60018251600181111561153857fe5b148015611572575060a082015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b1561157f5750600061115f565b428260600151116115925750600361115f565b600061159c611642565b60208085015173ffffffffffffffffffffffffffffffffffffffff166000908152828252604080822060808801805160081c84529352902054905191925090600160ff9091161b808216156115f7576002935050505061115f565b506001949350505050565b600061160e4734612a95565b905061161c84843485610b03565b47818110156116365761163661048e828403340134612ab4565b61114233838303611c6d565b60008061040e6009612aea565b60607f21916d9c05d4d89fb4c8db2934603a48c5480a95f94dfd3a2cd9ac40b8615d15838360405160240161168592919061498d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b805160208201fd5b61171a613a30565b5090565b611726613ae3565b61172e613a30565b61173783611712565b905061174281611149565b825261174d816114ea565b8260200190600381111561175d57fe5b9081600381111561176a57fe5b9052506001604083018190528260200151600381111561178657fe5b14611792576000611795565b60015b60ff16606083015250919050565b6000845160018111156117b257fe5b146117e9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a109061517a565b604084015173ffffffffffffffffffffffffffffffffffffffff161580159061184257508073ffffffffffffffffffffffffffffffffffffffff16846040015173ffffffffffffffffffffffffffffffffffffffff1614155b156118585761185861048e828660400151612b05565b60018260200151600381111561186a57fe5b146118945761189461048e856020015186608001518560200151600381111561188f57fe5b612b3b565b6118a782600001518486602001516129f7565b50505050565b6001855160018111156118bc57fe5b146118f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614fa9565b60a085015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561195b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614e92565b604085015173ffffffffffffffffffffffffffffffffffffffff16158015906119b457508173ffffffffffffffffffffffffffffffffffffffff16856040015173ffffffffffffffffffffffffffffffffffffffff1614155b156119ca576119ca61048e838760400151612b05565b6001836020015160038111156119dc57fe5b14611a0157611a0161048e866020015187608001518660200151600381111561188f57fe5b611a0b85826121cd565b61114283600001518587602001516129f7565b806fffffffffffffffffffffffffffffffff16600114611a3a57fe5b610ef2836020015184608001516129a6565b60607f2c837d7451f39ae9868ea7dacec7847412534d287da737ffde01c3c8b2f61c0a8383604051602401611685929190615453565b73ffffffffffffffffffffffffffffffffffffffff8416301415611ad2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906152ee565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152600080606483600073ffffffffffffffffffffffffffffffffffffffff8a165af180611b66573d806000843e8083fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff8416301415611bbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615291565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152602081606483600073ffffffffffffffffffffffffffffffffffffffff8a165af13d60018351146020821015168115178216915081611c6457806000843e8083fd5b50505050505050565b8015610aff5760008273ffffffffffffffffffffffffffffffffffffffff1682604051611c9990614964565b60006040518083038185875af1925050503d8060008114611cd6576040519150601f19603f3d011682016040523d82523d6000602084013e611cdb565b606091505b5050905080610ef2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906150c0565b60008115611dce5773ffffffffffffffffffffffffffffffffffffffff85163014611d3d57fe5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168660a0015173ffffffffffffffffffffffffffffffffffffffff161480611dc8575060a086015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b611dce57fe5b60005b8660e001515181101561206c57611de6613b35565b8760e001518281518110611df657fe5b602002602001015190503073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a109061511d565b6000856fffffffffffffffffffffffffffffffff16876fffffffffffffffffffffffffffffffff161415611ea357506020810151611ed9565b611ed6876fffffffffffffffffffffffffffffffff16876fffffffffffffffffffffffffffffffff168460200151612bf9565b90505b80611ee5575050612064565b8415611efc578151611ef79082611c6d565b611f10565b611f108960a0015189846000015184611b6e565b6040820151511561205557815160009073ffffffffffffffffffffffffffffffffffffffff166330787dd187611f4a578b60a00151611f60565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee5b8486604001516040518463ffffffff1660e01b8152600401611f8493929190614a11565b602060405180830381600087803b158015611f9e57600080fd5b505af1158015611fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd691906142f6565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f30787dd10000000000000000000000000000000000000000000000000000000014612053576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614f4c565b505b61205f8482612c17565b935050505b600101611dd1565b5095945050505050565b60607fcc7617254e6a41fba90a903927c0528c50be1de6f67462ac6cad28a99b1fdf728383604051602401611685929190615453565b60607f035a4cad8d6eddf7c418e1bf06082335925e99c1e1c08596b45ea79896833d73838360405160240161168592919061498d565b6121626120ee88611712565b876040518060c0016040528060016fffffffffffffffffffffffffffffffff16815260200189815260200188151581526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff16815260200185815250612c3a565b507f50273fa02273cceea9cf085b42de5c8af60624140168bd71357db833535877af87600001518860200151858a608001518b60a001518c60c001518d61010001518c60006040516121bc99989796959493929190614c42565b60405180910390a150505050505050565b6001825160018111156121dc57fe5b14612213576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615063565b6101408201515161224157816101200151811461223c5761223c61048e828461012001516130a7565b610aff565b60005b82610140015151811015610ef25761225a613b6c565b836101400151828151811061226b57fe5b60200260200101519050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614156122b45750612395565b805161010085015160208301516040517f1395c0f300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90931692631395c0f392612317929091889190600401614a11565b60006040518083038186803b15801561232f57600080fd5b505afa925050508015612340575060015b612393573d80801561236e576040519150601f19603f3d011682016040523d82523d6000602084013e612373565b606091505b5061239161048e8360000151876101000151878660200151866130dd565b505b505b600101612244565b60006123a7613ae3565b6123b08561171e565b90506123be858583336117a3565b80606001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff1611156124075761240761048e826060015185600001516131a1565b80518351612416918791611a1e565b80604001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161415612456578460c001519150612494565b61249183600001516fffffffffffffffffffffffffffffffff1682604001516fffffffffffffffffffffffffffffffff168760c001516131d7565b91505b6124c585610100015186602001513388610120015187600001516fffffffffffffffffffffffffffffffff166131fb565b60208301516040840151511561263f573330141561250f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615234565b815160408086015190517ff2b45c6f0000000000000000000000000000000000000000000000000000000081524792600092339263f2b45c6f92612557929091600401614ae0565b602060405180830381600087803b15801561257157600080fd5b505af1158015612585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a991906142f6565b90506125bf6125b84784612a95565b8490612c17565b92507fffffffff0000000000000000000000000000000000000000000000000000000081167ff2b45c6f000000000000000000000000000000000000000000000000000000001461263c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090614db2565b50505b60a086015173ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561269d57612683866020015184611c6d565b61269886856000015184604001518685613211565b612822565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168660a0015173ffffffffffffffffffffffffffffffffffffffff1614156127f6578281106127c6577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561276457600080fd5b505af1158015612778573d6000803e3d6000fd5b50505050506127ac7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2876020015185613244565b6127c186856000015184604001518685613211565b612698565b6127da8660a0015133886020015186611b6e565b6127f08633866000015185604001516000611d16565b50612822565b61280a8660a0015133886020015186611b6e565b6128208633866000015185604001516000611d16565b505b50509392505050565b6040517f6eb224cb0000000000000000000000000000000000000000000000000000000081523090636eb224cb906128899084907f0000000000000000000000004af649ffde640ceb34b1afaba3e0bb8e9698cb0190600401614b44565b600060405180830381600087803b1580156128a357600080fd5b505af1158015611142573d6000803e3d6000fd5b6000806128c883610140015161331e565b905060006128d98460e00151613550565b905060208410156128e657fe5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08401805160e08601805161014090970180517f2de32b2b090da7d8ab83ca4c85ba2eb6957bc7f6c50cb4ae1995e87560d808ed855294825294855261018083209190925294905290525090565b60007ffe3a8808ff7909b8c36164e6e9a076597c21c3fc2ec6f2c8ac04529c41ce507e8260405160200161298992919061492e565b604051602081830303815290604052805190602001209050919050565b600160ff82161b806129b6611642565b73ffffffffffffffffffffffffffffffffffffffff90941660009081526020948552604080822060089590951c825293909452919092208054909117905550565b600482516004811115612a0657fe5b1415612a47576000612a16611642565b6000858152600191909101602052604090205460ff16905080612a4157612a4161048e83600061372a565b50610ef2565b6000612a538484613760565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146118a7576118a761048e838361372a565b600082821115612aae57612aae61048e600285856138b1565b50900390565b60607ff066156ec319f3a42c58bb7c010e11f5c3620c829e5770398578cb4afa69970f8383604051602401611685929190615453565b6000608082600a811115612afa57fe5b600101901b92915050565b60607f95d9ecc19fc066a15ea87d62b14d6e6f74032bbb37cecf6f42cb5ae9e2b29820838360405160240161168592919061498d565b60607f03174b9cc303cd904c8eab3eb42c9a7f59293ef5eceb9fe1c27da0778ad16138848484604051602401612b7393929190614a46565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b6000612c0f83612c0986856138d0565b90613901565b949350505050565b600082820183811015612c3357612c3361048e600086866138b1565b9392505050565b6000612c44613ae3565b612c4d8561171e565b9050612c64858583866060015187602001516118ad565b80606001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161115612cad57612cad61048e826060015185600001516131a1565b80518351612cbc918791611a1e565b80604001516fffffffffffffffffffffffffffffffff1683600001516fffffffffffffffffffffffffffffffff161415612cfc578460c001519150612d3a565b612d3783600001516fffffffffffffffffffffffffffffffff1682604001516fffffffffffffffffffffffffffffffff168760c00151612bf9565b91505b826040015115612eb3577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168560a0015173ffffffffffffffffffffffffffffffffffffffff1614612dcc57612dcc61048e8660a001517f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26120ac565b612dfc7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc286602001513085611b6e565b6040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d90612e6e908590600401614ad7565b600060405180830381600087803b158015612e8857600080fd5b505af1158015612e9c573d6000803e3d6000fd5b50505050612eae836060015183611c6d565b612ecb565b612ecb8560a001518660200151856060015185611b6e565b60a0830151511561305957606083015173ffffffffffffffffffffffffffffffffffffffff16301415612f2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a10906151d7565b6060830151815160a08501516040517ff2b45c6f00000000000000000000000000000000000000000000000000000000815260009373ffffffffffffffffffffffffffffffffffffffff169263f2b45c6f92612f8892600401614ae0565b602060405180830381600087803b158015612fa257600080fd5b505af1158015612fb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fda91906142f6565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167ff2b45c6f0000000000000000000000000000000000000000000000000000000014613057576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615006565b505b61308d85610100015184608001518760200151866020015187600001516fffffffffffffffffffffffffffffffff166131fb565b612822858660200151856000015184604001516000611d16565b60607f3a0e82ab33a6ded59a82e996d14f78373afacfa934ad72bb76427beb2c8abd408383604051602401611685929190615453565b60607f409690f4d9f5014a9e8b0bc8995bfa0621e9da9daa9cd07a7c17d83cd3c4b59686868686866040516024016131199594939291906149b4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905095945050505050565b60607f4a5879850ad3b01848624d9559668b5a30a921c62ed2e7c3301591f9e7899a7683836040516024016116859291906153d3565b6000612c0f83612c096131eb826001612a95565b6131f588876138d0565b90612c17565b8060011461320557fe5b61114285858585611a82565b6000613221863087876001611d16565b905061322d8382612c17565b925081831115611b6657611b6661048e8484612ab4565b73ffffffffffffffffffffffffffffffffffffffff8316301415613294576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1090615291565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152816024820152602081604483600073ffffffffffffffffffffffffffffffffffffffff89165af13d60018351146020821015168115178216915081611b6657806000843e8083fd5b805160009080613350577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470915061354a565b806001141561344e57613361613b6c565b8360008151811061336e57fe5b60200260200101519050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161480156133bb5750602081015151155b156133e8577f720ee400a9024f6a49768142c339bf09d2dd9056ab52d20fbe7165faba6e142d9250613448565b602080820151805190820120604080517f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e88152845173ffffffffffffffffffffffffffffffffffffffff1681850152908101919091526060812081522092505b5061354a565b60608167ffffffffffffffff8111801561346757600080fd5b50604051908082528060200260200182016040528015613491578160200160208202803683370190505b50905060005b8281101561353e577f6292cf854241cb36887e639065eca63b3af9f7f70270cebeda4c29b6d3bc65e88582815181106134cc57fe5b6020026020010151600001518683815181106134e457fe5b6020026020010151602001518051906020012060405160200161350993929190615427565b6040516020818303038152906040528051906020012082828151811061352b57fe5b6020908102919091010152600101613497565b50602082810291012091505b50919050565b805160009080613582577fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470915061354a565b806001141561362157613593613b35565b836000815181106135a057fe5b60200260200101519050600081604001518051906020012090506040517fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e941158152825173ffffffffffffffffffffffffffffffffffffffff1660208201526020830151604082015281606082015260808120815260208120945050505061354a565b60608167ffffffffffffffff8111801561363a57600080fd5b50604051908082528060200260200182016040528015613664578160200160208202803683370190505b50905060005b8281101561353e577fe68c29f1b4e8cce0bbcac76eb1334bdc1dc1f293a517c90e9e532340e1e9411585828151811061369f57fe5b6020026020010151600001518683815181106136b757fe5b6020026020010151602001518784815181106136cf57fe5b602002602001015160400151805190602001206040516020016136f594939291906153f6565b6040516020818303038152906040528051906020012082828151811061371757fe5b602090810291909101015260010161366a565b60607f84356db366796dc6e2aeb1ad74b631fe4e5ec6a650464da6059e9f95c8810a10838360405160240161168592919061498d565b600061376c838361392b565b60028251600481111561377b57fe5b14156137e357600183836020015184604001518560600151604051600081526020016040526040516137b09493929190614af9565b6020604051602081039080840390855afa1580156137d2573d6000803e3d6000fd5b505050602060405103519050613888565b6003825160048111156137f257fe5b14156138885760007f19457468657265756d205369676e6564204d6573736167653a0a33320000000060005283601c52603c6000209050600181846020015185604001518660600151604051600081526020016040526040516138589493929190614af9565b6020604051602081039080840390855afa15801561387a573d6000803e3d6000fd5b505050602060405103519150505b73ffffffffffffffffffffffffffffffffffffffff811661040e5761040e61048e6005856139fa565b606063e946c1bb60e01b848484604051602401612b7393929190614b8c565b6000826138df5750600061040e565b828202828482816138ec57fe5b0414612c3357612c3361048e600186866138b1565b6000816139175761391761048e600385856138b1565b600082848161392257fe5b04949350505050565b60408101517ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141111580613982575060608101517f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a111155b156139955761399561048e6005846139fa565b6000815160048111156139a457fe5b14156139b8576139b861048e6003846139fa565b6001815160048111156139c757fe5b14156139db576139db61048e6000846139fa565b6004815160048111156139ea57fe5b1415610aff57610aff61048e6002845b60607ff18f11f3027e735c758137924b262d4d3aff0037dcd785aca3c699fa05d960bd8383604051602401611685929190614bc0565b6040805161016081019091528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160608152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b604080516080810190915260008082526020820190815260006020820181905260409091015290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b60408051808201909152600081526060602082015290565b803561040e816154e1565b600082601f830112613b9f578081fd5b8135613bb2613bad82615488565b615461565b818152915060208083019084810160005b84811015613bec57613bda888484358a0101613ea6565b84529282019290820190600101613bc3565b505050505092915050565b600082601f830112613c07578081fd5b8135613c15613bad82615488565b818152915060208083019084810160005b84811015613bec57813587016060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215613c6557600080fd5b613c6e81615461565b613c7a8b878501613b84565b815260408381013587830152918301359167ffffffffffffffff831115613ca057600080fd5b613cae8c8885870101613e10565b90820152865250509282019290820190600101613c26565b600082601f830112613cd6578081fd5b8135613ce4613bad82615488565b818152915060208083019084810160005b84811015613bec57813587016040807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215613d3457600080fd5b613d3d81615461565b85830135613d4a816154e1565b8152908201359067ffffffffffffffff821115613d6657600080fd5b613d748b8784860101613e10565b81870152865250509282019290820190600101613cf5565b600082601f830112613d9c578081fd5b8135613daa613bad82615488565b8181529150602080830190848101608080850287018301881015613dcd57600080fd5b60005b85811015613df457613de28984613fa2565b85529383019391810191600101613dd0565b50505050505092915050565b8035801515811461040e57600080fd5b600082601f830112613e20578081fd5b813567ffffffffffffffff811115613e36578182fd5b613e6760207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601615461565b9150808252836020828501011115613e7e57600080fd5b8060208401602084013760009082016020015292915050565b80356002811061040e57600080fd5b6000610160808385031215613eb9578182fd5b613ec281615461565b915050613ecf8383613e97565b8152613ede8360208401613b84565b6020820152613ef08360408401613b84565b60408201526060820135606082015260808201356080820152613f168360a08401613b84565b60a082015260c082013560c082015260e082013567ffffffffffffffff80821115613f4057600080fd5b613f4c85838601613bf7565b60e08401526101009150613f6285838601613b84565b828401526101209150818401358284015261014091508184013581811115613f8957600080fd5b613f9586828701613cc6565b8385015250505092915050565b600060808284031215613fb3578081fd5b613fbd6080615461565b9050813560058110613fce57600080fd5b8152602082013560ff81168114613fe457600080fd5b80602083015250604082013560408201526060820135606082015292915050565b60008060008060006080868803121561401c578081fd5b8535614027816154e1565b94506020860135614037816154e1565b935060408601359250606086013567ffffffffffffffff8082111561405a578283fd5b818801915088601f83011261406d578283fd5b81358181111561407b578384fd5b89602082850101111561408c578384fd5b9699959850939650602001949392505050565b600080604083850312156140b1578182fd5b82356140bc816154e1565b915060208301357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146140ef578182fd5b809150509250929050565b6000806000806080858703121561410f578182fd5b843567ffffffffffffffff80821115614126578384fd5b61413288838901613b8f565b95506020870135915080821115614147578384fd5b61415388838901613b8f565b94506040870135915080821115614168578384fd5b61417488838901613d8c565b93506060870135915080821115614189578283fd5b5061419687828801613d8c565b91505092959194509250565b600080600080608085870312156141b7578182fd5b843567ffffffffffffffff808211156141ce578384fd5b6141da88838901613b8f565b95506020915081870135818111156141f0578485fd5b6141fc89828a01613d8c565b955050604087013581811115614210578485fd5b87019050601f81018813614222578384fd5b8035614230613bad82615488565b81815283810190838501875b84811015614265576142538d888435890101613e10565b8452928601929086019060010161423c565b5050809650505050505061427c8660608701613e00565b905092959194509250565b60008060208385031215614299578182fd5b823567ffffffffffffffff808211156142b0578384fd5b818501915085601f8301126142c3578384fd5b8135818111156142d1578485fd5b86602080830285010111156142e4578485fd5b60209290920196919550909350505050565b600060208284031215614307578081fd5b81517fffffffff0000000000000000000000000000000000000000000000000000000081168114612c33578182fd5b600060208284031215614347578081fd5b813567ffffffffffffffff81111561435d578182fd5b612c0f84828501613ea6565b600080600080610140858703121561437f578182fd5b843567ffffffffffffffff80821115614396578384fd5b6143a288838901613ea6565b955060208701359150808211156143b7578384fd5b506143c487828801613ea6565b9350506143d48660408701613fa2565b915061427c8660c08701613fa2565b60008060a083850312156143f5578182fd5b823567ffffffffffffffff81111561440b578283fd5b61441785828601613ea6565b9250506144278460208501613fa2565b90509250929050565b600080600060c08486031215614444578081fd5b833567ffffffffffffffff81111561445a578182fd5b61446686828701613ea6565b9350506144768560208601613fa2565b915060a084013561448681615503565b809150509250925092565b600080600060c084860312156144a5578081fd5b833567ffffffffffffffff808211156144bc578283fd5b6144c887838801613ea6565b94506144d78760208801613fa2565b935060a08601359150808211156144ec578283fd5b506144f986828701613e10565b9150509250925092565b6000806000806000610100868803121561451b578283fd5b853567ffffffffffffffff80821115614532578485fd5b61453e89838a01613ea6565b965061454d8960208a01613fa2565b955060a0880135945060c0880135915061456682615503565b90925060e0870135908082111561457b578283fd5b5061458888828901613e10565b9150509295509295909350565b60008060008060e085870312156145aa578182fd5b843567ffffffffffffffff808211156145c1578384fd5b6145cd88838901613ea6565b95506145dc8860208901613fa2565b945060a0870135935060c08701359150808211156145f8578283fd5b5061419687828801613e10565b60008060408385031215614617578182fd5b823567ffffffffffffffff81111561462d578283fd5b61463985828601613ea6565b95602094909401359450505050565b600060208284031215614659578081fd5b5035919050565b600060208284031215614671578081fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208085019450808401835b838110156146c35781511515875295820195908201906001016146a5565b509495945050505050565b6000815180845260208085018081965082840281019150828601855b8581101561474a5782840389528151805173ffffffffffffffffffffffffffffffffffffffff1685528581015186860152604090810151606091860182905290614736818701836147c7565b9a87019a95505050908401906001016146ea565b5091979650505050505050565b6000815180845260208085018081965082840281019150828601855b8581101561474a5782840389528151805173ffffffffffffffffffffffffffffffffffffffff16855285015160408686018190526147b3818701836147c7565b9a87019a9550505090840190600101614773565b600081518084526147df8160208601602086016154a8565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6002811061481b57fe5b9052565b600061016061482f848451614811565b60208301516148416020860182614678565b5060408301516148546040860182614678565b50606083015160608501526080830151608085015260a083015161487b60a0860182614678565b5060c083015160c085015260e08301518160e086015261489d828601826146ce565b915050610100808401516148b382870182614678565b5050610120838101519085015261014080840151858303828701526148d88382614757565b9695505050505050565b8051600581106148ee57fe5b825260208181015160ff169083015260408082015190830152606090810151910152565b600082516149248184602087016154a8565b9190910192915050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b90565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525084604083015260a060608301526149f360a08301856147c7565b8281036080840152614a0581856147c7565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff85168252836020830152606060408301526109b460608301846147c7565b73ffffffffffffffffffffffffffffffffffffffff939093168352602083019190915260ff16604082015260600190565b600060208252612c336020830184614692565b604080825283519082018190526000906020906060840190828701845b82811015614ac357815184529284019290840190600101614aa7565b505050838103828501526148d88186614692565b90815260200190565b600083825260406020830152612c0f60408301846147c7565b93845260ff9290921660208401526040830152606082015260800190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000092909216825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60608101614b99856154d4565b938152602081019290925260409091015290565b60208101614bba836154d4565b91905290565b6040810160068410614bce57fe5b9281526020015290565b6101208101614be7828c614811565b73ffffffffffffffffffffffffffffffffffffffff998a16602083015297891660408201526060810196909652938716608086015260a0850192909252851660c084015260e083015290921661010090920191909152919050565b610120810160028b10614c5157fe5b99815273ffffffffffffffffffffffffffffffffffffffff988916602082015296881660408801526060870195909552928616608086015260a0850191909152841660c084015260e08301529091166101009091015290565b6000610160614cb9838f614811565b73ffffffffffffffffffffffffffffffffffffffff808e166020850152808d1660408501528b60608501528a6080850152808a1660a08501528860c08501528160e0850152614d0a828501896146ce565b91508087166101008501525084610120840152828103610140840152614d308185614757565b9e9d5050505050505050505050505050565b600060208252612c3360208301846147c7565b6020808252603a908201527f4552433732314f7264657273466561747572653a3a626174636842757945524360408201527f373231732f41525241595f4c454e4754485f4d49534d41544348000000000000606082015260800190565b60208082526022908201527f4e46544f72646572733a3a5f6275794e46542f43414c4c4241434b5f4641494c60408201527f4544000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526041908201527f4552433732314f7264657273466561747572653a3a62617463684d617463684560408201527f52433732314f72646572732f41525241595f4c454e4754485f4d49534d41544360608201527f4800000000000000000000000000000000000000000000000000000000000000608082015260a00190565b60208082526035908201527f4e46544f72646572733a3a5f76616c69646174654275794f726465722f4e415460408201527f4956455f544f4b454e5f4e4f545f414c4c4f5745440000000000000000000000606082015260800190565b60208082526032908201527f4552433732314f7264657273466561747572653a3a7072655369676e4552433760408201527f32314f726465722f4f4e4c595f4d414b45520000000000000000000000000000606082015260800190565b60208082526023908201527f4e46544f72646572733a3a5f706179466565732f43414c4c4241434b5f46414960408201527f4c45440000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f4e46544f72646572733a3a5f76616c69646174654275794f726465722f57524f60408201527f4e475f54524144455f444952454354494f4e0000000000000000000000000000606082015260800190565b60208082526023908201527f4e46544f72646572733a3a5f73656c6c4e46542f43414c4c4241434b5f46414960408201527f4c45440000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526039908201527f4e46544f72646572733a3a5f76616c69646174654f7264657250726f7065727460408201527f6965732f57524f4e475f54524144455f444952454354494f4e00000000000000606082015260800190565b6020808252602f908201527f466978696e546f6b656e5370656e6465723a3a5f7472616e736665724574682f60408201527f5452414e534645525f4641494c45440000000000000000000000000000000000606082015260800190565b60208082526036908201527f4e46544f72646572733a3a5f706179466565732f524543495049454e545f434160408201527f4e4e4f545f42455f45584348414e47455f50524f585900000000000000000000606082015260800190565b60208082526033908201527f4e46544f72646572733a3a5f76616c696461746553656c6c4f726465722f575260408201527f4f4e475f54524144455f444952454354494f4e00000000000000000000000000606082015260800190565b60208082526028908201527f4e46544f72646572733a3a5f73656c6c4e46542f43414e4e4f545f43414c4c4260408201527f41434b5f53454c46000000000000000000000000000000000000000000000000606082015260800190565b60208082526027908201527f4e46544f72646572733a3a5f6275794e46542f43414e4e4f545f43414c4c424160408201527f434b5f53454c4600000000000000000000000000000000000000000000000000606082015260800190565b60208082526024908201527f466978696e546f6b656e5370656e6465722f43414e4e4f545f494e564f4b455f60408201527f53454c4600000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f466978696e4552433732315370656e6465722f43414e4e4f545f494e564f4b4560408201527f5f53454c46000000000000000000000000000000000000000000000000000000606082015260800190565b600061014080835261535f8184018861481f565b90508281036020840152615373818761481f565b91505061538360408301856148e2565b6109b460c08301846148e2565b600060e082526153a360e083018761481f565b6153b060208401876148e2565b8460a084015282810360c08401526153c881856147c7565b979650505050505050565b6fffffffffffffffffffffffffffffffff92831681529116602082015260400190565b93845273ffffffffffffffffffffffffffffffffffffffff9290921660208401526040830152606082015260800190565b92835273ffffffffffffffffffffffffffffffffffffffff919091166020830152604082015260600190565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561548057600080fd5b604052919050565b600067ffffffffffffffff82111561549e578081fd5b5060209081020190565b60005b838110156154c35781810151838201526020016154ab565b838111156118a75750506000910152565b600481106154de57fe5b50565b73ffffffffffffffffffffffffffffffffffffffff811681146154de57600080fd5b80151581146154de57600080fdfea264697066735822122099f8a2da1f8a86b0d4dfa29321d8a27a9886210b24f5b5550c75c2429215ca3364736f6c634300060c0033

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

000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

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

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff
Arg [1] : 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.