ETH Price: $2,920.04 (-2.82%)
Gas: 1 Gwei

Contract

0x5A66a1bE5de85e770d2A7AaC6d1d30e39D4f6609
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x61010060131430462021-09-02 0:32:581040 days ago1630542778IN
 Create: MetaTransactionsFeature
0 ETH0.2115237985.69781334

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MetaTransactionsFeature

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
istanbul EvmVersion, Apache-2.0 license
File 1 of 33 : MetaTransactionsFeature.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 "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../errors/LibMetaTransactionsRichErrors.sol";
import "../fixins/FixinCommon.sol";
import "../fixins/FixinReentrancyGuard.sol";
import "../fixins/FixinTokenSpender.sol";
import "../fixins/FixinEIP712.sol";
import "../migrations/LibMigrate.sol";
import "../storage/LibMetaTransactionsStorage.sol";
import "./interfaces/IFeature.sol";
import "./interfaces/IMetaTransactionsFeature.sol";
import "./interfaces/INativeOrdersFeature.sol";
import "./interfaces/ITransformERC20Feature.sol";
import "./libs/LibSignature.sol";

/// @dev MetaTransactions feature.
contract MetaTransactionsFeature is
    IFeature,
    IMetaTransactionsFeature,
    FixinCommon,
    FixinReentrancyGuard,
    FixinEIP712,
    FixinTokenSpender
{
    using LibBytesV06 for bytes;
    using LibRichErrorsV06 for bytes;

    /// @dev Describes the state of a meta transaction.
    struct ExecuteState {
        // Sender of the meta-transaction.
        address sender;
        // Hash of the meta-transaction data.
        bytes32 hash;
        // The meta-transaction data.
        MetaTransactionData mtx;
        // The meta-transaction signature (by `mtx.signer`).
        LibSignature.Signature signature;
        // The selector of the function being called.
        bytes4 selector;
        // The ETH balance of this contract before performing the call.
        uint256 selfBalance;
        // The block number at which the meta-transaction was executed.
        uint256 executedBlockNumber;
    }

    /// @dev Arguments for a `TransformERC20.transformERC20()` call.
    struct ExternalTransformERC20Args {
        IERC20TokenV06 inputToken;
        IERC20TokenV06 outputToken;
        uint256 inputTokenAmount;
        uint256 minOutputTokenAmount;
        ITransformERC20Feature.Transformation[] transformations;
    }

    /// @dev Name of this feature.
    string public constant override FEATURE_NAME = "MetaTransactions";
    /// @dev Version of this feature.
    uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 2, 0);
    /// @dev EIP712 typehash of the `MetaTransactionData` struct.
    bytes32 public immutable MTX_EIP712_TYPEHASH = keccak256(
        "MetaTransactionData("
            "address signer,"
            "address sender,"
            "uint256 minGasPrice,"
            "uint256 maxGasPrice,"
            "uint256 expirationTimeSeconds,"
            "uint256 salt,"
            "bytes callData,"
            "uint256 value,"
            "address feeToken,"
            "uint256 feeAmount"
        ")"
    );

    /// @dev Refunds up to `msg.value` leftover ETH at the end of the call.
    modifier refundsAttachedEth() {
        _;
        uint256 remainingBalance =
            LibSafeMathV06.min256(msg.value, address(this).balance);
        if (remainingBalance > 0) {
            msg.sender.transfer(remainingBalance);
        }
    }

    constructor(address zeroExAddress)
        public
        FixinCommon()
        FixinEIP712(zeroExAddress)
    {
        // solhint-disable-next-line no-empty-blocks
    }

    /// @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.executeMetaTransaction.selector);
        _registerFeatureFunction(this.batchExecuteMetaTransactions.selector);
        _registerFeatureFunction(this.getMetaTransactionExecutedBlock.selector);
        _registerFeatureFunction(this.getMetaTransactionHashExecutedBlock.selector);
        _registerFeatureFunction(this.getMetaTransactionHash.selector);
        return LibMigrate.MIGRATE_SUCCESS;
    }

    /// @dev Execute a single meta-transaction.
    /// @param mtx The meta-transaction.
    /// @param signature The signature by `mtx.signer`.
    /// @return returnResult The ABI-encoded result of the underlying call.
    function executeMetaTransaction(
        MetaTransactionData memory mtx,
        LibSignature.Signature memory signature
    )
        public
        payable
        override
        nonReentrant(REENTRANCY_MTX)
        refundsAttachedEth
        returns (bytes memory returnResult)
    {
        ExecuteState memory state;
        state.sender = msg.sender;
        state.mtx = mtx;
        state.hash = getMetaTransactionHash(mtx);
        state.signature = signature;

        returnResult = _executeMetaTransactionPrivate(state);
    }

    /// @dev Execute multiple meta-transactions.
    /// @param mtxs The meta-transactions.
    /// @param signatures The signature by each respective `mtx.signer`.
    /// @return returnResults The ABI-encoded results of the underlying calls.
    function batchExecuteMetaTransactions(
        MetaTransactionData[] memory mtxs,
        LibSignature.Signature[] memory signatures
    )
        public
        payable
        override
        nonReentrant(REENTRANCY_MTX)
        refundsAttachedEth
        returns (bytes[] memory returnResults)
    {
        if (mtxs.length != signatures.length) {
            LibMetaTransactionsRichErrors.InvalidMetaTransactionsArrayLengthsError(
                mtxs.length,
                signatures.length
            ).rrevert();
        }
        returnResults = new bytes[](mtxs.length);
        for (uint256 i = 0; i < mtxs.length; ++i) {
            ExecuteState memory state;
            state.sender = msg.sender;
            state.mtx = mtxs[i];
            state.hash = getMetaTransactionHash(mtxs[i]);
            state.signature = signatures[i];

            returnResults[i] = _executeMetaTransactionPrivate(state);
        }
    }

    /// @dev Get the block at which a meta-transaction has been executed.
    /// @param mtx The meta-transaction.
    /// @return blockNumber The block height when the meta-transactioin was executed.
    function getMetaTransactionExecutedBlock(MetaTransactionData memory mtx)
        public
        override
        view
        returns (uint256 blockNumber)
    {
        return getMetaTransactionHashExecutedBlock(getMetaTransactionHash(mtx));
    }

    /// @dev Get the block at which a meta-transaction hash has been executed.
    /// @param mtxHash The meta-transaction hash.
    /// @return blockNumber The block height when the meta-transactioin was executed.
    function getMetaTransactionHashExecutedBlock(bytes32 mtxHash)
        public
        override
        view
        returns (uint256 blockNumber)
    {
        return LibMetaTransactionsStorage.getStorage().mtxHashToExecutedBlockNumber[mtxHash];
    }

    /// @dev Get the EIP712 hash of a meta-transaction.
    /// @param mtx The meta-transaction.
    /// @return mtxHash The EIP712 hash of `mtx`.
    function getMetaTransactionHash(MetaTransactionData memory mtx)
        public
        override
        view
        returns (bytes32 mtxHash)
    {
        return _getEIP712Hash(keccak256(abi.encode(
            MTX_EIP712_TYPEHASH,
            mtx.signer,
            mtx.sender,
            mtx.minGasPrice,
            mtx.maxGasPrice,
            mtx.expirationTimeSeconds,
            mtx.salt,
            keccak256(mtx.callData),
            mtx.value,
            mtx.feeToken,
            mtx.feeAmount
        )));
    }

    /// @dev Execute a meta-transaction by `sender`. Low-level, hidden variant.
    /// @param state The `ExecuteState` for this metatransaction, with `sender`,
    ///              `hash`, `mtx`, and `signature` fields filled.
    /// @return returnResult The ABI-encoded result of the underlying call.
    function _executeMetaTransactionPrivate(ExecuteState memory state)
        private
        returns (bytes memory returnResult)
    {
        _validateMetaTransaction(state);

        // Mark the transaction executed by storing the block at which it was executed.
        // Currently the block number just indicates that the mtx was executed and
        // serves no other purpose from within this contract.
        LibMetaTransactionsStorage.getStorage()
            .mtxHashToExecutedBlockNumber[state.hash] = block.number;

        // Pay the fee to the sender.
        if (state.mtx.feeAmount > 0) {
            _transferERC20TokensFrom(
                state.mtx.feeToken,
                state.mtx.signer,
                state.sender,
                state.mtx.feeAmount
            );
        }

        // Execute the call based on the selector.
        state.selector = state.mtx.callData.readBytes4(0);
        if (state.selector == ITransformERC20Feature.transformERC20.selector) {
            returnResult = _executeTransformERC20Call(state);
        } else if (state.selector == INativeOrdersFeature.fillLimitOrder.selector) {
            returnResult = _executeFillLimitOrderCall(state);
        } else if (state.selector == INativeOrdersFeature.fillRfqOrder.selector) {
            returnResult = _executeFillRfqOrderCall(state);
        } else {
            LibMetaTransactionsRichErrors
                .MetaTransactionUnsupportedFunctionError(state.hash, state.selector)
                .rrevert();
        }
        emit MetaTransactionExecuted(
            state.hash,
            state.selector,
            state.mtx.signer,
            state.mtx.sender
        );
    }

    /// @dev Validate that a meta-transaction is executable.
    function _validateMetaTransaction(ExecuteState memory state)
        private
        view
    {
        // Must be from the required sender, if set.
        if (state.mtx.sender != address(0) && state.mtx.sender != state.sender) {
            LibMetaTransactionsRichErrors
                .MetaTransactionWrongSenderError(
                    state.hash,
                    state.sender,
                    state.mtx.sender
                ).rrevert();
        }
        // Must not be expired.
        if (state.mtx.expirationTimeSeconds <= block.timestamp) {
            LibMetaTransactionsRichErrors
                .MetaTransactionExpiredError(
                    state.hash,
                    block.timestamp,
                    state.mtx.expirationTimeSeconds
                ).rrevert();
        }
        // Must have a valid gas price.
        if (state.mtx.minGasPrice > tx.gasprice || state.mtx.maxGasPrice < tx.gasprice) {
            LibMetaTransactionsRichErrors
                .MetaTransactionGasPriceError(
                    state.hash,
                    tx.gasprice,
                    state.mtx.minGasPrice,
                    state.mtx.maxGasPrice
                ).rrevert();
        }
        // Must have enough ETH.
        state.selfBalance  = address(this).balance;
        if (state.mtx.value > state.selfBalance) {
            LibMetaTransactionsRichErrors
                .MetaTransactionInsufficientEthError(
                    state.hash,
                    state.selfBalance,
                    state.mtx.value
                ).rrevert();
        }

        if (LibSignature.getSignerOfHash(state.hash, state.signature) !=
                state.mtx.signer) {
            LibSignatureRichErrors.SignatureValidationError(
                LibSignatureRichErrors.SignatureValidationErrorCodes.WRONG_SIGNER,
                state.hash,
                state.mtx.signer,
                // TODO: Remove this field from SignatureValidationError
                //       when rich reverts are part of the protocol repo.
                ""
            ).rrevert();
        }
        // Transaction must not have been already executed.
        state.executedBlockNumber = LibMetaTransactionsStorage
            .getStorage().mtxHashToExecutedBlockNumber[state.hash];
        if (state.executedBlockNumber != 0) {
            LibMetaTransactionsRichErrors
                .MetaTransactionAlreadyExecutedError(
                    state.hash,
                    state.executedBlockNumber
                ).rrevert();
        }
    }

    /// @dev Execute a `ITransformERC20Feature.transformERC20()` meta-transaction call
    ///      by decoding the call args and translating the call to the internal
    ///      `ITransformERC20Feature._transformERC20()` variant, where we can override
    ///      the taker address.
    function _executeTransformERC20Call(ExecuteState memory state)
        private
        returns (bytes memory returnResult)
    {
        // HACK(dorothy-zbornak): `abi.decode()` with the individual args
        // will cause a stack overflow. But we can prefix the call data with an
        // offset to transform it into the encoding for the equivalent single struct arg,
        // since decoding a single struct arg consumes far less stack space than
        // decoding multiple struct args.

        // Where the encoding for multiple args (with the selector ommitted)
        // would typically look like:
        // | argument                 |  offset |
        // |--------------------------|---------|
        // | inputToken               |       0 |
        // | outputToken              |      32 |
        // | inputTokenAmount         |      64 |
        // | minOutputTokenAmount     |      96 |
        // | transformations (offset) |     128 | = 32
        // | transformations (data)   |     160 |

        // We will ABI-decode a single struct arg copy with the layout:
        // | argument                 |  offset |
        // |--------------------------|---------|
        // | (arg 1 offset)           |       0 | = 32
        // | inputToken               |      32 |
        // | outputToken              |      64 |
        // | inputTokenAmount         |      96 |
        // | minOutputTokenAmount     |     128 |
        // | transformations (offset) |     160 | = 32
        // | transformations (data)   |     192 |

        ExternalTransformERC20Args memory args;
        {
            bytes memory encodedStructArgs = new bytes(state.mtx.callData.length - 4 + 32);
            // Copy the args data from the original, after the new struct offset prefix.
            bytes memory fromCallData = state.mtx.callData;
            assert(fromCallData.length >= 160);
            uint256 fromMem;
            uint256 toMem;
            assembly {
                // Prefix the calldata with a struct offset,
                // which points to just one word over.
                mstore(add(encodedStructArgs, 32), 32)
                // Copy everything after the selector.
                fromMem := add(fromCallData, 36)
                // Start copying after the struct offset.
                toMem := add(encodedStructArgs, 64)
            }
            LibBytesV06.memCopy(toMem, fromMem, fromCallData.length - 4);
            // Decode call args for `ITransformERC20Feature.transformERC20()` as a struct.
            args = abi.decode(encodedStructArgs, (ExternalTransformERC20Args));
        }
        // Call `ITransformERC20Feature._transformERC20()` (internal variant).
        return _callSelf(
            state.hash,
            abi.encodeWithSelector(
                ITransformERC20Feature._transformERC20.selector,
                ITransformERC20Feature.TransformERC20Args({
                    taker: state.mtx.signer, // taker is mtx signer
                    inputToken: args.inputToken,
                    outputToken: args.outputToken,
                    inputTokenAmount: args.inputTokenAmount,
                    minOutputTokenAmount: args.minOutputTokenAmount,
                    transformations: args.transformations,
                    useSelfBalance: false,
                    recipient: state.mtx.signer
              })
            ),
            state.mtx.value
        );
    }

    /// @dev Extract arguments from call data by copying everything after the
    ///      4-byte selector into a new byte array.
    /// @param callData The call data from which arguments are to be extracted.
    /// @return args The extracted arguments as a byte array.
    function _extractArgumentsFromCallData(
        bytes memory callData
    )
        private
        pure
        returns (bytes memory args)
    {
        args = new bytes(callData.length - 4);
        uint256 fromMem;
        uint256 toMem;

        assembly {
            fromMem := add(callData, 36) // skip length and 4-byte selector
            toMem := add(args, 32)       // write after length prefix
        }

        LibBytesV06.memCopy(toMem, fromMem, args.length);

        return args;
    }

    /// @dev Execute a `INativeOrdersFeature.fillLimitOrder()` meta-transaction call
    ///      by decoding the call args and translating the call to the internal
    ///      `INativeOrdersFeature._fillLimitOrder()` variant, where we can override
    ///      the taker address.
    function _executeFillLimitOrderCall(ExecuteState memory state)
        private
        returns (bytes memory returnResult)
    {
        LibNativeOrder.LimitOrder memory order;
        LibSignature.Signature memory signature;
        uint128 takerTokenFillAmount;

        bytes memory args = _extractArgumentsFromCallData(state.mtx.callData);
        (order, signature, takerTokenFillAmount) = abi.decode(args, (LibNativeOrder.LimitOrder, LibSignature.Signature, uint128));

        return _callSelf(
            state.hash,
            abi.encodeWithSelector(
                INativeOrdersFeature._fillLimitOrder.selector,
                order,
                signature,
                takerTokenFillAmount,
                state.mtx.signer, // taker is mtx signer
                msg.sender
            ),
            state.mtx.value
        );
    }

    /// @dev Execute a `INativeOrdersFeature.fillRfqOrder()` meta-transaction call
    ///      by decoding the call args and translating the call to the internal
    ///      `INativeOrdersFeature._fillRfqOrder()` variant, where we can overrideunimpleme
    ///      the taker address.
    function _executeFillRfqOrderCall(ExecuteState memory state)
        private
        returns (bytes memory returnResult)
    {
        LibNativeOrder.RfqOrder memory order;
        LibSignature.Signature memory signature;
        uint128 takerTokenFillAmount;

        bytes memory args = _extractArgumentsFromCallData(state.mtx.callData);
        (order, signature, takerTokenFillAmount) = abi.decode(args, (LibNativeOrder.RfqOrder, LibSignature.Signature, uint128));

        return _callSelf(
            state.hash,
            abi.encodeWithSelector(
                INativeOrdersFeature._fillRfqOrder.selector,
                order,
                signature,
                takerTokenFillAmount,
                state.mtx.signer, // taker is mtx signer
                false,
                state.mtx.signer
            ),
            state.mtx.value
        );
    }

    /// @dev Make an arbitrary internal, meta-transaction call.
    ///      Warning: Do not let unadulterated `callData` into this function.
    function _callSelf(bytes32 hash, bytes memory callData, uint256 value)
        private
        returns (bytes memory returnResult)
    {
        bool success;
        (success, returnResult) = address(this).call{value: value}(callData);
        if (!success) {
            LibMetaTransactionsRichErrors.MetaTransactionCallFailedError(
                hash,
                callData,
                returnResult
            ).rrevert();
        }
    }
}

File 2 of 33 : 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 3 of 33 : LibBytesV06.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/LibBytesRichErrorsV06.sol";
import "./errors/LibRichErrorsV06.sol";


library LibBytesV06 {

    using LibBytesV06 for bytes;

    /// @dev Gets the memory address for a byte array.
    /// @param input Byte array to lookup.
    /// @return memoryAddress Memory address of byte array. This
    ///         points to the header of the byte array which contains
    ///         the length.
    function rawAddress(bytes memory input)
        internal
        pure
        returns (uint256 memoryAddress)
    {
        assembly {
            memoryAddress := input
        }
        return memoryAddress;
    }

    /// @dev Gets the memory address for the contents of a byte array.
    /// @param input Byte array to lookup.
    /// @return memoryAddress Memory address of the contents of the byte array.
    function contentAddress(bytes memory input)
        internal
        pure
        returns (uint256 memoryAddress)
    {
        assembly {
            memoryAddress := add(input, 32)
        }
        return memoryAddress;
    }

    /// @dev Copies `length` bytes from memory location `source` to `dest`.
    /// @param dest memory address to copy bytes to.
    /// @param source memory address to copy bytes from.
    /// @param length number of bytes to copy.
    function memCopy(
        uint256 dest,
        uint256 source,
        uint256 length
    )
        internal
        pure
    {
        if (length < 32) {
            // Handle a partial word by reading destination and masking
            // off the bits we are interested in.
            // This correctly handles overlap, zero lengths and source == dest
            assembly {
                let mask := sub(exp(256, sub(32, length)), 1)
                let s := and(mload(source), not(mask))
                let d := and(mload(dest), mask)
                mstore(dest, or(s, d))
            }
        } else {
            // Skip the O(length) loop when source == dest.
            if (source == dest) {
                return;
            }

            // For large copies we copy whole words at a time. The final
            // word is aligned to the end of the range (instead of after the
            // previous) to handle partial words. So a copy will look like this:
            //
            //  ####
            //      ####
            //          ####
            //            ####
            //
            // We handle overlap in the source and destination range by
            // changing the copying direction. This prevents us from
            // overwriting parts of source that we still need to copy.
            //
            // This correctly handles source == dest
            //
            if (source > dest) {
                assembly {
                    // We subtract 32 from `sEnd` and `dEnd` because it
                    // is easier to compare with in the loop, and these
                    // are also the addresses we need for copying the
                    // last bytes.
                    length := sub(length, 32)
                    let sEnd := add(source, length)
                    let dEnd := add(dest, length)

                    // Remember the last 32 bytes of source
                    // This needs to be done here and not after the loop
                    // because we may have overwritten the last bytes in
                    // source already due to overlap.
                    let last := mload(sEnd)

                    // Copy whole words front to back
                    // Note: the first check is always true,
                    // this could have been a do-while loop.
                    // solhint-disable-next-line no-empty-blocks
                    for {} lt(source, sEnd) {} {
                        mstore(dest, mload(source))
                        source := add(source, 32)
                        dest := add(dest, 32)
                    }

                    // Write the last 32 bytes
                    mstore(dEnd, last)
                }
            } else {
                assembly {
                    // We subtract 32 from `sEnd` and `dEnd` because those
                    // are the starting points when copying a word at the end.
                    length := sub(length, 32)
                    let sEnd := add(source, length)
                    let dEnd := add(dest, length)

                    // Remember the first 32 bytes of source
                    // This needs to be done here and not after the loop
                    // because we may have overwritten the first bytes in
                    // source already due to overlap.
                    let first := mload(source)

                    // Copy whole words back to front
                    // We use a signed comparisson here to allow dEnd to become
                    // negative (happens when source and dest < 32). Valid
                    // addresses in local memory will never be larger than
                    // 2**255, so they can be safely re-interpreted as signed.
                    // Note: the first check is always true,
                    // this could have been a do-while loop.
                    // solhint-disable-next-line no-empty-blocks
                    for {} slt(dest, dEnd) {} {
                        mstore(dEnd, mload(sEnd))
                        sEnd := sub(sEnd, 32)
                        dEnd := sub(dEnd, 32)
                    }

                    // Write the first 32 bytes
                    mstore(dest, first)
                }
            }
        }
    }

    /// @dev Returns a slices from a byte array.
    /// @param b The byte array to take a slice from.
    /// @param from The starting index for the slice (inclusive).
    /// @param to The final index for the slice (exclusive).
    /// @return result The slice containing bytes at indices [from, to)
    function slice(
        bytes memory b,
        uint256 from,
        uint256 to
    )
        internal
        pure
        returns (bytes memory result)
    {
        // Ensure that the from and to positions are valid positions for a slice within
        // the byte array that is being used.
        if (from > to) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired,
                to,
                b.length
            ));
        }

        // Create a new bytes structure and copy contents
        result = new bytes(to - from);
        memCopy(
            result.contentAddress(),
            b.contentAddress() + from,
            result.length
        );
        return result;
    }

    /// @dev Returns a slice from a byte array without preserving the input.
    ///      When `from == 0`, the original array will match the slice.
    ///      In other cases its state will be corrupted.
    /// @param b The byte array to take a slice from. Will be destroyed in the process.
    /// @param from The starting index for the slice (inclusive).
    /// @param to The final index for the slice (exclusive).
    /// @return result The slice containing bytes at indices [from, to)
    function sliceDestructive(
        bytes memory b,
        uint256 from,
        uint256 to
    )
        internal
        pure
        returns (bytes memory result)
    {
        // Ensure that the from and to positions are valid positions for a slice within
        // the byte array that is being used.
        if (from > to) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired,
                to,
                b.length
            ));
        }

        // Create a new bytes structure around [from, to) in-place.
        assembly {
            result := add(b, from)
            mstore(result, sub(to, from))
        }
        return result;
    }

    /// @dev Pops the last byte off of a byte array by modifying its length.
    /// @param b Byte array that will be modified.
    /// @return result The byte that was popped off.
    function popLastByte(bytes memory b)
        internal
        pure
        returns (bytes1 result)
    {
        if (b.length == 0) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanZeroRequired,
                b.length,
                0
            ));
        }

        // Store last byte.
        result = b[b.length - 1];

        assembly {
            // Decrement length of byte array.
            let newLen := sub(mload(b), 1)
            mstore(b, newLen)
        }
        return result;
    }

    /// @dev Tests equality of two byte arrays.
    /// @param lhs First byte array to compare.
    /// @param rhs Second byte array to compare.
    /// @return equal True if arrays are the same. False otherwise.
    function equals(
        bytes memory lhs,
        bytes memory rhs
    )
        internal
        pure
        returns (bool equal)
    {
        // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare.
        // We early exit on unequal lengths, but keccak would also correctly
        // handle this.
        return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs);
    }

    /// @dev Reads an address from a position in a byte array.
    /// @param b Byte array containing an address.
    /// @param index Index in byte array of address.
    /// @return result address from byte array.
    function readAddress(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (address result)
    {
        if (b.length < index + 20) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired,
                b.length,
                index + 20 // 20 is length of address
            ));
        }

        // Add offset to index:
        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)
        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)
        index += 20;

        // Read address from array memory
        assembly {
            // 1. Add index to address of bytes array
            // 2. Load 32-byte word from memory
            // 3. Apply 20-byte mask to obtain address
            result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff)
        }
        return result;
    }

    /// @dev Writes an address into a specific position in a byte array.
    /// @param b Byte array to insert address into.
    /// @param index Index in byte array of address.
    /// @param input Address to put into byte array.
    function writeAddress(
        bytes memory b,
        uint256 index,
        address input
    )
        internal
        pure
    {
        if (b.length < index + 20) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired,
                b.length,
                index + 20 // 20 is length of address
            ));
        }

        // Add offset to index:
        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)
        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)
        index += 20;

        // Store address into array memory
        assembly {
            // The address occupies 20 bytes and mstore stores 32 bytes.
            // First fetch the 32-byte word where we'll be storing the address, then
            // apply a mask so we have only the bytes in the word that the address will not occupy.
            // Then combine these bytes with the address and store the 32 bytes back to memory with mstore.

            // 1. Add index to address of bytes array
            // 2. Load 32-byte word from memory
            // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address
            let neighbors := and(
                mload(add(b, index)),
                0xffffffffffffffffffffffff0000000000000000000000000000000000000000
            )

            // Make sure input address is clean.
            // (Solidity does not guarantee this)
            input := and(input, 0xffffffffffffffffffffffffffffffffffffffff)

            // Store the neighbors and address into memory
            mstore(add(b, index), xor(input, neighbors))
        }
    }

    /// @dev Reads a bytes32 value from a position in a byte array.
    /// @param b Byte array containing a bytes32 value.
    /// @param index Index in byte array of bytes32 value.
    /// @return result bytes32 value from byte array.
    function readBytes32(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes32 result)
    {
        if (b.length < index + 32) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired,
                b.length,
                index + 32
            ));
        }

        // Arrays are prefixed by a 256 bit length parameter
        index += 32;

        // Read the bytes32 from array memory
        assembly {
            result := mload(add(b, index))
        }
        return result;
    }

    /// @dev Writes a bytes32 into a specific position in a byte array.
    /// @param b Byte array to insert <input> into.
    /// @param index Index in byte array of <input>.
    /// @param input bytes32 to put into byte array.
    function writeBytes32(
        bytes memory b,
        uint256 index,
        bytes32 input
    )
        internal
        pure
    {
        if (b.length < index + 32) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired,
                b.length,
                index + 32
            ));
        }

        // Arrays are prefixed by a 256 bit length parameter
        index += 32;

        // Read the bytes32 from array memory
        assembly {
            mstore(add(b, index), input)
        }
    }

    /// @dev Reads a uint256 value from a position in a byte array.
    /// @param b Byte array containing a uint256 value.
    /// @param index Index in byte array of uint256 value.
    /// @return result uint256 value from byte array.
    function readUint256(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (uint256 result)
    {
        result = uint256(readBytes32(b, index));
        return result;
    }

    /// @dev Writes a uint256 into a specific position in a byte array.
    /// @param b Byte array to insert <input> into.
    /// @param index Index in byte array of <input>.
    /// @param input uint256 to put into byte array.
    function writeUint256(
        bytes memory b,
        uint256 index,
        uint256 input
    )
        internal
        pure
    {
        writeBytes32(b, index, bytes32(input));
    }

    /// @dev Reads an unpadded bytes4 value from a position in a byte array.
    /// @param b Byte array containing a bytes4 value.
    /// @param index Index in byte array of bytes4 value.
    /// @return result bytes4 value from byte array.
    function readBytes4(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes4 result)
    {
        if (b.length < index + 4) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired,
                b.length,
                index + 4
            ));
        }

        // Arrays are prefixed by a 32 byte length field
        index += 32;

        // Read the bytes4 from array memory
        assembly {
            result := mload(add(b, index))
            // Solidity does not require us to clean the trailing bytes.
            // We do it anyway
            result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000)
        }
        return result;
    }

    /// @dev Writes a new length to a byte array.
    ///      Decreasing length will lead to removing the corresponding lower order bytes from the byte array.
    ///      Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array.
    /// @param b Bytes array to write new length to.
    /// @param length New length of byte array.
    function writeLength(bytes memory b, uint256 length)
        internal
        pure
    {
        assembly {
            mstore(b, length)
        }
    }
}

File 4 of 33 : LibBytesRichErrorsV06.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 LibBytesRichErrorsV06 {

    enum InvalidByteOperationErrorCodes {
        FromLessThanOrEqualsToRequired,
        ToLessThanOrEqualsLengthRequired,
        LengthGreaterThanZeroRequired,
        LengthGreaterThanOrEqualsFourRequired,
        LengthGreaterThanOrEqualsTwentyRequired,
        LengthGreaterThanOrEqualsThirtyTwoRequired,
        LengthGreaterThanOrEqualsNestedBytesLengthRequired,
        DestinationLengthGreaterThanOrEqualSourceLengthRequired
    }

    // bytes4(keccak256("InvalidByteOperationError(uint8,uint256,uint256)"))
    bytes4 internal constant INVALID_BYTE_OPERATION_ERROR_SELECTOR =
        0x28006595;

    // solhint-disable func-name-mixedcase
    function InvalidByteOperationError(
        InvalidByteOperationErrorCodes errorCode,
        uint256 offset,
        uint256 required
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            INVALID_BYTE_OPERATION_ERROR_SELECTOR,
            errorCode,
            offset,
            required
        );
    }
}

File 5 of 33 : 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 6 of 33 : 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 33 : LibMetaTransactionsRichErrors.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 LibMetaTransactionsRichErrors {

    // solhint-disable func-name-mixedcase

    function InvalidMetaTransactionsArrayLengthsError(
        uint256 mtxCount,
        uint256 signatureCount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("InvalidMetaTransactionsArrayLengthsError(uint256,uint256)")),
            mtxCount,
            signatureCount
        );
    }

    function MetaTransactionUnsupportedFunctionError(
        bytes32 mtxHash,
        bytes4 selector
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionUnsupportedFunctionError(bytes32,bytes4)")),
            mtxHash,
            selector
        );
    }

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

    function MetaTransactionExpiredError(
        bytes32 mtxHash,
        uint256 time,
        uint256 expirationTime
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionExpiredError(bytes32,uint256,uint256)")),
            mtxHash,
            time,
            expirationTime
        );
    }

    function MetaTransactionGasPriceError(
        bytes32 mtxHash,
        uint256 gasPrice,
        uint256 minGasPrice,
        uint256 maxGasPrice
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionGasPriceError(bytes32,uint256,uint256,uint256)")),
            mtxHash,
            gasPrice,
            minGasPrice,
            maxGasPrice
        );
    }

    function MetaTransactionInsufficientEthError(
        bytes32 mtxHash,
        uint256 ethBalance,
        uint256 ethRequired
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionInsufficientEthError(bytes32,uint256,uint256)")),
            mtxHash,
            ethBalance,
            ethRequired
        );
    }

    function MetaTransactionInvalidSignatureError(
        bytes32 mtxHash,
        bytes memory signature,
        bytes memory errData
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionInvalidSignatureError(bytes32,bytes,bytes)")),
            mtxHash,
            signature,
            errData
        );
    }

    function MetaTransactionAlreadyExecutedError(
        bytes32 mtxHash,
        uint256 executedBlockNumber
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionAlreadyExecutedError(bytes32,uint256)")),
            mtxHash,
            executedBlockNumber
        );
    }

    function MetaTransactionCallFailedError(
        bytes32 mtxHash,
        bytes memory callData,
        bytes memory returnData
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("MetaTransactionCallFailedError(bytes32,bytes,bytes)")),
            mtxHash,
            callData,
            returnData
        );
    }
}

File 8 of 33 : 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 9 of 33 : 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 10 of 33 : 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 33 : 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 12 of 33 : 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 13 of 33 : 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 14 of 33 : FixinReentrancyGuard.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/LibBytesV06.sol";
import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "../errors/LibCommonRichErrors.sol";
import "../storage/LibReentrancyGuardStorage.sol";


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

    using LibRichErrorsV06 for bytes;
    using LibBytesV06 for bytes;

    // Combinable reentrancy flags.
    /// @dev Reentrancy guard flag for meta-transaction functions.
    uint256 constant internal REENTRANCY_MTX = 0x1;

    /// @dev Cannot reenter a function with the same reentrancy guard flags.
    modifier nonReentrant(uint256 reentrancyFlags) virtual {
        LibReentrancyGuardStorage.Storage storage stor =
            LibReentrancyGuardStorage.getStorage();
        {
            uint256 currentFlags = stor.reentrancyFlags;
            // Revert if any bits in `reentrancyFlags` has already been set.
            if ((currentFlags & reentrancyFlags) != 0) {
                LibCommonRichErrors.IllegalReentrancyError(
                    msg.data.readBytes4(0),
                    reentrancyFlags
                ).rrevert();
            }
            // Update reentrancy flags.
            stor.reentrancyFlags = currentFlags | reentrancyFlags;
        }

        _;

        // Clear reentrancy flags.
        stor.reentrancyFlags = stor.reentrancyFlags & (~reentrancyFlags);
    }
}

File 15 of 33 : LibReentrancyGuardStorage.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 "./LibStorage.sol";
import "../external/IFlashWallet.sol";


/// @dev Storage helpers for the `FixinReentrancyGuard` mixin.
library LibReentrancyGuardStorage {

    /// @dev Storage bucket for this feature.
    struct Storage {
        // Reentrancy flags set whenever a non-reentrant function is entered
        // and cleared when it is exited.
        uint256 reentrancyFlags;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        uint256 storageSlot = LibStorage.getStorageSlot(
            LibStorage.StorageId.ReentrancyGuard
        );
        // 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 16 of 33 : 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.5;
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
    }

    /// @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 17 of 33 : IFlashWallet.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";


/// @dev A contract that can execute arbitrary calls from its owner.
interface IFlashWallet {

    /// @dev Execute an arbitrary call. Only an authority can call this.
    /// @param target The call target.
    /// @param callData The call data.
    /// @param value Ether to attach to the call.
    /// @return resultData The data returned by the call.
    function executeCall(
        address payable target,
        bytes calldata callData,
        uint256 value
    )
        external
        payable
        returns (bytes memory resultData);

    /// @dev Execute an arbitrary delegatecall, in the context of this puppet.
    ///      Only an authority can call this.
    /// @param target The call target.
    /// @param callData The call data.
    /// @return resultData The data returned by the call.
    function executeDelegateCall(
        address payable target,
        bytes calldata callData
    )
        external
        payable
        returns (bytes memory resultData);

    /// @dev Allows the puppet to receive ETH.
    receive() external payable;

    /// @dev Fetch the immutable owner/deployer of this contract.
    /// @return owner_ The immutable owner/deployer/
    function owner() external view returns (address owner_);
}

File 18 of 33 : 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/IEtherTokenV06.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 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 19 of 33 : 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 20 of 33 : 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 21 of 33 : 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 22 of 33 : 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 23 of 33 : LibMetaTransactionsStorage.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 "./LibStorage.sol";


/// @dev Storage helpers for the `MetaTransactions` feature.
library LibMetaTransactionsStorage {

    /// @dev Storage bucket for this feature.
    struct Storage {
        // The block number when a hash was executed.
        mapping (bytes32 => uint256) mtxHashToExecutedBlockNumber;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        uint256 storageSlot = LibStorage.getStorageSlot(
            LibStorage.StorageId.MetaTransactions
        );
        // 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 24 of 33 : 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 25 of 33 : IMetaTransactionsFeature.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 "../libs/LibSignature.sol";

/// @dev Meta-transactions feature.
interface IMetaTransactionsFeature {
    /// @dev Describes an exchange proxy meta transaction.
    struct MetaTransactionData {
        // Signer of meta-transaction. On whose behalf to execute the MTX.
        address payable signer;
        // Required sender, or NULL for anyone.
        address sender;
        // Minimum gas price.
        uint256 minGasPrice;
        // Maximum gas price.
        uint256 maxGasPrice;
        // MTX is invalid after this time.
        uint256 expirationTimeSeconds;
        // Nonce to make this MTX unique.
        uint256 salt;
        // Encoded call data to a function on the exchange proxy.
        bytes callData;
        // Amount of ETH to attach to the call.
        uint256 value;
        // ERC20 fee `signer` pays `sender`.
        IERC20TokenV06 feeToken;
        // ERC20 fee amount.
        uint256 feeAmount;
    }

    /// @dev Emitted whenever a meta-transaction is executed via
    ///      `executeMetaTransaction()` or `executeMetaTransactions()`.
    /// @param hash The meta-transaction hash.
    /// @param selector The selector of the function being executed.
    /// @param signer Who to execute the meta-transaction on behalf of.
    /// @param sender Who executed the meta-transaction.
    event MetaTransactionExecuted(
        bytes32 hash,
        bytes4 indexed selector,
        address signer,
        address sender
    );

    /// @dev Execute a single meta-transaction.
    /// @param mtx The meta-transaction.
    /// @param signature The signature by `mtx.signer`.
    /// @return returnResult The ABI-encoded result of the underlying call.
    function executeMetaTransaction(
        MetaTransactionData calldata mtx,
        LibSignature.Signature calldata signature
    )
        external
        payable
        returns (bytes memory returnResult);

    /// @dev Execute multiple meta-transactions.
    /// @param mtxs The meta-transactions.
    /// @param signatures The signature by each respective `mtx.signer`.
    /// @return returnResults The ABI-encoded results of the underlying calls.
    function batchExecuteMetaTransactions(
        MetaTransactionData[] calldata mtxs,
        LibSignature.Signature[] calldata signatures
    )
        external
        payable
        returns (bytes[] memory returnResults);

    /// @dev Get the block at which a meta-transaction has been executed.
    /// @param mtx The meta-transaction.
    /// @return blockNumber The block height when the meta-transactioin was executed.
    function getMetaTransactionExecutedBlock(MetaTransactionData calldata mtx)
        external
        view
        returns (uint256 blockNumber);

    /// @dev Get the block at which a meta-transaction hash has been executed.
    /// @param mtxHash The meta-transaction hash.
    /// @return blockNumber The block height when the meta-transactioin was executed.
    function getMetaTransactionHashExecutedBlock(bytes32 mtxHash)
        external
        view
        returns (uint256 blockNumber);

    /// @dev Get the EIP712 hash of a meta-transaction.
    /// @param mtx The meta-transaction.
    /// @return mtxHash The EIP712 hash of `mtx`.
    function getMetaTransactionHash(MetaTransactionData calldata mtx)
        external
        view
        returns (bytes32 mtxHash);
}

File 26 of 33 : 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
    }

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

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

File 27 of 33 : 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 28 of 33 : INativeOrdersFeature.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 "../libs/LibSignature.sol";
import "../libs/LibNativeOrder.sol";
import "./INativeOrdersEvents.sol";


/// @dev Feature for interacting with limit orders.
interface INativeOrdersFeature is
    INativeOrdersEvents
{

    /// @dev Transfers protocol fees from the `FeeCollector` pools into
    ///      the staking contract.
    /// @param poolIds Staking pool IDs
    function transferProtocolFeesForPools(bytes32[] calldata poolIds)
        external;

    /// @dev Fill a limit order. The taker and sender will be the caller.
    /// @param order The limit order. ETH protocol fees can be
    ///      attached to this call. Any unspent ETH will be refunded to
    ///      the caller.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount Maximum taker token amount to fill this order with.
    /// @return takerTokenFilledAmount How much maker token was filled.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function fillLimitOrder(
        LibNativeOrder.LimitOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount
    )
        external
        payable
        returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount);

    /// @dev Fill an RFQ order for up to `takerTokenFillAmount` taker tokens.
    ///      The taker will be the caller.
    /// @param order The RFQ order.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount Maximum taker token amount to fill this order with.
    /// @return takerTokenFilledAmount How much maker token was filled.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function fillRfqOrder(
        LibNativeOrder.RfqOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount
    )
        external
        returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount);

    /// @dev Fill an RFQ order for exactly `takerTokenFillAmount` taker tokens.
    ///      The taker will be the caller. ETH protocol fees can be
    ///      attached to this call. Any unspent ETH will be refunded to
    ///      the caller.
    /// @param order The limit order.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount How much taker token to fill this order with.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function fillOrKillLimitOrder(
        LibNativeOrder.LimitOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount
    )
        external
        payable
        returns (uint128 makerTokenFilledAmount);

    /// @dev Fill an RFQ order for exactly `takerTokenFillAmount` taker tokens.
    ///      The taker will be the caller.
    /// @param order The RFQ order.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount How much taker token to fill this order with.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function fillOrKillRfqOrder(
        LibNativeOrder.RfqOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount
    )
        external
        returns (uint128 makerTokenFilledAmount);

    /// @dev Fill a limit order. Internal variant. ETH protocol fees can be
    ///      attached to this call. Any unspent ETH will be refunded to
    ///      `msg.sender` (not `sender`).
    /// @param order The limit order.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount Maximum taker token to fill this order with.
    /// @param taker The order taker.
    /// @param sender The order sender.
    /// @return takerTokenFilledAmount How much maker token was filled.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function _fillLimitOrder(
        LibNativeOrder.LimitOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount,
        address taker,
        address sender
    )
        external
        payable
        returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount);

    /// @dev Fill an RFQ order. Internal variant.
    /// @param order The RFQ order.
    /// @param signature The order signature.
    /// @param takerTokenFillAmount Maximum taker token to fill this order with.
    /// @param taker The order taker.
    /// @param useSelfBalance Whether to use the ExchangeProxy's transient
    ///        balance of taker tokens to fill the order.
    /// @param recipient The recipient of the maker tokens.
    /// @return takerTokenFilledAmount How much maker token was filled.
    /// @return makerTokenFilledAmount How much maker token was filled.
    function _fillRfqOrder(
        LibNativeOrder.RfqOrder calldata order,
        LibSignature.Signature calldata signature,
        uint128 takerTokenFillAmount,
        address taker,
        bool useSelfBalance,
        address recipient
    )
        external
        returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount);

    /// @dev Cancel a single limit order. The caller must be the maker or a valid order signer.
    ///      Silently succeeds if the order has already been cancelled.
    /// @param order The limit order.
    function cancelLimitOrder(LibNativeOrder.LimitOrder calldata order)
        external;

    /// @dev Cancel a single RFQ order. The caller must be the maker or a valid order signer.
    ///      Silently succeeds if the order has already been cancelled.
    /// @param order The RFQ order.
    function cancelRfqOrder(LibNativeOrder.RfqOrder calldata order)
        external;

    /// @dev Mark what tx.origin addresses are allowed to fill an order that
    ///      specifies the message sender as its txOrigin.
    /// @param origins An array of origin addresses to update.
    /// @param allowed True to register, false to unregister.
    function registerAllowedRfqOrigins(address[] memory origins, bool allowed)
        external;

    /// @dev Cancel multiple limit orders. The caller must be the maker or a valid order signer.
    ///      Silently succeeds if the order has already been cancelled.
    /// @param orders The limit orders.
    function batchCancelLimitOrders(LibNativeOrder.LimitOrder[] calldata orders)
        external;

    /// @dev Cancel multiple RFQ orders. The caller must be the maker or a valid order signer.
    ///      Silently succeeds if the order has already been cancelled.
    /// @param orders The RFQ orders.
    function batchCancelRfqOrders(LibNativeOrder.RfqOrder[] calldata orders)
        external;

    /// @dev Cancel all limit orders for a given maker and pair with a salt less
    ///      than the value provided. The caller must be the maker. Subsequent
    ///      calls to this function with the same caller and pair require the
    ///      new salt to be >= the old salt.
    /// @param makerToken The maker token.
    /// @param takerToken The taker token.
    /// @param minValidSalt The new minimum valid salt.
    function cancelPairLimitOrders(
        IERC20TokenV06 makerToken,
        IERC20TokenV06 takerToken,
        uint256 minValidSalt
    )
        external;

    /// @dev Cancel all limit orders for a given maker and pair with a salt less
    ///      than the value provided. The caller must be a signer registered to the maker.
    ///      Subsequent calls to this function with the same maker and pair require the
    ///      new salt to be >= the old salt.
    /// @param maker The maker for which to cancel.
    /// @param makerToken The maker token.
    /// @param takerToken The taker token.
    /// @param minValidSalt The new minimum valid salt.
    function cancelPairLimitOrdersWithSigner(
        address maker,
        IERC20TokenV06 makerToken,
        IERC20TokenV06 takerToken,
        uint256 minValidSalt
    )
        external;

    /// @dev Cancel all limit orders for a given maker and pairs with salts less
    ///      than the values provided. The caller must be the maker. Subsequent
    ///      calls to this function with the same caller and pair require the
    ///      new salt to be >= the old salt.
    /// @param makerTokens The maker tokens.
    /// @param takerTokens The taker tokens.
    /// @param minValidSalts The new minimum valid salts.
    function batchCancelPairLimitOrders(
        IERC20TokenV06[] calldata makerTokens,
        IERC20TokenV06[] calldata takerTokens,
        uint256[] calldata minValidSalts
    )
        external;

    /// @dev Cancel all limit orders for a given maker and pairs with salts less
    ///      than the values provided. The caller must be a signer registered to the maker.
    ///      Subsequent calls to this function with the same maker and pair require the
    ///      new salt to be >= the old salt.
    /// @param maker The maker for which to cancel.
    /// @param makerTokens The maker tokens.
    /// @param takerTokens The taker tokens.
    /// @param minValidSalts The new minimum valid salts.
    function batchCancelPairLimitOrdersWithSigner(
        address maker,
        IERC20TokenV06[] memory makerTokens,
        IERC20TokenV06[] memory takerTokens,
        uint256[] memory minValidSalts
    )
        external;

    /// @dev Cancel all RFQ orders for a given maker and pair with a salt less
    ///      than the value provided. The caller must be the maker. Subsequent
    ///      calls to this function with the same caller and pair require the
    ///      new salt to be >= the old salt.
    /// @param makerToken The maker token.
    /// @param takerToken The taker token.
    /// @param minValidSalt The new minimum valid salt.
    function cancelPairRfqOrders(
        IERC20TokenV06 makerToken,
        IERC20TokenV06 takerToken,
        uint256 minValidSalt
    )
        external;

    /// @dev Cancel all RFQ orders for a given maker and pair with a salt less
    ///      than the value provided. The caller must be a signer registered to the maker.
    ///      Subsequent calls to this function with the same maker and pair require the
    ///      new salt to be >= the old salt.
    /// @param maker The maker for which to cancel.
    /// @param makerToken The maker token.
    /// @param takerToken The taker token.
    /// @param minValidSalt The new minimum valid salt.
    function cancelPairRfqOrdersWithSigner(
        address maker,
        IERC20TokenV06 makerToken,
        IERC20TokenV06 takerToken,
        uint256 minValidSalt
    )
        external;

    /// @dev Cancel all RFQ orders for a given maker and pairs with salts less
    ///      than the values provided. The caller must be the maker. Subsequent
    ///      calls to this function with the same caller and pair require the
    ///      new salt to be >= the old salt.
    /// @param makerTokens The maker tokens.
    /// @param takerTokens The taker tokens.
    /// @param minValidSalts The new minimum valid salts.
    function batchCancelPairRfqOrders(
        IERC20TokenV06[] calldata makerTokens,
        IERC20TokenV06[] calldata takerTokens,
        uint256[] calldata minValidSalts
    )
        external;

    /// @dev Cancel all RFQ orders for a given maker and pairs with salts less
    ///      than the values provided. The caller must be a signer registered to the maker.
    ///      Subsequent calls to this function with the same maker and pair require the
    ///      new salt to be >= the old salt.
    /// @param maker The maker for which to cancel.
    /// @param makerTokens The maker tokens.
    /// @param takerTokens The taker tokens.
    /// @param minValidSalts The new minimum valid salts.
    function batchCancelPairRfqOrdersWithSigner(
        address maker,
        IERC20TokenV06[] memory makerTokens,
        IERC20TokenV06[] memory takerTokens,
        uint256[] memory minValidSalts
    )
        external;

    /// @dev Get the order info for a limit order.
    /// @param order The limit order.
    /// @return orderInfo Info about the order.
    function getLimitOrderInfo(LibNativeOrder.LimitOrder calldata order)
        external
        view
        returns (LibNativeOrder.OrderInfo memory orderInfo);

    /// @dev Get the order info for an RFQ order.
    /// @param order The RFQ order.
    /// @return orderInfo Info about the order.
    function getRfqOrderInfo(LibNativeOrder.RfqOrder calldata order)
        external
        view
        returns (LibNativeOrder.OrderInfo memory orderInfo);

    /// @dev Get the canonical hash of a limit order.
    /// @param order The limit order.
    /// @return orderHash The order hash.
    function getLimitOrderHash(LibNativeOrder.LimitOrder calldata order)
        external
        view
        returns (bytes32 orderHash);

    /// @dev Get the canonical hash of an RFQ order.
    /// @param order The RFQ order.
    /// @return orderHash The order hash.
    function getRfqOrderHash(LibNativeOrder.RfqOrder calldata order)
        external
        view
        returns (bytes32 orderHash);

    /// @dev Get the protocol fee multiplier. This should be multiplied by the
    ///      gas price to arrive at the required protocol fee to fill a native order.
    /// @return multiplier The protocol fee multiplier.
    function getProtocolFeeMultiplier()
        external
        view
        returns (uint32 multiplier);

    /// @dev Get order info, fillable amount, and signature validity for a limit order.
    ///      Fillable amount is determined using balances and allowances of the maker.
    /// @param order The limit order.
    /// @param signature The order signature.
    /// @return orderInfo Info about the order.
    /// @return actualFillableTakerTokenAmount How much of the order is fillable
    ///         based on maker funds, in taker tokens.
    /// @return isSignatureValid Whether the signature is valid.
    function getLimitOrderRelevantState(
        LibNativeOrder.LimitOrder calldata order,
        LibSignature.Signature calldata signature
    )
        external
        view
        returns (
            LibNativeOrder.OrderInfo memory orderInfo,
            uint128 actualFillableTakerTokenAmount,
            bool isSignatureValid
        );

    /// @dev Get order info, fillable amount, and signature validity for an RFQ order.
    ///      Fillable amount is determined using balances and allowances of the maker.
    /// @param order The RFQ order.
    /// @param signature The order signature.
    /// @return orderInfo Info about the order.
    /// @return actualFillableTakerTokenAmount How much of the order is fillable
    ///         based on maker funds, in taker tokens.
    /// @return isSignatureValid Whether the signature is valid.
    function getRfqOrderRelevantState(
        LibNativeOrder.RfqOrder calldata order,
        LibSignature.Signature calldata signature
    )
        external
        view
        returns (
            LibNativeOrder.OrderInfo memory orderInfo,
            uint128 actualFillableTakerTokenAmount,
            bool isSignatureValid
        );

    /// @dev Batch version of `getLimitOrderRelevantState()`, without reverting.
    ///      Orders that would normally cause `getLimitOrderRelevantState()`
    ///      to revert will have empty results.
    /// @param orders The limit orders.
    /// @param signatures The order signatures.
    /// @return orderInfos Info about the orders.
    /// @return actualFillableTakerTokenAmounts How much of each order is fillable
    ///         based on maker funds, in taker tokens.
    /// @return isSignatureValids Whether each signature is valid for the order.
    function batchGetLimitOrderRelevantStates(
        LibNativeOrder.LimitOrder[] calldata orders,
        LibSignature.Signature[] calldata signatures
    )
        external
        view
        returns (
            LibNativeOrder.OrderInfo[] memory orderInfos,
            uint128[] memory actualFillableTakerTokenAmounts,
            bool[] memory isSignatureValids
        );

    /// @dev Batch version of `getRfqOrderRelevantState()`, without reverting.
    ///      Orders that would normally cause `getRfqOrderRelevantState()`
    ///      to revert will have empty results.
    /// @param orders The RFQ orders.
    /// @param signatures The order signatures.
    /// @return orderInfos Info about the orders.
    /// @return actualFillableTakerTokenAmounts How much of each order is fillable
    ///         based on maker funds, in taker tokens.
    /// @return isSignatureValids Whether each signature is valid for the order.
    function batchGetRfqOrderRelevantStates(
        LibNativeOrder.RfqOrder[] calldata orders,
        LibSignature.Signature[] calldata signatures
    )
        external
        view
        returns (
            LibNativeOrder.OrderInfo[] memory orderInfos,
            uint128[] memory actualFillableTakerTokenAmounts,
            bool[] memory isSignatureValids
        );

    /// @dev Register a signer who can sign on behalf of msg.sender
    ///      This allows one to sign on behalf of a contract that calls this function
    /// @param signer The address from which you plan to generate signatures
    /// @param allowed True to register, false to unregister.
    function registerAllowedOrderSigner(
        address signer,
        bool allowed
    )
        external;

    /// @dev checks if a given address is registered to sign on behalf of a maker address
    /// @param maker The maker address encoded in an order (can be a contract)
    /// @param signer The address that is providing a signature
    function isValidOrderSigner(
        address maker,
        address signer
    )
        external
        view
        returns (bool isAllowed);
}

File 29 of 33 : LibNativeOrder.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/errors/LibRichErrorsV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../../errors/LibNativeOrdersRichErrors.sol";


/// @dev A library for common native order operations.
library LibNativeOrder {
    using LibSafeMathV06 for uint256;
    using LibRichErrorsV06 for bytes;

    enum OrderStatus {
        INVALID,
        FILLABLE,
        FILLED,
        CANCELLED,
        EXPIRED
    }

    /// @dev A standard OTC or OO limit order.
    struct LimitOrder {
        IERC20TokenV06 makerToken;
        IERC20TokenV06 takerToken;
        uint128 makerAmount;
        uint128 takerAmount;
        uint128 takerTokenFeeAmount;
        address maker;
        address taker;
        address sender;
        address feeRecipient;
        bytes32 pool;
        uint64 expiry;
        uint256 salt;
    }

    /// @dev An RFQ limit order.
    struct RfqOrder {
        IERC20TokenV06 makerToken;
        IERC20TokenV06 takerToken;
        uint128 makerAmount;
        uint128 takerAmount;
        address maker;
        address taker;
        address txOrigin;
        bytes32 pool;
        uint64 expiry;
        uint256 salt;
    }

    /// @dev An OTC limit order.
    struct OtcOrder {
        IERC20TokenV06 makerToken;
        IERC20TokenV06 takerToken;
        uint128 makerAmount;
        uint128 takerAmount;
        address maker;
        address taker;
        address txOrigin;
        uint256 expiryAndNonce; // [uint64 expiry, uint64 nonceBucket, uint128 nonce]
    }

    /// @dev Info on a limit or RFQ order.
    struct OrderInfo {
        bytes32 orderHash;
        OrderStatus status;
        uint128 takerTokenFilledAmount;
    }

    /// @dev Info on an OTC order.
    struct OtcOrderInfo {
        bytes32 orderHash;
        OrderStatus status;
    }

    uint256 private constant UINT_128_MASK = (1 << 128) - 1;
    uint256 private constant UINT_64_MASK = (1 << 64) - 1;
    uint256 private constant ADDRESS_MASK = (1 << 160) - 1;

    // The type hash for limit orders, which is:
    // keccak256(abi.encodePacked(
    //     "LimitOrder(",
    //       "address makerToken,",
    //       "address takerToken,",
    //       "uint128 makerAmount,",
    //       "uint128 takerAmount,",
    //       "uint128 takerTokenFeeAmount,",
    //       "address maker,",
    //       "address taker,",
    //       "address sender,",
    //       "address feeRecipient,",
    //       "bytes32 pool,",
    //       "uint64 expiry,",
    //       "uint256 salt"
    //     ")"
    // ))
    uint256 private constant _LIMIT_ORDER_TYPEHASH =
        0xce918627cb55462ddbb85e73de69a8b322f2bc88f4507c52fcad6d4c33c29d49;

    // The type hash for RFQ orders, which is:
    // keccak256(abi.encodePacked(
    //     "RfqOrder(",
    //       "address makerToken,",
    //       "address takerToken,",
    //       "uint128 makerAmount,",
    //       "uint128 takerAmount,",
    //       "address maker,",
    //       "address taker,",
    //       "address txOrigin,",
    //       "bytes32 pool,",
    //       "uint64 expiry,",
    //       "uint256 salt"
    //     ")"
    // ))
    uint256 private constant _RFQ_ORDER_TYPEHASH =
        0xe593d3fdfa8b60e5e17a1b2204662ecbe15c23f2084b9ad5bae40359540a7da9;

    // The type hash for OTC orders, which is:
    // keccak256(abi.encodePacked(
    //     "OtcOrder(",
    //       "address makerToken,",
    //       "address takerToken,",
    //       "uint128 makerAmount,",
    //       "uint128 takerAmount,",
    //       "address maker,",
    //       "address taker,",
    //       "address txOrigin,",
    //       "uint256 expiryAndNonce"
    //     ")"
    // ))
    uint256 private constant _OTC_ORDER_TYPEHASH =
        0x2f754524de756ae72459efbe1ec88c19a745639821de528ac3fb88f9e65e35c8;

    /// @dev Get the struct hash of a limit order.
    /// @param order The limit order.
    /// @return structHash The struct hash of the order.
    function getLimitOrderStructHash(LimitOrder memory order)
        internal
        pure
        returns (bytes32 structHash)
    {
        // The struct hash is:
        // keccak256(abi.encode(
        //   TYPE_HASH,
        //   order.makerToken,
        //   order.takerToken,
        //   order.makerAmount,
        //   order.takerAmount,
        //   order.takerTokenFeeAmount,
        //   order.maker,
        //   order.taker,
        //   order.sender,
        //   order.feeRecipient,
        //   order.pool,
        //   order.expiry,
        //   order.salt,
        // ))
        assembly {
            let mem := mload(0x40)
            mstore(mem, _LIMIT_ORDER_TYPEHASH)
            // order.makerToken;
            mstore(add(mem, 0x20), and(ADDRESS_MASK, mload(order)))
            // order.takerToken;
            mstore(add(mem, 0x40), and(ADDRESS_MASK, mload(add(order, 0x20))))
            // order.makerAmount;
            mstore(add(mem, 0x60), and(UINT_128_MASK, mload(add(order, 0x40))))
            // order.takerAmount;
            mstore(add(mem, 0x80), and(UINT_128_MASK, mload(add(order, 0x60))))
            // order.takerTokenFeeAmount;
            mstore(add(mem, 0xA0), and(UINT_128_MASK, mload(add(order, 0x80))))
            // order.maker;
            mstore(add(mem, 0xC0), and(ADDRESS_MASK, mload(add(order, 0xA0))))
            // order.taker;
            mstore(add(mem, 0xE0), and(ADDRESS_MASK, mload(add(order, 0xC0))))
            // order.sender;
            mstore(add(mem, 0x100), and(ADDRESS_MASK, mload(add(order, 0xE0))))
            // order.feeRecipient;
            mstore(add(mem, 0x120), and(ADDRESS_MASK, mload(add(order, 0x100))))
            // order.pool;
            mstore(add(mem, 0x140), mload(add(order, 0x120)))
            // order.expiry;
            mstore(add(mem, 0x160), and(UINT_64_MASK, mload(add(order, 0x140))))
            // order.salt;
            mstore(add(mem, 0x180), mload(add(order, 0x160)))
            structHash := keccak256(mem, 0x1A0)
        }
    }

    /// @dev Get the struct hash of a RFQ order.
    /// @param order The RFQ order.
    /// @return structHash The struct hash of the order.
    function getRfqOrderStructHash(RfqOrder memory order)
        internal
        pure
        returns (bytes32 structHash)
    {
        // The struct hash is:
        // keccak256(abi.encode(
        //   TYPE_HASH,
        //   order.makerToken,
        //   order.takerToken,
        //   order.makerAmount,
        //   order.takerAmount,
        //   order.maker,
        //   order.taker,
        //   order.txOrigin,
        //   order.pool,
        //   order.expiry,
        //   order.salt,
        // ))
        assembly {
            let mem := mload(0x40)
            mstore(mem, _RFQ_ORDER_TYPEHASH)
            // order.makerToken;
            mstore(add(mem, 0x20), and(ADDRESS_MASK, mload(order)))
            // order.takerToken;
            mstore(add(mem, 0x40), and(ADDRESS_MASK, mload(add(order, 0x20))))
            // order.makerAmount;
            mstore(add(mem, 0x60), and(UINT_128_MASK, mload(add(order, 0x40))))
            // order.takerAmount;
            mstore(add(mem, 0x80), and(UINT_128_MASK, mload(add(order, 0x60))))
            // order.maker;
            mstore(add(mem, 0xA0), and(ADDRESS_MASK, mload(add(order, 0x80))))
            // order.taker;
            mstore(add(mem, 0xC0), and(ADDRESS_MASK, mload(add(order, 0xA0))))
            // order.txOrigin;
            mstore(add(mem, 0xE0), and(ADDRESS_MASK, mload(add(order, 0xC0))))
            // order.pool;
            mstore(add(mem, 0x100), mload(add(order, 0xE0)))
            // order.expiry;
            mstore(add(mem, 0x120), and(UINT_64_MASK, mload(add(order, 0x100))))
            // order.salt;
            mstore(add(mem, 0x140), mload(add(order, 0x120)))
            structHash := keccak256(mem, 0x160)
        }
    }

    /// @dev Get the struct hash of an OTC order.
    /// @param order The OTC order.
    /// @return structHash The struct hash of the order.
    function getOtcOrderStructHash(OtcOrder memory order)
        internal
        pure
        returns (bytes32 structHash)
    {
        // The struct hash is:
        // keccak256(abi.encode(
        //   TYPE_HASH,
        //   order.makerToken,
        //   order.takerToken,
        //   order.makerAmount,
        //   order.takerAmount,
        //   order.maker,
        //   order.taker,
        //   order.txOrigin,
        //   order.expiryAndNonce,
        // ))
        assembly {
            let mem := mload(0x40)
            mstore(mem, _OTC_ORDER_TYPEHASH)
            // order.makerToken;
            mstore(add(mem, 0x20), and(ADDRESS_MASK, mload(order)))
            // order.takerToken;
            mstore(add(mem, 0x40), and(ADDRESS_MASK, mload(add(order, 0x20))))
            // order.makerAmount;
            mstore(add(mem, 0x60), and(UINT_128_MASK, mload(add(order, 0x40))))
            // order.takerAmount;
            mstore(add(mem, 0x80), and(UINT_128_MASK, mload(add(order, 0x60))))
            // order.maker;
            mstore(add(mem, 0xA0), and(ADDRESS_MASK, mload(add(order, 0x80))))
            // order.taker;
            mstore(add(mem, 0xC0), and(ADDRESS_MASK, mload(add(order, 0xA0))))
            // order.txOrigin;
            mstore(add(mem, 0xE0), and(ADDRESS_MASK, mload(add(order, 0xC0))))
            // order.expiryAndNonce;
            mstore(add(mem, 0x100), mload(add(order, 0xE0)))
            structHash := keccak256(mem, 0x120)
        }
    }

    /// @dev Refund any leftover protocol fees in `msg.value` to `msg.sender`.
    /// @param ethProtocolFeePaid How much ETH was paid in protocol fees.
    function refundExcessProtocolFeeToSender(uint256 ethProtocolFeePaid)
        internal
    {
        if (msg.value > ethProtocolFeePaid && msg.sender != address(this)) {
            uint256 refundAmount = msg.value.safeSub(ethProtocolFeePaid);
            (bool success,) = msg
                .sender
                .call{value: refundAmount}("");
            if (!success) {
                LibNativeOrdersRichErrors.ProtocolFeeRefundFailed(
                    msg.sender,
                    refundAmount
                ).rrevert();
            }
        }
    }
}

File 30 of 33 : LibNativeOrdersRichErrors.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 LibNativeOrdersRichErrors {

    // solhint-disable func-name-mixedcase

    function ProtocolFeeRefundFailed(
        address receiver,
        uint256 refundAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("ProtocolFeeRefundFailed(address,uint256)")),
            receiver,
            refundAmount
        );
    }

    function OrderNotFillableByOriginError(
        bytes32 orderHash,
        address txOrigin,
        address orderTxOrigin
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OrderNotFillableByOriginError(bytes32,address,address)")),
            orderHash,
            txOrigin,
            orderTxOrigin
        );
    }

    function OrderNotFillableError(
        bytes32 orderHash,
        uint8 orderStatus
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OrderNotFillableError(bytes32,uint8)")),
            orderHash,
            orderStatus
        );
    }

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

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

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

    function OrderNotFillableByTakerError(
        bytes32 orderHash,
        address taker,
        address orderTaker
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("OrderNotFillableByTakerError(bytes32,address,address)")),
            orderHash,
            taker,
            orderTaker
        );
    }

    function CancelSaltTooLowError(
        uint256 minValidSalt,
        uint256 oldMinValidSalt
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("CancelSaltTooLowError(uint256,uint256)")),
            minValidSalt,
            oldMinValidSalt
        );
    }

    function FillOrKillFailedError(
        bytes32 orderHash,
        uint256 takerTokenFilledAmount,
        uint256 takerTokenFillAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("FillOrKillFailedError(bytes32,uint256,uint256)")),
            orderHash,
            takerTokenFilledAmount,
            takerTokenFillAmount
        );
    }

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

    function BatchFillIncompleteError(
        bytes32 orderHash,
        uint256 takerTokenFilledAmount,
        uint256 takerTokenFillAmount
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            bytes4(keccak256("BatchFillIncompleteError(bytes32,uint256,uint256)")),
            orderHash,
            takerTokenFilledAmount,
            takerTokenFillAmount
        );
    }
}

File 31 of 33 : INativeOrdersEvents.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;
pragma experimental ABIEncoderV2;

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


/// @dev Events emitted by NativeOrdersFeature.
interface INativeOrdersEvents {

    /// @dev Emitted whenever a `LimitOrder` is filled.
    /// @param orderHash The canonical hash of the order.
    /// @param maker The maker of the order.
    /// @param taker The taker of the order.
    /// @param feeRecipient Fee recipient of the order.
    /// @param takerTokenFilledAmount How much taker token was filled.
    /// @param makerTokenFilledAmount How much maker token was filled.
    /// @param protocolFeePaid How much protocol fee was paid.
    /// @param pool The fee pool associated with this order.
    event LimitOrderFilled(
        bytes32 orderHash,
        address maker,
        address taker,
        address feeRecipient,
        address makerToken,
        address takerToken,
        uint128 takerTokenFilledAmount,
        uint128 makerTokenFilledAmount,
        uint128 takerTokenFeeFilledAmount,
        uint256 protocolFeePaid,
        bytes32 pool
    );

    /// @dev Emitted whenever an `RfqOrder` is filled.
    /// @param orderHash The canonical hash of the order.
    /// @param maker The maker of the order.
    /// @param taker The taker of the order.
    /// @param takerTokenFilledAmount How much taker token was filled.
    /// @param makerTokenFilledAmount How much maker token was filled.
    /// @param pool The fee pool associated with this order.
    event RfqOrderFilled(
        bytes32 orderHash,
        address maker,
        address taker,
        address makerToken,
        address takerToken,
        uint128 takerTokenFilledAmount,
        uint128 makerTokenFilledAmount,
        bytes32 pool
    );

    /// @dev Emitted whenever a limit or RFQ order is cancelled.
    /// @param orderHash The canonical hash of the order.
    /// @param maker The order maker.
    event OrderCancelled(
        bytes32 orderHash,
        address maker
    );

    /// @dev Emitted whenever Limit orders are cancelled by pair by a maker.
    /// @param maker The maker of the order.
    /// @param makerToken The maker token in a pair for the orders cancelled.
    /// @param takerToken The taker token in a pair for the orders cancelled.
    /// @param minValidSalt The new minimum valid salt an order with this pair must
    ///        have.
    event PairCancelledLimitOrders(
        address maker,
        address makerToken,
        address takerToken,
        uint256 minValidSalt
    );

    /// @dev Emitted whenever RFQ orders are cancelled by pair by a maker.
    /// @param maker The maker of the order.
    /// @param makerToken The maker token in a pair for the orders cancelled.
    /// @param takerToken The taker token in a pair for the orders cancelled.
    /// @param minValidSalt The new minimum valid salt an order with this pair must
    ///        have.
    event PairCancelledRfqOrders(
        address maker,
        address makerToken,
        address takerToken,
        uint256 minValidSalt
    );

    /// @dev Emitted when new addresses are allowed or disallowed to fill
    ///      orders with a given txOrigin.
    /// @param origin The address doing the allowing.
    /// @param addrs The address being allowed/disallowed.
    /// @param allowed Indicates whether the address should be allowed.
    event RfqOrderOriginsAllowed(
        address origin,
        address[] addrs,
        bool allowed
    );

    /// @dev Emitted when new order signers are registered
    /// @param maker The maker address that is registering a designated signer.
    /// @param signer The address that will sign on behalf of maker.
    /// @param allowed Indicates whether the address should be allowed.
    event OrderSignerRegistered(
        address maker,
        address signer,
        bool allowed
    );
}

File 32 of 33 : ITransformERC20Feature.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 "../../transformers/IERC20Transformer.sol";
import "../../external/IFlashWallet.sol";


/// @dev Feature to composably transform between ERC20 tokens.
interface ITransformERC20Feature {

    /// @dev Defines a transformation to run in `transformERC20()`.
    struct Transformation {
        // The deployment nonce for the transformer.
        // The address of the transformer contract will be derived from this
        // value.
        uint32 deploymentNonce;
        // Arbitrary data to pass to the transformer.
        bytes data;
    }

    /// @dev Arguments for `_transformERC20()`.
    struct TransformERC20Args {
        // The taker address.
        address payable taker;
        // The token being provided by the taker.
        // If `0xeee...`, ETH is implied and should be provided with the call.`
        IERC20TokenV06 inputToken;
        // The token to be acquired by the taker.
        // `0xeee...` implies ETH.
        IERC20TokenV06 outputToken;
        // The amount of `inputToken` to take from the taker.
        // If set to `uint256(-1)`, the entire spendable balance of the taker
        // will be solt.
        uint256 inputTokenAmount;
        // The minimum amount of `outputToken` the taker
        // must receive for the entire transformation to succeed. If set to zero,
        // the minimum output token transfer will not be asserted.
        uint256 minOutputTokenAmount;
        // The transformations to execute on the token balance(s)
        // in sequence.
        Transformation[] transformations;
        // Whether to use the Exchange Proxy's balance of `inputToken`.
        bool useSelfBalance;
        // The recipient of the bought `outputToken`.
        address payable recipient;
    }

    /// @dev Raised upon a successful `transformERC20`.
    /// @param taker The taker (caller) address.
    /// @param inputToken The token being provided by the taker.
    ///        If `0xeee...`, ETH is implied and should be provided with the call.`
    /// @param outputToken The token to be acquired by the taker.
    ///        `0xeee...` implies ETH.
    /// @param inputTokenAmount The amount of `inputToken` to take from the taker.
    /// @param outputTokenAmount The amount of `outputToken` received by the taker.
    event TransformedERC20(
        address indexed taker,
        address inputToken,
        address outputToken,
        uint256 inputTokenAmount,
        uint256 outputTokenAmount
    );

    /// @dev Raised when `setTransformerDeployer()` is called.
    /// @param transformerDeployer The new deployer address.
    event TransformerDeployerUpdated(address transformerDeployer);

    /// @dev Raised when `setQuoteSigner()` is called.
    /// @param quoteSigner The new quote signer.
    event QuoteSignerUpdated(address quoteSigner);

    /// @dev Replace the allowed deployer for transformers.
    ///      Only callable by the owner.
    /// @param transformerDeployer The address of the new trusted deployer
    ///        for transformers.
    function setTransformerDeployer(address transformerDeployer)
        external;

    /// @dev Replace the optional signer for `transformERC20()` calldata.
    ///      Only callable by the owner.
    /// @param quoteSigner The address of the new calldata signer.
    function setQuoteSigner(address quoteSigner)
        external;

    /// @dev Deploy a new flash wallet instance and replace the current one with it.
    ///      Useful if we somehow break the current wallet instance.
    ///       Only callable by the owner.
    /// @return wallet The new wallet instance.
    function createTransformWallet()
        external
        returns (IFlashWallet wallet);

    /// @dev Executes a series of transformations to convert an ERC20 `inputToken`
    ///      to an ERC20 `outputToken`.
    /// @param inputToken The token being provided by the sender.
    ///        If `0xeee...`, ETH is implied and should be provided with the call.`
    /// @param outputToken The token to be acquired by the sender.
    ///        `0xeee...` implies ETH.
    /// @param inputTokenAmount The amount of `inputToken` to take from the sender.
    /// @param minOutputTokenAmount The minimum amount of `outputToken` the sender
    ///        must receive for the entire transformation to succeed.
    /// @param transformations The transformations to execute on the token balance(s)
    ///        in sequence.
    /// @return outputTokenAmount The amount of `outputToken` received by the sender.
    function transformERC20(
        IERC20TokenV06 inputToken,
        IERC20TokenV06 outputToken,
        uint256 inputTokenAmount,
        uint256 minOutputTokenAmount,
        Transformation[] calldata transformations
    )
        external
        payable
        returns (uint256 outputTokenAmount);

    /// @dev Internal version of `transformERC20()`. Only callable from within.
    /// @param args A `TransformERC20Args` struct.
    /// @return outputTokenAmount The amount of `outputToken` received by the taker.
    function _transformERC20(TransformERC20Args calldata args)
        external
        payable
        returns (uint256 outputTokenAmount);

    /// @dev Return the current wallet instance that will serve as the execution
    ///      context for transformations.
    /// @return wallet The wallet instance.
    function getTransformWallet()
        external
        view
        returns (IFlashWallet wallet);

    /// @dev Return the allowed deployer for transformers.
    /// @return deployer The transform deployer address.
    function getTransformerDeployer()
        external
        view
        returns (address deployer);

    /// @dev Return the optional signer for `transformERC20()` calldata.
    /// @return signer The transform deployer address.
    function getQuoteSigner()
        external
        view
        returns (address signer);
}

File 33 of 33 : IERC20Transformer.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";


/// @dev A transformation callback used in `TransformERC20.transformERC20()`.
interface IERC20Transformer {

    /// @dev Context information to pass into `transform()` by `TransformERC20.transformERC20()`.
    struct TransformContext {
        // The caller of `TransformERC20.transformERC20()`.
        address payable sender;
        // The recipient address, which may be distinct from `sender` e.g. in
        // meta-transactions.
        address payable recipient;
        // Arbitrary data to pass to the transformer.
        bytes data;
    }

    /// @dev Called from `TransformERC20.transformERC20()`. This will be
    ///      delegatecalled in the context of the FlashWallet instance being used.
    /// @param context Context information.
    /// @return success The success bytes (`LibERC20Transformer.TRANSFORMER_SUCCESS`).
    function transform(TransformContext calldata context)
        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",
        "abi"
      ]
    }
  },
  "evmVersion": "istanbul"
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"zeroExAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"hash","type":"bytes32"},{"indexed":true,"internalType":"bytes4","name":"selector","type":"bytes4"},{"indexed":false,"internalType":"address","name":"signer","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"MetaTransactionExecuted","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":[],"name":"MTX_EIP712_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"signer","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"minGasPrice","type":"uint256"},{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"contract IERC20TokenV06","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"internalType":"struct IMetaTransactionsFeature.MetaTransactionData[]","name":"mtxs","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[]"}],"name":"batchExecuteMetaTransactions","outputs":[{"internalType":"bytes[]","name":"returnResults","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"signer","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"minGasPrice","type":"uint256"},{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"contract IERC20TokenV06","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"internalType":"struct IMetaTransactionsFeature.MetaTransactionData","name":"mtx","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":"executeMetaTransaction","outputs":[{"internalType":"bytes","name":"returnResult","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"signer","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"minGasPrice","type":"uint256"},{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"contract IERC20TokenV06","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"internalType":"struct IMetaTransactionsFeature.MetaTransactionData","name":"mtx","type":"tuple"}],"name":"getMetaTransactionExecutedBlock","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"signer","type":"address"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"minGasPrice","type":"uint256"},{"internalType":"uint256","name":"maxGasPrice","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"contract IERC20TokenV06","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"internalType":"struct IMetaTransactionsFeature.MetaTransactionData","name":"mtx","type":"tuple"}],"name":"getMetaTransactionHash","outputs":[{"internalType":"bytes32","name":"mtxHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"mtxHash","type":"bytes32"}],"name":"getMetaTransactionHashExecutedBlock","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrate","outputs":[{"internalType":"bytes4","name":"success","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"}]

6101006040526200001560016002600062000117565b60c0527fe866282978e74dc892efa3621df30a058ca4d374a338824c0b89f1dfdcb0ea0460e0523480156200004957600080fd5b5060405162002da738038062002da78339810160408190526200006c9162000149565b3060601b60805260405181904690620000f2907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f907f9e5dae0addaf20578aeb5d70341d092b53b4e14480ac5726438fd436df7ba427907f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c908590879060200162000179565b60408051601f19818403018152919052805160209091012060a05250620001a5915050565b6bffffffff0000000000000000604084901b1667ffffffff00000000602084901b161763ffffffff8216179392505050565b6000602082840312156200015b578081fd5b81516001600160a01b038116811462000172578182fd5b9392505050565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b60805160601c60a05160c05160e051612bbf620001e86000398061046552806106705250806101e45250806106945280610a9c525080610a3b5250612bbf6000f3fe6080604052600436106100b15760003560e01c80638fd3ab8011610069578063c5579ec81161004e578063c5579ec814610198578063d036092d146101b8578063dab400f3146101cd576100b1565b80638fd3ab8014610156578063ae55049714610178576100b1565b80633fb2da381161009a5780633fb2da38146101015780636ae4b4f71461012157806372d17d0314610136576100b1565b8063031b905c146100b65780633d61ed3e146100e1575b600080fd5b3480156100c257600080fd5b506100cb6101e2565b6040516100d891906124e6565b60405180910390f35b6100f46100ef3660046121ab565b610206565b6040516100d891906126e0565b34801561010d57600080fd5b506100cb61011c366004612170565b610300565b34801561012d57600080fd5b506100f4610316565b34801561014257600080fd5b506100cb610151366004611f93565b61034f565b34801561016257600080fd5b5061016b61036a565b6040516100d89190612639565b34801561018457600080fd5b506100cb610193366004612170565b61045e565b6101ab6101a6366004611ee2565b6104f4565b6040516100d89190612468565b3480156101c457600080fd5b506100cb61066e565b3480156101d957600080fd5b506100cb610692565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060600160006102146106b6565b8054909150828116156102765761027661027161026b600080368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506106c99050565b85610715565b6107d0565b82178155610282611911565b338152604081018690526102958661045e565b6020820152606081018590526102aa816107d8565b93505060006102b934476109e0565b905080156102f057604051339082156108fc029083906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505b5080549119909116905592915050565b600061030e6101518361045e565b90505b919050565b6040518060400160405280601081526020017f4d6574615472616e73616374696f6e730000000000000000000000000000000081525081565b60006103596109f8565b600092835260205250604090205490565b60006103957f3d61ed3e00000000000000000000000000000000000000000000000000000000610a05565b6103be7fc5579ec800000000000000000000000000000000000000000000000000000000610a05565b6103e77f3fb2da3800000000000000000000000000000000000000000000000000000000610a05565b6104107f72d17d0300000000000000000000000000000000000000000000000000000000610a05565b6104397fae55049700000000000000000000000000000000000000000000000000000000610a05565b507f2c64c5ef0000000000000000000000000000000000000000000000000000000090565b600061030e7f0000000000000000000000000000000000000000000000000000000000000000836000015184602001518560400151866060015187608001518860a001518960c00151805190602001208a60e001518b61010001518c61012001516040516020016104d99b9a9998979695949392919061251b565b60405160208183030381529060405280519060200120610a98565b6060600160006105026106b6565b8054909150828116156105595761055961027161026b600080368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506106c99050565b8217815583518551146105755761057561027186518651610aea565b845167ffffffffffffffff8111801561058d57600080fd5b506040519080825280602002602001820160405280156105c157816020015b60608152602001906001900390816105ac5790505b50925060005b8551811015610661576105d8611911565b33815286518790839081106105e957fe5b6020026020010151816040018190525061061587838151811061060857fe5b602002602001015161045e565b6020820152855186908390811061062857fe5b60200260200101518160600181905250610641816107d8565b85838151811061064d57fe5b6020908102919091010152506001016105c7565b5060006102b934476109e0565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806106c36006610b20565b92915050565b600081600401835110156106ea576106ea6102716003855185600401610b3b565b5001602001517fffffffff000000000000000000000000000000000000000000000000000000001690565b60607fc7a7103e21e41a5c3158b3028d34cb9bb9593b10b1892f49d7187efa71219d4e838360405160240161074b9291906126ae565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b805160208201fd5b60606107e382610be0565b436107ec6109f8565b60208085015160009081529190526040908190209190915582015161012001511561083157604082015161010081015181518451610120909301516108319390610dc1565b604082015160c001516108459060006106c9565b7fffffffff0000000000000000000000000000000000000000000000000000000016608083018190527f415565b00000000000000000000000000000000000000000000000000000000014156108a55761089e82610ec9565b9050610968565b60808201517fffffffff00000000000000000000000000000000000000000000000000000000167ff6274f660000000000000000000000000000000000000000000000000000000014156108fc5761089e826110fe565b60808201517fffffffff00000000000000000000000000000000000000000000000000000000167faa77476c0000000000000000000000000000000000000000000000000000000014156109535761089e82611222565b610968610271836020015184608001516112b5565b81608001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f7f4fe3ff8ae440e1570c558da08440b26f89fb1c1f2910cd91ca6452955f121a83602001518460400151600001518560400151602001516040516109d3939291906124ef565b60405180910390a2919050565b60008183106109ef57816109f1565b825b9392505050565b6000806106c36005610b20565b6040517f6eb224cb0000000000000000000000000000000000000000000000000000000081523090636eb224cb90610a639084907f000000000000000000000000000000000000000000000000000000000000000090600401612666565b600060405180830381600087803b158015610a7d57600080fd5b505af1158015610a91573d6000803e3d6000fd5b5050505050565b60007f000000000000000000000000000000000000000000000000000000000000000082604051602001610acd929190612432565b604051602081830303815290604052805190602001209050919050565b60607f52974c3a86e985173f72e2fb84ba2bfca8fb3b7c5031eb8077ebd59458abf2a4838360405160240161074b9291906125dc565b60006080826008811115610b3057fe5b600101901b92915050565b6060632800659560e01b848484604051602401610b5a939291906126f3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b60408101516020015173ffffffffffffffffffffffffffffffffffffffff1615801590610c455750806000015173ffffffffffffffffffffffffffffffffffffffff1681604001516020015173ffffffffffffffffffffffffffffffffffffffff1614155b15610c6857610c68610271826020015183600001518460400151602001516112eb565b4281604001516080015111610c9157610c91610271826020015142846040015160800151611323565b3a8160400151604001511180610cae57503a816040015160600151105b15610cd657610cd661027182602001513a84604001516040015185604001516060015161135b565b4760a08201819052604082015160e001511115610d0b57610d0b61027182602001518360a00151846040015160e0015161141c565b80604001516000015173ffffffffffffffffffffffffffffffffffffffff16610d3c82602001518360600151611454565b73ffffffffffffffffffffffffffffffffffffffff1614610d8257610d8261027160048360200151846040015160000151604051806020016040528060008152506115a5565b610d8a6109f8565b6020808301516000908152919052604090205460c0820181905215610dbe57610dbe61027182602001518360c001516115df565b50565b73ffffffffffffffffffffffffffffffffffffffff8416301415610e1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1190612774565b60405180910390fd5b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152602081606483600073ffffffffffffffffffffffffffffffffffffffff8a165af13d60018351146020821015168115178216915081610ec057806000843e8083fd5b50505050505050565b6060610ed3611958565b604083015160c0015151606090601c0167ffffffffffffffff81118015610ef957600080fd5b506040519080825280601f01601f191660200182016040528015610f24576020820181803683370190505b5090506060846040015160c00151905060a081511015610f4057fe5b602082810152805160248201906040840190610f8190829084907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc01611615565b83806020019051810190610f959190611fab565b9450505050506109f18360200151638aa6539b60e01b60405180610100016040528087604001516000015173ffffffffffffffffffffffffffffffffffffffff168152602001856000015173ffffffffffffffffffffffffffffffffffffffff168152602001856020015173ffffffffffffffffffffffffffffffffffffffff16815260200185604001518152602001856060015181526020018560800151815260200160001515815260200187604001516000015173ffffffffffffffffffffffffffffffffffffffff1681525060405160240161107491906129e3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529086015160e001516116f6565b60606111086119b3565b611110611a17565b60006060611125866040015160c00151611782565b90508080602001905181019061113b919061204e565b60208901516040808b01515190519498509296509094506112189290917f414e4ccf000000000000000000000000000000000000000000000000000000009161118e9189918991899133906024016127d1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529089015160e001516116f6565b9695505050505050565b606061122c611a40565b611234611a17565b60006060611249866040015160c00151611782565b90508080602001905181019061125f91906121f8565b60208901516040808b01515190519498509296509094506112189290917faa6b21cd000000000000000000000000000000000000000000000000000000009161118e9189918991899160009082906024016128e2565b60607f547a32a328d8a78dbe9bf090fa60ba3d4d1c6833a592a2c942666ce3249c1210838360405160240161074b929190612581565b60607fa78002a166fcae5236d89e3ff35c53dadb775f7818de4a020714cba4bf360822848484604051602401610b5a939291906124ef565b60607fbea726efdf9868bbc5755dce9f13d585b3cf731177be75300d15bb8f5e286158848484604051602401610b5a939291906125ea565b60607f6fec11a99ebb0ff14b6648f609f57864dadeba8b29869c4df2b3b76894147849858585856040516024016113959493929190612600565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050949350505050565b60607f0a5ade45208123132815e1591a1c7e64045fd006152f5e85d100aee42ba02c75848484604051602401610b5a939291906125ea565b600061146083836117ef565b60028251600381111561146f57fe5b14156114d757600183836020015184604001518560600151604051600081526020016040526040516114a4949392919061261b565b6020604051602081039080840390855afa1580156114c6573d6000803e3d6000fd5b50505060206040510351905061157c565b6003825160038111156114e657fe5b141561157c5760007f19457468657265756d205369676e6564204d6573736167653a0a33320000000060005283601c52603c60002090506001818460200151856040015186606001516040516000815260200160405260405161154c949392919061261b565b6020604051602081039080840390855afa15801561156e573d6000803e3d6000fd5b505050602060405103519150505b73ffffffffffffffffffffffffffffffffffffffff81166106c3576106c36102716005856118a3565b60607f4c7607a3ebba99c9acde0e2a04d88829f7001b63f028b796dda6ff02406ddad5858585856040516024016113959493929190612731565b60607ffe251a07f3cbffd23c1c1db9ec776d259099c832333d99ef48cacfa93a4d7b32838360405160240161074b9291906125dc565b602081101561165c578151835160208390036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161783526116f1565b82821415611669576116f1565b828211156116a35760208103905080820181840181515b8285101561169b578451865260209586019590940193611680565b9052506116f1565b60208103905080820181840183515b818612156116ec57825182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe092830192909101906116b2565b855250505b505050565b606060003073ffffffffffffffffffffffffffffffffffffffff1683856040516117209190612416565b60006040518083038185875af1925050503d806000811461175d576040519150601f19603f3d011682016040523d82523d6000602084013e611762565b606091505b50925090508061177a5761177a6102718686856118d9565b509392505050565b6060600482510367ffffffffffffffff8111801561179f57600080fd5b506040519080825280601f01601f1916602001820160405280156117ca576020820181803683370190505b5090506000806024840191506020830190506117e881838551611615565b5050919050565b60408101517ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141111580611846575060608101517f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a111155b15611859576118596102716005846118a3565b60008151600381111561186857fe5b141561187c5761187c6102716003846118a3565b60018151600381111561188b57fe5b141561189f5761189f6102716000846118a3565b5050565b60607ff18f11f3027e735c758137924b262d4d3aff0037dcd785aca3c699fa05d960bd838360405160240161074b929190612715565b60607fa9f0c547643c02afed4cf2699e794bc383effca840eed62fddb64a15a4e55bc4848484604051602401610b5a939291906125b1565b6040805160e08101825260008082526020820152908101611930611a94565b815260200161193d611a17565b81526000602082018190526040820181905260609091015290565b6040518060a00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001606081525090565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b604051806101400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200160008152602001600081526020016060815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b80356106c381612b4b565b80516106c381612b4b565b600082601f830112611b4f578081fd5b8135611b62611b5d82612aae565b612a87565b8181529150602080830190848101608080850287018301881015611b8557600080fd5b60005b85811015611bac57611b9a8984611de4565b85529383019391810191600101611b88565b50505050505092915050565b600082601f830112611bc8578081fd5b8151611bd6611b5d82612aae565b818152915060208083019084810160005b84811015611c7d57815187016040807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215611c2657600080fd5b611c2f81612a87565b611c3b8b878501611eb6565b8152908201519067ffffffffffffffff821115611c5757600080fd5b611c658b8784860101611cd6565b81870152865250509282019290820190600101611be7565b505050505092915050565b600082601f830112611c98578081fd5b8135611ca6611b5d82612ace565b9150808252836020828501011115611cbd57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112611ce6578081fd5b8151611cf4611b5d82612ace565b9150808252836020828501011115611d0b57600080fd5b611d1c816020840160208601612b1b565b5092915050565b6000610140808385031215611d36578182fd5b611d3f81612a87565b915050611d4c8383611b29565b8152611d5b8360208401611b29565b602082015260408201356040820152606082013560608201526080820135608082015260a082013560a082015260c082013567ffffffffffffffff811115611da257600080fd5b611dae84828501611c88565b60c08301525060e082013560e0820152610100611dcd84828501611b29565b818301525061012080830135818301525092915050565b600060808284031215611df5578081fd5b611dff6080612a87565b90508135611e0c81612b6d565b81526020820135611e1c81612b7a565b80602083015250604082013560408201526060820135606082015292915050565b600060808284031215611e4e578081fd5b611e586080612a87565b90508151611e6581612b6d565b81526020820151611e7581612b7a565b80602083015250604082015160408201526060820151606082015292915050565b80516fffffffffffffffffffffffffffffffff811681146106c357600080fd5b805163ffffffff811681146106c357600080fd5b805167ffffffffffffffff811681146106c357600080fd5b60008060408385031215611ef4578182fd5b823567ffffffffffffffff80821115611f0b578384fd5b818501915085601f830112611f1e578384fd5b8135611f2c611b5d82612aae565b81815260208082019190858101885b85811015611f6457611f528c8484358b0101611d23565b85529382019390820190600101611f3b565b50919750880135945050505080821115611f7c578283fd5b50611f8985828601611b3f565b9150509250929050565b600060208284031215611fa4578081fd5b5035919050565b600060208284031215611fbc578081fd5b815167ffffffffffffffff80821115611fd3578283fd5b9083019060a08286031215611fe6578283fd5b611ff060a0612a87565b611ffa8684611b34565b81526120098660208501611b34565b60208201526040830151604082015260608301516060820152608083015182811115612033578485fd5b61203f87828601611bb8565b60808301525095945050505050565b6000806000838503610220811215612064578182fd5b61018080821215612073578283fd5b61207c81612a87565b91506120888787611b34565b82526120978760208801611b34565b60208301526120a98760408801611e96565b60408301526120bb8760608801611e96565b60608301526120cd8760808801611e96565b60808301526120df8760a08801611b34565b60a08301526120f18760c08801611b34565b60c08301526121038760e08801611b34565b60e083015261010061211788828901611b34565b90830152610120868101519083015261014061213588828901611eca565b818401525061016080870151818401525081945061215587828801611e3d565b93505050612167856102008601611e96565b90509250925092565b600060208284031215612181578081fd5b813567ffffffffffffffff811115612197578182fd5b6121a384828501611d23565b949350505050565b60008060a083850312156121bd578182fd5b823567ffffffffffffffff8111156121d3578283fd5b6121df85828601611d23565b9250506121ef8460208501611de4565b90509250929050565b60008060008385036101e081121561220e578182fd5b6101408082121561221d578283fd5b61222681612a87565b91506122328787611b34565b82526122418760208801611b34565b60208301526122538760408801611e96565b60408301526122658760608801611e96565b60608301526122778760808801611b34565b60808301526122898760a08801611b34565b60a083015261229b8760c08801611b34565b60c083015260e086015160e08301526101006122b988828901611eca565b81840152506101208087015181840152508194506122d987828801611e3d565b93505050612167856101c08601611e96565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208085018081965082840281019150828601855b858110156123655782840389528151805163ffffffff168552850151604086860181905261235181870183612378565b9a87019a9550505090840190600101612321565b5091979650505050505050565b15159052565b60008151808452612390816020860160208601612b1b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8051600481106123ce57fe5b825260208181015160ff169083015260408082015190830152606090810151910152565b6fffffffffffffffffffffffffffffffff169052565b67ffffffffffffffff169052565b60008251612428818460208701612b1b565b9190910192915050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6000602080830181845280855180835260408601915060408482028701019250838701855b828110156124d9577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08886030184526124c7858351612378565b9450928501929085019060010161248d565b5092979650505050505050565b90815260200190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b9a8b5273ffffffffffffffffffffffffffffffffffffffff998a1660208c015297891660408b015260608a0196909652608089019490945260a088019290925260c087015260e08601526101008501529091166101208301526101408201526101600190565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260400190565b6000848252606060208301526125ca6060830185612378565b82810360408401526112188185612378565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b93845260ff9290921660208401526040830152606082015260800190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000092909216825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b7fffffffff00000000000000000000000000000000000000000000000000000000929092168252602082015260400190565b6000602082526109f16020830184612378565b606081016008851061270157fe5b938152602081019290925260409091015290565b6040810161272284612b10565b82528260208301529392505050565b600061273c86612b10565b825284602083015273ffffffffffffffffffffffffffffffffffffffff84166040830152608060608301526112186080830184612378565b60208082526024908201527f466978696e546f6b656e5370656e6465722f43414e4e4f545f494e564f4b455f60408201527f53454c4600000000000000000000000000000000000000000000000000000000606082015260800190565b6000610260820190506127e58288516122eb565b60208701516127f760208401826122eb565b50604087015161280a60408401826123f2565b50606087015161281d60608401826123f2565b50608087015161283060808401826123f2565b5060a087015161284360a08401826122eb565b5060c087015161285660c08401826122eb565b5060e087015161286960e08401826122eb565b506101008088015161287d828501826122eb565b505061012087810151908301526101408088015161289d82850182612408565b505061016087810151908301526128b86101808301876123c2565b6128c66102008301866123f2565b6128d46102208301856122eb565b6112186102408301846122eb565b6000610240820190506128f68289516122eb565b602088015161290860208401826122eb565b50604088015161291b60408401826123f2565b50606088015161292e60608401826123f2565b50608088015161294160808401826122eb565b5060a088015161295460a08401826122eb565b5060c088015161296760c08401826122eb565b5060e088015160e08301526101008089015161298582850182612408565b505061012088810151908301526129a06101408301886123c2565b6129ae6101c08301876123f2565b6129bc6101e08301866122eb565b6129ca610200830185612372565b6129d86102208301846122eb565b979650505050505050565b60006020825273ffffffffffffffffffffffffffffffffffffffff808451166020840152806020850151166040840152506040830151612a2660608401826122eb565b5060608301516080830152608083015160a083015260a08301516101008060c0850152612a57610120850183612305565b915060c0850151612a6b60e0860182612372565b5060e0850151612a7d828601826122eb565b5090949350505050565b60405181810167ffffffffffffffff81118282101715612aa657600080fd5b604052919050565b600067ffffffffffffffff821115612ac4578081fd5b5060209081020190565b600067ffffffffffffffff821115612ae4578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b806006811061031157fe5b60005b83811015612b36578181015183820152602001612b1e565b83811115612b45576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610dbe57600080fd5b60048110610dbe57600080fd5b60ff81168114610dbe57600080fdfea264697066735822122038de8d2e36ddcd189607c61647f081c263e77851a765ea238c2ba5deb4b71ae864736f6c634300060c0033000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff

Deployed Bytecode

0x6080604052600436106100b15760003560e01c80638fd3ab8011610069578063c5579ec81161004e578063c5579ec814610198578063d036092d146101b8578063dab400f3146101cd576100b1565b80638fd3ab8014610156578063ae55049714610178576100b1565b80633fb2da381161009a5780633fb2da38146101015780636ae4b4f71461012157806372d17d0314610136576100b1565b8063031b905c146100b65780633d61ed3e146100e1575b600080fd5b3480156100c257600080fd5b506100cb6101e2565b6040516100d891906124e6565b60405180910390f35b6100f46100ef3660046121ab565b610206565b6040516100d891906126e0565b34801561010d57600080fd5b506100cb61011c366004612170565b610300565b34801561012d57600080fd5b506100f4610316565b34801561014257600080fd5b506100cb610151366004611f93565b61034f565b34801561016257600080fd5b5061016b61036a565b6040516100d89190612639565b34801561018457600080fd5b506100cb610193366004612170565b61045e565b6101ab6101a6366004611ee2565b6104f4565b6040516100d89190612468565b3480156101c457600080fd5b506100cb61066e565b3480156101d957600080fd5b506100cb610692565b7f000000000000000000000000000000000000000000000001000000020000000081565b6060600160006102146106b6565b8054909150828116156102765761027661027161026b600080368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506106c99050565b85610715565b6107d0565b82178155610282611911565b338152604081018690526102958661045e565b6020820152606081018590526102aa816107d8565b93505060006102b934476109e0565b905080156102f057604051339082156108fc029083906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505b5080549119909116905592915050565b600061030e6101518361045e565b90505b919050565b6040518060400160405280601081526020017f4d6574615472616e73616374696f6e730000000000000000000000000000000081525081565b60006103596109f8565b600092835260205250604090205490565b60006103957f3d61ed3e00000000000000000000000000000000000000000000000000000000610a05565b6103be7fc5579ec800000000000000000000000000000000000000000000000000000000610a05565b6103e77f3fb2da3800000000000000000000000000000000000000000000000000000000610a05565b6104107f72d17d0300000000000000000000000000000000000000000000000000000000610a05565b6104397fae55049700000000000000000000000000000000000000000000000000000000610a05565b507f2c64c5ef0000000000000000000000000000000000000000000000000000000090565b600061030e7fe866282978e74dc892efa3621df30a058ca4d374a338824c0b89f1dfdcb0ea04836000015184602001518560400151866060015187608001518860a001518960c00151805190602001208a60e001518b61010001518c61012001516040516020016104d99b9a9998979695949392919061251b565b60405160208183030381529060405280519060200120610a98565b6060600160006105026106b6565b8054909150828116156105595761055961027161026b600080368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092939250506106c99050565b8217815583518551146105755761057561027186518651610aea565b845167ffffffffffffffff8111801561058d57600080fd5b506040519080825280602002602001820160405280156105c157816020015b60608152602001906001900390816105ac5790505b50925060005b8551811015610661576105d8611911565b33815286518790839081106105e957fe5b6020026020010151816040018190525061061587838151811061060857fe5b602002602001015161045e565b6020820152855186908390811061062857fe5b60200260200101518160600181905250610641816107d8565b85838151811061064d57fe5b6020908102919091010152506001016105c7565b5060006102b934476109e0565b7fe866282978e74dc892efa3621df30a058ca4d374a338824c0b89f1dfdcb0ea0481565b7ffe3a8808ff7909b8c36164e6e9a076597c21c3fc2ec6f2c8ac04529c41ce507e81565b6000806106c36006610b20565b92915050565b600081600401835110156106ea576106ea6102716003855185600401610b3b565b5001602001517fffffffff000000000000000000000000000000000000000000000000000000001690565b60607fc7a7103e21e41a5c3158b3028d34cb9bb9593b10b1892f49d7187efa71219d4e838360405160240161074b9291906126ae565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b805160208201fd5b60606107e382610be0565b436107ec6109f8565b60208085015160009081529190526040908190209190915582015161012001511561083157604082015161010081015181518451610120909301516108319390610dc1565b604082015160c001516108459060006106c9565b7fffffffff0000000000000000000000000000000000000000000000000000000016608083018190527f415565b00000000000000000000000000000000000000000000000000000000014156108a55761089e82610ec9565b9050610968565b60808201517fffffffff00000000000000000000000000000000000000000000000000000000167ff6274f660000000000000000000000000000000000000000000000000000000014156108fc5761089e826110fe565b60808201517fffffffff00000000000000000000000000000000000000000000000000000000167faa77476c0000000000000000000000000000000000000000000000000000000014156109535761089e82611222565b610968610271836020015184608001516112b5565b81608001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167f7f4fe3ff8ae440e1570c558da08440b26f89fb1c1f2910cd91ca6452955f121a83602001518460400151600001518560400151602001516040516109d3939291906124ef565b60405180910390a2919050565b60008183106109ef57816109f1565b825b9392505050565b6000806106c36005610b20565b6040517f6eb224cb0000000000000000000000000000000000000000000000000000000081523090636eb224cb90610a639084907f0000000000000000000000005a66a1be5de85e770d2a7aac6d1d30e39d4f660990600401612666565b600060405180830381600087803b158015610a7d57600080fd5b505af1158015610a91573d6000803e3d6000fd5b5050505050565b60007ffe3a8808ff7909b8c36164e6e9a076597c21c3fc2ec6f2c8ac04529c41ce507e82604051602001610acd929190612432565b604051602081830303815290604052805190602001209050919050565b60607f52974c3a86e985173f72e2fb84ba2bfca8fb3b7c5031eb8077ebd59458abf2a4838360405160240161074b9291906125dc565b60006080826008811115610b3057fe5b600101901b92915050565b6060632800659560e01b848484604051602401610b5a939291906126f3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b60408101516020015173ffffffffffffffffffffffffffffffffffffffff1615801590610c455750806000015173ffffffffffffffffffffffffffffffffffffffff1681604001516020015173ffffffffffffffffffffffffffffffffffffffff1614155b15610c6857610c68610271826020015183600001518460400151602001516112eb565b4281604001516080015111610c9157610c91610271826020015142846040015160800151611323565b3a8160400151604001511180610cae57503a816040015160600151105b15610cd657610cd661027182602001513a84604001516040015185604001516060015161135b565b4760a08201819052604082015160e001511115610d0b57610d0b61027182602001518360a00151846040015160e0015161141c565b80604001516000015173ffffffffffffffffffffffffffffffffffffffff16610d3c82602001518360600151611454565b73ffffffffffffffffffffffffffffffffffffffff1614610d8257610d8261027160048360200151846040015160000151604051806020016040528060008152506115a5565b610d8a6109f8565b6020808301516000908152919052604090205460c0820181905215610dbe57610dbe61027182602001518360c001516115df565b50565b73ffffffffffffffffffffffffffffffffffffffff8416301415610e1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1190612774565b60405180910390fd5b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152816044820152602081606483600073ffffffffffffffffffffffffffffffffffffffff8a165af13d60018351146020821015168115178216915081610ec057806000843e8083fd5b50505050505050565b6060610ed3611958565b604083015160c0015151606090601c0167ffffffffffffffff81118015610ef957600080fd5b506040519080825280601f01601f191660200182016040528015610f24576020820181803683370190505b5090506060846040015160c00151905060a081511015610f4057fe5b602082810152805160248201906040840190610f8190829084907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc01611615565b83806020019051810190610f959190611fab565b9450505050506109f18360200151638aa6539b60e01b60405180610100016040528087604001516000015173ffffffffffffffffffffffffffffffffffffffff168152602001856000015173ffffffffffffffffffffffffffffffffffffffff168152602001856020015173ffffffffffffffffffffffffffffffffffffffff16815260200185604001518152602001856060015181526020018560800151815260200160001515815260200187604001516000015173ffffffffffffffffffffffffffffffffffffffff1681525060405160240161107491906129e3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529086015160e001516116f6565b60606111086119b3565b611110611a17565b60006060611125866040015160c00151611782565b90508080602001905181019061113b919061204e565b60208901516040808b01515190519498509296509094506112189290917f414e4ccf000000000000000000000000000000000000000000000000000000009161118e9189918991899133906024016127d1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529089015160e001516116f6565b9695505050505050565b606061122c611a40565b611234611a17565b60006060611249866040015160c00151611782565b90508080602001905181019061125f91906121f8565b60208901516040808b01515190519498509296509094506112189290917faa6b21cd000000000000000000000000000000000000000000000000000000009161118e9189918991899160009082906024016128e2565b60607f547a32a328d8a78dbe9bf090fa60ba3d4d1c6833a592a2c942666ce3249c1210838360405160240161074b929190612581565b60607fa78002a166fcae5236d89e3ff35c53dadb775f7818de4a020714cba4bf360822848484604051602401610b5a939291906124ef565b60607fbea726efdf9868bbc5755dce9f13d585b3cf731177be75300d15bb8f5e286158848484604051602401610b5a939291906125ea565b60607f6fec11a99ebb0ff14b6648f609f57864dadeba8b29869c4df2b3b76894147849858585856040516024016113959493929190612600565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050949350505050565b60607f0a5ade45208123132815e1591a1c7e64045fd006152f5e85d100aee42ba02c75848484604051602401610b5a939291906125ea565b600061146083836117ef565b60028251600381111561146f57fe5b14156114d757600183836020015184604001518560600151604051600081526020016040526040516114a4949392919061261b565b6020604051602081039080840390855afa1580156114c6573d6000803e3d6000fd5b50505060206040510351905061157c565b6003825160038111156114e657fe5b141561157c5760007f19457468657265756d205369676e6564204d6573736167653a0a33320000000060005283601c52603c60002090506001818460200151856040015186606001516040516000815260200160405260405161154c949392919061261b565b6020604051602081039080840390855afa15801561156e573d6000803e3d6000fd5b505050602060405103519150505b73ffffffffffffffffffffffffffffffffffffffff81166106c3576106c36102716005856118a3565b60607f4c7607a3ebba99c9acde0e2a04d88829f7001b63f028b796dda6ff02406ddad5858585856040516024016113959493929190612731565b60607ffe251a07f3cbffd23c1c1db9ec776d259099c832333d99ef48cacfa93a4d7b32838360405160240161074b9291906125dc565b602081101561165c578151835160208390036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161783526116f1565b82821415611669576116f1565b828211156116a35760208103905080820181840181515b8285101561169b578451865260209586019590940193611680565b9052506116f1565b60208103905080820181840183515b818612156116ec57825182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe092830192909101906116b2565b855250505b505050565b606060003073ffffffffffffffffffffffffffffffffffffffff1683856040516117209190612416565b60006040518083038185875af1925050503d806000811461175d576040519150601f19603f3d011682016040523d82523d6000602084013e611762565b606091505b50925090508061177a5761177a6102718686856118d9565b509392505050565b6060600482510367ffffffffffffffff8111801561179f57600080fd5b506040519080825280601f01601f1916602001820160405280156117ca576020820181803683370190505b5090506000806024840191506020830190506117e881838551611615565b5050919050565b60408101517ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141111580611846575060608101517f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a111155b15611859576118596102716005846118a3565b60008151600381111561186857fe5b141561187c5761187c6102716003846118a3565b60018151600381111561188b57fe5b141561189f5761189f6102716000846118a3565b5050565b60607ff18f11f3027e735c758137924b262d4d3aff0037dcd785aca3c699fa05d960bd838360405160240161074b929190612715565b60607fa9f0c547643c02afed4cf2699e794bc383effca840eed62fddb64a15a4e55bc4848484604051602401610b5a939291906125b1565b6040805160e08101825260008082526020820152908101611930611a94565b815260200161193d611a17565b81526000602082018190526040820181905260609091015290565b6040518060a00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001606081525090565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b604051806101400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200160008152602001600081526020016060815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b80356106c381612b4b565b80516106c381612b4b565b600082601f830112611b4f578081fd5b8135611b62611b5d82612aae565b612a87565b8181529150602080830190848101608080850287018301881015611b8557600080fd5b60005b85811015611bac57611b9a8984611de4565b85529383019391810191600101611b88565b50505050505092915050565b600082601f830112611bc8578081fd5b8151611bd6611b5d82612aae565b818152915060208083019084810160005b84811015611c7d57815187016040807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c03011215611c2657600080fd5b611c2f81612a87565b611c3b8b878501611eb6565b8152908201519067ffffffffffffffff821115611c5757600080fd5b611c658b8784860101611cd6565b81870152865250509282019290820190600101611be7565b505050505092915050565b600082601f830112611c98578081fd5b8135611ca6611b5d82612ace565b9150808252836020828501011115611cbd57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112611ce6578081fd5b8151611cf4611b5d82612ace565b9150808252836020828501011115611d0b57600080fd5b611d1c816020840160208601612b1b565b5092915050565b6000610140808385031215611d36578182fd5b611d3f81612a87565b915050611d4c8383611b29565b8152611d5b8360208401611b29565b602082015260408201356040820152606082013560608201526080820135608082015260a082013560a082015260c082013567ffffffffffffffff811115611da257600080fd5b611dae84828501611c88565b60c08301525060e082013560e0820152610100611dcd84828501611b29565b818301525061012080830135818301525092915050565b600060808284031215611df5578081fd5b611dff6080612a87565b90508135611e0c81612b6d565b81526020820135611e1c81612b7a565b80602083015250604082013560408201526060820135606082015292915050565b600060808284031215611e4e578081fd5b611e586080612a87565b90508151611e6581612b6d565b81526020820151611e7581612b7a565b80602083015250604082015160408201526060820151606082015292915050565b80516fffffffffffffffffffffffffffffffff811681146106c357600080fd5b805163ffffffff811681146106c357600080fd5b805167ffffffffffffffff811681146106c357600080fd5b60008060408385031215611ef4578182fd5b823567ffffffffffffffff80821115611f0b578384fd5b818501915085601f830112611f1e578384fd5b8135611f2c611b5d82612aae565b81815260208082019190858101885b85811015611f6457611f528c8484358b0101611d23565b85529382019390820190600101611f3b565b50919750880135945050505080821115611f7c578283fd5b50611f8985828601611b3f565b9150509250929050565b600060208284031215611fa4578081fd5b5035919050565b600060208284031215611fbc578081fd5b815167ffffffffffffffff80821115611fd3578283fd5b9083019060a08286031215611fe6578283fd5b611ff060a0612a87565b611ffa8684611b34565b81526120098660208501611b34565b60208201526040830151604082015260608301516060820152608083015182811115612033578485fd5b61203f87828601611bb8565b60808301525095945050505050565b6000806000838503610220811215612064578182fd5b61018080821215612073578283fd5b61207c81612a87565b91506120888787611b34565b82526120978760208801611b34565b60208301526120a98760408801611e96565b60408301526120bb8760608801611e96565b60608301526120cd8760808801611e96565b60808301526120df8760a08801611b34565b60a08301526120f18760c08801611b34565b60c08301526121038760e08801611b34565b60e083015261010061211788828901611b34565b90830152610120868101519083015261014061213588828901611eca565b818401525061016080870151818401525081945061215587828801611e3d565b93505050612167856102008601611e96565b90509250925092565b600060208284031215612181578081fd5b813567ffffffffffffffff811115612197578182fd5b6121a384828501611d23565b949350505050565b60008060a083850312156121bd578182fd5b823567ffffffffffffffff8111156121d3578283fd5b6121df85828601611d23565b9250506121ef8460208501611de4565b90509250929050565b60008060008385036101e081121561220e578182fd5b6101408082121561221d578283fd5b61222681612a87565b91506122328787611b34565b82526122418760208801611b34565b60208301526122538760408801611e96565b60408301526122658760608801611e96565b60608301526122778760808801611b34565b60808301526122898760a08801611b34565b60a083015261229b8760c08801611b34565b60c083015260e086015160e08301526101006122b988828901611eca565b81840152506101208087015181840152508194506122d987828801611e3d565b93505050612167856101c08601611e96565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208085018081965082840281019150828601855b858110156123655782840389528151805163ffffffff168552850151604086860181905261235181870183612378565b9a87019a9550505090840190600101612321565b5091979650505050505050565b15159052565b60008151808452612390816020860160208601612b1b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8051600481106123ce57fe5b825260208181015160ff169083015260408082015190830152606090810151910152565b6fffffffffffffffffffffffffffffffff169052565b67ffffffffffffffff169052565b60008251612428818460208701612b1b565b9190910192915050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b6000602080830181845280855180835260408601915060408482028701019250838701855b828110156124d9577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08886030184526124c7858351612378565b9450928501929085019060010161248d565b5092979650505050505050565b90815260200190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b9a8b5273ffffffffffffffffffffffffffffffffffffffff998a1660208c015297891660408b015260608a0196909652608089019490945260a088019290925260c087015260e08601526101008501529091166101208301526101408201526101600190565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260400190565b6000848252606060208301526125ca6060830185612378565b82810360408401526112188185612378565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b93845260ff9290921660208401526040830152606082015260800190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000092909216825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b7fffffffff00000000000000000000000000000000000000000000000000000000929092168252602082015260400190565b6000602082526109f16020830184612378565b606081016008851061270157fe5b938152602081019290925260409091015290565b6040810161272284612b10565b82528260208301529392505050565b600061273c86612b10565b825284602083015273ffffffffffffffffffffffffffffffffffffffff84166040830152608060608301526112186080830184612378565b60208082526024908201527f466978696e546f6b656e5370656e6465722f43414e4e4f545f494e564f4b455f60408201527f53454c4600000000000000000000000000000000000000000000000000000000606082015260800190565b6000610260820190506127e58288516122eb565b60208701516127f760208401826122eb565b50604087015161280a60408401826123f2565b50606087015161281d60608401826123f2565b50608087015161283060808401826123f2565b5060a087015161284360a08401826122eb565b5060c087015161285660c08401826122eb565b5060e087015161286960e08401826122eb565b506101008088015161287d828501826122eb565b505061012087810151908301526101408088015161289d82850182612408565b505061016087810151908301526128b86101808301876123c2565b6128c66102008301866123f2565b6128d46102208301856122eb565b6112186102408301846122eb565b6000610240820190506128f68289516122eb565b602088015161290860208401826122eb565b50604088015161291b60408401826123f2565b50606088015161292e60608401826123f2565b50608088015161294160808401826122eb565b5060a088015161295460a08401826122eb565b5060c088015161296760c08401826122eb565b5060e088015160e08301526101008089015161298582850182612408565b505061012088810151908301526129a06101408301886123c2565b6129ae6101c08301876123f2565b6129bc6101e08301866122eb565b6129ca610200830185612372565b6129d86102208301846122eb565b979650505050505050565b60006020825273ffffffffffffffffffffffffffffffffffffffff808451166020840152806020850151166040840152506040830151612a2660608401826122eb565b5060608301516080830152608083015160a083015260a08301516101008060c0850152612a57610120850183612305565b915060c0850151612a6b60e0860182612372565b5060e0850151612a7d828601826122eb565b5090949350505050565b60405181810167ffffffffffffffff81118282101715612aa657600080fd5b604052919050565b600067ffffffffffffffff821115612ac4578081fd5b5060209081020190565b600067ffffffffffffffff821115612ae4578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b806006811061031157fe5b60005b83811015612b36578181015183820152602001612b1e565b83811115612b45576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610dbe57600080fd5b60048110610dbe57600080fd5b60ff81168114610dbe57600080fdfea264697066735822122038de8d2e36ddcd189607c61647f081c263e77851a765ea238c2ba5deb4b71ae864736f6c634300060c0033

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

000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff

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

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


Deployed Bytecode Sourcemap

1445:18806:6:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2840:75;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;4842:539;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;6774:248::-;;;;;;;;;;-1:-1:-1;6774:248:6;;;;;:::i;:::-;;:::i;2731:65::-;;;;;;;;;;;;;:::i;7243:250::-;;;;;;;;;;-1:-1:-1;7243:250:6;;;;;:::i;:::-;;:::i;4104:511::-;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;7646:531::-;;;;;;;;;;-1:-1:-1;7646:531:6;;;;;:::i;:::-;;:::i;5631:936::-;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;2987:432::-;;;;;;;;;;;;;:::i;990:48:17:-;;;;;;;;;;;;;:::i;2840:75:6:-;;;:::o;4842:539::-;5098:25;1214:3:18;1366:46;1427:38;:36;:38::i;:::-;1512:20;;1366:99;;-1:-1:-1;1628:30:18;;;1627:37;1623:227;;1684:151;:141;1748:22;1768:1;1748:8;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1748:19:18;;:22;-1:-1:-1;;1748:19:18;:22;-1:-1:-1;1748:22:18:i;:::-;1792:15;1684:42;:141::i;:::-;:149;:151::i;:::-;1926:30;;1903:53;;5139:25:6::2;;:::i;:::-;5189:10;5174:25:::0;;5209:9:::2;::::0;::::2;:15:::0;;;5247:27:::2;5221:3:::0;5247:22:::2;:27::i;:::-;5234:10;::::0;::::2;:40:::0;5284:15:::2;::::0;::::2;:27:::0;;;5337:37:::2;5234:5:::0;5337:30:::2;:37::i;:::-;5322:52;;3542:1;3553:24:::1;3592:55;3614:9;3625:21;3592;:55::i;:::-;3553:94:::0;-1:-1:-1;3661:20:6;;3657:88:::1;;3697:37;::::0;:10:::1;::::0;:37;::::1;;;::::0;3717:16;;3697:37:::1;::::0;;;3717:16;3697:10;:37;::::1;;;;;;;;;;;;;::::0;::::1;;;;;;3657:88;-1:-1:-1::0;2047:20:18;;2071:16;;2047:41;;;2024:64;;4842:539:6;;-1:-1:-1;;4842:539:6:o;6774:248::-;6909:19;6951:64;6987:27;7010:3;6987:22;:27::i;6951:64::-;6944:71;;6774:248;;;;:::o;2731:65::-;;;;;;;;;;;;;;;;;;;:::o;7243:250::-;7367:19;7409:39;:37;:39::i;:::-;:68;:77;;;;;-1:-1:-1;7409:77:6;;;;;7243:250::o;4104:511::-;4157:14;4187:62;4212:36;4187:24;:62::i;:::-;4259:68;4284:42;4259:24;:68::i;:::-;4337:71;4362:45;4337:24;:71::i;:::-;4418:75;4443:49;4418:24;:75::i;:::-;4503:62;4528:36;4503:24;:62::i;:::-;-1:-1:-1;4582:26:6;4104:511;:::o;7646:531::-;7772:15;7810:360;7859:19;7892:3;:10;;;7916:3;:10;;;7940:3;:15;;;7969:3;:15;;;7998:3;:25;;;8037:3;:8;;;8069:3;:12;;;8059:23;;;;;;8096:3;:9;;;8119:3;:12;;;8145:3;:13;;;7835:333;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;7825:344;;;;;;7810:14;:360::i;5631:936::-;5899:28;1214:3:18;1366:46;1427:38;:36;:38::i;:::-;1512:20;;1366:99;;-1:-1:-1;1628:30:18;;;1627:37;1623:227;;1684:151;:141;1748:22;1768:1;1748:8;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1748:19:18;;:22;-1:-1:-1;;1748:19:18;:22;-1:-1:-1;1748:22:18:i;1684:151::-;1926:30;;1903:53;;5962:17:6;;5947:11;;:32:::2;5943:221;;5995:158;:148;6083:4;:11;6112:10;:17;5995:70;:148::i;:158::-;6201:4;:11;6189:24;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6173:40;;6228:9;6223:338;6247:4;:11;6243:1;:15;6223:338;;;6279:25;;:::i;:::-;6333:10;6318:25:::0;;6369:7;;:4;;6374:1;;6369:7;::::2;;;;;;;;;;;6357:5;:9;;:19;;;;6403:31;6426:4;6431:1;6426:7;;;;;;;;;;;;;;6403:22;:31::i;:::-;6390:10;::::0;::::2;:44:::0;6466:13;;:10;;6477:1;;6466:13;::::2;;;;;;;;;;;6448:5;:15;;:31;;;;6513:37;6544:5;6513:30;:37::i;:::-;6494:13;6508:1;6494:16;;;;;;;;;::::0;;::::2;::::0;;;;;:56;-1:-1:-1;6260:3:6::2;;6223:338;;;;3553:24:::1;3592:55;3614:9;3625:21;3592;:55::i;2987:432::-:0;;;:::o;990:48:17:-;;;:::o;1131:476:22:-;1176:20;1208:19;1230:85;1269:36;1230:25;:85::i;:::-;1208:107;1573:28;-1:-1:-1;;1573:28:22:o;17014:880:27:-;17134:13;17178:5;17186:1;17178:9;17167:1;:8;:20;17163:299;;;17203:248;17228:222;17293:90;17401:1;:8;17427:5;17435:1;17427:9;17228:47;:222::i;17203:248::-;-1:-1:-1;17635:13:27;17538:2;17635:13;17629:20;17788:66;17776:79;;17014:880::o;987:319:0:-;1108:12;1186:51;1252:8;1274:15;1143:156;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;987:319:0;;;;:::o;1531:170:30:-;1674:9;1668:16;1661:4;1650:9;1646:20;1639:46;8487:1693:6;8587:25;8628:31;8653:5;8628:24;:31::i;:::-;8999:12;8903:39;:37;:39::i;:::-;8985:10;;;;;8903:81;:93;;;;;;;;;;;:108;;;;9064:9;;;:19;;;:23;9060:229;;9145:9;;;;:18;;;;9181:16;;9215:12;;9245:19;;;;;9103:175;;9215:12;9103:24;:175::i;:::-;9367:9;;;;:18;;;:32;;9397:1;9367:29;:32::i;:::-;9350:49;;:14;;;:49;;;9431:46;9413:64;9409:605;;;9508:33;9535:5;9508:26;:33::i;:::-;9493:48;;9409:605;;;9562:14;;;;:62;;9580:44;9562:62;9558:456;;;9655:33;9682:5;9655:26;:33::i;9558:456::-;9709:14;;;;:60;;9727:42;9709:60;9705:309;;;9800:31;9825:5;9800:24;:31::i;9705:309::-;9862:141;:114;9949:5;:10;;;9961:5;:14;;;9862:86;:114::i;:141::-;10089:5;:14;;;10028:145;;;;10065:5;:10;;;10117:5;:9;;;:16;;;10147:5;:9;;;:16;;;10028:145;;;;;;;;:::i;:::-;;;;;;;;8487:1693;;;:::o;2544:135:28:-;2629:7;2663:1;2659;:5;:13;;2671:1;2659:13;;;2667:1;2659:13;2652:20;2544:135;-1:-1:-1;;;2544:135:28:o;1060:477:21:-;1105:20;1137:19;1159:86;1198:37;1159:25;:86::i;2201:168:16:-;2283:79;;;;;2322:4;;2283:52;;:79;;2336:8;;2346:15;;2283:79;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2201:168;:::o;1810:260:17:-;1901:18;2005:23;2042:10;1952:110;;;;;;;;;:::i;:::-;;;;;;;;;;;;;1942:121;;;;;;1935:128;;1810:260;;;:::o;734:377:1:-;895:12;973:70;1058:8;1080:14;930:174;;;;;;;;;:::i;1625:335:23:-;1717:12;922:3;1918:9;1910:18;;;;;;;;1931:1;1910:22;1909:44;;;1625:335;-1:-1:-1;;1625:335:23:o;1334:378:29:-;1522:12;1274:10;1593:37;;1644:9;1667:6;1687:8;1557:148;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1334:378:29;;;;;:::o;10247:2569:6:-;10408:9;;;;:16;;;:30;;;;;;:66;;;10462:5;:12;;;10442:32;;:5;:9;;;:16;;;:32;;;;10408:66;10404:307;;;10490:210;:200;10590:5;:10;;;10622:5;:12;;;10656:5;:9;;;:16;;;10490:78;:200::i;:210::-;10791:15;10756:5;:9;;;:31;;;:50;10752:305;;10822:224;:214;10918:5;:10;;;10950:15;10987:5;:9;;;:31;;;10822:74;:214::i;:224::-;11134:11;11110:5;:9;;;:21;;;:35;:74;;;;11173:11;11149:5;:9;;;:21;;;:35;11110:74;11106:359;;;11200:254;:244;11297:5;:10;;;11329:11;11362:5;:9;;;:21;;;11405:5;:9;;;:21;;;11200:75;:244::i;:254::-;11528:21;11507:17;;;:42;;;11563:9;;;;:15;;;:35;11559:284;;;11614:218;:208;11718:5;:10;;;11750:5;:17;;;11789:5;:9;;;:15;;;11614:82;:208::i;:218::-;11934:5;:9;;;:16;;;11857:93;;:57;11886:5;:10;;;11898:5;:15;;;11857:28;:57::i;:::-;:93;;;11853:507;;11966:383;:373;12031:65;12114:5;:10;;;12142:5;:9;;;:16;;;11966:373;;;;;;;;;;;;:47;:373::i;:383::-;12457:52;:50;:52::i;:::-;12539:10;;;;;12457:81;:93;;;;;;;;;;12429:25;;;:121;;;12564:30;12560:250;;12610:189;:179;12714:5;:10;;;12746:5;:25;;;12610:82;:179::i;:189::-;10247:2569;:::o;1310:1717:19:-;1486:31;;;1512:4;1486:31;;1478:80;;;;;;;;;;;;:::i;:::-;;;;;;;;;1609:4;1603:11;1729:66;1724:3;1717:79;1843:12;1836:5;1832:24;1825:4;1820:3;1816:14;1809:48;1901:12;1897:2;1893:21;1886:4;1881:3;1877:14;1870:45;1951:6;1944:4;1939:3;1935:14;1928:30;2157:2;2136:3;2114:4;2093:3;2074:1;2043:12;2036:5;2032:24;2009:5;1987:186;2201:16;2787:1;2781:3;2775:10;2772:17;2716:2;2708:6;2705:14;2698:22;2669:179;2601:6;2594:14;2570:296;2492:7;2471:409;2460:420;;2904:7;2894:2;;2954:6;2951:1;2946:3;2931:30;2990:6;2985:3;2978:19;2894:2;;;;1578:1443;;;;:::o;13108:3445:6:-;13204:25;14667:38;;:::i;:::-;14772:9;;;;:18;;;:25;14729:30;;14772:34;;14762:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;14762:45:6;;14729:78;;14910:25;14938:5;:9;;;:18;;;14910:46;;15000:3;14977:12;:19;:26;;14970:34;;;;15252:2;15224:26;;;15217:38;15532:19;;15356:2;15338:21;;;15466:2;15443:26;;;15496:60;;15443:26;;15338:21;;15532:23;;15496:19;:60::i;:::-;15679:17;15668:59;;;;;;;;;;;;:::i;:::-;15661:66;;13108:3445;;;;15833:713;15856:5;:10;;;15920:47;;;15985:508;;;;;;;;16056:5;:9;;;:16;;;15985:508;;;;;;16129:4;:15;;;15985:508;;;;;;16179:4;:16;;;15985:508;;;;;;16235:4;:21;;;15985:508;;;;16300:4;:25;;;15985:508;;;;16364:4;:20;;;15985:508;;;;16422:5;15985:508;;;;;;16460:5;:9;;;:16;;;15985:508;;;;;15880:627;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16521:9;;;;:15;;;15833:9;:713::i;17623:856::-;17719:25;17760:38;;:::i;:::-;17808:39;;:::i;:::-;17857:28;17896:17;17916:49;17946:5;:9;;;:18;;;17916:29;:49::i;:::-;17896:69;;18029:4;18018:78;;;;;;;;;;;;:::i;:::-;18137:10;;;;18352:9;;;;;:16;18161:272;;17975:121;;-1:-1:-1;17975:121:6;;-1:-1:-1;17975:121:6;;-1:-1:-1;18114:358:6;;18137:10;;18201:45;;18161:272;;17975:121;;;;;;18409:10;;18161:272;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;18447:9;;;;:15;;;18114:9;:358::i;:::-;18107:365;17623:856;-1:-1:-1;;;;;;17623:856:6:o;18772:877::-;18866:25;18907:36;;:::i;:::-;18953:39;;:::i;:::-;19002:28;19041:17;19061:49;19091:5;:9;;;:18;;;19061:29;:49::i;:::-;19041:69;;19174:4;19163:76;;;;;;;;;;;;:::i;:::-;19280:10;;;;19493:9;;;;;:16;19304:299;;19120:119;;-1:-1:-1;19120:119:6;;-1:-1:-1;19120:119:6;;-1:-1:-1;19257:385:6;;19280:10;;19344:43;;19304:299;;19120:119;;;;;;19493:16;;;;19304:299;;;:::i;1117:359:1:-;1269:12;1347:68;1430:7;1451:8;1304:165;;;;;;;;;:::i;1482:409::-;1657:12;1735:69;1819:7;1840:6;1860:14;1692:192;;;;;;;;;;:::i;1897:397::-;2066:12;2144:65;2224:7;2245:4;2263:14;2101:186;;;;;;;;;;:::i;2300:463::-;2500:12;2578:74;2667:7;2688:8;2710:11;2735;2535:221;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2300:463:1;;;;;;:::o;2769:419::-;2949:12;3027:73;3115:7;3136:10;3160:11;2984:197;;;;;;;;;;:::i;2295:1567:15:-;2431:17;2545:49;2578:4;2584:9;2545:32;:49::i;:::-;2636:20;2609:23;;:47;;;;;;;;;2605:929;;;2719:132;2746:4;2768:9;:11;;;2797:9;:11;;;2826:9;:11;;;2719:132;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2707:144;;2605:929;;;2899:21;2872:23;;:48;;;;;;;;;2868:666;;;3092:19;3199:20;3196:1;3189:31;3270:4;3266:2;3259:16;3342:2;3339:1;3329:16;3314:31;;3384:139;3411:11;3440:9;:11;;;3469:9;:11;;;3498:9;:11;;;3384:139;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3372:151;;2868:666;;3624:23;;;3620:236;;3663:182;:172;3728:71;3817:4;3663:47;:172::i;910:464:4:-;1126:12;1204:66;1285:4;1303;1321:13;1348:9;1161:206;;;;;;;;;;;:::i;3617:375:1:-;3777:12;3855:65;3935:7;3956:19;3812:173;;;;;;;;;:::i;1935:4297:27:-;2085:2;2076:6;:11;2072:4154;;;2406:13;;2461:11;;2360:2;2356:15;;;2351:3;2347:25;2343:33;;2421:9;;2402:29;;;2457:22;;2509:8;2496:22;;2313:219;;;2636:4;2626:6;:14;2622:59;;;2660:7;;2622:59;3370:4;3361:6;:13;3357:2859;;;3696:2;3688:6;3684:15;3674:25;;3744:6;3736;3732:19;3794:6;3788:4;3784:17;4101:4;4095:11;4369:198;4387:4;4379:6;4376:16;4369:198;;;4435:13;;4422:27;;4496:2;4532:13;;;;4484:15;;;;4369:198;;;4636:18;;-1:-1:-1;3403:1269:27;;;4917:2;4909:6;4905:15;4895:25;;4965:6;4957;4953:19;5015:6;5009:4;5005:17;5325:6;5319:13;5904:191;5921:4;5915;5911:15;5904:191;;;5969:11;;5956:25;;6014:13;;;;;6060;;;;5904:191;;;6165:19;;-1:-1:-1;;4719:1483:27;1935:4297;;;:::o;19797:452:6:-;19901:25;19942:12;19998:4;19990:18;;20016:5;20023:8;19990:42;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;19964:68:6;-1:-1:-1;19964:68:6;-1:-1:-1;19964:68:6;20042:201;;20070:162;:152;20148:4;20170:8;20196:12;20070:60;:152::i;:162::-;19797:452;;;;;;:::o;16831:504::-;16953:17;17021:1;17003:8;:15;:19;16993:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16993:30:6;;16986:37;;17033:15;17058:13;17130:2;17120:8;17116:17;17105:28;;17200:2;17194:4;17190:13;17181:22;;17258:48;17278:5;17285:7;17294:4;:11;17258:19;:48::i;:::-;17317:11;;16831:504;;;:::o;4028:1255:15:-;4251:11;;;;1321:66;-1:-1:-1;4243:47:15;;:110;;-1:-1:-1;4314:11:15;;;;1584:31;-1:-1:-1;4306:47:15;4243:110;4239:331;;;4377:182;:172;4442:71;4531:4;4377:47;:172::i;:182::-;4648:21;4621:23;;:48;;;;;;;;;4617:250;;;4685:171;:161;4750:60;4828:4;4685:47;:161::i;:171::-;4935:21;4908:23;;:48;;;;;;;;;4904:257;;;4972:178;:168;5037:67;5122:4;4972:47;:168::i;:178::-;4028:1255;;:::o;1380:337:4:-;1533:12;1611:52;1678:4;1696;1568:142;;;;;;;;;:::i;3998:409:1:-;4180:12;4258:64;4337:7;4358:8;4380:10;4215:185;;;;;;;;;;:::i;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;5:130::-;72:20;;97:33;72:20;97:33;:::i;142:134::-;220:13;;238:33;220:13;238:33;:::i;1335:788::-;;1479:3;1472:4;1464:6;1460:17;1456:27;1446:2;;-1:-1;;1487:12;1446:2;1534:6;1521:20;1556:107;1571:91;1655:6;1571:91;:::i;:::-;1556:107;:::i;:::-;1691:21;;;1547:116;-1:-1;1735:4;1748:14;;;;1723:17;;;1849:4;1837:17;;;1828:27;;;;1825:36;-1:-1;1822:2;;;1874:1;;1864:12;1822:2;1899:1;1884:233;1909:6;1906:1;1903:13;1884:233;;;1989:64;2049:3;2037:10;1989:64;:::i;:::-;1977:77;;2068:14;;;;2096;;;;1931:1;1924:9;1884:233;;;1888:14;;;;;;1439:684;;;;:::o;2186:782::-;;2346:3;2339:4;2331:6;2327:17;2323:27;2313:2;;-1:-1;;2354:12;2313:2;2394:6;2388:13;2416:112;2431:96;2520:6;2431:96;:::i;2416:112::-;2556:21;;;2407:121;-1:-1;2600:4;2613:14;;;;2588:17;;;2708:1;2693:269;2718:6;2715:1;2712:13;2693:269;;;2794:3;2788:10;2592:6;2776:23;14015:4;;13994:19;2776:23;13998:3;13994:19;;13990:30;13987:2;;;2708:1;;14023:12;13987:2;14051:20;14015:4;14051:20;:::i;:::-;14164:59;14219:3;2600:4;2776:23;;14164:59;:::i;:::-;14139:85;;14291:18;;;14285:25;;14330:18;14319:30;;14316:2;;;2708:1;;14352:12;14316:2;14397:69;14462:3;2600:4;14453:6;2776:23;14438:22;;14397:69;:::i;:::-;14379:16;;;14372:95;2806:93;;-1:-1;;2913:14;;;;2941;;;;2740:1;2733:9;2693:269;;;2697:14;;;;;2306:662;;;;:::o;3255:440::-;;3356:3;3349:4;3341:6;3337:17;3333:27;3323:2;;-1:-1;;3364:12;3323:2;3411:6;3398:20;3433:64;3448:48;3489:6;3448:48;:::i;3433:64::-;3424:73;;3517:6;3510:5;3503:21;3621:3;3553:4;3612:6;3545;3603:16;;3600:25;3597:2;;;3638:1;;3628:12;3597:2;55222:6;3553:4;3545:6;3541:17;3553:4;3579:5;3575:16;55199:30;55278:1;55260:16;;;3553:4;55260:16;55253:27;3579:5;3316:379;-1:-1;;3316:379::o;3704:442::-;;3816:3;3809:4;3801:6;3797:17;3793:27;3783:2;;-1:-1;;3824:12;3783:2;3864:6;3858:13;3886:64;3901:48;3942:6;3901:48;:::i;3886:64::-;3877:73;;3970:6;3963:5;3956:21;4074:3;4006:4;4065:6;3998;4056:16;;4053:25;4050:2;;;4091:1;;4081:12;4050:2;4101:39;4133:6;4006:4;4032:5;4028:16;4006:4;3998:6;3994:17;4101:39;:::i;:::-;;3776:370;;;;:::o;8440:1820::-;;8566:6;;8554:9;8549:3;8545:19;8541:32;8538:2;;;-1:-1;;8576:12;8538:2;8604:22;8566:6;8604:22;:::i;:::-;8595:31;;;8710:57;8763:3;8739:22;8710:57;:::i;:::-;8692:16;8685:83;8864:49;8909:3;8831:2;8889:9;8885:22;8864:49;:::i;:::-;8831:2;8850:5;8846:16;8839:75;8982:2;9040:9;9036:22;14703:20;8982:2;9001:5;8997:16;8990:75;9133:2;9191:9;9187:22;14703:20;9133:2;9152:5;9148:16;9141:75;9294:3;9353:9;9349:22;14703:20;9294:3;9314:5;9310:16;9303:75;9439:3;9498:9;9494:22;14703:20;9439:3;9459:5;9455:16;9448:75;9616:3;9605:9;9601:19;9588:33;9641:18;9633:6;9630:30;9627:2;;;8678:1;;9663:12;9627:2;9708:58;9762:3;9753:6;9742:9;9738:22;9708:58;:::i;:::-;9616:3;9694:5;9690:16;9683:84;;9829:3;9888:9;9884:22;14703:20;9829:3;9849:5;9845:16;9838:75;9978:3;10014:72;10082:3;9978;10062:9;10058:22;10014:72;:::i;:::-;9978:3;9998:5;9994:18;9987:100;;10153:3;;10214:9;10210:22;14703:20;10153:3;10173:5;10169:18;10162:77;;8532:1728;;;;:::o;12181:773::-;;12297:4;12285:9;12280:3;12276:19;12272:30;12269:2;;;-1:-1;;12305:12;12269:2;12333:20;12297:4;12333:20;:::i;:::-;12324:29;;4622:6;4609:20;4634:51;4679:5;4634:51;:::i;:::-;12419:93;;12570:2;12622:22;;15257:20;15282:31;15257:20;15282:31;:::i;:::-;12603:47;12570:2;12589:5;12585:16;12578:73;;12709:2;12767:9;12763:22;3043:20;12709:2;12728:5;12724:16;12717:75;12850:2;12908:9;12904:22;3043:20;12850:2;12869:5;12865:16;12858:75;12263:691;;;;:::o;12997:828::-;;13124:4;13112:9;13107:3;13103:19;13099:30;13096:2;;;-1:-1;;13132:12;13096:2;13160:20;13124:4;13160:20;:::i;:::-;13151:29;;4799:6;4793:13;4811:51;4856:5;4811:51;:::i;:::-;13246:104;;13408:2;13471:22;;15401:13;15419:31;15401:13;15419:31;:::i;:::-;13441:58;13408:2;13427:5;13423:16;13416:84;;13558:2;13627:9;13623:22;3191:13;13558:2;13577:5;13573:16;13566:86;13710:2;13779:9;13775:22;3191:13;13710:2;13729:5;13725:16;13718:86;13090:735;;;;:::o;14495:134::-;14573:13;;53398:34;53387:46;;56873:35;;56863:2;;56922:1;;56912:12;14914:132;14991:13;;53724:10;53713:22;;57120:34;;57110:2;;57168:1;;57158:12;15053:132;15130:13;;53819:18;53808:30;;57242:34;;57232:2;;57290:1;;57280:12;15462:766;;;15697:2;15685:9;15676:7;15672:23;15668:32;15665:2;;;-1:-1;;15703:12;15665:2;15761:17;15748:31;15799:18;;15791:6;15788:30;15785:2;;;-1:-1;;15821:12;15785:2;15949:6;15938:9;15934:22;;;652:3;645:4;637:6;633:17;629:27;619:2;;-1:-1;;660:12;619:2;707:6;694:20;729:117;744:101;838:6;744:101;:::i;729:117::-;874:21;;;918:4;931:14;;;;852:16;906:17;;;-1:-1;1011:270;1036:6;1033:1;1030:13;1011:270;;;1143:74;1213:3;918:4;1119:3;1106:17;910:6;1094:30;;1143:74;:::i;:::-;1131:87;;1232:14;;;;1260;;;;1058:1;1051:9;1011:270;;;-1:-1;15841:125;;-1:-1;16016:18;;16003:32;;-1:-1;;;;16044:30;;;16041:2;;;-1:-1;;16077:12;16041:2;;16107:105;16204:7;16195:6;16184:9;16180:22;16107:105;:::i;:::-;16097:115;;;15659:569;;;;;:::o;16235:241::-;;16339:2;16327:9;16318:7;16314:23;16310:32;16307:2;;;-1:-1;;16345:12;16307:2;-1:-1;3043:20;;16301:175;-1:-1;16301:175::o;16483:428::-;;16641:2;16629:9;16620:7;16616:23;16612:32;16609:2;;;-1:-1;;16647:12;16609:2;16698:17;16692:24;16736:18;;16728:6;16725:30;16722:2;;;-1:-1;;16758:12;16722:2;16863:22;;;;5081:4;5060:19;;;5056:30;5053:2;;;-1:-1;;5089:12;5053:2;5117:20;5081:4;5117:20;:::i;:::-;5225:83;5304:3;5280:22;5225:83;:::i;:::-;5207:16;5200:109;5410:83;5489:3;16641:2;5469:9;5465:22;5410:83;:::i;:::-;16641:2;5396:5;5392:16;5385:109;5567:2;5636:9;5632:22;14851:13;5567:2;5586:5;5582:16;5575:86;5738:2;5807:9;5803:22;14851:13;5738:2;5757:5;5753:16;5746:86;5925:3;5914:9;5910:19;5904:26;16736:18;5942:6;5939:30;5936:2;;;-1:-1;;5972:12;5936:2;6017:117;6130:3;6121:6;6110:9;6106:22;6017:117;:::i;:::-;5925:3;5999:16;;5992:143;-1:-1;6003:5;16603:308;-1:-1;;;;;16603:308::o;16918:648::-;;;;17110:9;17101:7;17097:23;17122:3;17097:23;17093:33;17090:2;;;-1:-1;;17129:12;17090:2;6330:6;;6309:19;6305:32;6302:2;;;-1:-1;;6340:12;6302:2;6368:22;6330:6;6368:22;:::i;:::-;6359:31;;6478:83;6557:3;6533:22;6478:83;:::i;:::-;6460:16;6453:109;6662:83;6741:3;6629:2;6721:9;6717:22;6662:83;:::i;:::-;6629:2;6648:5;6644:16;6637:109;6847:60;6903:3;6814:2;6883:9;6879:22;6847:60;:::i;:::-;6814:2;6833:5;6829:16;6822:86;7009:60;7065:3;6976:2;7045:9;7041:22;7009:60;:::i;:::-;6976:2;6995:5;6991:16;6984:86;7180:60;7236:3;7146;7216:9;7212:22;7180:60;:::i;:::-;7146:3;7166:5;7162:16;7155:86;7337:60;7393:3;7303;7373:9;7369:22;7337:60;:::i;:::-;7303:3;7323:5;7319:16;7312:86;7494:60;7550:3;7460;7530:9;7526:22;7494:60;:::i;:::-;7460:3;7480:5;7476:16;7469:86;7652:60;7708:3;7618;7688:9;7684:22;7652:60;:::i;:::-;7618:3;7638:5;7634:16;7627:86;7782:3;7818:60;7874:3;7782;7854:9;7850:22;7818:60;:::i;:::-;7798:18;;;7791:88;7940:3;8008:22;;;3191:13;7956:18;;;7949:88;8100:3;8136:59;8191:3;8167:22;;;8136:59;:::i;:::-;8100:3;8120:5;8116:18;8109:87;;8257:3;;8329:9;8325:22;14851:13;8257:3;8277:5;8273:18;8266:88;;17181:102;;;17339:91;17422:7;6330:6;17402:9;17398:22;17339:91;:::i;:::-;17329:101;;;;17486:64;17542:7;17467:3;17522:9;17518:22;17486:64;:::i;:::-;17476:74;;17084:482;;;;;:::o;17573:401::-;;17714:2;17702:9;17693:7;17689:23;17685:32;17682:2;;;-1:-1;;17720:12;17682:2;17778:17;17765:31;17816:18;17808:6;17805:30;17802:2;;;-1:-1;;17838:12;17802:2;17868:90;17950:7;17941:6;17930:9;17926:22;17868:90;:::i;:::-;17858:100;17676:298;-1:-1;;;;17676:298::o;17981:581::-;;;18166:3;18154:9;18145:7;18141:23;18137:33;18134:2;;;-1:-1;;18173:12;18134:2;18231:17;18218:31;18269:18;18261:6;18258:30;18255:2;;;-1:-1;;18291:12;18255:2;18321:90;18403:7;18394:6;18383:9;18379:22;18321:90;:::i;:::-;18311:100;;;18466:80;18538:7;18448:2;18518:9;18514:22;18466:80;:::i;:::-;18456:90;;18128:434;;;;;:::o;18569:644::-;;;;18759:9;18750:7;18746:23;18771:3;18746:23;18742:33;18739:2;;;-1:-1;;18778:12;18739:2;10430:6;;10409:19;10405:32;10402:2;;;-1:-1;;10440:12;10402:2;10468:22;10430:6;10468:22;:::i;:::-;10459:31;;10578:83;10657:3;10633:22;10578:83;:::i;:::-;10560:16;10553:109;10762:83;10841:3;10729:2;10821:9;10817:22;10762:83;:::i;:::-;10729:2;10748:5;10744:16;10737:109;10947:60;11003:3;10914:2;10983:9;10979:22;10947:60;:::i;:::-;10914:2;10933:5;10929:16;10922:86;11109:60;11165:3;11076:2;11145:9;11141:22;11109:60;:::i;:::-;11076:2;11095:5;11091:16;11084:86;11266:60;11322:3;11232;11302:9;11298:22;11266:60;:::i;:::-;11232:3;11252:5;11248:16;11241:86;11423:60;11479:3;11389;11459:9;11455:22;11423:60;:::i;:::-;11389:3;11409:5;11405:16;11398:86;11583:60;11639:3;11549;11619:9;11615:22;11583:60;:::i;:::-;11549:3;11569:5;11565:16;11558:86;11705:3;11775:9;11771:22;3191:13;11705:3;11725:5;11721:16;11714:86;11863:3;11899:59;11954:3;11863;11934:9;11930:22;11899:59;:::i;:::-;11863:3;11883:5;11879:18;11872:87;;12020:3;;12092:9;12088:22;14851:13;12020:3;12040:5;12036:18;12029:88;;18830:100;;;18986:91;19069:7;10430:6;19049:9;19045:22;18986:91;:::i;:::-;18976:101;;;;19133:64;19189:7;19114:3;19169:9;19165:22;19133:64;:::i;19857:127::-;53518:42;53507:54;19934:45;;19928:56::o;21425:1084::-;;21704:5;50206:12;51091:6;51086:3;51079:19;51128:4;;51123:3;51119:14;21716:115;;;;51128:4;21888:6;21884:17;21879:3;21875:27;21863:39;;51128:4;22005:5;49861:14;-1:-1;22044:426;22069:6;22066:1;22063:13;22044:426;;;22121:20;;;22109:33;;22170:13;;33489:23;;53724:10;53713:22;34365:36;;33647:16;;33641:23;33412:4;33684:14;;;33677:38;;;33730:71;33403:14;;;33641:23;33730:71;:::i;:::-;22449:14;;;;22190:136;-1:-1;;;50778:14;;;;22091:1;22084:9;22044:426;;;-1:-1;22493:10;;21603:906;-1:-1;;;;;;;21603:906::o;22517:94::-;52437:13;52430:21;22572:34;;22566:45::o;23235:323::-;;23367:5;50206:12;51091:6;51086:3;51079:19;23450:52;23495:6;51128:4;51123:3;51119:14;51128:4;23476:5;23472:16;23450:52;:::i;:::-;55740:2;55720:14;55736:7;55716:28;23514:39;;;;51128:4;23514:39;;23315:243;-1:-1;;23315:243::o;30484:800::-;30712:16;30706:23;55977:1;55970:5;55967:12;55957:2;;55983:9;55957:2;24902:66;;30890:4;30879:16;;;30873:23;53921:4;53910:16;30946:14;;;34577:35;31037:4;31026:16;;;31020:23;31097:14;;;22790:37;31188:4;31177:16;;;31171:23;31248:14;;22790:37;30604:680::o;33846:103::-;53398:34;53387:46;33907:37;;33901:48::o;34413:100::-;53819:18;53808:30;34472:36;;34466:47::o;34738:271::-;;24075:5;50206:12;24186:52;24231:6;24226:3;24219:4;24212:5;24208:16;24186:52;:::i;:::-;24250:16;;;;;34872:137;-1:-1;;34872:137::o;35016:659::-;25825:66;25805:87;;25790:1;25911:11;;22790:37;;;;35527:12;;;22790:37;35638:12;;;35261:414::o;35682:406::-;;35877:2;;35866:9;35862:18;35877:2;35898:17;35891:47;35952:126;20612:5;50206:12;51091:6;51086:3;51079:19;51119:14;35866:9;51119:14;20624:102;;51119:14;35877:2;20783:6;20779:17;35866:9;20770:27;;20758:39;;35877:2;20877:5;49861:14;-1:-1;20916:357;20941:6;20938:1;20935:13;20916:357;;;20993:20;35866:9;20997:4;20993:20;;20988:3;20981:33;19340:64;19400:3;21048:6;21042:13;19340:64;:::i;:::-;21062:90;-1:-1;21252:14;;;;50778;;;;20963:1;20956:9;20916:357;;;-1:-1;35944:134;;35848:240;-1:-1;;;;;;;35848:240::o;36095:222::-;22790:37;;;36222:2;36207:18;;36193:124::o;36324:460::-;22790:37;;;53518:42;53507:54;;;36687:2;36672:18;;19787:58;53507:54;36770:2;36755:18;;19934:45;36515:2;36500:18;;36486:298::o;36791:1420::-;22790:37;;;53518:42;53507:54;;;37419:2;37404:18;;19934:45;53507:54;;;37502:2;37487:18;;19934:45;37585:2;37570:18;;22790:37;;;;37668:3;37653:19;;22790:37;;;;37752:3;37737:19;;22790:37;;;;37836:3;37821:19;;22790:37;37920:3;37905:19;;22790:37;38004:3;37989:19;;22790:37;53507:54;;;38111:3;38096:19;;19934:45;38196:3;38181:19;;22790:37;37238:3;37223:19;;37209:1002::o;38669:329::-;22790:37;;;52614:66;52603:78;38984:2;38969:18;;23187:36;38822:2;38807:18;;38793:205::o;39005:612::-;;22820:5;22797:3;22790:37;39224:2;39342;39331:9;39327:18;39320:48;39382:76;39224:2;39213:9;39209:18;39444:6;39382:76;:::i;:::-;39506:9;39500:4;39496:20;39491:2;39480:9;39476:18;39469:48;39531:76;39602:4;39593:6;39531:76;:::i;39624:333::-;22790:37;;;39943:2;39928:18;;22790:37;39779:2;39764:18;;39750:207::o;39964:444::-;22790:37;;;40311:2;40296:18;;22790:37;;;;40394:2;40379:18;;22790:37;40147:2;40132:18;;40118:290::o;40415:556::-;22790:37;;;40791:2;40776:18;;22790:37;;;;40874:2;40859:18;;22790:37;40957:2;40942:18;;22790:37;40626:3;40611:19;;40597:374::o;40978:548::-;22790:37;;;53921:4;53910:16;;;;41346:2;41331:18;;34577:35;41429:2;41414:18;;22790:37;41512:2;41497:18;;22790:37;41185:3;41170:19;;41156:370::o;41533:218::-;52614:66;52603:78;;;;23187:36;;41658:2;41643:18;;41629:122::o;41758:329::-;52614:66;52603:78;;;;23187:36;;53518:42;53507:54;42073:2;42058:18;;19934:45;41911:2;41896:18;;41882:205::o;42094:329::-;52614:66;52603:78;;;;23187:36;;42409:2;42394:18;;22790:37;42247:2;42232:18;;42218:205::o;42430:306::-;;42575:2;42596:17;42589:47;42650:76;42575:2;42564:9;42560:18;42712:6;42650:76;:::i;42743:510::-;42959:2;42944:18;;55861:1;55851:12;;55841:2;;55867:9;55841:2;24730:83;;;43156:2;43141:18;;22790:37;;;;43239:2;43224:18;;;22790:37;42930:323;:::o;43260:395::-;43446:2;43431:18;;54828:57;25156:5;54828:57;:::i;:::-;25089:3;25082:81;22820:5;43641:2;43630:9;43626:18;22790:37;43417:238;;;;;:::o;43662:702::-;;54828:57;25156:5;54828:57;:::i;:::-;25089:3;25082:81;22820:5;44118:2;44107:9;44103:18;22790:37;53518:42;52247:5;53507:54;44201:2;44190:9;44186:18;19934:45;43922:3;44238:2;44227:9;44223:18;44216:48;44278:76;43922:3;43911:9;43907:19;44340:6;44278:76;:::i;44688:416::-;44888:2;44902:47;;;26161:2;44873:18;;;51079:19;26197:34;51119:14;;;26177:55;26266:6;26252:12;;;26245:28;26292:12;;;44859:245::o;45111:955::-;;45492:3;45481:9;45477:19;45469:27;;26645:86;26716:14;26622:16;26616:23;26645:86;:::i;:::-;26816:4;26809:5;26805:16;26799:23;26828:86;26816:4;26903:3;26899:14;26885:12;26828:86;:::i;:::-;;27000:4;26993:5;26989:16;26983:23;27012:63;27000:4;27064:3;27060:14;27046:12;27012:63;:::i;:::-;;27161:4;27154:5;27150:16;27144:23;27173:63;27161:4;27225:3;27221:14;27207:12;27173:63;:::i;:::-;;27330:4;27323:5;27319:16;27313:23;27342:63;27330:4;27394:3;27390:14;27376:12;27342:63;:::i;:::-;;27485:4;27478:5;27474:16;27468:23;27497:63;27485:4;27549:3;27545:14;27531:12;27497:63;:::i;:::-;;27640:4;27633:5;27629:16;27623:23;27652:63;27640:4;27704:3;27700:14;27686:12;27652:63;:::i;:::-;;27796:4;27789:5;27785:16;27779:23;27808:63;27796:4;27860:3;27856:14;27842:12;27808:63;:::i;:::-;;27958:6;;27951:5;27947:18;27941:25;27972:65;27958:6;28024:3;28020:16;28006:12;27972:65;:::i;:::-;-1:-1;;28116:6;28105:18;;;28099:25;28178:16;;;22790:37;28276:6;28265:18;;;28259:25;28290:63;28336:16;;;28259:25;28290:63;:::i;:::-;-1:-1;;28432:6;28421:18;;;28415:25;28494:16;;;22790:37;45645:127;45767:3;45752:19;;45743:6;45645:127;:::i;:::-;45783:73;45851:3;45840:9;45836:19;45827:6;45783:73;:::i;:::-;45867:89;45951:3;45940:9;45936:19;45927:6;45867:89;:::i;:::-;45967;46051:3;46040:9;46036:19;46027:6;45967:89;:::i;46073:1047::-;;46472:3;46461:9;46457:19;46449:27;;28858:86;28929:14;28835:16;28829:23;28858:86;:::i;:::-;29029:4;29022:5;29018:16;29012:23;29041:86;29029:4;29116:3;29112:14;29098:12;29041:86;:::i;:::-;;29213:4;29206:5;29202:16;29196:23;29225:63;29213:4;29277:3;29273:14;29259:12;29225:63;:::i;:::-;;29374:4;29367:5;29363:16;29357:23;29386:63;29374:4;29438:3;29434:14;29420:12;29386:63;:::i;:::-;;29529:4;29522:5;29518:16;29512:23;29541:63;29529:4;29593:3;29589:14;29575:12;29541:63;:::i;:::-;;29684:4;29677:5;29673:16;29667:23;29696:63;29684:4;29748:3;29744:14;29730:12;29696:63;:::i;:::-;;29842:4;29835:5;29831:16;29825:23;29854:63;29842:4;29906:3;29902:14;29888:12;29854:63;:::i;:::-;;29996:4;29989:5;29985:16;29979:23;29996:4;30060:3;30056:14;22790:37;30152:6;;30145:5;30141:18;30135:25;30166:63;30152:6;30216:3;30212:16;30198:12;30166:63;:::i;:::-;-1:-1;;30308:6;30297:18;;;30291:25;30370:16;;;22790:37;46621:127;46743:3;46728:19;;46719:6;46621:127;:::i;:::-;46759:73;46827:3;46816:9;46812:19;46803:6;46759:73;:::i;:::-;46843:89;46927:3;46916:9;46912:19;46903:6;46843:89;:::i;:::-;46943:67;47005:3;46994:9;46990:19;46981:6;46943:67;:::i;:::-;47021:89;47105:3;47094:9;47090:19;47081:6;47021:89;:::i;:::-;46443:677;;;;;;;;;:::o;47127:414::-;;47326:2;47347:17;47340:47;53518:42;;31646:16;31640:23;53507:54;47326:2;47315:9;47311:18;19934:45;53518:42;47326:2;31826:5;31822:16;31816:23;53507:54;31916:14;47315:9;31916:14;19934:45;;31916:14;32010:5;32006:16;32000:23;32029:86;32100:14;47315:9;32100:14;32086:12;32029:86;:::i;:::-;;32100:14;32199:5;32195:16;32189:23;32266:14;47315:9;32266:14;22790:37;32266:14;32369:5;32365:16;32359:23;32436:14;47315:9;32436:14;22790:37;32436:14;32534:5;32530:16;32524:23;31571:6;;32567:14;47315:9;32567:14;32560:38;32613:167;31562:16;47315:9;31562:16;32761:12;32613:167;:::i;:::-;32605:175;;32567:14;32868:5;32864:16;32858:23;32887:57;32929:14;47315:9;32929:14;32915:12;32887:57;:::i;:::-;;32929:14;33021:5;33017:16;33011:23;33040:79;31571:6;47315:9;33104:14;33090:12;33040:79;:::i;:::-;-1:-1;47393:138;;47297:244;-1:-1;;;;47297:244::o;48117:256::-;48179:2;48173:9;48205:17;;;48280:18;48265:34;;48301:22;;;48262:62;48259:2;;;48337:1;;48327:12;48259:2;48179;48346:22;48157:216;;-1:-1;48157:216::o;48380:341::-;;48576:18;48568:6;48565:30;48562:2;;;-1:-1;;48598:12;48562:2;-1:-1;48643:4;48631:17;;;48696:15;;48499:222::o;49409:321::-;;49552:18;49544:6;49541:30;49538:2;;;-1:-1;;49574:12;49538:2;-1:-1;49651:4;49628:17;49647:9;49624:33;49715:4;49705:15;;49475:255::o;53146:172::-;53230:16;56108:1;56098:12;;56088:2;;56114:9;55295:268;55360:1;55367:101;55381:6;55378:1;55375:13;55367:101;;;55448:11;;;55442:18;55429:11;;;55422:39;55403:2;55396:10;55367:101;;;55483:6;55480:1;55477:13;55474:2;;;55360:1;55539:6;55534:3;55530:16;55523:27;55474:2;;55344:219;;;:::o;56137:117::-;53518:42;56224:5;53507:54;56199:5;56196:35;56186:2;;56245:1;;56235:12;56695:112;56782:1;56775:5;56772:12;56762:2;;56798:1;;56788:12;57306:113;53921:4;57389:5;53910:16;57366:5;57363:33;57353:2;;57410:1;;57400:12

Swarm Source

ipfs://38de8d2e36ddcd189607c61647f081c263e77851a765ea238c2ba5deb4b71ae8

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.