ETH Price: $2,429.27 (+0.27%)

Contract

0xc56C1dfE64D21A345E3A3C715FFcA1c6450b964b
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040185521012023-11-11 23:55:47329 days ago1699746947IN
 Create: ExchangeV3
0 ETH0.333026470

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ExchangeV3

Compiler Version
v0.7.0+commit.9e61f92b

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion, Apache-2.0 license
File 1 of 95 : ExchangeV3.sol
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022

import "../../lib/AddressUtil.sol";
import "../../lib/EIP712.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../../thirdparty/proxies/OwnedUpgradabilityProxy.sol";
import "../iface/IAgentRegistry.sol";
import "../iface/IExchangeV3.sol";
import "../iface/IBlockVerifier.sol";
import "./libexchange/ExchangeAdmins.sol";
import "./libexchange/ExchangeBalances.sol";
import "./libexchange/ExchangeBlocks.sol";
import "./libexchange/ExchangeDeposits.sol";
import "./libexchange/ExchangeGenesis.sol";
import "./libexchange/ExchangeMode.sol";
import "./libexchange/ExchangeTokens.sol";
import "./libexchange/ExchangeWithdrawals.sol";

/// @title An Implementation of IExchangeV3.
/// @dev This contract supports upgradability proxy, therefore its constructor
///      must do NOTHING.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
contract ExchangeV3 is IExchangeV3, ReentrancyGuard
{
    using AddressUtil           for address;
    using ERC20SafeTransfer     for address;
    using MathUint              for uint;
    using ExchangeAdmins        for ExchangeData.State;
    using ExchangeBalances      for ExchangeData.State;
    using ExchangeBlocks        for ExchangeData.State;
    using ExchangeDeposits      for ExchangeData.State;
    using ExchangeGenesis       for ExchangeData.State;
    using ExchangeMode          for ExchangeData.State;
    using ExchangeTokens        for ExchangeData.State;
    using ExchangeWithdrawals   for ExchangeData.State;

    ExchangeData.State public state;
    bool public allowOnchainTransferFrom = false;

    modifier onlyWhenUninitialized()
    {
        require(
            address(state.loopring) == address(0) && state.merkleRoot == bytes32(0),
            "INITIALIZED"
        );
        _;
    }

    modifier onlyFromUserOrAgent(address from)
    {
        require(isUserOrAgent(from), "UNAUTHORIZED");
        _;
    }

    /// @dev The constructor must do NOTHING to support proxy.
    constructor() {}

    function version()
        public
        pure
        returns (string memory)
    {
        return "0.1.0";
    }

    function domainSeparator()
        external
        view
        returns (bytes32)
    {
        return state.DOMAIN_SEPARATOR;
    }

    // -- Initialization --
    function initialize(
        address _loopring,
        address _owner,
        bytes32 _genesisMerkleRoot,
        bytes32 _genesisMerkleAssetRoot
        )
        external
        override
        nonReentrant
        onlyWhenUninitialized
    {
        require(address(0) != _owner, "ZERO_ADDRESS");
        owner = _owner;

        state.initializeGenesisBlock(
            _loopring,
            _genesisMerkleRoot,
            _genesisMerkleAssetRoot,
            EIP712.hash(EIP712.Domain("DeGate Protocol", version(), address(this)))
        );
    }

    function setDepositContract(address _depositContract)
        external
        override
        nonReentrant
        onlyOwner
    {
        require(_depositContract != address(0), "ZERO_ADDRESS");
        // Only used for initialization
        require(state.depositContract == IDepositContract(0), "ALREADY_SET");
        state.depositContract = IDepositContract(_depositContract);

        emit DepositContractUpdate(_depositContract);
    }

    function getDepositContract()
        external
        override
        view
        returns (IDepositContract)
    {
        return state.depositContract;
    }

    function withdrawExchangeFees(
        address token,
        address recipient
        )
        external
        override
        nonReentrant
        onlyOwner
    {
        require(recipient != address(0), "INVALID_ADDRESS");

        if (token == address(0)) {
            uint amount = address(this).balance;
            recipient.sendETHAndVerify(amount, gasleft());
        } else {
            uint amount = ERC20(token).balanceOf(address(this));
            token.safeTransferAndVerify(recipient, amount);
        }

        emit WithdrawExchangeFees(token, recipient);
    }

    function setDepositParams(
        uint256 freeDepositMax,
        uint256 freeDepositRemained,
        uint256 freeSlotPerBlock,
        uint256 depositFee
        )
        external
        override
        nonReentrant
        onlyOwner
    {
        state.setDepositParams(
            freeDepositMax,
            freeDepositRemained,
            freeSlotPerBlock,
            depositFee
        );

        emit DepositParamsUpdate(freeDepositMax, freeDepositRemained, freeSlotPerBlock, depositFee);
    }

    function isUserOrAgent(address from)
        public
        view
        returns (bool)
    {
         return from == msg.sender ||
            state.agentRegistry != IAgentRegistry(address(0)) &&
            state.agentRegistry.isAgent(from, msg.sender);
    }

    // -- Constants --
    function getConstants()
        external
        override
        pure
        returns(ExchangeData.Constants memory)
    {
        return ExchangeData.Constants(
            uint(ExchangeData.SNARK_SCALAR_FIELD),
            uint(ExchangeData.MAX_OPEN_FORCED_REQUESTS),
            uint(ExchangeData.MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE),
            uint(ExchangeData.TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS),
            uint(ExchangeData.MAX_NUM_ACCOUNTS),
            uint(ExchangeData.MAX_NUM_TOKENS),
            uint(ExchangeData.MIN_AGE_PROTOCOL_FEES_UNTIL_UPDATED),
            uint(ExchangeData.MIN_TIME_IN_SHUTDOWN),
            uint(ExchangeData.TX_DATA_AVAILABILITY_SIZE),
            uint(ExchangeData.MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND),
            uint(ExchangeData.MAX_FORCED_WITHDRAWAL_FEE),
            uint(ExchangeData.DEFAULT_PROTOCOL_FEE_BIPS)
        );
    }

    // -- Mode --
    function isInWithdrawalMode()
        external
        override
        view
        returns (bool)
    {
        return state.isInWithdrawalMode();
    }

    function isShutdown()
        external
        override
        view
        returns (bool)
    {
        return state.isShutdown();
    }

    // -- Tokens --

    function registerToken(
        address tokenAddress
        )
        external
        override
        nonReentrant
        returns (uint32)
    {
        return state.registerToken(tokenAddress, msg.sender == owner);
    }

    function getTokenID(
        address tokenAddress
        )
        external
        override
        view
        returns (uint32)
    {
        return state.getTokenID(tokenAddress);
    }

    function getTokenAddress(
        uint32 tokenID
        )
        external
        override
        view
        returns (address)
    {
        return state.getTokenAddress(tokenID);
    }

    // -- Stakes --
    function getExchangeStake()
        external
        override
        view
        returns (uint)
    {
        return state.loopring.getExchangeStake(address(this));
    }

    function withdrawExchangeStake(
        address recipient
        )
        external
        override
        nonReentrant
        onlyOwner
        returns (uint)
    {
        return state.withdrawExchangeStake(recipient);
    }

    function getProtocolFeeLastWithdrawnTime(
        address tokenAddress
        )
        external
        override
        view
        returns (uint)
    {
        return state.protocolFeeLastWithdrawnTime[tokenAddress];
    }

    function burnExchangeStake()
        external
        override
        nonReentrant
    {
        // Allow burning the complete exchange stake when the exchange gets into withdrawal mode
        if (state.isInWithdrawalMode()) {
            // Burn the complete stake of the exchange
            uint stake = state.loopring.getExchangeStake(address(this));
            state.loopring.burnExchangeStake(stake);
        }
    }

    // -- Blocks --
    function getMerkleRoot()
        external
        override
        view
        returns (bytes32)
    {
        return state.merkleRoot;
    }

    // -- Blocks --
    function getMerkleAssetRoot()
        external
        override
        view
        returns (bytes32)
    {
        return state.merkleAssetRoot;
    }

    function getBlockHeight()
        external
        override
        view
        returns (uint)
    {
        return state.numBlocks;
    }

    function getBlockInfo(uint blockIdx)
        external
        override
        view
        returns (ExchangeData.BlockInfo memory)
    {
        return state.blocks[blockIdx];
    }

    function submitBlocks(ExchangeData.Block[] calldata blocks)
        external
        override
        nonReentrant
        onlyOwner
    {
        state.submitBlocks(blocks);
    }

    function getNumAvailableForcedSlots()
        external
        override
        view
        returns (uint)
    {
        return state.getNumAvailableForcedSlots();
    }

    // -- Deposits --

    function deposit(
        address from,
        address to,
        address tokenAddress,
        uint248  amount,
        bytes   calldata extraData
        )
        external
        payable
        override
        nonReentrant
        onlyFromUserOrAgent(from)
    {
        state.deposit(from, to, tokenAddress, amount, extraData);
    }

    function getPendingDepositAmount(
        address from,
        address tokenAddress
        )
        external
        override
        view
        returns (uint248)
    {
        uint32 tokenID = state.getTokenID(tokenAddress);
        return state.pendingDeposits[from][tokenID].amount;
    }

    // -- Withdrawals --

    function forceWithdraw(
        address from,
        address token,
        uint32  accountID
        )
        external
        override
        nonReentrant
        payable
        onlyFromUserOrAgent(from)
    {
        state.forceWithdraw(from, token, accountID);
    }

    function isForcedWithdrawalPending(
        uint32  accountID,
        address token
        )
        external
        override
        view
        returns (bool)
    {
        uint32 tokenID = state.getTokenID(token);
        return state.pendingForcedWithdrawals[accountID][tokenID].timestamp != 0;
    }

    // We still alow anyone to withdraw these funds for the account owner
    function withdrawFromMerkleTree(
        ExchangeData.MerkleProof calldata merkleProof
        )
        external
        override
        nonReentrant
    {
        state.withdrawFromMerkleTree(merkleProof);
    }

    function isWithdrawnInWithdrawalMode(
        uint32  accountID,
        address token
        )
        external
        override
        view
        returns (bool)
    {
        uint32 tokenID = state.getTokenID(token);
        return state.withdrawnInWithdrawMode[accountID][tokenID];
    }

    function withdrawFromDepositRequest(
        address from,
        address token
        )
        external
        override
        nonReentrant
    {
        state.withdrawFromDepositRequest(
            from,
            token
        );
    }

    function withdrawFromApprovedWithdrawals(
        address[] calldata owners,
        address[] calldata tokens
        )
        external
        override
        nonReentrant
    {
        state.withdrawFromApprovedWithdrawals(
            owners,
            tokens
        );
    }

    function getAmountWithdrawable(
        address from,
        address token
        )
        external
        override
        view
        returns (uint)
    {
        uint32 tokenID = state.getTokenID(token);
        return state.amountWithdrawable[from][tokenID];
    }

    function notifyForcedRequestTooOld(
        uint32  accountID,
        address token
        )
        external
        override
        nonReentrant
    {
        uint32 tokenID = state.getTokenID(token);
        ExchangeData.ForcedWithdrawal storage withdrawal = state.pendingForcedWithdrawals[accountID][tokenID];
        require(withdrawal.timestamp != 0, "WITHDRAWAL_NOT_TOO_OLD");

        // Check if the withdrawal has indeed exceeded the time limit
        require(block.timestamp >= withdrawal.timestamp + ExchangeData.MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE, "WITHDRAWAL_NOT_TOO_OLD");

        // Enter withdrawal mode
        state.modeTime.withdrawalModeStartTime = block.timestamp;

        emit WithdrawalModeActivated(state.modeTime.withdrawalModeStartTime);
    }

    function setWithdrawalRecipient(
        address from,
        address to,
        address token,
        uint248  amount,
        uint32  storageID,
        address newRecipient
        )
        external
        override
        nonReentrant
        onlyFromUserOrAgent(from)
    {
        require(newRecipient != address(0), "INVALID_DATA");
        uint32 tokenID = state.getTokenID(token);
        require(state.withdrawalRecipient[from][to][tokenID][amount][storageID] == address(0), "CANNOT_OVERRIDE_RECIPIENT_ADDRESS");
        state.withdrawalRecipient[from][to][tokenID][amount][storageID] = newRecipient;

        emit WithdrawalRecipientUpdate(from, to, token, amount, storageID, newRecipient);
    }

    function getWithdrawalRecipient(
        address from,
        address to,
        address token,
        uint248  amount,
        uint32  storageID
        )
        external
        override
        view
        returns (address)
    {
        uint32 tokenID = state.getTokenID(token);
        return state.withdrawalRecipient[from][to][tokenID][amount][storageID];
    }

    function onchainTransferFrom(
        address from,
        address to,
        address token,
        uint    amount
        )
        external
        override
        nonReentrant
        onlyFromUserOrAgent(from)
    {
        require(allowOnchainTransferFrom, "NOT_ALLOWED");
        state.depositContract.transfer(from, to, token, amount);
    }

    function approveTransaction(
        address from,
        bytes32 transactionHash
        )
        external
        override
        nonReentrant
        onlyFromUserOrAgent(from)
    {
        state.approvedTx[from][transactionHash] = true;
        emit TransactionApproved(from, transactionHash);
    }

    function approveTransactions(
        address[] calldata owners,
        bytes32[] calldata transactionHashes
        )
        external
        override
        nonReentrant
    {
        require(owners.length == transactionHashes.length, "INVALID_DATA");
        require(state.agentRegistry.isAgent(owners, msg.sender), "UNAUTHORIZED");
        for (uint i = 0; i < owners.length; i++) {
            state.approvedTx[owners[i]][transactionHashes[i]] = true;
        }
        emit TransactionsApproved(owners, transactionHashes);
    }

    function isTransactionApproved(
        address from,
        bytes32 transactionHash
        )
        external
        override
        view
        returns (bool)
    {
        return state.approvedTx[from][transactionHash];
    }

    function getDomainSeparator()
        external
        override
        view
        returns (bytes32)
    {
        return state.DOMAIN_SEPARATOR;
    }

    // -- Admins --
    function setMaxAgeDepositUntilWithdrawable(
        uint32 newValue
        )
        external
        override
        nonReentrant
        onlyOwner
        returns (uint32)
    {
        return state.setMaxAgeDepositUntilWithdrawable(newValue);
    }

    function getMaxAgeDepositUntilWithdrawable()
        external
        override
        view
        returns (uint32)
    {
        return state.maxAgeDepositUntilWithdrawable;
    }

    function shutdown()
        external
        override
        nonReentrant
        onlyOwner
        returns (bool success)
    {
        require(!state.isInWithdrawalMode(), "INVALID_MODE");
        require(!state.isShutdown(), "ALREADY_SHUTDOWN");
        state.modeTime.shutdownModeStartTime = block.timestamp;
        emit Shutdown(state.modeTime.shutdownModeStartTime);
        return true;
    }

    function getProtocolFeeValues()
        external
        override
        view
        returns (
            uint32 syncedAt,
            uint16 protocolFeeBips,
            uint16 previousProtocolFeeBips,
            uint32 executeTimeOfNextProtocolFeeBips,
            uint16 nextProtocolFeeBips
        )
    {
        syncedAt = state.protocolFeeData.syncedAt;
        protocolFeeBips = state.protocolFeeData.protocolFeeBips;
        previousProtocolFeeBips = state.protocolFeeData.previousProtocolFeeBips;
        executeTimeOfNextProtocolFeeBips = state.protocolFeeData.executeTimeOfNextProtocolFeeBips;
        nextProtocolFeeBips = state.protocolFeeData.nextProtocolFeeBips;
    }

    function setAllowOnchainTransferFrom(bool value)
        external
        nonReentrant
        onlyOwner
    {
        require(allowOnchainTransferFrom != value, "SAME_VALUE");
        allowOnchainTransferFrom = value;

        emit AllowOnchainTransferFrom(value);
    }

    function getUnconfirmedBalance(address token)
        external
        override
        view
        returns(uint256)
    {
        uint32 tokenId = state.getTokenID(token);

        uint256 unconfirmedBalance = 0;

        if (tokenId == 0) {
            unconfirmedBalance = address(state.depositContract).balance.sub(state.tokenIdToDepositBalance[tokenId]);
        } else {
            unconfirmedBalance = ERC20(token).balanceOf(address(state.depositContract)).sub(state.tokenIdToDepositBalance[tokenId]);
        }
        return unconfirmedBalance;
    }

    function getFreeDepositRemained()
        external
        override
        view
        returns(uint256)
    {
        return state.depositState.freeDepositRemained;
    }

    function getDepositBalance(address token)
        external
        override
        view
        returns(uint248)
    {
        uint32 tokenId = state.getTokenID(token);

        return state.tokenIdToDepositBalance[tokenId];
    }

}

File 2 of 95 : AddressUtil.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title Utility Functions for addresses
/// @author Daniel Wang - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library AddressUtil
{
    using AddressUtil for *;

    function isContract(
        address addr
        )
        internal
        view
        returns (bool)
    {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(addr) }
        return (codehash != 0x0 &&
                codehash != 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470);
    }

    function toPayable(
        address addr
        )
        internal
        pure
        returns (address payable)
    {
        return payable(addr);
    }

    // Works like address.send but with a customizable gas limit
    // Make sure your code is safe for reentrancy when using this function!
    function sendETH(
        address to,
        uint    amount,
        uint    gasLimit
        )
        internal
        returns (bool success)
    {
        if (amount == 0) {
            return true;
        }
        address payable recipient = to.toPayable();
        /* solium-disable-next-line */
        (success, ) = recipient.call{value: amount, gas: gasLimit}("");
    }

    // Works like address.transfer but with a customizable gas limit
    // Make sure your code is safe for reentrancy when using this function!
    function sendETHAndVerify(
        address to,
        uint    amount,
        uint    gasLimit
        )
        internal
        returns (bool success)
    {
        success = to.sendETH(amount, gasLimit);
        require(success, "TRANSFER_FAILURE");
    }

    // Works like call but is slightly more efficient when data
    // needs to be copied from memory to do the call.
    function fastCall(
        address to,
        uint    gasLimit,
        uint    value,
        bytes   memory data
        )
        internal
        returns (bool success, bytes memory returnData)
    {
        if (to != address(0)) {
            assembly {
                // Do the call
                success := call(gasLimit, to, value, add(data, 32), mload(data), 0, 0)
                // Copy the return data
                let size := returndatasize()
                returnData := mload(0x40)
                mstore(returnData, size)
                returndatacopy(add(returnData, 32), 0, size)
                // Update free memory pointer
                mstore(0x40, add(returnData, add(32, size)))
            }
        }
    }

    // Like fastCall, but throws when the call is unsuccessful.
    function fastCallAndVerify(
        address to,
        uint    gasLimit,
        uint    value,
        bytes   memory data
        )
        internal
        returns (bytes memory returnData)
    {
        bool success;
        (success, returnData) = fastCall(to, gasLimit, value, data);
        if (!success) {
            assembly {
                revert(add(returnData, 32), mload(returnData))
            }
        }
    }
}

File 3 of 95 : EIP712.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;


library EIP712
{
    struct Domain {
        string  name;
        string  version;
        address verifyingContract;
    }

    bytes32 constant internal EIP712_DOMAIN_TYPEHASH = keccak256(
        "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
    );

    string constant internal EIP191_HEADER = "\x19\x01";

    function hash(Domain memory domain)
        internal
        pure
        returns (bytes32)
    {
        uint _chainid;
        assembly { _chainid := chainid() }

        return keccak256(
            abi.encode(
                EIP712_DOMAIN_TYPEHASH,
                keccak256(bytes(domain.name)),
                keccak256(bytes(domain.version)),
                _chainid,
                domain.verifyingContract
            )
        );
    }

    function hashPacked(
        bytes32 domainHash,
        bytes32 dataHash
        )
        internal
        pure
        returns (bytes32)
    {
        return keccak256(
            abi.encodePacked(
                EIP191_HEADER,
                domainHash,
                dataHash
            )
        );
    }
}

File 4 of 95 : ERC20SafeTransfer.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;


/// @title ERC20 safe transfer
/// @dev see https://github.com/sec-bit/badERC20Fix
/// @author Brecht Devos - <[email protected]>
library ERC20SafeTransfer
{
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

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

    function safeTransferAndVerify(
        address token,
        address to,
        uint    value
        )
        internal
    {
        safeTransferWithGasLimitAndVerify(
            token,
            to,
            value,
            gasleft()
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint    value
        )
        internal
        returns (bool)
    {
        return safeTransferWithGasLimit(
            token,
            to,
            value,
            gasleft()
        );
    }

    function safeTransferWithGasLimitAndVerify(
        address token,
        address to,
        uint    value,
        uint    gasLimit
        )
        internal
    {
        require(
            safeTransferWithGasLimit(token, to, value, gasLimit),
            "TRANSFER_FAILURE"
        );
    }

    function safeTransferWithGasLimit(
        address token,
        address to,
        uint    value,
        uint    gasLimit
        )
        internal
        returns (bool)
    {
        // A transfer is successful when 'call' is successful and depending on the token:
        // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false)
        // - A single boolean is returned: this boolean needs to be true (non-zero)

        require(isContract(token), "ERC20SafeTransfer: call to non-contract");

        // bytes4(keccak256("transfer(address,uint256)")) = 0xa9059cbb
        bytes memory callData = abi.encodeWithSelector(
            bytes4(0xa9059cbb),
            to,
            value
        );
        (bool success, ) = token.call{gas: gasLimit}(callData);
        return checkReturnValue(success);
    }

    function safeTransferFromAndVerify(
        address token,
        address from,
        address to,
        uint    value
        )
        internal
    {
        safeTransferFromWithGasLimitAndVerify(
            token,
            from,
            to,
            value,
            gasleft()
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint    value
        )
        internal
        returns (bool)
    {
        return safeTransferFromWithGasLimit(
            token,
            from,
            to,
            value,
            gasleft()
        );
    }

    function safeTransferFromWithGasLimitAndVerify(
        address token,
        address from,
        address to,
        uint    value,
        uint    gasLimit
        )
        internal
    {
        bool result = safeTransferFromWithGasLimit(
            token,
            from,
            to,
            value,
            gasLimit
        );
        require(result, "TRANSFER_FAILURE");
    }

    function safeTransferFromWithGasLimit(
        address token,
        address from,
        address to,
        uint    value,
        uint    gasLimit
        )
        internal
        returns (bool)
    {
        // A transferFrom is successful when 'call' is successful and depending on the token:
        // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false)
        // - A single boolean is returned: this boolean needs to be true (non-zero)

        require(isContract(token), "ERC20SafeTransfer: call to non-contract");

        // bytes4(keccak256("transferFrom(address,address,uint256)")) = 0x23b872dd
        bytes memory callData = abi.encodeWithSelector(
            bytes4(0x23b872dd),
            from,
            to,
            value
        );
        (bool success, ) = token.call{gas: gasLimit}(callData);
        return checkReturnValue(success);
    }

    function checkReturnValue(
        bool success
        )
        internal
        pure
        returns (bool)
    {
        // A transfer/transferFrom is successful when 'call' is successful and depending on the token:
        // - No value is returned: we assume a revert when the transfer failed (i.e. 'call' returns false)
        // - A single boolean is returned: this boolean needs to be true (non-zero)
        if (success) {
            assembly {
                switch returndatasize()
                // Non-standard ERC20: nothing is returned so if 'call' was successful we assume the transfer succeeded
                case 0 {
                    success := 1
                }
                // Standard ERC20: a single boolean value is returned which needs to be true
                case 32 {
                    returndatacopy(0, 0, 32)
                    success := mload(0)
                }
                // None of the above: not successful
                default {
                    success := 0
                }
            }
        }
        return success;
    }
}

File 5 of 95 : MathUint.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title Utility Functions for uint
/// @author Daniel Wang - <[email protected]>
library MathUint
{
    using MathUint for uint;

    function mul(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint c)
    {
        c = a * b;
        require(a == 0 || c / a == b, "MUL_OVERFLOW");
    }

    function sub(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint)
    {
        require(b <= a, "SUB_UNDERFLOW");
        return a - b;
    }

    function add(
        uint a,
        uint b
        )
        internal
        pure
        returns (uint c)
    {
        c = a + b;
        require(c >= a, "ADD_OVERFLOW");
    }

    function add64(
        uint64 a,
        uint64 b
        )
        internal
        pure
        returns (uint64 c)
    {
        c = a + b;
        require(c >= a, "ADD_OVERFLOW");
    }
}

File 6 of 95 : ReentrancyGuard.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title ReentrancyGuard
/// @author Brecht Devos - <[email protected]>
/// @dev Exposes a modifier that guards a function against reentrancy
///      Changing the value of the same storage value multiple times in a transaction
///      is cheap (starting from Istanbul) so there is no need to minimize
///      the number of times the value is changed
contract ReentrancyGuard
{
    //The default value must be 0 in order to work behind a proxy.
    uint private _guardValue;

    // Use this modifier on a function to prevent reentrancy
    modifier nonReentrant()
    {
        // Check if the guard value has its original value
        require(_guardValue == 0, "REENTRANCY");

        // Set the value to something else
        _guardValue = 1;

        // Function body
        _;

        // Set the value back
        _guardValue = 0;
    }
}

File 7 of 95 : OwnedUpgradabilityProxy.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://github.com/OpenZeppelin/openzeppelin-labs
// with minor modifications.
pragma solidity ^0.7.0;

import './UpgradabilityProxy.sol';


/**
 * @title OwnedUpgradabilityProxy
 * @dev This contract combines an upgradeability proxy with basic authorization control functionalities
 */
contract OwnedUpgradabilityProxy is UpgradeabilityProxy {
  /**
  * @dev Event to show ownership has been transferred
  * @param previousOwner representing the address of the previous owner
  * @param newOwner representing the address of the new owner
  */
  event ProxyOwnershipTransferred(address previousOwner, address newOwner);

  // Storage position of the owner of the contract
  bytes32 private constant proxyOwnerPosition = keccak256("org.zeppelinos.proxy.owner");

  /**
  * @dev the constructor sets the original owner of the contract to the sender account.
  */
  constructor() {
    setUpgradabilityOwner(msg.sender);
  }

  /**
  * @dev Throws if called by any account other than the owner.
  */
  modifier onlyProxyOwner() {
    require(msg.sender == proxyOwner());
    _;
  }

  /**
   * @dev Tells the address of the owner
   * @return owner the address of the owner
   */
  function proxyOwner() public view returns (address owner) {
    bytes32 position = proxyOwnerPosition;
    assembly {
      owner := sload(position)
    }
  }

  /**
   * @dev Sets the address of the owner
   */
  function setUpgradabilityOwner(address newProxyOwner) internal {
    bytes32 position = proxyOwnerPosition;
    assembly {
      sstore(position, newProxyOwner)
    }
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferProxyOwnership(address newOwner) public onlyProxyOwner {
    require(newOwner != address(0));
    emit ProxyOwnershipTransferred(proxyOwner(), newOwner);
    setUpgradabilityOwner(newOwner);
  }

  /**
   * @dev Allows the proxy owner to upgrade the current version of the proxy.
   * @param implementation representing the address of the new implementation to be set.
   */
  function upgradeTo(address implementation) public onlyProxyOwner {
    _upgradeTo(implementation);
  }

  /**
   * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation
   * to initialize whatever is needed through a low level call.
   * @param implementation representing the address of the new implementation to be set.
   * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function
   * signature of the implementation to be called with the needed payload
   */
  function upgradeToAndCall(address implementation, bytes memory data) payable public onlyProxyOwner {
    upgradeTo(implementation);
    (bool success, ) = address(this).call{value: msg.value}(data);
    require(success);
  }
}

File 8 of 95 : UpgradabilityProxy.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://github.com/OpenZeppelin/openzeppelin-labs
// with minor modifications.
pragma solidity ^0.7.0;

import './Proxy.sol';


/**
 * @title UpgradeabilityProxy
 * @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded
 */
contract UpgradeabilityProxy is Proxy {
  /**
   * @dev This event will be emitted every time the implementation gets upgraded
   * @param implementation representing the address of the upgraded implementation
   */
  event Upgraded(address indexed implementation);

  // Storage position of the address of the current implementation
  bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation");

  /**
   * @dev Constructor function
   */
  constructor() {}

  /**
   * @dev Tells the address of the current implementation
   * @return impl address of the current implementation
   */
  function implementation() public view override returns (address impl) {
    bytes32 position = implementationPosition;
    assembly {
      impl := sload(position)
    }
  }

  /**
   * @dev Sets the address of the current implementation
   * @param newImplementation address representing the new implementation to be set
   */
  function setImplementation(address newImplementation) internal {
    bytes32 position = implementationPosition;
    assembly {
      sstore(position, newImplementation)
    }
  }

  /**
   * @dev Upgrades the implementation address
   * @param newImplementation representing the address of the new implementation to be set
   */
  function _upgradeTo(address newImplementation) internal {
    address currentImplementation = implementation();
    require(currentImplementation != newImplementation);
    setImplementation(newImplementation);
    emit Upgraded(newImplementation);
  }
}

File 9 of 95 : Proxy.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://github.com/OpenZeppelin/openzeppelin-labs
// with minor modifications.
pragma solidity ^0.7.0;

/**
 * @title Proxy
 * @dev Gives the possibility to delegate any call to a foreign implementation.
 */
abstract contract Proxy {
  /**
  * @dev Tells the address of the implementation where every call will be delegated.
  * @return impl address of the implementation to which it will be delegated
  */
  function implementation() public view virtual returns (address impl);

  receive() payable external {
    _fallback();
  }

  fallback() payable external {
    _fallback();
  }

  function _fallback() private {
    address _impl = implementation();
    require(_impl != address(0));

    assembly {
      let ptr := mload(0x40)
      calldatacopy(ptr, 0, calldatasize())
      let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)
      let size := returndatasize()
      returndatacopy(ptr, 0, size)

      switch result
      case 0 { revert(ptr, size) }
      default { return(ptr, size) }
    }
  }
}

File 10 of 95 : IAgentRegistry.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

interface IAgent{}

abstract contract IAgentRegistry
{
    /// @dev Returns whether an agent address is an agent of an account owner
    /// @param owner The account owner.
    /// @param agent The agent address
    /// @return True if the agent address is an agent for the account owner, else false
    function isAgent(
        address owner,
        address agent
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Returns whether an agent address is an agent of all account owners
    /// @param owners The account owners.
    /// @param agent The agent address
    /// @return True if the agent address is an agent for the account owner, else false
    function isAgent(
        address[] calldata owners,
        address            agent
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Returns whether an agent address is a universal agent.
    /// @param agent The agent address
    /// @return True if the agent address is a universal agent, else false
    function isUniversalAgent(address agent)
        public
        virtual
        view
        returns (bool);
}

File 11 of 95 : IExchangeV3.sol
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022

import "../../lib/Claimable.sol";
import "./ExchangeData.sol";

/// @title IExchangeV3
/// @dev Note that Claimable and RentrancyGuard are inherited here to
///      ensure all data members are declared on IExchangeV3 to make it
///      easy to support upgradability through proxies.
///
///      Subclasses of this contract must NOT define constructor to
///      initialize data.
///
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
abstract contract IExchangeV3 is Claimable
{
    // -- Events --

    event ExchangeCloned(
        address exchangeAddress,
        address owner,
        bytes32 genesisMerkleRoot
    );

    event TokenRegistered(
        address token,
        uint32  tokenId
    );

    event Shutdown(
        uint timestamp
    );

    event WithdrawalModeActivated(
        uint timestamp
    );

    event BlockSubmitted(
        uint    indexed blockIdx,
        bytes32         merkleRoot,
        bytes32         publicDataHash
    );

    event DepositRequested(
        address from,
        address to,
        address token,
        uint32  tokenId,
        uint248  amount
    );

    event ForcedWithdrawalRequested(
        address owner,
        address token,
        uint32  accountID
    );

    event WithdrawalCompleted(
        uint8   category,
        address from,
        address to,
        address token,
        uint    amount
    );

    event WithdrawalFailed(
        uint8   category,
        address from,
        address to,
        address token,
        uint    amount
    );

    event ProtocolFeesUpdated(
        uint16 protocolFeeBips,
        uint16 previousProtocolFeeBips
    );

    event TransactionApproved(
        address owner,
        bytes32 transactionHash
    );

    event TransactionsApproved(
        address[] owners,
        bytes32[] transactionHashes
    );

    event BlockVerifierRefreshed(address blockVerifier);
    event DepositContractUpdate(address depositContract);
    event WithdrawExchangeFees(address token, address recipient);

    event WithdrawalRecipientUpdate(
        address from,
        address to,
        address token,
        uint248 amount,
        uint32 storageID,
        address newRecipient
    );

    event DepositParamsUpdate(
        uint256 freeDepositMax,
        uint256 freeDepositRemained,
        uint256 freeSlotPerBlock,
        uint256 depositFee
    );

    event AllowOnchainTransferFrom(bool value);

    // -- Initialization --
    /// @dev Initializes this exchange. This method can only be called once.
    /// @param  loopring The LoopringV3 contract address.
    /// @param  owner The owner of this exchange.
    /// @param  genesisMerkleRoot The initial Merkle tree state.
    /// @param  genesisMerkleAssetRoot The initial Asset Merkle tree state.
    function initialize(
        address loopring,
        address owner,
        bytes32 genesisMerkleRoot,
        bytes32 genesisMerkleAssetRoot
        )
        virtual
        external;

    ///      Can only be called by the exchange owner once.
    /// @param depositContract The deposit contract to be used
    function setDepositContract(address depositContract)
        external
        virtual;

    /// @dev Gets the deposit contract used by the exchange.
    /// @return the deposit contract
    function getDepositContract()
        external
        virtual
        view
        returns (IDepositContract);

    // @dev Exchange owner set params for deposit.
    // @param freeDepositMax Max slots for free deposit
    // @param freeDepositRemained Remained free deposit
    // @param freeSlotPerBlock Free slot for every block
    // @param depositFee Deposit fee in ETH
    function setDepositParams(
        uint256 freeDepositMax,
        uint256 freeDepositRemained,
        uint256 freeSlotPerBlock,
        uint256 depositFee
    ) external virtual;

    // @dev Exchange owner withdraws fees from the exchange.
    // @param token Fee token address
    // @param feeRecipient Fee recipient address
    function withdrawExchangeFees(
        address token,
        address feeRecipient
        )
        external
        virtual;

    // -- Constants --
    /// @dev Returns a list of constants used by the exchange.
    /// @return constants The list of constants.
    function getConstants()
        external
        virtual
        pure
        returns(ExchangeData.Constants memory);

    // -- Mode --
    /// @dev Returns hether the exchange is in withdrawal mode.
    /// @return Returns true if the exchange is in withdrawal mode, else false.
    function isInWithdrawalMode()
        external
        virtual
        view
        returns (bool);

    /// @dev Returns whether the exchange is shutdown.
    /// @return Returns true if the exchange is shutdown, else false.
    function isShutdown()
        external
        virtual
        view
        returns (bool);

    // -- Tokens --
    /// @dev Registers an ERC20 token for a token id. Note that different exchanges may have
    ///      different ids for the same ERC20 token.
    ///
    ///      Please note that 1 is reserved for Ether (ETH), 2 is reserved for Wrapped Ether (ETH),
    ///      and 3 is reserved for Loopring Token (LRC).
    ///
    ///      This function is only callable by the exchange owner.
    ///
    /// @param  tokenAddress The token's address
    /// @return tokenID The token's ID in this exchanges.
    function registerToken(
        address tokenAddress
        )
        external
        virtual
        returns (uint32 tokenID);

    /// @dev Returns the id of a registered token.
    /// @param  tokenAddress The token's address
    /// @return tokenID The token's ID in this exchanges.
    function getTokenID(
        address tokenAddress
        )
        external
        virtual
        view
        returns (uint32 tokenID);

    /// @dev Returns the address of a registered token.
    /// @param  tokenID The token's ID in this exchanges.
    /// @return tokenAddress The token's address
    function getTokenAddress(
        uint32 tokenID
        )
        external
        virtual
        view
        returns (address tokenAddress);

    // -- Stakes --
    /// @dev Gets the amount of LRC the owner has staked onchain for this exchange.
    ///      The stake will be burned if the exchange does not fulfill its duty by
    ///      processing user requests in time. Please note that order matching may potentially
    ///      performed by another party and is not part of the exchange's duty.
    ///
    /// @return The amount of LRC staked
    function getExchangeStake()
        external
        virtual
        view
        returns (uint);

    /// @dev Withdraws the amount staked for this exchange.
    ///      This can only be done if the exchange has been correctly shutdown:
    ///      - The exchange owner has shutdown the exchange
    ///      - All deposit requests are processed
    ///      - All funds are returned to the users (merkle root is reset to initial state)
    ///
    ///      Can only be called by the exchange owner.
    ///
    /// @return amountLRC The amount of LRC withdrawn
    function withdrawExchangeStake(
        address recipient
        )
        external
        virtual
        returns (uint amountLRC);

    /// @dev Can by called by anyone to burn the stake of the exchange when certain
    ///      conditions are fulfilled.
    ///
    ///      Currently this will only burn the stake of the exchange if
    ///      the exchange is in withdrawal mode.
    function burnExchangeStake()
        external
        virtual;

    // -- Blocks --

    /// @dev Gets the current Merkle root of this exchange's virtual blockchain.
    /// @return The current Merkle root.
    function getMerkleRoot()
        external
        virtual
        view
        returns (bytes32);

    /// @dev Gets the current Asset Merkle root of this exchange's virtual blockchain.
    /// @return The current Asset Merkle root.
    function getMerkleAssetRoot()
        external
        virtual
        view
        returns (bytes32);

    /// @dev Gets the height of this exchange's virtual blockchain. The block height for a
    ///      new exchange is 1.
    /// @return The virtual blockchain height which is the index of the last block.
    function getBlockHeight()
        external
        virtual
        view
        returns (uint);

    /// @dev Gets some minimal info of a previously submitted block that's kept onchain.
    ///      A DEX can use this function to implement a payment receipt verification
    ///      contract with a challange-response scheme.
    /// @param blockIdx The block index.
    function getBlockInfo(uint blockIdx)
        external
        virtual
        view
        returns (ExchangeData.BlockInfo memory);

    /// @dev Sumbits new blocks to the rollup blockchain.
    ///
    ///      This function can only be called by the exchange operator.
    ///
    /// @param blocks The blocks being submitted
    ///      - blockType: The type of the new block
    ///      - blockSize: The number of onchain or offchain requests/settlements
    ///        that have been processed in this block
    ///      - blockVersion: The circuit version to use for verifying the block
    ///      - storeBlockInfoOnchain: If the block info for this block needs to be stored on-chain
    ///      - data: The data for this block
    ///      - offchainData: Arbitrary data, mainly for off-chain data-availability, i.e.,
    ///        the multihash of the IPFS file that contains the block data.
    function submitBlocks(ExchangeData.Block[] calldata blocks)
        external
        virtual;

    /// @dev Gets the number of available forced request slots.
    /// @return The number of available slots.
    function getNumAvailableForcedSlots()
        external
        virtual
        view
        returns (uint);

    // -- Deposits --

    /// @dev Deposits Ether or ERC20 tokens to the specified account.
    ///
    ///      This function is only callable by an agent of 'from'.
    ///
    ///      A fee to the owner is paid in ETH to process the deposit.
    ///      The operator is not forced to do the deposit and the user can send
    ///      any fee amount.
    ///
    /// @param from The address that deposits the funds to the exchange
    /// @param to The account owner's address receiving the funds
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @param amount The amount of tokens to deposit
    /// @param auxiliaryData Optional extra data used by the deposit contract
    function deposit(
        address from,
        address to,
        address tokenAddress,
        uint248  amount,
        bytes   calldata auxiliaryData
        )
        external
        virtual
        payable;

    /// @dev Gets the amount of tokens that may be added to the owner's account.
    /// @param owner The destination address for the amount deposited.
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @return The amount of tokens pending.
    function getPendingDepositAmount(
        address owner,
        address tokenAddress
        )
        external
        virtual
        view
        returns (uint248);

    // -- Withdrawals --
    /// @dev Submits an onchain request to force withdraw Ether or ERC20 tokens.
    ///      This request always withdraws the full balance.
    ///
    ///      This function is only callable by an agent of the account.
    ///
    ///      The total fee in ETH that the user needs to pay is 'withdrawalFee'.
    ///      If the user sends too much ETH the surplus is sent back immediately.
    ///
    ///      Note that after such an operation, it will take the owner some
    ///      time (no more than MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE) to process the request
    ///      and create the deposit to the offchain account.
    ///
    /// @param owner The expected owner of the account
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @param accountID The address the account in the Merkle tree.
    function forceWithdraw(
        address owner,
        address tokenAddress,
        uint32  accountID
        )
        external
        virtual
        payable;

    /// @dev Checks if a forced withdrawal is pending for an account balance.
    /// @param  accountID The accountID of the account to check.
    /// @param  token The token address
    /// @return True if a request is pending, false otherwise
    function isForcedWithdrawalPending(
        uint32  accountID,
        address token
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Gets the time the protocol fee for a token was last withdrawn.
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @return The time the protocol fee was last withdrawn.
    function getProtocolFeeLastWithdrawnTime(
        address tokenAddress
        )
        external
        virtual
        view
        returns (uint);

    /// @dev Allows anyone to withdraw funds for a specified user using the balances stored
    ///      in the Merkle tree. The funds will be sent to the owner of the acount.
    ///
    ///      Can only be used in withdrawal mode (i.e. when the owner has stopped
    ///      committing blocks and is not able to commit any more blocks).
    ///
    ///      This will NOT modify the onchain merkle root! The merkle root stored
    ///      onchain will remain the same after the withdrawal. We store if the user
    ///      has withdrawn the balance in State.withdrawnInWithdrawMode.
    ///
    /// @param  merkleProof The Merkle inclusion proof
    function withdrawFromMerkleTree(
        ExchangeData.MerkleProof calldata merkleProof
        )
        external
        virtual;

    /// @dev Checks if the balance for the account was withdrawn with `withdrawFromMerkleTree`.
    /// @param  accountID The accountID of the balance to check.
    /// @param  token The token address
    /// @return True if it was already withdrawn, false otherwise
    function isWithdrawnInWithdrawalMode(
        uint32  accountID,
        address token
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Allows withdrawing funds deposited to the contract in a deposit request when
    ///      it was never processed by the owner within the maximum time allowed.
    ///
    ///      Can be called by anyone. The deposited tokens will be sent back to
    ///      the owner of the account they were deposited in.
    ///
    /// @param  owner The address of the account the withdrawal was done for.
    /// @param  token The token address
    function withdrawFromDepositRequest(
        address owner,
        address token
        )
        external
        virtual;

    /// @dev Allows withdrawing funds after a withdrawal request (either onchain
    ///      or offchain) was submitted in a block by the operator.
    ///
    ///      Can be called by anyone. The withdrawn tokens will be sent to
    ///      the owner of the account they were withdrawn out.
    ///
    ///      Normally it is should not be needed for users to call this manually.
    ///      Funds from withdrawal requests will be sent to the account owner
    ///      immediately by the owner when the block is submitted.
    ///      The user will however need to call this manually if the transfer failed.
    ///
    ///      Tokens and owners must have the same size.
    ///
    /// @param  owners The addresses of the account the withdrawal was done for.
    /// @param  tokens The token addresses
    function withdrawFromApprovedWithdrawals(
        address[] calldata owners,
        address[] calldata tokens
        )
        external
        virtual;

    /// @dev Gets the amount that can be withdrawn immediately with `withdrawFromApprovedWithdrawals`.
    /// @param  owner The address of the account the withdrawal was done for.
    /// @param  token The token address
    /// @return The amount withdrawable
    function getAmountWithdrawable(
        address owner,
        address token
        )
        external
        virtual
        view
        returns (uint);

    /// @dev Notifies the exchange that the owner did not process a forced request.
    ///      If this is indeed the case, the exchange will enter withdrawal mode.
    ///
    ///      Can be called by anyone.
    ///
    /// @param  accountID The accountID the forced request was made for
    /// @param  token The token address of the the forced request
    function notifyForcedRequestTooOld(
        uint32  accountID,
        address token
        )
        external
        virtual;

    /// @dev Allows a withdrawal to be done to an adddresss that is different
    ///      than initialy specified in the withdrawal request. This can be used to
    ///      implement functionality like fast withdrawals.
    ///
    ///      This function can only be called by an agent.
    ///
    /// @param from The address of the account that does the withdrawal.
    /// @param to The address to which 'amount' tokens were going to be withdrawn.
    /// @param token The address of the token that is withdrawn ('0x0' for ETH).
    /// @param amount The amount of tokens that are going to be withdrawn.
    /// @param storageID The storageID of the withdrawal request.
    /// @param newRecipient The new recipient address of the withdrawal.
    function setWithdrawalRecipient(
        address from,
        address to,
        address token,
        uint248  amount,
        uint32  storageID,
        address newRecipient
        )
        external
        virtual;

    /// @dev Gets the withdrawal recipient.
    ///
    /// @param from The address of the account that does the withdrawal.
    /// @param to The address to which 'amount' tokens were going to be withdrawn.
    /// @param token The address of the token that is withdrawn ('0x0' for ETH).
    /// @param amount The amount of tokens that are going to be withdrawn.
    /// @param storageID The storageID of the withdrawal request.
    function getWithdrawalRecipient(
        address from,
        address to,
        address token,
        uint248  amount,
        uint32  storageID
        )
        external
        virtual
        view
        returns (address);

    /// @dev Allows an agent to transfer ERC-20 tokens for a user using the allowance
    ///      the user has set for the exchange. This way the user only needs to approve a single exchange contract
    ///      for all exchange/agent features, which allows for a more seamless user experience.
    ///
    ///      This function can only be called by an agent.
    ///
    /// @param from The address of the account that sends the tokens.
    /// @param to The address to which 'amount' tokens are transferred.
    /// @param token The address of the token to transfer (ETH is and cannot be suppported).
    /// @param amount The amount of tokens transferred.
    function onchainTransferFrom(
        address from,
        address to,
        address token,
        uint    amount
        )
        external
        virtual;

    /// @dev Allows an agent to approve a rollup tx.
    ///
    ///      This function can only be called by an agent.
    ///
    /// @param owner The owner of the account
    /// @param txHash The hash of the transaction
    function approveTransaction(
        address owner,
        bytes32 txHash
        )
        external
        virtual;

    /// @dev Allows an agent to approve multiple rollup txs.
    ///
    ///      This function can only be called by an agent.
    ///
    /// @param owners The account owners
    /// @param txHashes The hashes of the transactions
    function approveTransactions(
        address[] calldata owners,
        bytes32[] calldata txHashes
        )
        external
        virtual;

    /// @dev Checks if a rollup tx is approved using the tx's hash.
    ///
    /// @param owner The owner of the account that needs to authorize the tx
    /// @param txHash The hash of the transaction
    /// @return True if the tx is approved, else false
    function isTransactionApproved(
        address owner,
        bytes32 txHash
        )
        external
        virtual
        view
        returns (bool);

    // -- Admins --
    /// @dev Sets the max time deposits have to wait before becoming withdrawable.
    /// @param newValue The new value.
    /// @return  The old value.
    function setMaxAgeDepositUntilWithdrawable(
        uint32 newValue
        )
        external
        virtual
        returns (uint32);

    /// @dev Returns the max time deposits have to wait before becoming withdrawable.
    /// @return The value.
    function getMaxAgeDepositUntilWithdrawable()
        external
        virtual
        view
        returns (uint32);

    /// @dev Shuts down the exchange.
    ///      Once the exchange is shutdown all onchain requests are permanently disabled.
    ///      When all requirements are fulfilled the exchange owner can withdraw
    ///      the exchange stake with withdrawStake.
    ///
    ///      Note that the exchange can still enter the withdrawal mode after this function
    ///      has been invoked successfully. To prevent entering the withdrawal mode before the
    ///      the echange stake can be withdrawn, all withdrawal requests still need to be handled
    ///      for at least MIN_TIME_IN_SHUTDOWN seconds.
    ///
    ///      Can only be called by the exchange owner.
    ///
    /// @return success True if the exchange is shutdown, else False
    function shutdown()
        external
        virtual
        returns (bool success);

    /// @dev Gets the protocol fees for this exchange.
    /// @return syncedAt The timestamp the protocol fees were last updated
    /// @return protocolFeeBips The protocol fee
    /// @return previousProtocolFeeBips The previous protocol fee
    /// @return executeTimeOfNextProtocolFeeBips The timestamp the next protocol fees will be updated
    /// @return nextProtocolFeeBips The next protocol fee
    function getProtocolFeeValues()
        external
        virtual
        view
        returns (
            uint32 syncedAt,
            uint16 protocolFeeBips,
            uint16 previousProtocolFeeBips,
            uint32 executeTimeOfNextProtocolFeeBips,
            uint16 nextProtocolFeeBips
        );

    /// @dev Gets the domain separator used in this exchange.
    function getDomainSeparator()
        external
        virtual
        view
        returns (bytes32);

    /// @dev Gets the uncomfirmed balance in DepositContract, which can be used for DepositTransaction.
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @return Unconfirmed balance of the token
    function getUnconfirmedBalance(
        address tokenAddress
        )
        external
        virtual
        view
        returns (uint256);

    /// @dev Gets free deposit slots
    function getFreeDepositRemained()
        external
        virtual
        view
        returns (uint256);

    /// @dev Gets token deposit balance
    /// @param tokenAddress The address of the token, use `0x0` for Ether.
    /// @return deposit balance of the token
    function getDepositBalance(
        address tokenAddress
        )
        external
        virtual
        view
        returns (uint248);
}

File 12 of 95 : Claimable.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./Ownable.sol";


/// @title Claimable
/// @author Brecht Devos - <[email protected]>
/// @dev Extension for the Ownable contract, where the ownership needs
///      to be claimed. This allows the new owner to accept the transfer.
contract Claimable is Ownable
{
    address public pendingOwner;

    /// @dev Modifier throws if called by any account other than the pendingOwner.
    modifier onlyPendingOwner() {
        require(msg.sender == pendingOwner, "UNAUTHORIZED");
        _;
    }

    /// @dev Allows the current owner to set the pendingOwner address.
    /// @param newOwner The address to transfer ownership to.
    function transferOwnership(
        address newOwner
        )
        public
        override
        onlyOwner
    {
        require(newOwner != address(0) && newOwner != owner, "INVALID_ADDRESS");
        pendingOwner = newOwner;
    }

    /// @dev Allows the pendingOwner address to finalize the transfer.
    function claimOwnership()
        public
        onlyPendingOwner
    {
        emit OwnershipTransferred(owner, pendingOwner);
        owner = pendingOwner;
        pendingOwner = address(0);
    }
}

File 13 of 95 : Ownable.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title Ownable
/// @author Brecht Devos - <[email protected]>
/// @dev The Ownable contract has an owner address, and provides basic
///      authorization control functions, this simplifies the implementation of
///      "user permissions".
contract Ownable
{
    address public owner;

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

    /// @dev The Ownable constructor sets the original `owner` of the contract
    ///      to the sender.
    constructor()
    {
        owner = msg.sender;
    }

    /// @dev Throws if called by any account other than the owner.
    modifier onlyOwner()
    {
        require(msg.sender == owner, "UNAUTHORIZED");
        _;
    }

    /// @dev Allows the current owner to transfer control of the contract to a
    ///      new owner.
    /// @param newOwner The address to transfer ownership to.
    function transferOwnership(
        address newOwner
        )
        public
        virtual
        onlyOwner
    {
        require(newOwner != address(0), "ZERO_ADDRESS");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    function renounceOwnership()
        public
        onlyOwner
    {
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }
}

File 14 of 95 : ExchangeData.sol
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022

import "./IAgentRegistry.sol";
import "./IBlockVerifier.sol";
import "./IDepositContract.sol";
import "./ILoopringV3.sol";

/// @title ExchangeData
/// @dev All methods in this lib are internal, therefore, there is no need
///      to deploy this library independently.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeData
{
    // -- Enums --
    enum TransactionType
    {
        NOOP,
        DEPOSIT,
        WITHDRAWAL,
        TRANSFER,
        SPOT_TRADE,
        ACCOUNT_UPDATE,
        ORDER_CANCEL,
        BATCH_SPOT_TRADE,
        APPKEY_UPDATE
    }

    // -- Structs --
    struct Token
    {
        address token;
    }

    struct ProtocolFeeData
    {
        uint32 syncedAt; // only valid before 2105 (85 years to go)
        uint16 protocolFeeBips;
        uint16 previousProtocolFeeBips;

        uint32 executeTimeOfNextProtocolFeeBips;
        uint16 nextProtocolFeeBips;
    }

    // General auxiliary data for each conditional transaction
    struct AuxiliaryData
    {
        bytes data;
    }

    // This is the (virtual) block the owner  needs to submit onchain to maintain the
    // per-exchange (virtual) blockchain.
    struct Block
    {
        uint8      blockType;
        uint16     blockSize;
        uint8      blockVersion;
        bytes      data;
        uint256[8] proof;

        // Whether we should store the @BlockInfo for this block on-chain.
        bool storeBlockInfoOnchain;

        // Block specific data that is only used to help process the block on-chain.
        // It is not used as input for the circuits and it is not necessary for data-availability.
        // This bytes array contains the abi encoded AuxiliaryData[] data.
        bytes auxiliaryData;

        // Arbitrary data, mainly for off-chain data-availability, i.e.,
        // the multihash of the IPFS file that contains the block data.
        bytes offchainData;
    }

    struct BlockInfo
    {
        // The time the block was submitted on-chain.
        uint32  timestamp;
        // The public data hash of the block (the 28 most significant bytes).
        bytes28 blockDataHash;
    }

    // Represents an onchain deposit request.
    struct Deposit
    {
        uint248 amount;
        uint64 timestamp;
    }

    // A forced withdrawal request.
    // If the actual owner of the account initiated the request (we don't know who the owner is
    // at the time the request is being made) the full balance will be withdrawn.
    struct ForcedWithdrawal
    {
        address owner;
        uint64  timestamp;
    }

    struct Constants
    {
        uint SNARK_SCALAR_FIELD;
        uint MAX_OPEN_FORCED_REQUESTS;
        uint MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE;
        uint TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS;
        uint MAX_NUM_ACCOUNTS;
        uint MAX_NUM_TOKENS;
        uint MIN_AGE_PROTOCOL_FEES_UNTIL_UPDATED;
        uint MIN_TIME_IN_SHUTDOWN;
        uint TX_DATA_AVAILABILITY_SIZE;
        uint MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND;
        uint MAX_FORCED_WITHDRAWAL_FEE;
        uint DEFAULT_PROTOCOL_FEE_BIPS;
    }

    // This is the prime number that is used for the alt_bn128 elliptic curve, see EIP-196.
    uint public constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617;

    uint public constant MAX_OPEN_FORCED_REQUESTS = 1000000;
    uint public constant MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE = 15 days;
    uint public constant TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS = 7 days;
    uint public constant BINARY_TREE_DEPTH_ACCOUNTS = 32;
    uint public constant MAX_NUM_ACCOUNTS = 2 ** BINARY_TREE_DEPTH_ACCOUNTS;
    uint public constant BINARY_TREE_DEPTH_TOKENS = 32;
    uint public constant MAX_NUM_TOKENS = 2 ** BINARY_TREE_DEPTH_TOKENS;
    uint public constant MAX_NUM_RESERVED_TOKENS = 32;
    uint public constant MAX_NUM_NORMAL_TOKENS = 2 ** BINARY_TREE_DEPTH_TOKENS - 32;

    uint public constant MIN_AGE_PROTOCOL_FEES_UNTIL_UPDATED = 7 days;
    uint public constant MIN_TIME_IN_SHUTDOWN = 30 days;
    uint32 public constant MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND = 15 days;
    uint32 public constant ACCOUNTID_PROTOCOLFEE = 0;

    // The amount of bytes each rollup transaction uses in the block data for data-availability.
    // This is the maximum amount of bytes of all different transaction types.
    uint public constant TX_DATA_AVAILABILITY_SIZE = 83;
    uint public constant TX_DATA_AVAILABILITY_SIZE_PART_1 = 80;
    uint public constant TX_DATA_AVAILABILITY_SIZE_PART_2 = 3;

    uint public constant MAX_FORCED_WITHDRAWAL_FEE = 0.25 ether;

    uint16 public constant DEFAULT_PROTOCOL_FEE_BIPS = 18;

    struct AccountLeaf
    {
        uint32   accountID;
        address  owner;
        uint     pubKeyX;
        uint     pubKeyY;
        uint32   nonce;
    }

    struct BalanceLeaf
    {
        uint32  tokenID;
        uint248 balance;
    }

    struct MerkleProof
    {
        ExchangeData.AccountLeaf accountLeaf;
        ExchangeData.BalanceLeaf balanceLeaf;
        uint[48]                 accountMerkleProof;
        uint[48]                 balanceMerkleProof;
    }

    struct BlockContext
    {
        bytes32 DOMAIN_SEPARATOR;
        uint32  timestamp;
    }

   struct DepositState {
        uint256 freeDepositMax;
        uint256 freeDepositRemained;
        uint256 lastDepositBlockNum;
        uint256 freeSlotPerBlock;
        uint256 depositFee;
    }

    struct ModeTime {
        // Time when the exchange was shutdown
        uint shutdownModeStartTime;

        // Time when the exchange has entered withdrawal mode
        uint withdrawalModeStartTime;
    }

    // Represents the entire exchange state except the owner of the exchange.
    struct State
    {
        uint32  maxAgeDepositUntilWithdrawable;
        bytes32 DOMAIN_SEPARATOR;

        ILoopringV3      loopring;
        IBlockVerifier   blockVerifier;
        IAgentRegistry   agentRegistry;
        IDepositContract depositContract;
        DepositState depositState;
        // The merkle root of the offchain data stored in a Merkle tree. The Merkle tree
        // stores balances for users using an account model.
        bytes32 merkleRoot;
        bytes32 merkleAssetRoot;

        // List of all blocks
        mapping(uint => BlockInfo) blocks;
        uint  numBlocks;

        // List of all tokens
        Token[] reservedTokens;
        Token[] normalTokens;

        // A map from a tokenID to deposit balance
        mapping(uint32 => uint248) tokenIdToDepositBalance;

        // A map from a token to its tokenID + 1
        mapping (address => uint32) tokenToTokenId;
        mapping (uint32 => address) tokenIdToToken;

        // A map from an accountID to a tokenID to if the balance is withdrawn
        mapping (uint32 => mapping (uint32 => bool)) withdrawnInWithdrawMode;

        // A map from an account to a token to the amount withdrawable for that account.
        // This is only used when the automatic distribution of the withdrawal failed.
        mapping (address => mapping (uint32 => uint248)) amountWithdrawable;

        // A map from an account to a token to the forced withdrawal (always full balance)
        mapping (uint32 => mapping (uint32 => ForcedWithdrawal)) pendingForcedWithdrawals;

        // A map from an address to a token to a deposit
        mapping (address => mapping (uint32 => Deposit)) pendingDeposits;

        // A map from an account owner to an approved transaction hash to if the transaction is approved or not
        mapping (address => mapping (bytes32 => bool)) approvedTx;

        // A map from an account owner to a destination address to a tokenID to an amount to a storageID to a new recipient address
        mapping (address => mapping (address => mapping (uint32 => mapping (uint => mapping (uint32 => address))))) withdrawalRecipient;

        // Counter to keep track of how many of forced requests are open so we can limit the work that needs to be done by the owner
        uint32 numPendingForcedTransactions;

        // Cached data for the protocol fee
        ProtocolFeeData protocolFeeData;

        ModeTime modeTime;

        // Last time the protocol fee was withdrawn for a specific token
        mapping (address => uint) protocolFeeLastWithdrawnTime;
    }
}

File 15 of 95 : IBlockVerifier.sol
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022

import "../../lib/Claimable.sol";

/// @title IBlockVerifier
/// @author Brecht Devos - <[email protected]>
abstract contract IBlockVerifier is Claimable
{
    // -- Events --

    event CircuitRegistered(
        uint8  indexed blockType,
        uint16         blockSize,
        uint8          blockVersion
    );

    event CircuitDisabled(
        uint8  indexed blockType,
        uint16         blockSize,
        uint8          blockVersion
    );

    // -- Public functions --

    /// @dev Verifies blocks with the given public data and proofs.
    ///      Verifying a block makes sure all requests handled in the block
    ///      are correctly handled by the operator.
    /// @param blockType The type of block
    /// @param blockSize The number of requests handled in the block
    /// @param blockVersion The block version (i.e. which circuit version needs to be used)
    /// @param publicInputs The hash of all the public data of the blocks
    /// @param proofs The ZK proofs proving that the blocks are correct
    /// @return True if the block is valid, false otherwise
    function verifyProofs(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion,
        uint[] calldata publicInputs,
        uint[] calldata proofs
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Checks if a circuit with the specified parameters is registered.
    /// @param blockType The type of the block
    /// @param blockSize The number of requests handled in the block
    /// @param blockVersion The block version (i.e. which circuit version needs to be used)
    /// @return True if the circuit is registered, false otherwise
    function isCircuitRegistered(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion
        )
        external
        virtual
        view
        returns (bool);

    /// @dev Checks if a circuit can still be used to commit new blocks.
    /// @param blockType The type of the block
    /// @param blockSize The number of requests handled in the block
    /// @param blockVersion The block version (i.e. which circuit version needs to be used)
    /// @return True if the circuit is enabled, false otherwise
    function isCircuitEnabled(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion
        )
        external
        virtual
        view
        returns (bool);
}

File 16 of 95 : IDepositContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;


/// @title IDepositContract.
/// @dev   Contract storing and transferring funds for an exchange.
///
///        ERC1155 tokens can be supported by registering pseudo token addresses calculated
///        as `address(keccak256(real_token_address, token_params))`. Then the custom
///        deposit contract can look up the real token address and paramsters with the
///        pseudo token address before doing the transfers.
/// @author Brecht Devos - <[email protected]>
interface IDepositContract
{
    /// @dev Returns if a token is suppoprted by this contract.
    function isTokenSupported(address token)
        external
        view
        returns (bool);

    /// @dev Transfers tokens from a user to the exchange. This function will
    ///      be called when a user deposits funds to the exchange.
    ///      In a simple implementation the funds are simply stored inside the
    ///      deposit contract directly. More advanced implementations may store the funds
    ///      in some DeFi application to earn interest, so this function could directly
    ///      call the necessary functions to store the funds there.
    ///
    ///      This function needs to throw when an error occurred!
    ///
    ///      This function can only be called by the exchange.
    ///
    /// @param from The address of the account that sends the tokens.
    /// @param token The address of the token to transfer (`0x0` for ETH).
    /// @param amount The amount of tokens to transfer.
    /// @param extraData Opaque data that can be used by the contract to handle the deposit
    /// @return amountReceived The amount to deposit to the user's account in the Merkle tree
    function deposit(
        address from,
        address token,
        uint248  amount,
        bytes   calldata extraData
        )
        external
        payable
        returns (uint248 amountReceived);

    /// @dev Transfers tokens from the exchange to a user. This function will
    ///      be called when a withdrawal is done for a user on the exchange.
    ///      In the simplest implementation the funds are simply stored inside the
    ///      deposit contract directly so this simply transfers the requested tokens back
    ///      to the user. More advanced implementations may store the funds
    ///      in some DeFi application to earn interest so the function would
    ///      need to get those tokens back from the DeFi application first before they
    ///      can be transferred to the user.
    ///
    ///      This function needs to throw when an error occurred!
    ///
    ///      This function can only be called by the exchange.
    ///
    /// @param from The address from which 'amount' tokens are transferred.
    /// @param to The address to which 'amount' tokens are transferred.
    /// @param token The address of the token to transfer (`0x0` for ETH).
    /// @param amount The amount of tokens transferred.
    function withdraw(
        address from,
        address to,
        address token,
        uint    amount
        )
        external
        payable;

    /// @dev Transfers tokens (ETH not supported) for a user using the allowance set
    ///      for the exchange. This way the approval can be used for all functionality (and
    ///      extended functionality) of the exchange.
    ///      Should NOT be used to deposit/withdraw user funds, `deposit`/`withdraw`
    ///      should be used for that as they will contain specialised logic for those operations.
    ///      This function can be called by the exchange to transfer onchain funds of users
    ///      necessary for Agent functionality.
    ///
    ///      This function needs to throw when an error occurred!
    ///
    ///      This function can only be called by the exchange.
    ///
    /// @param from The address of the account that sends the tokens.
    /// @param to The address to which 'amount' tokens are transferred.
    /// @param token The address of the token to transfer (ETH is and cannot be suppported).
    /// @param amount The amount of tokens transferred.
    function transfer(
        address from,
        address to,
        address token,
        uint    amount
        )
        external
        payable;

    /// @dev Checks if the given address is used for depositing ETH or not.
    ///      Is used while depositing to send the correct ETH amount to the deposit contract.
    ///
    ///      Note that 0x0 is always registered for deposting ETH when the exchange is created!
    ///      This function allows additional addresses to be used for depositing ETH, the deposit
    ///      contract can implement different behaviour based on the address value.
    ///
    /// @param addr The address to check
    /// @return True if the address is used for depositing ETH, else false.
    function isETH(address addr)
        external
        view
        returns (bool);
}

File 17 of 95 : ILoopringV3.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../../lib/Claimable.sol";


/// @title ILoopringV3
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
abstract contract ILoopringV3 is Claimable
{
    // == Events ==
    event ExchangeStakeDeposited(address exchangeAddr, uint amount);
    event ExchangeStakeWithdrawn(address exchangeAddr, uint amount);
    event ExchangeStakeBurned(address exchangeAddr, uint amount);
    event SettingsUpdated(uint time);

    // == Public Variables ==
    mapping (address => uint) internal exchangeStake;

    uint    public totalStake;
    address public blockVerifierAddress;
    uint    public forcedWithdrawalFee;
    uint16  public protocolFeeBips;
    

    address payable public protocolFeeVault;

    // == Public Functions ==

    /// @dev Returns the LRC token address
    /// @return the LRC token address
    function lrcAddress()
        external
        view
        virtual
        returns (address);

    /// @dev Updates the global exchange settings.
    ///      This function can only be called by the owner of this contract.
    ///
    ///      Warning: these new values will be used by existing and
    ///      new Loopring exchanges.
    function updateSettings(
        address payable _protocolFeeVault,   // address(0) not allowed
        uint    _forcedWithdrawalFee
        )
        external
        virtual;

    /// @dev Updates the global protocol fee settings.
    ///      This function can only be called by the owner of this contract.
    ///
    ///      Warning: these new values will be used by existing and
    ///      new Loopring exchanges.
    function updateProtocolFeeSettings(
        uint16 _protocolFeeBips
        )
        external
        virtual;

    /// @dev Gets the amount of staked LRC for an exchange.
    /// @param exchangeAddr The address of the exchange
    /// @return stakedLRC The amount of LRC
    function getExchangeStake(
        address exchangeAddr
        )
        external
        virtual
        view
        returns (uint stakedLRC);

    /// @dev Burns a certain amount of staked LRC for a specific exchange.
    ///      This function is meant to be called only from exchange contracts.
    /// @return burnedLRC The amount of LRC burned. If the amount is greater than
    ///         the staked amount, all staked LRC will be burned.
    function burnExchangeStake(
        uint amount
        )
        external
        virtual
        returns (uint burnedLRC);

    /// @dev Stakes more LRC for an exchange.
    /// @param  exchangeAddr The address of the exchange
    /// @param  amountLRC The amount of LRC to stake
    /// @return stakedLRC The total amount of LRC staked for the exchange
    function depositExchangeStake(
        address exchangeAddr,
        uint    amountLRC
        )
        external
        virtual
        returns (uint stakedLRC);

    /// @dev Withdraws a certain amount of staked LRC for an exchange to the given address.
    ///      This function is meant to be called only from within exchange contracts.
    /// @param  recipient The address to receive LRC
    /// @param  requestedAmount The amount of LRC to withdraw
    /// @return amountLRC The amount of LRC withdrawn
    function withdrawExchangeStake(
        address recipient,
        uint    requestedAmount
        )
        external
        virtual
        returns (uint amountLRC);

    /// @dev Gets the protocol fee values for an exchange.
    /// @return feeBips The protocol fee
    function getProtocolFeeValues(
        )
        external
        virtual
        view
        returns (
            uint16 feeBips
        );
}

File 18 of 95 : ExchangeAdmins.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/ERC20.sol";
import "../../../lib/ERC20SafeTransfer.sol";
import "../../../lib/MathUint.sol";
import "../../iface/ExchangeData.sol";
import "./ExchangeMode.sol";


/// @title ExchangeAdmins.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeAdmins
{
    using ERC20SafeTransfer for address;
    using ExchangeMode      for ExchangeData.State;
    using MathUint          for uint;

    event MaxAgeDepositUntilWithdrawableChanged(
        address indexed exchangeAddr,
        uint32          oldValue,
        uint32          newValue
    );

    function setMaxAgeDepositUntilWithdrawable(
        ExchangeData.State storage S,
        uint32 newValue
        )
        public
        returns (uint32 oldValue)
    {
        require(!S.isInWithdrawalMode(), "INVALID_MODE");
        require(
            newValue > 0 &&
            newValue <= ExchangeData.MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND,
            "INVALID_VALUE"
        );
        oldValue = S.maxAgeDepositUntilWithdrawable;
        S.maxAgeDepositUntilWithdrawable = newValue;

        emit MaxAgeDepositUntilWithdrawableChanged(
            address(this),
            oldValue,
            newValue
        );
    }

    function withdrawExchangeStake(
        ExchangeData.State storage S,
        address recipient
        )
        public
        returns (uint)
    {
        // Exchange needs to be shutdown
        require(S.isShutdown(), "EXCHANGE_NOT_SHUTDOWN");
        require(!S.isInWithdrawalMode(), "CANNOT_BE_IN_WITHDRAWAL_MODE");

        // Need to remain in shutdown for some time
        require(block.timestamp >= S.modeTime.shutdownModeStartTime + ExchangeData.MIN_TIME_IN_SHUTDOWN, "TOO_EARLY");

        // Withdraw the complete stake
        uint amount = S.loopring.getExchangeStake(address(this));
        return S.loopring.withdrawExchangeStake(recipient, amount);
    }
}

File 19 of 95 : ERC20.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title ERC20 Token Interface
/// @dev see https://github.com/ethereum/EIPs/issues/20
/// @author Daniel Wang - <[email protected]>
abstract contract ERC20
{
    function totalSupply()
        public
        virtual
        view
        returns (uint);

    function balanceOf(
        address who
        )
        public
        virtual
        view
        returns (uint);

    function allowance(
        address owner,
        address spender
        )
        public
        virtual
        view
        returns (uint);

    function transfer(
        address to,
        uint value
        )
        public
        virtual
        returns (bool);

    function transferFrom(
        address from,
        address to,
        uint    value
        )
        public
        virtual
        returns (bool);

    function approve(
        address spender,
        uint    value
        )
        public
        virtual
        returns (bool);
}

File 20 of 95 : ExchangeMode.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/MathUint.sol";
import "../../iface/ExchangeData.sol";


/// @title ExchangeMode.
/// @dev All methods in this lib are internal, therefore, there is no need
///      to deploy this library independently.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
library ExchangeMode
{
    using MathUint  for uint;

    function isInWithdrawalMode(
        ExchangeData.State storage S
        )
        internal // inline call
        view
        returns (bool result)
    {
        result = S.modeTime.withdrawalModeStartTime > 0;
    }

    function isShutdown(
        ExchangeData.State storage S
        )
        internal // inline call
        view
        returns (bool)
    {
        return S.modeTime.shutdownModeStartTime > 0;
    }

    function getNumAvailableForcedSlots(
        ExchangeData.State storage S
        )
        internal
        view
        returns (uint)
    {
        return ExchangeData.MAX_OPEN_FORCED_REQUESTS - S.numPendingForcedTransactions;
    }
}

File 21 of 95 : ExchangeBalances.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/MathUint.sol";
import "../../../lib/Poseidon.sol";
import "../../iface/ExchangeData.sol";


/// @title ExchangeBalances.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeBalances
{
    using MathUint  for uint;

    function verifyAccountBalance(
        uint                              merkleRoot,
        ExchangeData.MerkleProof calldata merkleProof
        )
        public
        pure
    {
        require(
            isAccountBalanceCorrect(merkleRoot, merkleProof),
            "INVALID_MERKLE_TREE_DATA"
        );
    }

    function isAccountBalanceCorrect(
        uint                            merkleRoot,
        ExchangeData.MerkleProof memory merkleProof
        )
        public
        pure
        returns (bool)
    {
        // Calculate the Merkle root using the Merkle paths provided
        uint calculatedRoot = getBalancesRoot(
            merkleProof.balanceLeaf.tokenID,
            merkleProof.balanceLeaf.balance,
            merkleProof.balanceMerkleProof
        );
        calculatedRoot = getAccountInternalsRoot(
            merkleProof.accountLeaf.accountID,
            merkleProof.accountLeaf.owner,
            merkleProof.accountLeaf.pubKeyX,
            merkleProof.accountLeaf.pubKeyY,
            merkleProof.accountLeaf.nonce,
            calculatedRoot,
            merkleProof.accountMerkleProof
        );
        // Check against the expected Merkle root
        return (calculatedRoot == merkleRoot);
    }

    function getBalancesRoot(
        uint32   tokenID,
        uint     balance,
        uint[48] memory balanceMerkleProof
        )
        private
        pure
        returns (uint)
    {
        // Hash the balance leaf
        uint balanceItem = hashImpl(balance, 0, 0, 0);
        // Calculate the Merkle root of the balance quad Merkle tree
        uint _id = tokenID;
        for (uint depth = 0; depth < ExchangeData.BINARY_TREE_DEPTH_TOKENS/2; depth++) { // quad tree depth 
            uint base = depth * 3;
            if (_id & 3 == 0) {
                balanceItem = hashImpl(
                    balanceItem,
                    balanceMerkleProof[base],
                    balanceMerkleProof[base + 1],
                    balanceMerkleProof[base + 2]
                );
            } else if (_id & 3 == 1) {
                balanceItem = hashImpl(
                    balanceMerkleProof[base],
                    balanceItem,
                    balanceMerkleProof[base + 1],
                    balanceMerkleProof[base + 2]
                );
            } else if (_id & 3 == 2) {
                balanceItem = hashImpl(
                    balanceMerkleProof[base],
                    balanceMerkleProof[base + 1],
                    balanceItem,
                    balanceMerkleProof[base + 2]
                );
            } else if (_id & 3 == 3) {
                balanceItem = hashImpl(
                    balanceMerkleProof[base],
                    balanceMerkleProof[base + 1],
                    balanceMerkleProof[base + 2],
                    balanceItem
                );
            }
            _id = _id >> 2;
        }
        return balanceItem;
    }

    function getAccountInternalsRoot(
        uint32   accountID,
        address  owner,
        uint     pubKeyX,
        uint     pubKeyY,
        uint     nonce,
        uint     balancesRoot,
        uint[48] memory accountMerkleProof
        )
        private
        pure
        returns (uint)
    {
        // Hash the account leaf
        uint accountItem = hashAccountLeaf(uint(owner), pubKeyX, pubKeyY, nonce, balancesRoot);
        // Calculate the Merkle root of the account quad Merkle tree
        uint _id = accountID;
        for (uint depth = 0; depth < ExchangeData.BINARY_TREE_DEPTH_ACCOUNTS/2; depth++) { // quad tree depth 
            uint base = depth * 3;
            if (_id & 3 == 0) {
                accountItem = hashImpl(
                    accountItem,
                    accountMerkleProof[base],
                    accountMerkleProof[base + 1],
                    accountMerkleProof[base + 2]
                );
            } else if (_id & 3 == 1) {
                accountItem = hashImpl(
                    accountMerkleProof[base],
                    accountItem,
                    accountMerkleProof[base + 1],
                    accountMerkleProof[base + 2]
                );
            } else if (_id & 3 == 2) {
                accountItem = hashImpl(
                    accountMerkleProof[base],
                    accountMerkleProof[base + 1],
                    accountItem,
                    accountMerkleProof[base + 2]
                );
            } else if (_id & 3 == 3) {
                accountItem = hashImpl(
                    accountMerkleProof[base],
                    accountMerkleProof[base + 1],
                    accountMerkleProof[base + 2],
                    accountItem
                );
            }
            _id = _id >> 2;
        }
        return accountItem;
    }

    function hashAccountLeaf(
        uint t0,
        uint t1,
        uint t2,
        uint t3,
        uint t4
        )
        public
        pure
        returns (uint)
    {
        Poseidon.HashInputs6 memory inputs = Poseidon.HashInputs6(t0, t1, t2, t3, t4, 0);
        return Poseidon.hash_t6f6p52(inputs, ExchangeData.SNARK_SCALAR_FIELD);
    }

    function hashImpl(
        uint t0,
        uint t1,
        uint t2,
        uint t3
        )
        private
        pure
        returns (uint)
    {
        Poseidon.HashInputs5 memory inputs = Poseidon.HashInputs5(t0, t1, t2, t3, 0);
        return Poseidon.hash_t5f6p52(inputs, ExchangeData.SNARK_SCALAR_FIELD);
    }
}

File 22 of 95 : Poseidon.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;


/// @title Poseidon hash function
///        See: https://eprint.iacr.org/2019/458.pdf
///        Code auto-generated by generate_poseidon_EVM_code.py
/// @author Brecht Devos - <[email protected]>
library Poseidon
{
    //
    // hash_t5f6p52
    //

    struct HashInputs5
    {
        uint t0;
        uint t1;
        uint t2;
        uint t3;
        uint t4;
    }

    function hash_t5f6p52_internal(
        uint t0,
        uint t1,
        uint t2,
        uint t3,
        uint t4,
        uint q
        )
        internal
        pure
        returns (uint)
    {
        assembly {
            function mix(_t0, _t1, _t2, _t3, _t4, _q) -> nt0, nt1, nt2, nt3, nt4 {
                nt0 := mulmod(_t0, 4977258759536702998522229302103997878600602264560359702680165243908162277980, _q)
                nt0 := addmod(nt0, mulmod(_t1, 19167410339349846567561662441069598364702008768579734801591448511131028229281, _q), _q)
                nt0 := addmod(nt0, mulmod(_t2, 14183033936038168803360723133013092560869148726790180682363054735190196956789, _q), _q)
                nt0 := addmod(nt0, mulmod(_t3, 9067734253445064890734144122526450279189023719890032859456830213166173619761, _q), _q)
                nt0 := addmod(nt0, mulmod(_t4, 16378664841697311562845443097199265623838619398287411428110917414833007677155, _q), _q)
                nt1 := mulmod(_t0, 107933704346764130067829474107909495889716688591997879426350582457782826785, _q)
                nt1 := addmod(nt1, mulmod(_t1, 17034139127218860091985397764514160131253018178110701196935786874261236172431, _q), _q)
                nt1 := addmod(nt1, mulmod(_t2, 2799255644797227968811798608332314218966179365168250111693473252876996230317, _q), _q)
                nt1 := addmod(nt1, mulmod(_t3, 2482058150180648511543788012634934806465808146786082148795902594096349483974, _q), _q)
                nt1 := addmod(nt1, mulmod(_t4, 16563522740626180338295201738437974404892092704059676533096069531044355099628, _q), _q)
                nt2 := mulmod(_t0, 13596762909635538739079656925495736900379091964739248298531655823337482778123, _q)
                nt2 := addmod(nt2, mulmod(_t1, 18985203040268814769637347880759846911264240088034262814847924884273017355969, _q), _q)
                nt2 := addmod(nt2, mulmod(_t2, 8652975463545710606098548415650457376967119951977109072274595329619335974180, _q), _q)
                nt2 := addmod(nt2, mulmod(_t3, 970943815872417895015626519859542525373809485973005165410533315057253476903, _q), _q)
                nt2 := addmod(nt2, mulmod(_t4, 19406667490568134101658669326517700199745817783746545889094238643063688871948, _q), _q)
                nt3 := mulmod(_t0, 2953507793609469112222895633455544691298656192015062835263784675891831794974, _q)
                nt3 := addmod(nt3, mulmod(_t1, 19025623051770008118343718096455821045904242602531062247152770448380880817517, _q), _q)
                nt3 := addmod(nt3, mulmod(_t2, 9077319817220936628089890431129759976815127354480867310384708941479362824016, _q), _q)
                nt3 := addmod(nt3, mulmod(_t3, 4770370314098695913091200576539533727214143013236894216582648993741910829490, _q), _q)
                nt3 := addmod(nt3, mulmod(_t4, 4298564056297802123194408918029088169104276109138370115401819933600955259473, _q), _q)
                nt4 := mulmod(_t0, 8336710468787894148066071988103915091676109272951895469087957569358494947747, _q)
                nt4 := addmod(nt4, mulmod(_t1, 16205238342129310687768799056463408647672389183328001070715567975181364448609, _q), _q)
                nt4 := addmod(nt4, mulmod(_t2, 8303849270045876854140023508764676765932043944545416856530551331270859502246, _q), _q)
                nt4 := addmod(nt4, mulmod(_t3, 20218246699596954048529384569730026273241102596326201163062133863539137060414, _q), _q)
                nt4 := addmod(nt4, mulmod(_t4, 1712845821388089905746651754894206522004527237615042226559791118162382909269, _q), _q)
            }

            function ark(_t0, _t1, _t2, _t3, _t4, _q, c) -> nt0, nt1, nt2, nt3, nt4 {
                nt0 := addmod(_t0, c, _q)
                nt1 := addmod(_t1, c, _q)
                nt2 := addmod(_t2, c, _q)
                nt3 := addmod(_t3, c, _q)
                nt4 := addmod(_t4, c, _q)
            }

            function sbox_full(_t0, _t1, _t2, _t3, _t4, _q) -> nt0, nt1, nt2, nt3, nt4 {
                nt0 := mulmod(_t0, _t0, _q)
                nt0 := mulmod(nt0, nt0, _q)
                nt0 := mulmod(_t0, nt0, _q)
                nt1 := mulmod(_t1, _t1, _q)
                nt1 := mulmod(nt1, nt1, _q)
                nt1 := mulmod(_t1, nt1, _q)
                nt2 := mulmod(_t2, _t2, _q)
                nt2 := mulmod(nt2, nt2, _q)
                nt2 := mulmod(_t2, nt2, _q)
                nt3 := mulmod(_t3, _t3, _q)
                nt3 := mulmod(nt3, nt3, _q)
                nt3 := mulmod(_t3, nt3, _q)
                nt4 := mulmod(_t4, _t4, _q)
                nt4 := mulmod(nt4, nt4, _q)
                nt4 := mulmod(_t4, nt4, _q)
            }

            function sbox_partial(_t, _q) -> nt {
                nt := mulmod(_t, _t, _q)
                nt := mulmod(nt, nt, _q)
                nt := mulmod(_t, nt, _q)
            }

            // round 0
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 14397397413755236225575615486459253198602422701513067526754101844196324375522)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 1
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 10405129301473404666785234951972711717481302463898292859783056520670200613128)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 2
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 5179144822360023508491245509308555580251733042407187134628755730783052214509)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 3
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9132640374240188374542843306219594180154739721841249568925550236430986592615)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 4
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20360807315276763881209958738450444293273549928693737723235350358403012458514)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 5
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 17933600965499023212689924809448543050840131883187652471064418452962948061619)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 6
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 3636213416533737411392076250708419981662897009810345015164671602334517041153)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 7
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 2008540005368330234524962342006691994500273283000229509835662097352946198608)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 8
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16018407964853379535338740313053768402596521780991140819786560130595652651567)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 9
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20653139667070586705378398435856186172195806027708437373983929336015162186471)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 10
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 17887713874711369695406927657694993484804203950786446055999405564652412116765)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 11
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 4852706232225925756777361208698488277369799648067343227630786518486608711772)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 12
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 8969172011633935669771678412400911310465619639756845342775631896478908389850)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 13
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20570199545627577691240476121888846460936245025392381957866134167601058684375)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 14
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16442329894745639881165035015179028112772410105963688121820543219662832524136)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 15
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20060625627350485876280451423010593928172611031611836167979515653463693899374)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 16
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16637282689940520290130302519163090147511023430395200895953984829546679599107)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 17
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 15599196921909732993082127725908821049411366914683565306060493533569088698214)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 18
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 19
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 20
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 6172482022646932735745595886795230725225293469762393889050804649558459236626)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 21
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 21004037394166516054140386756510609698837211370585899203851827276330669555417)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 22
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 15262034989144652068456967541137853724140836132717012646544737680069032573006)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 23
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 15017690682054366744270630371095785995296470601172793770224691982518041139766)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 24
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 15159744167842240513848638419303545693472533086570469712794583342699782519832)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 25
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 11178069035565459212220861899558526502477231302924961773582350246646450941231)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 26
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 21154888769130549957415912997229564077486639529994598560737238811887296922114)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 27
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20162517328110570500010831422938033120419484532231241180224283481905744633719)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 28
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 2777362604871784250419758188173029886707024739806641263170345377816177052018)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 29
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 15732290486829619144634131656503993123618032247178179298922551820261215487562)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 30
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 6024433414579583476444635447152826813568595303270846875177844482142230009826)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 31
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 17677827682004946431939402157761289497221048154630238117709539216286149983245)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 32
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 10716307389353583413755237303156291454109852751296156900963208377067748518748)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 33
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 14925386988604173087143546225719076187055229908444910452781922028996524347508)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 34
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 8940878636401797005293482068100797531020505636124892198091491586778667442523)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 35
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 18911747154199663060505302806894425160044925686870165583944475880789706164410)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 36
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 8821532432394939099312235292271438180996556457308429936910969094255825456935)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 37
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 20632576502437623790366878538516326728436616723089049415538037018093616927643)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 38
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 71447649211767888770311304010816315780740050029903404046389165015534756512)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 39
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 2781996465394730190470582631099299305677291329609718650018200531245670229393)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 40
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 12441376330954323535872906380510501637773629931719508864016287320488688345525)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 41
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 2558302139544901035700544058046419714227464650146159803703499681139469546006)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 42
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 10087036781939179132584550273563255199577525914374285705149349445480649057058)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 43
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 4267692623754666261749551533667592242661271409704769363166965280715887854739)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 44
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 4945579503584457514844595640661884835097077318604083061152997449742124905548)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 45
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 17742335354489274412669987990603079185096280484072783973732137326144230832311)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 46
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 47
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 2716062168542520412498610856550519519760063668165561277991771577403400784706)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 48
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 19118392018538203167410421493487769944462015419023083813301166096764262134232)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 49
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9386595745626044000666050847309903206827901310677406022353307960932745699524)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 50
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9121640807890366356465620448383131419933298563527245687958865317869840082266)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 51
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 3078975275808111706229899605611544294904276390490742680006005661017864583210)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 52
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 7157404299437167354719786626667769956233708887934477609633504801472827442743)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 53
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 14056248655941725362944552761799461694550787028230120190862133165195793034373)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 54
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 14124396743304355958915937804966111851843703158171757752158388556919187839849)
            t0 := sbox_partial(t0, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 55
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 11851254356749068692552943732920045260402277343008629727465773766468466181076)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 56
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9799099446406796696742256539758943483211846559715874347178722060519817626047)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
            // round 57
            t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 10156146186214948683880719664738535455146137901666656566575307300522957959544)
            t0, t1, t2, t3, t4 := sbox_full(t0, t1, t2, t3, t4, q)
            t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
        }
        return t0;
    }

    function hash_t5f6p52(HashInputs5 memory i, uint q) internal pure returns (uint)
    {
        // validate inputs
        require(i.t0 < q, "INVALID_INPUT");
        require(i.t1 < q, "INVALID_INPUT");
        require(i.t2 < q, "INVALID_INPUT");
        require(i.t3 < q, "INVALID_INPUT");
        require(i.t4 < q, "INVALID_INPUT");

        return hash_t5f6p52_internal(i.t0, i.t1, i.t2, i.t3, i.t4, q);
    }

    //
    // hash_t6f6p52
    //

    struct HashInputs6
    {
        uint t0;
        uint t1;
        uint t2;
        uint t3;
        uint t4;
        uint t5;
    }


    function mix(HashInputs6 memory i, uint q) internal pure 
    {
        HashInputs6 memory o;
        o.t0 = mulmod(i.t0, 19167410339349846567561662441069598364702008768579734801591448511131028229281, q);
        o.t0 = addmod(o.t0, mulmod(i.t1, 14183033936038168803360723133013092560869148726790180682363054735190196956789, q), q);
        o.t0 = addmod(o.t0, mulmod(i.t2, 9067734253445064890734144122526450279189023719890032859456830213166173619761, q), q);
        o.t0 = addmod(o.t0, mulmod(i.t3, 16378664841697311562845443097199265623838619398287411428110917414833007677155, q), q);
        o.t0 = addmod(o.t0, mulmod(i.t4, 12968540216479938138647596899147650021419273189336843725176422194136033835172, q), q);
        o.t0 = addmod(o.t0, mulmod(i.t5, 3636162562566338420490575570584278737093584021456168183289112789616069756675, q), q);
        o.t1 = mulmod(i.t0, 17034139127218860091985397764514160131253018178110701196935786874261236172431, q);
        o.t1 = addmod(o.t1, mulmod(i.t1, 2799255644797227968811798608332314218966179365168250111693473252876996230317, q), q);
        o.t1 = addmod(o.t1, mulmod(i.t2, 2482058150180648511543788012634934806465808146786082148795902594096349483974, q), q);
        o.t1 = addmod(o.t1, mulmod(i.t3, 16563522740626180338295201738437974404892092704059676533096069531044355099628, q), q);
        o.t1 = addmod(o.t1, mulmod(i.t4, 10468644849657689537028565510142839489302836569811003546969773105463051947124, q), q);
        o.t1 = addmod(o.t1, mulmod(i.t5, 3328913364598498171733622353010907641674136720305714432354138807013088636408, q), q);
        o.t2 = mulmod(i.t0, 18985203040268814769637347880759846911264240088034262814847924884273017355969, q);
        o.t2 = addmod(o.t2, mulmod(i.t1, 8652975463545710606098548415650457376967119951977109072274595329619335974180, q), q);
        o.t2 = addmod(o.t2, mulmod(i.t2, 970943815872417895015626519859542525373809485973005165410533315057253476903, q), q);
        o.t2 = addmod(o.t2, mulmod(i.t3, 19406667490568134101658669326517700199745817783746545889094238643063688871948, q), q);
        o.t2 = addmod(o.t2, mulmod(i.t4, 17049854690034965250221386317058877242629221002521630573756355118745574274967, q), q);
        o.t2 = addmod(o.t2, mulmod(i.t5, 4964394613021008685803675656098849539153699842663541444414978877928878266244, q), q);
        o.t3 = mulmod(i.t0, 19025623051770008118343718096455821045904242602531062247152770448380880817517, q);
        o.t3 = addmod(o.t3, mulmod(i.t1, 9077319817220936628089890431129759976815127354480867310384708941479362824016, q), q);
        o.t3 = addmod(o.t3, mulmod(i.t2, 4770370314098695913091200576539533727214143013236894216582648993741910829490, q), q);
        o.t3 = addmod(o.t3, mulmod(i.t3, 4298564056297802123194408918029088169104276109138370115401819933600955259473, q), q);
        o.t3 = addmod(o.t3, mulmod(i.t4, 6905514380186323693285869145872115273350947784558995755916362330070690839131, q), q);
        o.t3 = addmod(o.t3, mulmod(i.t5, 4783343257810358393326889022942241108539824540285247795235499223017138301952, q), q);
        o.t4 = mulmod(i.t0, 16205238342129310687768799056463408647672389183328001070715567975181364448609, q);
        o.t4 = addmod(o.t4, mulmod(i.t1, 8303849270045876854140023508764676765932043944545416856530551331270859502246, q), q);
        o.t4 = addmod(o.t4, mulmod(i.t2, 20218246699596954048529384569730026273241102596326201163062133863539137060414, q), q);
        o.t4 = addmod(o.t4, mulmod(i.t3, 1712845821388089905746651754894206522004527237615042226559791118162382909269, q), q);
        o.t4 = addmod(o.t4, mulmod(i.t4, 13001155522144542028910638547179410124467185319212645031214919884423841839406, q), q);
        o.t4 = addmod(o.t4, mulmod(i.t5, 16037892369576300958623292723740289861626299352695838577330319504984091062115, q), q);
        o.t5 = mulmod(i.t0, 15162889384227198851506890526431746552868519326873025085114621698588781611738, q);
        o.t5 = addmod(o.t5, mulmod(i.t1, 13272957914179340594010910867091459756043436017766464331915862093201960540910, q), q);
        o.t5 = addmod(o.t5, mulmod(i.t2, 9416416589114508529880440146952102328470363729880726115521103179442988482948, q), q);
        o.t5 = addmod(o.t5, mulmod(i.t3, 8035240799672199706102747147502951589635001418759394863664434079699838251138, q), q);
        o.t5 = addmod(o.t5, mulmod(i.t4, 21642389080762222565487157652540372010968704000567605990102641816691459811717, q), q);
        o.t5 = addmod(o.t5, mulmod(i.t5, 20261355950827657195644012399234591122288573679402601053407151083849785332516, q), q);
        i.t0 = o.t0;
        i.t1 = o.t1;
        i.t2 = o.t2;
        i.t3 = o.t3;
        i.t4 = o.t4;
        i.t5 = o.t5;
    }

    function ark(HashInputs6 memory i, uint q, uint c) internal pure 
    {
        HashInputs6 memory o;
        o.t0 = addmod(i.t0, c, q);
        o.t1 = addmod(i.t1, c, q);
        o.t2 = addmod(i.t2, c, q);
        o.t3 = addmod(i.t3, c, q);
        o.t4 = addmod(i.t4, c, q);
        o.t5 = addmod(i.t5, c, q);
        i.t0 = o.t0;
        i.t1 = o.t1;
        i.t2 = o.t2;
        i.t3 = o.t3;
        i.t4 = o.t4;
        i.t5 = o.t5;
    }

    function sbox_full(HashInputs6 memory i, uint q) internal pure 
    {
        HashInputs6 memory o;
        o.t0 = mulmod(i.t0, i.t0, q);
        o.t0 = mulmod(o.t0, o.t0, q);
        o.t0 = mulmod(i.t0, o.t0, q);
        o.t1 = mulmod(i.t1, i.t1, q);
        o.t1 = mulmod(o.t1, o.t1, q);
        o.t1 = mulmod(i.t1, o.t1, q);
        o.t2 = mulmod(i.t2, i.t2, q);
        o.t2 = mulmod(o.t2, o.t2, q);
        o.t2 = mulmod(i.t2, o.t2, q);
        o.t3 = mulmod(i.t3, i.t3, q);
        o.t3 = mulmod(o.t3, o.t3, q);
        o.t3 = mulmod(i.t3, o.t3, q);
        o.t4 = mulmod(i.t4, i.t4, q);
        o.t4 = mulmod(o.t4, o.t4, q);
        o.t4 = mulmod(i.t4, o.t4, q);
        o.t5 = mulmod(i.t5, i.t5, q);
        o.t5 = mulmod(o.t5, o.t5, q);
        o.t5 = mulmod(i.t5, o.t5, q);
        i.t0 = o.t0;
        i.t1 = o.t1;
        i.t2 = o.t2;
        i.t3 = o.t3;
        i.t4 = o.t4;
        i.t5 = o.t5;
    }

    function sbox_partial(HashInputs6 memory i, uint q) internal pure 
    {
        HashInputs6 memory o;
        o.t0 = mulmod(i.t0, i.t0, q);
        o.t0 = mulmod(o.t0, o.t0, q);
        o.t0 = mulmod(i.t0, o.t0, q);
        i.t0 = o.t0;
    }

    function hash_t6f6p52(HashInputs6 memory i, uint q) internal pure returns (uint)
    {
        // validate inputs
        require(i.t0 < q, "INVALID_INPUT");
        require(i.t1 < q, "INVALID_INPUT");
        require(i.t2 < q, "INVALID_INPUT");
        require(i.t3 < q, "INVALID_INPUT");
        require(i.t4 < q, "INVALID_INPUT");
        require(i.t5 < q, "INVALID_INPUT");

        // round 0
        ark(i, q, 14397397413755236225575615486459253198602422701513067526754101844196324375522);
        sbox_full(i, q);
        mix(i, q);
        // round 1
        ark(i, q, 10405129301473404666785234951972711717481302463898292859783056520670200613128);
        sbox_full(i, q);
        mix(i, q);
        // round 2
        ark(i, q, 5179144822360023508491245509308555580251733042407187134628755730783052214509);
        sbox_full(i, q);
        mix(i, q);
        // round 3
        ark(i, q, 9132640374240188374542843306219594180154739721841249568925550236430986592615);
        sbox_partial(i, q);
        mix(i, q);
        // round 4
        ark(i, q, 20360807315276763881209958738450444293273549928693737723235350358403012458514);
        sbox_partial(i, q);
        mix(i, q);
        // round 5
        ark(i, q, 17933600965499023212689924809448543050840131883187652471064418452962948061619);
        sbox_partial(i, q);
        mix(i, q);
        // round 6
        ark(i, q, 3636213416533737411392076250708419981662897009810345015164671602334517041153);
        sbox_partial(i, q);
        mix(i, q);
        // round 7
        ark(i, q, 2008540005368330234524962342006691994500273283000229509835662097352946198608);
        sbox_partial(i, q);
        mix(i, q);
        // round 8
        ark(i, q, 16018407964853379535338740313053768402596521780991140819786560130595652651567);
        sbox_partial(i, q);
        mix(i, q);
        // round 9
        ark(i, q, 20653139667070586705378398435856186172195806027708437373983929336015162186471);
        sbox_partial(i, q);
        mix(i, q);
        // round 10
        ark(i, q, 17887713874711369695406927657694993484804203950786446055999405564652412116765);
        sbox_partial(i, q);
        mix(i, q);
        // round 11
        ark(i, q, 4852706232225925756777361208698488277369799648067343227630786518486608711772);
        sbox_partial(i, q);
        mix(i, q);
        // round 12
        ark(i, q, 8969172011633935669771678412400911310465619639756845342775631896478908389850);
        sbox_partial(i, q);
        mix(i, q);
        // round 13
        ark(i, q, 20570199545627577691240476121888846460936245025392381957866134167601058684375);
        sbox_partial(i, q);
        mix(i, q);
        // round 14
        ark(i, q, 16442329894745639881165035015179028112772410105963688121820543219662832524136);
        sbox_partial(i, q);
        mix(i, q);
        // round 15
        ark(i, q, 20060625627350485876280451423010593928172611031611836167979515653463693899374);
        sbox_partial(i, q);
        mix(i, q);
        // round 16
        ark(i, q, 16637282689940520290130302519163090147511023430395200895953984829546679599107);
        sbox_partial(i, q);
        mix(i, q);
        // round 17
        ark(i, q, 15599196921909732993082127725908821049411366914683565306060493533569088698214);
        sbox_partial(i, q);
        mix(i, q);
        // round 18
        ark(i, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455);
        sbox_partial(i, q);
        mix(i, q);
        // round 19
        ark(i, q, 1197934381747032348421303489683932612752526046745577259575778515005162320212);
        sbox_partial(i, q);
        mix(i, q);
        // round 20
        ark(i, q, 6172482022646932735745595886795230725225293469762393889050804649558459236626);
        sbox_partial(i, q);
        mix(i, q);
        // round 21
        ark(i, q, 21004037394166516054140386756510609698837211370585899203851827276330669555417);
        sbox_partial(i, q);
        mix(i, q);
        // round 22
        ark(i, q, 15262034989144652068456967541137853724140836132717012646544737680069032573006);
        sbox_partial(i, q);
        mix(i, q);
        // round 23
        ark(i, q, 15017690682054366744270630371095785995296470601172793770224691982518041139766);
        sbox_partial(i, q);
        mix(i, q);
        // round 24
        ark(i, q, 15159744167842240513848638419303545693472533086570469712794583342699782519832);
        sbox_partial(i, q);
        mix(i, q);
        // round 25
        ark(i, q, 11178069035565459212220861899558526502477231302924961773582350246646450941231);
        sbox_partial(i, q);
        mix(i, q);
        // round 26
        ark(i, q, 21154888769130549957415912997229564077486639529994598560737238811887296922114);
        sbox_partial(i, q);
        mix(i, q);
        // round 27
        ark(i, q, 20162517328110570500010831422938033120419484532231241180224283481905744633719);
        sbox_partial(i, q);
        mix(i, q);
        // round 28
        ark(i, q, 2777362604871784250419758188173029886707024739806641263170345377816177052018);
        sbox_partial(i, q);
        mix(i, q);
        // round 29
        ark(i, q, 15732290486829619144634131656503993123618032247178179298922551820261215487562);
        sbox_partial(i, q);
        mix(i, q);
        // round 30
        ark(i, q, 6024433414579583476444635447152826813568595303270846875177844482142230009826);
        sbox_partial(i, q);
        mix(i, q);
        // round 31
        ark(i, q, 17677827682004946431939402157761289497221048154630238117709539216286149983245);
        sbox_partial(i, q);
        mix(i, q);
        // round 32
        ark(i, q, 10716307389353583413755237303156291454109852751296156900963208377067748518748);
        sbox_partial(i, q);
        mix(i, q);
        // round 33
        ark(i, q, 14925386988604173087143546225719076187055229908444910452781922028996524347508);
        sbox_partial(i, q);
        mix(i, q);
        // round 34
        ark(i, q, 8940878636401797005293482068100797531020505636124892198091491586778667442523);
        sbox_partial(i, q);
        mix(i, q);
        // round 35
        ark(i, q, 18911747154199663060505302806894425160044925686870165583944475880789706164410);
        sbox_partial(i, q);
        mix(i, q);
        // round 36
        ark(i, q, 8821532432394939099312235292271438180996556457308429936910969094255825456935);
        sbox_partial(i, q);
        mix(i, q);
        // round 37
        ark(i, q, 20632576502437623790366878538516326728436616723089049415538037018093616927643);
        sbox_partial(i, q);
        mix(i, q);
        // round 38
        ark(i, q, 71447649211767888770311304010816315780740050029903404046389165015534756512);
        sbox_partial(i, q);
        mix(i, q);
        // round 39
        ark(i, q, 2781996465394730190470582631099299305677291329609718650018200531245670229393);
        sbox_partial(i, q);
        mix(i, q);
        // round 40
        ark(i, q, 12441376330954323535872906380510501637773629931719508864016287320488688345525);
        sbox_partial(i, q);
        mix(i, q);
        // round 41
        ark(i, q, 2558302139544901035700544058046419714227464650146159803703499681139469546006);
        sbox_partial(i, q);
        mix(i, q);
        // round 42
        ark(i, q, 10087036781939179132584550273563255199577525914374285705149349445480649057058);
        sbox_partial(i, q);
        mix(i, q);
        // round 43
        ark(i, q, 4267692623754666261749551533667592242661271409704769363166965280715887854739);
        sbox_partial(i, q);
        mix(i, q);
        // round 44
        ark(i, q, 4945579503584457514844595640661884835097077318604083061152997449742124905548);
        sbox_partial(i, q);
        mix(i, q);
        // round 45
        ark(i, q, 17742335354489274412669987990603079185096280484072783973732137326144230832311);
        sbox_partial(i, q);
        mix(i, q);
        // round 46
        ark(i, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208);
        sbox_partial(i, q);
        mix(i, q);
        // round 47
        ark(i, q, 2716062168542520412498610856550519519760063668165561277991771577403400784706);
        sbox_partial(i, q);
        mix(i, q);
        // round 48
        ark(i, q, 19118392018538203167410421493487769944462015419023083813301166096764262134232);
        sbox_partial(i, q);
        mix(i, q);
        // round 49
        ark(i, q, 9386595745626044000666050847309903206827901310677406022353307960932745699524);
        sbox_partial(i, q);
        mix(i, q);
        // round 50
        ark(i, q, 9121640807890366356465620448383131419933298563527245687958865317869840082266);
        sbox_partial(i, q);
        mix(i, q);
        // round 51
        ark(i, q, 3078975275808111706229899605611544294904276390490742680006005661017864583210);
        sbox_partial(i, q);
        mix(i, q);
        // round 52
        ark(i, q, 7157404299437167354719786626667769956233708887934477609633504801472827442743);
        sbox_partial(i, q);
        mix(i, q);
        // round 53
        ark(i, q, 14056248655941725362944552761799461694550787028230120190862133165195793034373);
        sbox_partial(i, q);
        mix(i, q);
        // round 54
        ark(i, q, 14124396743304355958915937804966111851843703158171757752158388556919187839849);
        sbox_partial(i, q);
        mix(i, q);
        // round 55
        ark(i, q, 11851254356749068692552943732920045260402277343008629727465773766468466181076);
        sbox_full(i, q);
        mix(i, q);
        // round 56
        ark(i, q, 9799099446406796696742256539758943483211846559715874347178722060519817626047);
        sbox_full(i, q);
        mix(i, q);
        // round 57
        ark(i, q, 10156146186214948683880719664738535455146137901666656566575307300522957959544);
        sbox_full(i, q);
        mix(i, q);

        return i.t0;
    }
}

File 23 of 95 : ExchangeBlocks.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/AddressUtil.sol";
import "../../../lib/MathUint.sol";
import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";
import "../../iface/IBlockVerifier.sol";
import "../libtransactions/BlockReader.sol";
import "../libtransactions/AccountUpdateTransaction.sol";
import "../libtransactions/DepositTransaction.sol";
import "../libtransactions/WithdrawTransaction.sol";
import "./ExchangeMode.sol";
import "./ExchangeWithdrawals.sol";


/// @title ExchangeBlocks.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
library ExchangeBlocks
{
    using AddressUtil          for address;
    using AddressUtil          for address payable;
    using BlockReader          for bytes;
    using BytesUtil            for bytes;
    using MathUint             for uint;
    using ExchangeMode         for ExchangeData.State;
    using ExchangeWithdrawals  for ExchangeData.State;
    using SignatureUtil        for bytes32;

    event BlockSubmitted(
        uint    indexed blockIdx,
        bytes32         merkleRoot,
        bytes32         publicDataHash
    );

    event ProtocolFeesUpdated(
        uint16 protocolFeeBips,
        uint16 previousProtocolFeeBips
    );

    function submitBlocks(
        ExchangeData.State   storage S,
        ExchangeData.Block[] memory  blocks
        )
        public
    {
        // Exchange cannot be in withdrawal mode
        require(!S.isInWithdrawalMode(), "INVALID_MODE");

        // Commit the blocks
        bytes32[] memory publicDataHashes = new bytes32[](blocks.length);
        for (uint i = 0; i < blocks.length; i++) {
            // Hash all the public data to a single value which is used as the input for the circuit
            publicDataHashes[i] = blocks[i].data.fastSHA256();
            // Commit the block
            commitBlock(S, blocks[i], publicDataHashes[i]);
        }

        // Verify the blocks - blocks are verified in a batch to save gas.
        verifyBlocks(S, blocks, publicDataHashes);
    }

    // == Internal Functions ==

    function commitBlock(
        ExchangeData.State storage S,
        ExchangeData.Block memory  _block,
        bytes32                    _publicDataHash
        )
        private
    {
        // Read the block header
        BlockReader.BlockHeader memory header = _block.data.readHeader();

        // Validate the exchange
        require(header.exchange == address(this), "INVALID_EXCHANGE");
        // Validate the Merkle roots
        require(header.merkleRootBefore == S.merkleRoot, "INVALID_MERKLE_ROOT");
        require(header.merkleRootAfter != header.merkleRootBefore, "EMPTY_BLOCK_DISABLED");
        require(header.merkleAssetRootBefore == S.merkleAssetRoot, "INVALID_MERKLE_ASSET_ROOT");
        require(header.merkleAssetRootAfter != header.merkleAssetRootBefore, "EMPTY_BLOCK_DISABLED");

        require(uint(header.merkleRootAfter) < ExchangeData.SNARK_SCALAR_FIELD, "INVALID_MERKLE_ROOT");
        require(uint(header.merkleAssetRootAfter) < ExchangeData.SNARK_SCALAR_FIELD, "INVALID_ASSERT_MERKLE_ROOT");
        // Validate the timestamp
        require(
            header.timestamp > block.timestamp - ExchangeData.TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS &&
            header.timestamp < block.timestamp + ExchangeData.TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS,
            "INVALID_TIMESTAMP"
        );
        // Validate the protocol fee values
        require(
            validateAndSyncProtocolFees(S, header.protocolFeeBips),
            "INVALID_PROTOCOL_FEES"
        );

        // Process conditional transactions
        processConditionalTransactions(
            S,
            _block,
            header
        );

        // Emit an event
        uint numBlocks = S.numBlocks;
        emit BlockSubmitted(numBlocks, header.merkleRootAfter, _publicDataHash);

        S.merkleRoot = header.merkleRootAfter;
        S.merkleAssetRoot = header.merkleAssetRootAfter;

        if (_block.storeBlockInfoOnchain) {
            S.blocks[numBlocks] = ExchangeData.BlockInfo(
                uint32(block.timestamp),
                bytes28(_publicDataHash)
            );
        }

        S.numBlocks = numBlocks + 1;
    }

    function verifyBlocks(
        ExchangeData.State   storage S,
        ExchangeData.Block[] memory  blocks,
        bytes32[]            memory  publicDataHashes
        )
        private
        view
    {
        IBlockVerifier blockVerifier = S.blockVerifier;
        uint numBlocksVerified = 0;
        bool[] memory blockVerified = new bool[](blocks.length);
        ExchangeData.Block memory firstBlock;
        uint[] memory batch = new uint[](blocks.length);

        while (numBlocksVerified < blocks.length) {
            // Find all blocks of the same type
            uint batchLength = 0;
            for (uint i = 0; i < blocks.length; i++) {
                if (blockVerified[i] == false) {
                    if (batchLength == 0) {
                        firstBlock = blocks[i];
                        batch[batchLength++] = i;
                    } else {
                        ExchangeData.Block memory _block = blocks[i];
                        if (_block.blockType == firstBlock.blockType &&
                            _block.blockSize == firstBlock.blockSize &&
                            _block.blockVersion == firstBlock.blockVersion) {
                            batch[batchLength++] = i;
                        }
                    }
                }
            }

            // Prepare the data for batch verification
            uint[] memory publicInputs = new uint[](batchLength);
            uint[] memory proofs = new uint[](batchLength * 8);

            for (uint i = 0; i < batchLength; i++) {
                uint blockIdx = batch[i];
                // Mark the block as verified
                blockVerified[blockIdx] = true;
                // Strip the 3 least significant bits of the public data hash
                // so we don't have any overflow in the snark field
                publicInputs[i] = uint(publicDataHashes[blockIdx]) >> 3;
                // Copy proof
                ExchangeData.Block memory _block = blocks[blockIdx];
                for (uint j = 0; j < 8; j++) {
                    proofs[i*8 + j] = _block.proof[j];
                }
            }

            // Verify the proofs
            require(
                blockVerifier.verifyProofs(
                    uint8(firstBlock.blockType),
                    firstBlock.blockSize,
                    firstBlock.blockVersion,
                    publicInputs,
                    proofs
                ),
                "INVALID_PROOF"
            );

            numBlocksVerified += batchLength;
        }
    }

    function processConditionalTransactions(
        ExchangeData.State      storage S,
        ExchangeData.Block      memory _block,
        BlockReader.BlockHeader memory header
        )
        private
    {
        if (header.numConditionalTransactions > 0) {
            // Cache the domain seperator to save on SLOADs each time it is accessed.
            ExchangeData.BlockContext memory ctx = ExchangeData.BlockContext({
                DOMAIN_SEPARATOR: S.DOMAIN_SEPARATOR,
                timestamp: header.timestamp
            });

            ExchangeData.AuxiliaryData[] memory block_auxiliaryData;
            bytes memory blockAuxData = _block.auxiliaryData;
            assembly {
                block_auxiliaryData := add(blockAuxData, 64)
            }

            require(
                block_auxiliaryData.length == header.numConditionalTransactions,
                "AUXILIARYDATA_INVALID_LENGTH"
            );

            require(
                header.numConditionalTransactions == (header.depositSize + header.accountUpdateSize + header.withdrawSize),
                "invalid number of conditional transactions"
            );

            // Run over all conditional transactions
            uint minTxIndex = 0;
            bytes memory txData = new bytes(ExchangeData.TX_DATA_AVAILABILITY_SIZE);
            for (uint i = 0; i < block_auxiliaryData.length; i++) {
                uint txIndex;
                ExchangeData.TransactionType txType;
                if (i < header.depositSize) {
                    txType = ExchangeData.TransactionType.DEPOSIT;
                    txIndex = i; 
                }else if(i < header.depositSize + header.accountUpdateSize) {
                    txType = ExchangeData.TransactionType.ACCOUNT_UPDATE;
                    txIndex = i;
                }else {
                    txType = ExchangeData.TransactionType.WITHDRAWAL;
                    txIndex = i + _block.blockSize - header.depositSize - header.accountUpdateSize - header.withdrawSize; 
                }

                // Load the data from auxiliaryData, which is still encoded as calldata



                bytes memory auxData;
                assembly {
                    // Offset to block_auxiliaryData[i]
                    let auxOffset := mload(add(block_auxiliaryData, add(32, mul(32, i))))

                    // Load `data` (pos 0)
                    let auxDataOffset := mload(add(add(32, block_auxiliaryData), auxOffset))
                    auxData := add(add(32, block_auxiliaryData), add(auxOffset, auxDataOffset))
                }

                // Each conditional transaction needs to be processed from left to right
                require(txIndex >= minTxIndex, "AUXILIARYDATA_INVALID_ORDER");

                minTxIndex = txIndex + 1;


                // Get the transaction data
                _block.data.readTransactionData(txIndex, _block.blockSize, txData);

                // Process the transaction
                uint txDataOffset = 0;

                if (txType == ExchangeData.TransactionType.DEPOSIT) {
                    DepositTransaction.process(
                        S,
                        ctx,
                        txData,
                        txDataOffset,
                        auxData
                    );
                } else if (txType == ExchangeData.TransactionType.WITHDRAWAL) {
                    WithdrawTransaction.process(
                        S,
                        ctx,
                        txData,
                        txDataOffset,
                        auxData
                    );
                } else if (txType == ExchangeData.TransactionType.ACCOUNT_UPDATE) {
                    AccountUpdateTransaction.process(
                        S,
                        ctx,
                        txData,
                        txDataOffset,
                        auxData
                    );
                } else {
                    // ExchangeData.TransactionType.NOOP,
                    // ExchangeData.TransactionType.TRANSFER and
                    // ExchangeData.TransactionType.SPOT_TRADE and
                    // ExchangeData.TransactionType.ORDER_CANCEL and
                    // ExchangeData.TransactionType.BATCH_SPOT_TRADE 
                    // ExchangeData.TransactionType.APPKEY_UPDATE 
                    // are not supported
                    revert("UNSUPPORTED_TX_TYPE");
                }
            }
        }
    }

    function validateAndSyncProtocolFees(
        ExchangeData.State storage S,
        uint16 protocolFeeBips
        )
        private
        returns (bool)
    {
        ExchangeData.ProtocolFeeData memory data = S.protocolFeeData;

        uint16 protocolFeeBipsInLoopring = S.loopring.getProtocolFeeValues();
        if (data.nextProtocolFeeBips != protocolFeeBipsInLoopring ) {
            data.executeTimeOfNextProtocolFeeBips = uint32(block.timestamp + ExchangeData.MIN_AGE_PROTOCOL_FEES_UNTIL_UPDATED);
            data.nextProtocolFeeBips = protocolFeeBipsInLoopring;

            // Update the data in storage
            S.protocolFeeData = data;
        }

        if ((data.executeTimeOfNextProtocolFeeBips !=0) && (block.timestamp > data.executeTimeOfNextProtocolFeeBips)) {
            // Store the current protocol fees in the previous protocol fees
            data.previousProtocolFeeBips = data.protocolFeeBips;
            // Get the latest protocol fees for this exchange
            data.protocolFeeBips = data.nextProtocolFeeBips;
            data.syncedAt = uint32(block.timestamp);

            data.executeTimeOfNextProtocolFeeBips = 0;

            if (data.protocolFeeBips != data.previousProtocolFeeBips ) {
                emit ProtocolFeesUpdated(
                    data.protocolFeeBips,
                    data.previousProtocolFeeBips
                );
            }

            // Update the data in storage
            S.protocolFeeData = data;
        }

        // The given fee values are valid if they are the current or previous protocol fee values
        return (protocolFeeBips == data.protocolFeeBips) ||
            (protocolFeeBips == data.previousProtocolFeeBips );
    }
}

File 24 of 95 : BytesUtil.sol
// SPDX-License-Identifier: UNLICENSED
//Mainly taken from https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol
pragma solidity ^0.7.0;

library BytesUtil {

    function concat(
        bytes memory _preBytes,
        bytes memory _postBytes
    )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory tempBytes;

        assembly {
            // Get a location of some free memory and store it in tempBytes as
            // Solidity does for memory variables.
            tempBytes := mload(0x40)

            // Store the length of the first bytes array at the beginning of
            // the memory for tempBytes.
            let length := mload(_preBytes)
            mstore(tempBytes, length)

            // Maintain a memory counter for the current write location in the
            // temp bytes array by adding the 32 bytes for the array length to
            // the starting location.
            let mc := add(tempBytes, 0x20)
            // Stop copying when the memory counter reaches the length of the
            // first bytes array.
            let end := add(mc, length)

            for {
                // Initialize a copy counter to the start of the _preBytes data,
                // 32 bytes into its memory.
                let cc := add(_preBytes, 0x20)
            } lt(mc, end) {
                // Increase both counters by 32 bytes each iteration.
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                // Write the _preBytes data into the tempBytes memory 32 bytes
                // at a time.
                mstore(mc, mload(cc))
            }

            // Add the length of _postBytes to the current length of tempBytes
            // and store it as the new length in the first 32 bytes of the
            // tempBytes memory.
            length := mload(_postBytes)
            mstore(tempBytes, add(length, mload(tempBytes)))

            // Move the memory counter back from a multiple of 0x20 to the
            // actual end of the _preBytes data.
            mc := end
            // Stop copying when the memory counter reaches the new combined
            // length of the arrays.
            end := add(mc, length)

            for {
                let cc := add(_postBytes, 0x20)
            } lt(mc, end) {
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                mstore(mc, mload(cc))
            }

            // Update the free-memory pointer by padding our last write location
            // to 32 bytes: add 31 bytes to the end of tempBytes to move to the
            // next 32 byte block, then round down to the nearest multiple of
            // 32. If the sum of the length of the two arrays is zero then add
            // one before rounding down to leave a blank 32 bytes (the length block with 0).
            mstore(0x40, and(
              add(add(end, iszero(add(length, mload(_preBytes)))), 31),
              not(31) // Round down to the nearest 32 bytes.
            ))
        }

        return tempBytes;
    }

    function slice(
        bytes memory _bytes,
        uint _start,
        uint _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_bytes.length >= (_start + _length));

        bytes memory tempBytes;

        assembly {
            switch iszero(_length)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // The first word of the slice result is potentially a partial
                // word read from the original array. To read it, we calculate
                // the length of that partial word and start copying that many
                // bytes into the array. The first word we copy will start with
                // data we don't care about, but the last `lengthmod` bytes will
                // land at the beginning of the contents of the new array. When
                // we're done copying, we overwrite the full first word with
                // the actual length of the slice.
                let lengthmod := and(_length, 31)

                // The multiplication in the next line is necessary
                // because when slicing multiples of 32 bytes (lengthmod == 0)
                // the following copy loop was copying the origin's length
                // and then ending prematurely not copying everything it should.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, _length)

                for {
                    // The multiplication in the next line has the same exact purpose
                    // as the one above.
                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                } lt(mc, end) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    mstore(mc, mload(cc))
                }

                mstore(tempBytes, _length)

                //update free-memory pointer
                //allocating the array padded to 32 bytes like the compiler does now
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            //if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)

                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return tempBytes;
    }

    function toAddress(bytes memory _bytes, uint _start) internal  pure returns (address) {
        require(_bytes.length >= (_start + 20));
        address tempAddress;

        assembly {
            tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
        }

        return tempAddress;
    }

    function toUint8(bytes memory _bytes, uint _start) internal  pure returns (uint8) {
        require(_bytes.length >= (_start + 1));
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }

    function toUint16(bytes memory _bytes, uint _start) internal  pure returns (uint16) {
        require(_bytes.length >= (_start + 2));
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x2), _start))
        }

        return tempUint;
    }

    function toUint24(bytes memory _bytes, uint _start) internal  pure returns (uint24) {
        require(_bytes.length >= (_start + 3));
        uint24 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x3), _start))
        }

        return tempUint;
    }

    function toUint32(bytes memory _bytes, uint _start) internal  pure returns (uint32) {
        require(_bytes.length >= (_start + 4));
        uint32 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x4), _start))
        }

        return tempUint;
    }

    function toUint64(bytes memory _bytes, uint _start) internal  pure returns (uint64) {
        require(_bytes.length >= (_start + 8));
        uint64 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x8), _start))
        }

        return tempUint;
    }

    function toUint96(bytes memory _bytes, uint _start) internal  pure returns (uint96) {
        require(_bytes.length >= (_start + 12));
        uint96 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0xc), _start))
        }

        return tempUint;
    }

    function toUint128(bytes memory _bytes, uint _start) internal  pure returns (uint128) {
        require(_bytes.length >= (_start + 16));
        uint128 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x10), _start))
        }

        return tempUint;
    }

    function toUint(bytes memory _bytes, uint _start) internal  pure returns (uint256) {
        require(_bytes.length >= (_start + 32));
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x20), _start))
        }

        return tempUint;
    }

    function toBytes4(bytes memory _bytes, uint _start) internal  pure returns (bytes4) {
        require(_bytes.length >= (_start + 4));
        bytes4 tempBytes4;

        assembly {
            tempBytes4 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes4;
    }

    function toBytes20(bytes memory _bytes, uint _start) internal  pure returns (bytes20) {
        require(_bytes.length >= (_start + 20));
        bytes20 tempBytes20;

        assembly {
            tempBytes20 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes20;
    }

    function toBytes32(bytes memory _bytes, uint _start) internal  pure returns (bytes32) {
        require(_bytes.length >= (_start + 32));
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes32;
    }


    function toAddressUnsafe(bytes memory _bytes, uint _start) internal  pure returns (address) {
        address tempAddress;

        assembly {
            tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
        }

        return tempAddress;
    }

    function toUint8Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint8) {
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }

    function toUint16Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint16) {
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x2), _start))
        }

        return tempUint;
    }

    function toUint24Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint24) {
        uint24 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x3), _start))
        }

        return tempUint;
    }

    function toUint32Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint32) {
        uint32 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x4), _start))
        }

        return tempUint;
    }

    function toUint64Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint64) {
        uint64 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x8), _start))
        }

        return tempUint;
    }

    function toUint96Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint96) {
        uint96 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0xc), _start))
        }

        return tempUint;
    }

    function toUint128Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint128) {
        uint128 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x10), _start))
        }

        return tempUint;
    }


    function toUint248Unsafe(bytes memory _bytes, uint _start) internal  pure returns (uint248) {
        uint248 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1f), _start))
        }

        return tempUint;
    }

    function toUintUnsafe(bytes memory _bytes, uint _start) internal  pure returns (uint256) {
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x20), _start))
        }

        return tempUint;
    }

    function toBytes4Unsafe(bytes memory _bytes, uint _start) internal  pure returns (bytes4) {
        bytes4 tempBytes4;

        assembly {
            tempBytes4 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes4;
    }

    function toBytes20Unsafe(bytes memory _bytes, uint _start) internal  pure returns (bytes20) {
        bytes20 tempBytes20;

        assembly {
            tempBytes20 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes20;
    }

    function toBytes32Unsafe(bytes memory _bytes, uint _start) internal  pure returns (bytes32) {
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes32;
    }


    function fastSHA256(
        bytes memory data
        )
        internal
        view
        returns (bytes32)
    {
        bytes32[] memory result = new bytes32[](1);
        bool success;
        assembly {
             let ptr := add(data, 32)
             success := staticcall(sub(gas(), 2000), 2, ptr, mload(data), add(result, 32), 32)
        }
        require(success, "SHA256_FAILED");
        return result[0];
    }
}

File 25 of 95 : BlockReader.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";

/// @title BlockReader
/// @author Brecht Devos - <[email protected]>
/// @dev Utility library to read block data.
library BlockReader {
    using BlockReader       for ExchangeData.Block;
    using BytesUtil         for bytes;

    uint public constant OFFSET_TO_TRANSACTIONS = 20 + 32 + 32 + 32 + 32 + 4 + 2 + 4 + 4 + 2 + 2 + 2;


    struct BlockHeader
    {
        address exchange;
        bytes32 merkleRootBefore;
        bytes32 merkleRootAfter;
        bytes32 merkleAssetRootBefore;
        bytes32 merkleAssetRootAfter;
        uint32  timestamp;
        uint16  protocolFeeBips;

        uint32  numConditionalTransactions;
        uint32  operatorAccountID;

        uint16  depositSize;
        uint16  accountUpdateSize;
        uint16  withdrawSize;
    }

    function readHeader(
        bytes memory _blockData
        )
        internal
        pure
        returns (BlockHeader memory header)
    {
        uint offset = 0;
        header.exchange = _blockData.toAddress(offset);
        offset += 20;
        header.merkleRootBefore = _blockData.toBytes32(offset);
        offset += 32;
        header.merkleRootAfter = _blockData.toBytes32(offset);
        offset += 32;
        
        header.merkleAssetRootBefore = _blockData.toBytes32(offset);
        offset += 32;
        header.merkleAssetRootAfter = _blockData.toBytes32(offset);
        offset += 32;

        header.timestamp = _blockData.toUint32(offset);
        offset += 4;

        header.protocolFeeBips = _blockData.toUint16(offset);
        offset += 2;

        header.numConditionalTransactions = _blockData.toUint32(offset);
        offset += 4;
        header.operatorAccountID = _blockData.toUint32(offset);
        offset += 4;

        header.depositSize = _blockData.toUint16(offset);
        offset += 2;
        header.accountUpdateSize = _blockData.toUint16(offset);
        offset += 2;
        header.withdrawSize = _blockData.toUint16(offset);
        offset += 2;


        assert(offset == OFFSET_TO_TRANSACTIONS);
    }

    function readTransactionData(
        bytes memory data,
        uint txIdx,
        uint blockSize,
        bytes memory txData
        )
        internal
        pure
    {
        require(txIdx < blockSize, "INVALID_TX_IDX");

        // The transaction was transformed to make it easier to compress.
        // Transform it back here.
        // Part 1
        uint txDataOffset = OFFSET_TO_TRANSACTIONS +
            txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1;
        assembly {
            //  first 32 bytes of an Array stores the length of that array.

            // part_1 is 80 bytes, longer than 32 bytes,  80 = 32 + 32 + 16
            mstore(add(txData, 32), mload(add(data, add(txDataOffset, 32))))
            mstore(add(txData, 64), mload(add(data, add(txDataOffset, 64))))
            mstore(add(txData, 80), mload(add(data, add(txDataOffset, 80))))
        }
        // Part 2
        txDataOffset = OFFSET_TO_TRANSACTIONS +
            blockSize * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_1 +
            txIdx * ExchangeData.TX_DATA_AVAILABILITY_SIZE_PART_2;
        assembly {
            // part_2 is 3 bytes
            // 112 = 32 + 80(part_1)
            mstore(add(txData, 112 ), mload(add(data, add(txDataOffset, 32))))
        }
    }
}

File 26 of 95 : AccountUpdateTransaction.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/EIP712.sol";
import "../../../lib/FloatUtil.sol";
import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";
import "../libexchange/ExchangeSignatures.sol";


/// @title AccountUpdateTransaction
/// @author Brecht Devos - <[email protected]>
library AccountUpdateTransaction
{
    using BytesUtil            for bytes;
    using FloatUtil            for uint16;
    using ExchangeSignatures   for ExchangeData.State;

    bytes32 constant public ACCOUNTUPDATE_TYPEHASH = keccak256(
        "AccountUpdate(address owner,uint32 accountID,uint32 feeTokenID,uint96 maxFee,uint256 publicKey,uint32 validUntil,uint32 nonce)"
    );

    struct AccountUpdate
    {
        address owner;
        uint32  accountID;
        uint32  feeTokenID;
        uint96  maxFee;
        uint96  fee;
        uint    publicKey;
        uint32  validUntil;
        uint32  nonce;
    }

    // Auxiliary data for each account update
    struct AccountUpdateAuxiliaryData
    {
        bytes  signature;
        uint96 maxFee;
        uint32 validUntil;
    }

    function process(
        ExchangeData.State        storage S,
        ExchangeData.BlockContext memory  ctx,
        bytes                     memory  data,
        uint                              offset,
        bytes                     memory  auxiliaryData
        )
        internal
    {
        // Read the account update
        AccountUpdate memory accountUpdate;
        readTx(data, offset, accountUpdate);
        AccountUpdateAuxiliaryData memory auxData = abi.decode(auxiliaryData, (AccountUpdateAuxiliaryData));

        // Fill in withdrawal data missing from DA
        accountUpdate.validUntil = auxData.validUntil;
        accountUpdate.maxFee = auxData.maxFee;
        // Validate
        require(ctx.timestamp < accountUpdate.validUntil, "ACCOUNT_UPDATE_EXPIRED");
        require(accountUpdate.fee <= accountUpdate.maxFee, "ACCOUNT_UPDATE_FEE_TOO_HIGH");

        // Calculate the tx hash
        bytes32 txHash = hashTx(ctx.DOMAIN_SEPARATOR, accountUpdate);

        // Check onchain authorization
        S.requireAuthorizedTx(accountUpdate.owner, auxData.signature, txHash);

    }

    function readTx(
        bytes memory data,
        uint         offset,
        AccountUpdate memory accountUpdate
        )
        private
        pure
    {
        uint _offset = offset;

        // Check that this is a conditional offset
        require(data.toUint8Unsafe(_offset) == 1, "INVALID_AUXILIARYDATA_DATA");
        _offset += 1;

        // Extract the data from the tx data
        // We don't use abi.decode for this because of the large amount of zero-padding
        // bytes the circuit would also have to hash.
        accountUpdate.owner = data.toAddressUnsafe(_offset);
        _offset += 20;
        accountUpdate.accountID = data.toUint32Unsafe(_offset);
        _offset += 4;
        accountUpdate.feeTokenID = data.toUint32Unsafe(_offset);
        _offset += 4;
        accountUpdate.fee = data.toUint16Unsafe(_offset).decodeFloat16();
        _offset += 2;
        accountUpdate.publicKey = data.toUintUnsafe(_offset);
        _offset += 32;
        accountUpdate.nonce = data.toUint32Unsafe(_offset);
        _offset += 4;
    }

    function hashTx(
        bytes32 DOMAIN_SEPARATOR,
        AccountUpdate memory accountUpdate
        )
        private
        pure
        returns (bytes32)
    {
        return EIP712.hashPacked(
            DOMAIN_SEPARATOR,
            keccak256(
                abi.encode(
                    ACCOUNTUPDATE_TYPEHASH,
                    accountUpdate.owner,
                    accountUpdate.accountID,
                    accountUpdate.feeTokenID,
                    accountUpdate.maxFee,
                    accountUpdate.publicKey,
                    accountUpdate.validUntil,
                    accountUpdate.nonce
                )
            )
        );
    }
}

File 27 of 95 : FloatUtil.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./MathUint.sol";
import "../thirdparty/SafeCast.sol";


/// @title Utility Functions for floats
/// @author Brecht Devos - <[email protected]>
library FloatUtil
{
    using MathUint for uint;
    using SafeCast for uint;

    // Decodes a decimal float value that is encoded like `exponent | mantissa`.
    // Both exponent and mantissa are in base 10.
    // Decoding to an integer is as simple as `mantissa * (10 ** exponent)`
    // Will throw when the decoded value overflows an uint96
    /// @param f The float value with 5 bits for the exponent
    /// @param numBits The total number of bits (numBitsMantissa := numBits - numBitsExponent)
    /// @return value The decoded integer value.
    function decodeFloat(
        uint f,
        uint numBits
        )
        internal
        pure
        returns (uint96 value)
    {
        if (f == 0) {
            return 0;
        }
        uint numBitsMantissa = numBits.sub(5);
        uint exponent = f >> numBitsMantissa;
        // log2(10**77) = 255.79 < 256
        require(exponent <= 77, "EXPONENT_TOO_LARGE");
        uint mantissa = f & ((1 << numBitsMantissa) - 1);
        value = mantissa.mul(10 ** exponent).toUint96();
    }

    // Decodes a decimal float value that is encoded like `exponent | mantissa`.
    // Both exponent and mantissa are in base 10.
    // Decoding to an integer is as simple as `mantissa * (10 ** exponent)`
    // Will throw when the decoded value overflows an uint96
    /// @param f The float value with 5 bits exponent, 11 bits mantissa
    /// @return value The decoded integer value.
    function decodeFloat16(
        uint16 f
        )
        internal
        pure
        returns (uint96)
    {
        uint value = ((uint(f) & 2047) * (10 ** (uint(f) >> 11)));
        require(value < 2**96, "SafeCast: value doesn\'t fit in 96 bits");
        return uint96(value);
    }

    // Decodes a decimal float value that is encoded like `exponent | mantissa`.
    // Both exponent and mantissa are in base 10.
    // Decoding to an integer is as simple as `mantissa * (10 ** exponent)`
    // Will throw when the decoded value overflows an uint96
    /// @param f The float value with 5 bits exponent, 19 bits mantissa
    /// @return value The decoded integer value.
    function decodeFloat24(
        uint24 f
        )
        internal
        pure
        returns (uint96)
    {
        uint value = ((uint(f) & 524287) * (10 ** (uint(f) >> 19)));
        require(value < 2**96, "SafeCast: value doesn\'t fit in 96 bits");
        return uint96(value);
    }
}

File 28 of 95 : SafeCast.sol
// SPDX-License-Identifier: MIT
// Taken from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/SafeCast.sol

pragma solidity ^0.7.0;


/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value < 2**248, "SafeCast: value doesn\'t fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value < 2**96, "SafeCast: value doesn\'t fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value < 2**40, "SafeCast: value doesn\'t fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < 2**255, "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 29 of 95 : ExchangeSignatures.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/SignatureUtil.sol";
import "../../iface/ExchangeData.sol";


/// @title ExchangeSignatures.
/// @dev All methods in this lib are internal, therefore, there is no need
///      to deploy this library independently.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
library ExchangeSignatures
{
    using SignatureUtil for bytes32;

    function requireAuthorizedTx(
        ExchangeData.State storage S,
        address signer,
        bytes memory signature,
        bytes32 txHash
        )
        internal // inline call
    {
        require(signer != address(0), "INVALID_SIGNER");
        // Verify the signature if one is provided, otherwise fall back to an approved tx
        if (signature.length > 0) {
            require(txHash.verifySignature(signer, signature), "INVALID_SIGNATURE");
        } else {
            require(S.approvedTx[signer][txHash], "TX_NOT_APPROVED");
            delete S.approvedTx[signer][txHash];
        }
    }
}

File 30 of 95 : SignatureUtil.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../thirdparty/BytesUtil.sol";
import "./AddressUtil.sol";
import "./MathUint.sol";
import "./ERC1271.sol";


/// @title SignatureUtil
/// @author Daniel Wang - <[email protected]>
/// @dev This method supports multihash standard. Each signature's last byte indicates
///      the signature's type.
library SignatureUtil
{
    using BytesUtil     for bytes;
    using MathUint      for uint;
    using AddressUtil   for address;

    enum SignatureType {
        ILLEGAL,
        INVALID,
        EIP_712,
        ETH_SIGN,
        WALLET   // deprecated
    }

    bytes4 constant internal ERC1271_MAGICVALUE = 0x1626ba7e;

    function verifySignatures(
        bytes32          signHash,
        address[] memory signers,
        bytes[]   memory signatures
        )
        internal
        view
        returns (bool)
    {
        require(signers.length == signatures.length, "BAD_SIGNATURE_DATA");
        address lastSigner;
        for (uint i = 0; i < signers.length; i++) {
            require(signers[i] > lastSigner, "INVALID_SIGNERS_ORDER");
            lastSigner = signers[i];
            if (!verifySignature(signHash, signers[i], signatures[i])) {
                return false;
            }
        }
        return true;
    }

    function verifySignature(
        bytes32        signHash,
        address        signer,
        bytes   memory signature
        )
        internal
        view
        returns (bool)
    {
        if (signer == address(0)) {
            return false;
        }

        return signer.isContract()?
            verifyERC1271Signature(signHash, signer, signature):
            verifyEOASignature(signHash, signer, signature);
    }

    function recoverECDSASigner(
        bytes32      signHash,
        bytes memory signature
        )
        internal
        pure
        returns (address)
    {
        if (signature.length != 65) {
            return address(0);
        }

        bytes32 r;
        bytes32 s;
        uint8   v;
        // we jump 32 (0x20) as the first slot of bytes contains the length
        // we jump 65 (0x41) per signature
        // for v we load 32 bytes ending with v (the first 31 come from s) then apply a mask
        assembly {
            r := mload(add(signature, 0x20))
            s := mload(add(signature, 0x40))
            v := and(mload(add(signature, 0x41)), 0xff)
        }
        // See https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/cryptography/ECDSA.sol
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return address(0);
        }
        if (v == 27 || v == 28) {
            return ecrecover(signHash, v, r, s);
        } else {
            return address(0);
        }
    }

    function verifyEOASignature(
        bytes32        signHash,
        address        signer,
        bytes   memory signature
        )
        private
        pure
        returns (bool success)
    {
        if (signer == address(0)) {
            return false;
        }

        uint signatureTypeOffset = signature.length.sub(1);
        SignatureType signatureType = SignatureType(signature.toUint8(signatureTypeOffset));

        // Strip off the last byte of the signature by updating the length
        assembly {
            mstore(signature, signatureTypeOffset)
        }

        if (signatureType == SignatureType.EIP_712) {
            success = (signer == recoverECDSASigner(signHash, signature));
        } else if (signatureType == SignatureType.ETH_SIGN) {
            bytes32 hash = keccak256(
                abi.encodePacked("\x19Ethereum Signed Message:\n32", signHash)
            );
            success = (signer == recoverECDSASigner(hash, signature));
        } else {
            success = false;
        }

        // Restore the signature length
        assembly {
            mstore(signature, add(signatureTypeOffset, 1))
        }

        return success;
    }

    function verifyERC1271Signature(
        bytes32 signHash,
        address signer,
        bytes   memory signature
        )
        private
        view
        returns (bool)
    {
        bytes memory callData = abi.encodeWithSelector(
            ERC1271.isValidSignature.selector,
            signHash,
            signature
        );
        (bool success, bytes memory result) = signer.staticcall(callData);
        return (
            success &&
            result.length == 32 &&
            result.toBytes4(0) == ERC1271_MAGICVALUE
        );
    }
}

File 31 of 95 : ERC1271.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

abstract contract ERC1271 {
    // bytes4(keccak256("isValidSignature(bytes32,bytes)")
    bytes4 constant internal ERC1271_MAGICVALUE = 0x1626ba7e;

    function isValidSignature(
        bytes32      _hash,
        bytes memory _signature)
        external
        view
        virtual
        returns (bytes4 magicValueB32);

}

File 32 of 95 : DepositTransaction.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/EIP712.sol";
import "../../../lib/ERC20.sol";
import "../../../lib/MathUint248.sol";
import "../../../lib/SignatureUtil.sol";
import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";

/// @title DepositTransaction
/// @author Brecht Devos - <[email protected]>
library DepositTransaction
{
    using BytesUtil for bytes;
    using MathUint248 for uint248;
    using MathUint for uint256;

    struct Deposit
    {
        uint depositType;
        address to;
        uint32 toAccountID;
        uint32 tokenID;
        uint248 amount;
    }

    function process(
        ExchangeData.State        storage S,
        ExchangeData.BlockContext memory  /*ctx*/,
        bytes                     memory  data,
        uint                              offset,
        bytes                     memory  /*auxiliaryData*/
        )
        internal
    {
        // Read in the deposit
        Deposit memory deposit;
        readTx(data, offset, deposit);
        if (deposit.amount == 0) {
            return;
        }

        // depositType 0: deposit by exchange::deposit()
        // depositType 1: deposit by transfer tokens to DepositContract directly 
        if(deposit.depositType == 0) { 
            // Process the deposit
            ExchangeData.Deposit memory pendingDeposit = S.pendingDeposits[deposit.to][deposit.tokenID];
            // Make sure the deposit was actually done
            require(pendingDeposit.timestamp > 0, "DEPOSIT_DOESNT_EXIST");

            // Processing partial amounts of the deposited amount is allowed.
            // This is done to ensure the user can do multiple deposits after each other
            // without invalidating work done by the exchange owner for previous deposit amounts.

            require(pendingDeposit.amount >= deposit.amount, "INVALID_AMOUNT");
            pendingDeposit.amount = pendingDeposit.amount.sub(deposit.amount);

            // If the deposit was fully consumed, reset it so the storage is freed up
            // and the owner receives a gas refund.
            if (pendingDeposit.amount == 0) {
                delete S.pendingDeposits[deposit.to][deposit.tokenID];
            } else {
                S.pendingDeposits[deposit.to][deposit.tokenID] = pendingDeposit;
            }

        }else if(deposit.depositType == 1) {
            uint32 tokenId = deposit.tokenID;
            uint256 unconfirmedBalance;

            if (tokenId == 0) {
                unconfirmedBalance = address(S.depositContract).balance.sub(S.tokenIdToDepositBalance[tokenId]);
            } else {
                address token = S.tokenIdToToken[tokenId];
                unconfirmedBalance = ERC20(token).balanceOf(address(S.depositContract)).sub(S.tokenIdToDepositBalance[tokenId]);
            }

            require(unconfirmedBalance >= deposit.amount, "INVALID_DIRECT_DEPOSIT_AMOUNT");

            S.tokenIdToDepositBalance[deposit.tokenID] = S.tokenIdToDepositBalance[deposit.tokenID].add(deposit.amount);
        }else{
            revert("INVALID_DEPOSIT_TYPE");
        }
    }

    function readTx(
        bytes   memory data,
        uint           offset,
        Deposit memory deposit
        )
        internal
        pure
    {
        uint _offset = offset;

        // We don't use abi.decode for this because of the large amount of zero-padding
        // bytes the circuit would also have to hash.

        deposit.depositType = data.toUint8Unsafe(_offset);
        _offset += 1;
        deposit.to = data.toAddressUnsafe(_offset);
        _offset += 20;
        deposit.toAccountID = data.toUint32Unsafe(_offset);
        _offset += 4;
        deposit.tokenID = data.toUint32Unsafe(_offset);
        _offset += 4;
        deposit.amount = data.toUint248Unsafe(_offset);
        _offset += 31;
    }
}

File 33 of 95 : MathUint248.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 DeGate DAO
pragma solidity ^0.7.0;


/// @title Utility Functions for uint
/// @author Daniel Wang - <[email protected]>
library MathUint248
{
    function add(
        uint248 a,
        uint248 b
        )
        internal
        pure
        returns (uint248 c)
    {
        c = a + b;
        require(c >= a, "ADD_OVERFLOW");
    }

    function sub(
        uint248 a,
        uint248 b
        )
        internal
        pure
        returns (uint248 c)
    {
        require(b <= a, "SUB_UNDERFLOW");
        return a - b;
    }
}

File 34 of 95 : WithdrawTransaction.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/EIP712.sol";
import "../../../lib/FloatUtil.sol";
import "../../../lib/MathUint.sol";
import "../../../lib/SignatureUtil.sol";
import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";
import "../libexchange/ExchangeMode.sol";
import "../libexchange/ExchangeSignatures.sol";
import "../libexchange/ExchangeWithdrawals.sol";


/// @title WithdrawTransaction
/// @author Brecht Devos - <[email protected]>
/// @dev The following 4 types of withdrawals are supported:
///      - withdrawType = 0: offchain withdrawals with EdDSA signatures
///      - withdrawType = 1: offchain withdrawals with ECDSA signatures or onchain appprovals
///      - withdrawType = 2: onchain valid forced withdrawals (owner and accountID match), or
///                          offchain operator-initiated withdrawals for protocol fees or for
///                          users in shutdown mode
///      - withdrawType = 3: onchain invalid forced withdrawals (owner and accountID mismatch)
library WithdrawTransaction
{
    using BytesUtil            for bytes;
    using FloatUtil            for uint16;
    using MathUint             for uint;
    using SafeCast             for uint;
    using ExchangeMode         for ExchangeData.State;
    using ExchangeSignatures   for ExchangeData.State;
    using ExchangeWithdrawals  for ExchangeData.State;
    using SignatureUtil        for bytes32;

    bytes32 constant public WITHDRAWAL_TYPEHASH = keccak256(
        "Withdrawal(address owner,uint32 accountID,uint32 tokenID,uint248 amount,uint32 feeTokenID,uint96 maxFee,address to,uint248 minGas,uint32 validUntil,uint32 storageID)"
    );

    struct Withdrawal
    {
        uint    withdrawalType;
        address from;
        uint32  fromAccountID;
        uint32  tokenID;
        uint248 amount;
        uint32  feeTokenID;
        uint96  maxFee;
        uint96  fee;
        address to;
        uint248 minGas;
        uint32  validUntil;
        uint32  storageID;
        bytes20 onchainDataHash;
    }

    // Auxiliary data for each withdrawal
    struct WithdrawalAuxiliaryData
    {
        bool  storeRecipient;
        uint  gasLimit;
        bytes signature;

        uint248 minGas;
        address to;
        uint96  maxFee;
        uint32  validUntil;
        uint248 amount;
    }

    function process(
        ExchangeData.State        storage S,
        ExchangeData.BlockContext memory  ctx,
        bytes                     memory  data,
        uint                              offset,
        bytes                     memory  auxiliaryData
        )
        internal
    {
        Withdrawal memory withdrawal;
        readTx(data, offset, withdrawal);
        WithdrawalAuxiliaryData memory auxData = abi.decode(auxiliaryData, (WithdrawalAuxiliaryData));

        // Validate the withdrawal data not directly part of the DA
        bytes20 onchainDataHash = hashOnchainData(
            auxData.minGas,
            auxData.to,
            auxData.amount
        );

        // Only the 20 MSB are used, which is still 80-bit of security, which is more
        // than enough, especially when combined with validUntil.
        require(withdrawal.onchainDataHash == onchainDataHash, "INVALID_WITHDRAWAL_DATA");

        // Fill in withdrawal data missing from DA
        withdrawal.to = auxData.to;
        withdrawal.minGas = auxData.minGas;
        withdrawal.maxFee = auxData.maxFee;
        withdrawal.validUntil = auxData.validUntil;
        withdrawal.amount = auxData.amount;

        // If the account has an owner, don't allow withdrawing to the zero address
        // (which will be the protocol fee vault contract).
        require(withdrawal.from == address(0) || withdrawal.to != address(0), "INVALID_WITHDRAWAL_RECIPIENT");

        if (withdrawal.withdrawalType == 0) {
            // Signature checked offchain, nothing to do
        } else if (withdrawal.withdrawalType == 1) {
            // Validate
            require(ctx.timestamp < withdrawal.validUntil, "WITHDRAWAL_EXPIRED");
            require(withdrawal.fee <= withdrawal.maxFee, "WITHDRAWAL_FEE_TOO_HIGH");

            // Check appproval onchain
            // Calculate the tx hash
            bytes32 txHash = hashTx(ctx.DOMAIN_SEPARATOR, withdrawal);
            // Check onchain authorization
            S.requireAuthorizedTx(withdrawal.from, auxData.signature, txHash);
        } else if (withdrawal.withdrawalType == 2 || withdrawal.withdrawalType == 3) {
            // Forced withdrawals cannot make use of certain features because the
            // necessary data is not authorized by the account owner.
            // For protocol fee withdrawals, `owner` and `to` are both address(0).
            require(withdrawal.from == withdrawal.to, "INVALID_WITHDRAWAL_ADDRESS");

            // Forced withdrawal fees are charged when the request is submitted.
            require(withdrawal.fee == 0, "FEE_NOT_ZERO");

            ExchangeData.ForcedWithdrawal memory forcedWithdrawal =
                S.pendingForcedWithdrawals[withdrawal.fromAccountID][withdrawal.tokenID];

            if (forcedWithdrawal.timestamp != 0) {
                if (withdrawal.withdrawalType == 2) {
                    require(withdrawal.from == forcedWithdrawal.owner, "INCONSISENT_OWNER");
                } else { //withdrawal.withdrawalType == 3
                    require(withdrawal.from != forcedWithdrawal.owner, "INCONSISENT_OWNER");
                    require(withdrawal.amount == 0, "UNAUTHORIZED_WITHDRAWAL");
                }

                // delete the withdrawal request and free a slot
                delete S.pendingForcedWithdrawals[withdrawal.fromAccountID][withdrawal.tokenID];
                S.numPendingForcedTransactions--;
            } else {
                // Allow the owner to submit full withdrawals without authorization
                // - when in shutdown mode
                // - to withdraw protocol fees
                require(
                    withdrawal.fromAccountID == ExchangeData.ACCOUNTID_PROTOCOLFEE ||
                    S.isShutdown(),
                    "FULL_WITHDRAWAL_UNAUTHORIZED"
                );
            }
        } else {
            revert("INVALID_WITHDRAWAL_TYPE");
        }

        // Check if there is a withdrawal recipient
        address recipient = S.withdrawalRecipient[withdrawal.from][withdrawal.to][withdrawal.tokenID][withdrawal.amount][withdrawal.storageID];
        if (recipient != address(0)) {
            // Set the new recipient address
            withdrawal.to = recipient;
            // Allow any amount of gas to be used on this withdrawal (which allows the transfer to be skipped)
            withdrawal.minGas = 0;

            // Do NOT delete the recipient to prevent replay attack
            // delete S.withdrawalRecipient[withdrawal.owner][withdrawal.to][withdrawal.tokenID][withdrawal.amount][withdrawal.storageID];
        } else if (auxData.storeRecipient) {
            // Store the destination address to mark the withdrawal as done
            require(withdrawal.to != address(0), "INVALID_DESTINATION_ADDRESS");
            S.withdrawalRecipient[withdrawal.from][withdrawal.to][withdrawal.tokenID][withdrawal.amount][withdrawal.storageID] = withdrawal.to;
        }

        // Validate gas provided
        require(auxData.gasLimit >= withdrawal.minGas, "OUT_OF_GAS_FOR_WITHDRAWAL");

        // Try to transfer the tokens with the provided gas limit
        S.distributeWithdrawal(
            withdrawal.from,
            withdrawal.to,
            withdrawal.tokenID,
            withdrawal.amount,
            auxData.gasLimit
        );
    }

    function readTx(
        bytes      memory data,
        uint              offset,
        Withdrawal memory withdrawal
        )
        internal
        pure
    {
        uint _offset = offset;

        // Extract the transfer data
        // We don't use abi.decode for this because of the large amount of zero-padding
        // bytes the circuit would also have to hash.
        withdrawal.withdrawalType = data.toUint8Unsafe(_offset);
        _offset += 1;
        withdrawal.from = data.toAddressUnsafe(_offset);
        _offset += 20;
        withdrawal.fromAccountID = data.toUint32Unsafe(_offset);
        _offset += 4;
        withdrawal.tokenID = data.toUint32Unsafe(_offset);
        _offset += 4;
        withdrawal.feeTokenID = data.toUint32Unsafe(_offset);
        _offset += 4;
        withdrawal.fee = data.toUint16Unsafe(_offset).decodeFloat16();
        _offset += 2;
        withdrawal.storageID = data.toUint32Unsafe(_offset);
        _offset += 4;
        withdrawal.onchainDataHash = data.toBytes20Unsafe(_offset);
        _offset += 20;
    }

    function hashTx(
        bytes32 DOMAIN_SEPARATOR,
        Withdrawal memory withdrawal
        )
        private
        pure
        returns (bytes32)
    {
        return EIP712.hashPacked(
            DOMAIN_SEPARATOR,
            keccak256(
                abi.encode(
                    WITHDRAWAL_TYPEHASH,
                    withdrawal.from,
                    withdrawal.fromAccountID,
                    withdrawal.tokenID,
                    withdrawal.amount,
                    withdrawal.feeTokenID,
                    withdrawal.maxFee,
                    withdrawal.to,
                    withdrawal.minGas,
                    withdrawal.validUntil,
                    withdrawal.storageID
                )
            )
        );
    }

    function hashOnchainData(
        uint248 minGas,
        address to,
        uint248 amount
        )
        private
        view
        returns (bytes20)
    {
        // Only the 20 MSB are used, which is still 80-bit of security, which is more
        // than enough, especially when combined with validUntil.
        return bytes20(
            abi.encodePacked(
                minGas,
                to,
                amount
            ).fastSHA256()
        );
    }
}

File 35 of 95 : ExchangeWithdrawals.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/AddressUtil.sol";
import "../../../lib/MathUint248.sol";
import "../../../thirdparty/BytesUtil.sol";
import "../../iface/ExchangeData.sol";
import "./ExchangeBalances.sol";
import "./ExchangeMode.sol";
import "./ExchangeTokens.sol";


/// @title ExchangeWithdrawals.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
library ExchangeWithdrawals
{
    enum WithdrawalCategory
    {
        DISTRIBUTION,
        FROM_MERKLE_TREE,
        FROM_DEPOSIT_REQUEST,
        FROM_APPROVED_WITHDRAWAL
    }

    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using BytesUtil         for bytes;
    using MathUint          for uint;
    using MathUint248       for uint248;
    using ExchangeBalances  for ExchangeData.State;
    using ExchangeMode      for ExchangeData.State;
    using ExchangeTokens    for ExchangeData.State;

    event ForcedWithdrawalRequested(
        address owner,
        address token,
        uint32  accountID
    );

    event WithdrawalCompleted(
        uint8   category,
        address from,
        address to,
        address token,
        uint    amount
    );

    event WithdrawalFailed(
        uint8   category,
        address from,
        address to,
        address token,
        uint    amount
    );

    function forceWithdraw(
        ExchangeData.State storage S,
        address owner,
        address token,
        uint32  accountID
        )
        public
    {
        require(!S.isInWithdrawalMode(), "INVALID_MODE");
        // Limit the amount of pending forced withdrawals so that the owner cannot be overwhelmed.
        require(S.getNumAvailableForcedSlots() > 0, "TOO_MANY_REQUESTS_OPEN");
        require(accountID < ExchangeData.MAX_NUM_ACCOUNTS, "INVALID_ACCOUNTID");
        require(accountID != 0, "INVALID_ACCOUNTID");

        uint32 tokenID = S.getTokenID(token);

        // A user needs to pay a fixed ETH withdrawal fee, set by the protocol.
        uint withdrawalFeeETH = S.loopring.forcedWithdrawalFee();

        // Check ETH value sent, can be larger than the expected withdraw fee
        require(msg.value >= withdrawalFeeETH, "INSUFFICIENT_WITHDRAW_FEE");

        // Send surplus of ETH back to the sender
        uint feeSurplus = msg.value.sub(withdrawalFeeETH);
        if (feeSurplus > 0) {
            msg.sender.sendETHAndVerify(feeSurplus, gasleft());
        }

        // There can only be a single forced withdrawal per (account, token) pair.
        require(
            S.pendingForcedWithdrawals[accountID][tokenID].timestamp == 0,
            "WITHDRAWAL_ALREADY_PENDING"
        );

        // Store the forced withdrawal request data
        S.pendingForcedWithdrawals[accountID][tokenID] = ExchangeData.ForcedWithdrawal({
            owner: owner,
            timestamp: uint64(block.timestamp)
        });

        // Increment the number of pending forced transactions so we can keep count.
        S.numPendingForcedTransactions++;

        emit ForcedWithdrawalRequested(
            owner,
            token,
            accountID
        );
    }

    // We alow anyone to withdraw these funds for the account owner
    function withdrawFromMerkleTree(
        ExchangeData.State       storage S,
        ExchangeData.MerkleProof calldata merkleProof
        )
        public
    {
        require(S.isInWithdrawalMode(), "NOT_IN_WITHDRAW_MODE");

        address owner = merkleProof.accountLeaf.owner;
        uint32 accountID = merkleProof.accountLeaf.accountID;
        uint32 tokenID = merkleProof.balanceLeaf.tokenID;
        uint248 balance = merkleProof.balanceLeaf.balance;

        // Make sure the funds aren't withdrawn already.
        require(S.withdrawnInWithdrawMode[accountID][tokenID] == false, "WITHDRAWN_ALREADY");

        // Verify that the provided Merkle tree data is valid by using the Merkle proof.
        ExchangeBalances.verifyAccountBalance(
            uint(S.merkleAssetRoot),
            merkleProof
        );

        // Make sure the balance can only be withdrawn once
        S.withdrawnInWithdrawMode[accountID][tokenID] = true;

        // Transfer the tokens to the account owner
        transferTokens(
            S,
            uint8(WithdrawalCategory.FROM_MERKLE_TREE),
            owner,
            owner,
            tokenID,
            balance,
            gasleft(),
            false
        );
    }

    function withdrawFromDepositRequest(
        ExchangeData.State storage S,
        address owner,
        address token
        )
        public
    {
        uint32 tokenID = S.getTokenID(token);
        ExchangeData.Deposit storage deposit = S.pendingDeposits[owner][tokenID];
        require(deposit.timestamp != 0, "DEPOSIT_NOT_WITHDRAWABLE_YET");

        // Check if the deposit has indeed exceeded the time limit of if the exchange is in withdrawal mode
        require(
            block.timestamp >= deposit.timestamp + S.maxAgeDepositUntilWithdrawable ||
            S.isInWithdrawalMode(),
            "DEPOSIT_NOT_WITHDRAWABLE_YET"
        );

        uint248 amount = deposit.amount;

        // Reset the deposit request
        delete S.pendingDeposits[owner][tokenID];

        // Transfer the tokens
        transferTokens(
            S,
            uint8(WithdrawalCategory.FROM_DEPOSIT_REQUEST),
            owner,
            owner,
            tokenID,
            amount,
            gasleft(),
            false
        );
    }

    function withdrawFromApprovedWithdrawals(
        ExchangeData.State storage S,
        address[] memory owners,
        address[] memory tokens
        )
        public
    {
        require(owners.length == tokens.length, "INVALID_INPUT_DATA");
        for (uint i = 0; i < owners.length; i++) {
            address owner = owners[i];
            uint32 tokenID = S.getTokenID(tokens[i]);
            uint248 amount = S.amountWithdrawable[owner][tokenID];

            // Make sure this amount can't be withdrawn again
            delete S.amountWithdrawable[owner][tokenID];

            // Transfer the tokens to the owner
            transferTokens(
                S,
                uint8(WithdrawalCategory.FROM_APPROVED_WITHDRAWAL),
                owner,
                owner,
                tokenID,
                amount,
                gasleft(),
                false
            );
        }
    }

    function distributeWithdrawal(
        ExchangeData.State storage S,
        address from,
        address to,
        uint32  tokenID,
        uint248    amount,
        uint    gasLimit
        )
        public
    {
        // Try to transfer the tokens
        bool success = transferTokens(
            S,
            uint8(WithdrawalCategory.DISTRIBUTION),
            from,
            to,
            tokenID,
            amount,
            gasLimit,
            true
        );
        // If the transfer was successful there's nothing left to do.
        // However, if the transfer failed the tokens are still in the contract and can be
        // withdrawn later to `to` by anyone by using `withdrawFromApprovedWithdrawal.
        if (!success) {
            S.amountWithdrawable[to][tokenID] = S.amountWithdrawable[to][tokenID].add(amount);
        }
    }

    // == Internal and Private Functions ==

    // If allowFailure is true the transfer can fail because of a transfer error or
    // because the transfer uses more than `gasLimit` gas. The function
    // will return true when successful, false otherwise.
    // If allowFailure is false the transfer is guaranteed to succeed using
    // as much gas as needed, otherwise it throws. The function always returns true.
    function transferTokens(
        ExchangeData.State storage S,
        uint8   category,
        address from,
        address to,
        uint32  tokenID,
        uint248 amount,
        uint    gasLimit,
        bool    allowFailure
        )
        private
        returns (bool success)
    {
        // Redirect withdrawals to address(0) to the protocol fee vault
        if (to == address(0)) {
            to = S.loopring.protocolFeeVault();
        }
        address token = S.getTokenAddress(tokenID);

        // Transfer the tokens from the deposit contract to the owner
        if (gasLimit > 0) {
            try S.depositContract.withdraw{gas: gasLimit}(from, to, token, amount) {
                success = true;
            } catch {
                success = false;
            }
        } else {
            success = false;
        }

        require(allowFailure || success, "TRANSFER_FAILURE");

        if (success) {
            emit WithdrawalCompleted(category, from, to, token, amount);

            // Keep track of when the protocol fees were last withdrawn
            // (only done to make this data easier available).
            if (from == address(0)) {
                S.protocolFeeLastWithdrawnTime[token] = block.timestamp;
            }

            S.tokenIdToDepositBalance[tokenID] = S.tokenIdToDepositBalance[tokenID].sub(amount);

        } else {
            emit WithdrawalFailed(category, from, to, token, amount);
        }
    }
}

File 36 of 95 : ExchangeTokens.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/ERC20SafeTransfer.sol";
import "../../../lib/MathUint.sol";
import "../../iface/ExchangeData.sol";
import "./ExchangeMode.sol";

/// @title ExchangeTokens.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeTokens
{
    using MathUint          for uint;
    using ERC20SafeTransfer for address;
    using ExchangeMode      for ExchangeData.State;

    event TokenRegistered(
        address token,
        uint32  tokenId
    );

    function getTokenAddress(
        ExchangeData.State storage S,
        uint32 tokenID
        )
        public
        view
        returns (address)
    {
        require(tokenID < S.normalTokens.length.add(ExchangeData.MAX_NUM_RESERVED_TOKENS), "INVALID_TOKEN_ID");

        if (tokenID < ExchangeData.MAX_NUM_RESERVED_TOKENS) {
            return S.reservedTokens[tokenID].token;
        }

        return S.normalTokens[tokenID - ExchangeData.MAX_NUM_RESERVED_TOKENS].token;
    }

    function registerToken(
        ExchangeData.State storage S,
        address tokenAddress,
        bool isOwnerRegister
        )
        public
        returns (uint32 tokenID)
    {
        require(!S.isInWithdrawalMode(), "INVALID_MODE");
        require(S.tokenToTokenId[tokenAddress] == 0, "TOKEN_ALREADY_EXIST");

        if (isOwnerRegister) {
            require(S.reservedTokens.length < ExchangeData.MAX_NUM_RESERVED_TOKENS, "TOKEN_REGISTRY_FULL");
        } else {
            require(S.normalTokens.length < ExchangeData.MAX_NUM_NORMAL_TOKENS, "TOKEN_REGISTRY_FULL");
        }

        // Check if the deposit contract supports the new token
        if (S.depositContract != IDepositContract(0)) {
            require(S.depositContract.isTokenSupported(tokenAddress), "UNSUPPORTED_TOKEN");
        }

        // Assign a tokenID and store the token
        ExchangeData.Token memory token = ExchangeData.Token(tokenAddress);

        if (isOwnerRegister) {
            tokenID = uint32(S.reservedTokens.length);
            S.reservedTokens.push(token);
        } else {
            tokenID = uint32(S.normalTokens.length.add(ExchangeData.MAX_NUM_RESERVED_TOKENS));
            S.normalTokens.push(token);
        }
        S.tokenToTokenId[tokenAddress] = tokenID + 1;
        S.tokenIdToToken[tokenID] = tokenAddress;

        S.tokenIdToDepositBalance[tokenID] = 0;

        emit TokenRegistered(tokenAddress, tokenID);
    }

    function getTokenID(
        ExchangeData.State storage S,
        address tokenAddress
        )
        internal  // inline call
        view
        returns (uint32 tokenID)
    {
        tokenID = S.tokenToTokenId[tokenAddress];
        require(tokenID != 0, "TOKEN_NOT_FOUND");
        tokenID = tokenID - 1;
    }

    function findTokenID(
        ExchangeData.State storage S,
        address tokenAddress
        )
        internal  // inline call
        view
        returns (uint32 tokenID, bool found)
    {
        tokenID = S.tokenToTokenId[tokenAddress];
        if(tokenID == 0) {
            return (0, false);
        }
        tokenID = tokenID - 1;
        found = true;
    }

}

File 37 of 95 : ExchangeDeposits.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/AddressUtil.sol";
import "../../../lib/MathUint248.sol";
import "../../../lib/MathUint.sol";
import "../../iface/ExchangeData.sol";
import "./ExchangeMode.sol";
import "./ExchangeTokens.sol";


/// @title ExchangeDeposits.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeDeposits
{
    using AddressUtil       for address payable;
    using MathUint248       for uint248;
    using MathUint          for uint;
    using ExchangeMode      for ExchangeData.State;
    using ExchangeTokens    for ExchangeData.State;

    event DepositRequested(
        address from,
        address to,
        address token,
        uint32  tokenId,
        uint248  amount
    );

    event DepositFee(
        uint256  amount
    );

    function deposit(
        ExchangeData.State storage S,
        address from,
        address to,
        address tokenAddress,
        uint248  amount,                 // can be zero
        bytes   memory extraData
        )
        internal  // inline call
    {
        require(to != address(0), "ZERO_ADDRESS");
        require(from == to, "INVALID_DEPOSIT_FROM"); // Only allow deposits to the user's own account

        // Deposits are still possible when the exchange is being shutdown, or even in withdrawal mode.
        // This is fine because the user can easily withdraw the deposited amounts again.
        // We don't want to make all deposits more expensive just to stop that from happening.

        (uint32 tokenID, bool tokenFound) = S.findTokenID(tokenAddress);
        if(!tokenFound) {
            tokenID = S.registerToken(tokenAddress, false);
        }

        if (tokenID == 0 && amount == 0) {
            require(msg.value == 0, "INVALID_ETH_DEPOSIT");
        }

        // A user may need to pay a fixed ETH deposit fee, set by the protocol.
        uint256 depositFeeETH = 0;
        if (needChargeDepositFee(S)) {
            depositFeeETH = S.depositState.depositFee;
            emit DepositFee(depositFeeETH);
        }

        // Check ETH value sent
        require(msg.value >= depositFeeETH, "INSUFFICIENT_DEPOSIT_FEE");

        uint256 ethAmountToDeposit = msg.value - depositFeeETH;

        // Transfer the tokens to this contract
        uint248 amountDeposited = S.depositContract.deposit{value: ethAmountToDeposit}(
            from,
            tokenAddress,
            amount,
            extraData
        );

        // Add the amount to the deposit request and reset the time the operator has to process it
        ExchangeData.Deposit memory _deposit = S.pendingDeposits[to][tokenID];
        _deposit.timestamp = uint64(block.timestamp);
        _deposit.amount = _deposit.amount.add(amountDeposited);
        S.pendingDeposits[to][tokenID] = _deposit;


        S.tokenIdToDepositBalance[tokenID] = S.tokenIdToDepositBalance[tokenID].add(amountDeposited);

        emit DepositRequested(
            from,
            to,
            tokenAddress,
            tokenID,
            amountDeposited
        );
    }

    function setDepositParams(
        ExchangeData.State storage S,
        uint256 freeDepositMax,
        uint256 freeDepositRemained,
        uint256 freeSlotPerBlock,
        uint256 depositFee
    ) internal {
        S.depositState.freeDepositMax = freeDepositMax;
        S.depositState.freeDepositRemained = freeDepositRemained;
        S.depositState.freeSlotPerBlock = freeSlotPerBlock;
        S.depositState.depositFee = depositFee;
    }

    function needChargeDepositFee(ExchangeData.State storage S)
        private
        returns (bool)
    {
        bool needCharge = false;

        // S.depositState.freeDepositRemained + (block.number - S.depositState.lastDepositBlockNum) * S.depositState.freeSlotPerBlock;
        uint256 freeDepositRemained = S.depositState.freeDepositRemained.add(
            (block.number.sub(S.depositState.lastDepositBlockNum)).mul(S.depositState.freeSlotPerBlock)
        );
        
        if (freeDepositRemained > S.depositState.freeDepositMax) {
            freeDepositRemained = S.depositState.freeDepositMax;
        }

        if (freeDepositRemained > 0) {
            freeDepositRemained -= 1;
        } else {
            needCharge = true;
        }

        S.depositState.freeDepositRemained = freeDepositRemained;
        S.depositState.lastDepositBlockNum = block.number;

        return needCharge;
    }
}

File 38 of 95 : ExchangeGenesis.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../../lib/MathUint.sol";
import "../../iface/ExchangeData.sol";
import "../../iface/IAgentRegistry.sol";
import "../../iface/IBlockVerifier.sol";
import "../../iface/ILoopringV3.sol";
import "./ExchangeTokens.sol";


/// @title ExchangeGenesis.
/// @author Daniel Wang  - <[email protected]>
/// @author Brecht Devos - <[email protected]>
library ExchangeGenesis
{
    using ExchangeTokens    for ExchangeData.State;

    event ExchangeGenesisBlockInitialized(
        address loopringAddr,
        bytes32 genesisMerkleRoot,
        bytes32 genesisMerkleAssetRoot,
        bytes32 domainSeparator
    );

    function initializeGenesisBlock(
        ExchangeData.State storage S,
        address _loopringAddr,
        bytes32 _genesisMerkleRoot,
        bytes32 _genesisMerkleAssetRoot,
        bytes32 _domainSeparator
        )
        public
    {
        require(address(0) != _loopringAddr, "INVALID_LOOPRING_ADDRESS");
        require(_genesisMerkleRoot != 0, "INVALID_GENESIS_MERKLE_ROOT");
        require(_genesisMerkleAssetRoot != 0, "INVALID_GENESIS_MERKLE_ASSET_ROOT");

        S.maxAgeDepositUntilWithdrawable = ExchangeData.MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND;
        S.DOMAIN_SEPARATOR = _domainSeparator;

        ILoopringV3 loopring = ILoopringV3(_loopringAddr);
        S.loopring = loopring;

        S.blockVerifier = IBlockVerifier(loopring.blockVerifierAddress());

        S.merkleRoot = _genesisMerkleRoot;
        S.merkleAssetRoot = _genesisMerkleAssetRoot;
        S.blocks[0] = ExchangeData.BlockInfo(uint32(block.timestamp), bytes28(0));
        S.numBlocks = 1;

        // Get the protocol fees for this exchange
        S.protocolFeeData.syncedAt = uint32(0);

        S.protocolFeeData.protocolFeeBips = S.loopring.protocolFeeBips();
        S.protocolFeeData.previousProtocolFeeBips = S.protocolFeeData.protocolFeeBips;

        S.protocolFeeData.nextProtocolFeeBips = S.protocolFeeData.protocolFeeBips;
        S.protocolFeeData.executeTimeOfNextProtocolFeeBips = uint32(0);

        // Call these after the main state has been set up
        S.registerToken(address(0), true);
        S.registerToken(loopring.lrcAddress(), true);

        emit ExchangeGenesisBlockInitialized(_loopringAddr, _genesisMerkleRoot, _genesisMerkleAssetRoot, _domainSeparator);
    }
}

File 39 of 95 : VerificationKeys.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2023
pragma solidity ^0.7.0;


/// @title Hard coded verification keys
/// @dev Generated on 15-Aug-2023 14:33:47, CST
/// @author Berg Jefferson - <[email protected]>
library VerificationKeys
{
    function getKey(
        uint blockType,
        uint blockSize,
        uint blockVersion
        )
        internal
        pure
        returns (uint[14] memory vk, uint[4] memory vk_gammaABC, bool found)
    {
        if (blockType == 0 && blockSize == 355 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              19760025665389040574669313531546717657656149524084804067683173476598633347217,
              8681285008979231253584131418280549966668656633778462421522971536229540611100,
              18798434756947700726104468006561655919432232191929811303855911412217440125667,
              4895239414340886883932811486284299485369484812546390836923605136668910960748
            ];
            vk_gammaABC = [
              15994735701982501893281561659502790339445584899856908648266622586176947947712,
              7361268664974638411518369795539097080258960911401842501578539448125984668800,
              13265800526484792661870233234273851793639251980370323196725514166683051383928,
              20858060294258787851448278584983160822044423166256995816053731968307949262101
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 300 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              14235946865829112632752539493601547137632657230741209246519518250699480805205,
              6967141800784895942783338603745304387422535386816926525812704388502114326988,
              12683227934048664786383675220429532816173512587502561737250003308952233291460,
              8488943500806152489223141795077890220297279736370070741075723200915117523254
            ];
            vk_gammaABC = [
              8806459804669793202954905935329910294058868731174967645604375542502573040708,
              12543721066411832382798608485452549942956669880563238364604680284842888126429,
              2928496424875642434667785713891436609643219129508400681284579022695102725380,
              3027864754806311465011327661191681929640715721312168076913911599239421207324
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 250 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              5993696791732517943092115269423495677246181433149307938453047224227183396798,
              16869378563392886489772675356108474779523187151234463207567621581036386928034,
              16889675691915030882848541445779096370335793005488059532125608656680603619148,
              4167016322498545629032826407165960856436537393314546027479969257141947349734
            ];
            vk_gammaABC = [
              11187794810261942162121471475980797237399171563476121540240270556628515047880,
              4107100073680610609152577607342707486010143037436697961021247403806019077484,
              13272202414345635464587891625160333879490468408043875132726212932440824214275,
              4345198734027632705724046489917451825055826674048172390122004011430195463662
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 200 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              11560354501037013352548889078382712289717597081317678309136057991714258883252,
              5651868439771919901431737192323038545281805159848286026530678292130754030430,
              13217996951221129076367612370256572313087688477999074031634709910224661915254,
              15253914445714503984403352842794696923027706277916796171482787311827079416242
            ];
            vk_gammaABC = [
              6929301941304058588754992684625849592885079444105586245390188436338641084113,
              10040824508342793849453367293903726010737187563628894725402792808674366937841,
              18241484522463335065012169134205838292427261202862736992927113811755720589154,
              15842766469740454896087053857137279760605746016323782911442386472682078146829
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 150 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              17879806419101810099642857775338001339045128759147621497472640585185980997980,
              14931394887459821693949115096098610848942106247872393311165153047173672127380,
              20712326581627272803950938782949543219891315526746531157155584730947175863341,
              19232952284162279987571191286690881249628548786586957564099625239223547704554
            ];
            vk_gammaABC = [
              6463610925874157273211327569431670146803307691532540361327746673579906207683,
              21267691629007352745847386706301764176825159398278390577483150316778699638023,
              8745660291681468769241056754002645328668086963304461654548965421703319458837,
              5346311246956789910011498895076872099202501398274200302905518255053982937000
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 100 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              6529692161751475858313309527450984548781665641593633506182505754745727196510,
              13068755445852863818618949207193890516694611837034717589073094976619812812908,
              1548719507625532397426544813181681972650870639164291716335117845017454543563,
              19959983332581242151994670328103165222266351804841238718966421567703462840935
            ];
            vk_gammaABC = [
              14730090432668223077187138709661258635714971376664356352675379573250303325513,
              12686760845307393879142593891023672456949698837210451151449698940380132718198,
              10245202824582381372389689691809112333066052994811851675441651883549165916471,
              6095934639479628946546235430545660922867934168897411248036302860714364689130
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 50 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              14661046842440323316616614277057997269152980686877190140052408752150016899210,
              3112412548425178302432888969425041262662654802448577497513995434191465186576,
              21317380959789284217975700639939350890946964839624893618875162698892897288912,
              11036853041997732126386355643893538932024093233295524629738653638515942223988
            ];
            vk_gammaABC = [
              17398233715790157118994336633819124798002587056280418325392557473024912703279,
              19274940240030232583146705082556813897248319423816007307063024158927374673179,
              10381449904089248740375623505444383862563421180654918981536065666090993597044,
              20345879717942455554044512833452929800589322103308014157448206707459538187642
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 25 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              14564288883793785548176630302341773636262349395539015366676541188460270244290,
              10866393509588443274192981078975110324995785480874370113624857070665676132372,
              5238259802144989543838462194185374673156000016087052856488335246466423876240,
              5873208035088785643729951419599818468680936716924668656471159029990699604574
            ];
            vk_gammaABC = [
              16413973243506348805303605786333000229660248967543306939623262585423182797727,
              783337630640679821410192340798083101667113347928786509370750961095284683687,
              15584628837518381480038812380017821857720404082377657057978420158563977293442,
              4677492183972018480220227572015854418810356913511446472116076902881577761701
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 10 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              13614537976094436737313514851037883815697620289551926816509850856709639968037,
              7324443629517302675818066548289274310297518196271698234798398231713406549169,
              7976128016411045071961197740645582453642613815225356236495440754727097852825,
              2485797979423298629241255522564847960340802153936497262605826650523721393700
            ];
            vk_gammaABC = [
              18691832131706639289406837616553812041210490388107336583278675068113912869654,
              8097572363825978257127235169596727096728710544542299739033391598707006730783,
              2374656712079589787058538439682685747173546281916021763211033576415943268277,
              7093912687883313504582938199093991338601182768696869718499986045980769744947
            ];
            found = true;
        } else if (blockType == 0 && blockSize == 5 && blockVersion == 0) {
            vk = [
              6303993385263809522772733982497344834770685605218539434395639849619491280272,
              19193430227906658223519665688701250315527732983973844350848394261336780279830,
              11289160824829433904792589186366897626840760940227519684893249495714090765164,
              17898739242208732835232039788553992019145466925320485499315248009959239840478,
              19132711554685110864066887246319748272374406922432552969263103396849184885892,
              8788783306581471843891169798804317853208672878480808778044649547438301110376,
              11559732032986387107991004021392285783925812861821192530917403151452391805634,
              10857046999023057135944570762232829481370756359578518086990519993285655852781,
              4082367875863433681332203403145435568316851327593401208105741076214120093531,
              8495653923123431417604973247489272438418190587263600148770280649306958101930,
              6872418517477687891167172916315888972065027438886458878476855741460801505302,
              9593441151844561502666185142735499084036116088705990883706685485313234560957,
              6943604095407599869501799128380053045566695539420571369905701609859904107574,
              8941343150907402609586267784806496535368081966242689115335634791150352737556
            ];
            vk_gammaABC = [
              7406256442456090339582884416820934440456563301661341925498926292837193699239,
              10119305488270089190265317677598090831698978139602904080295024541450169148305,
              10506612595109045625928488632243543456469116085198290902425102381963912290787,
              13116825451580392860138062595484030595125511561643927433037440455740722889721
            ];
            found = true;
        } else {
            found = false;
        }
    }
}

File 40 of 95 : DefaultDepositContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../../lib/AddressUtil.sol";
import "../../lib/Claimable.sol";
import "../../lib/ERC20.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../thirdparty/SafeCast.sol";
import "../iface/IDepositContract.sol";


/// @title DefaultDepositContract
/// @dev   Default implementation of IDepositContract that just stores
///        all funds without doing anything with them.
///
///        Should be able to work with proxy contracts so the contract
///        can be updated easily (but with great caution and transparency!)
///        when necessary.
///
/// @author Brecht Devos - <[email protected]>
contract DefaultDepositContract is IDepositContract, Claimable
{
    using AddressUtil       for address;
    using ERC20SafeTransfer for address;
    using MathUint          for uint;
    using SafeCast          for uint;

    address public exchange;

    mapping (address => bool) private needCheckBalance;

    modifier onlyExchange()
    {
        require(msg.sender == exchange, "UNAUTHORIZED");
        _;
    }

    modifier ifNotZero(uint amount)
    {
        if (amount == 0) return;
        else  _;
    }

    event CheckBalance(
        address indexed token,
        bool            checkBalance
    );

    receive() external payable { }

    function initialize(
        address _exchange
        )
        external
    {
        require(
            exchange == address(0) && _exchange != address(0),
            "INVALID_EXCHANGE"
        );
        owner = msg.sender;
        exchange = _exchange;
    }

    function setCheckBalance(
        address token,
        bool    checkBalance
        )
        external
        onlyOwner
    {
        require(needCheckBalance[token] != checkBalance, "INVALID_VALUE");

        needCheckBalance[token] = checkBalance;
        emit CheckBalance(token, checkBalance);
    }

    function isTokenSupported(address /*token*/)
        external
        override
        pure
        returns (bool)
    {
        return true;
    }

    function deposit(
        address from,
        address token,
        uint248  amount, // 0-value supported
        bytes   calldata /*extraData*/
        )
        external
        override
        payable
        onlyExchange
        returns (uint248 amountReceived)
    {
        uint ethToReturn = 0;

        if (isETHInternal(token)) {
            require(msg.value >= amount, "INVALID_ETH_DEPOSIT");
            amountReceived = amount;
            ethToReturn = msg.value - amount;
        } else {
            // When checkBalance is enabled for a token we check the balance change
            // on the contract instead of counting on transferFrom to transfer exactly
            // the amount of tokens that is specified in the transferFrom call.
            // This is to support non-standard tokens which do custom transfer logic.
            bool checkBalance = needCheckBalance[token];
            uint balanceBefore = checkBalance ? ERC20(token).balanceOf(address(this)) : 0;

            token.safeTransferFromAndVerify(from, address(this), uint(amount));

            uint balanceAfter = checkBalance ? ERC20(token).balanceOf(address(this)) : amount;
            uint diff = balanceAfter.sub(balanceBefore);
            amountReceived = diff.toUint248();

            ethToReturn = msg.value;
        }

        if (ethToReturn > 0) {
            from.sendETHAndVerify(ethToReturn, gasleft());
        }
    }

    function withdraw(
        address /*from*/,
        address to,
        address token,
        uint    amount
        )
        external
        override
        payable
        onlyExchange
        ifNotZero(amount)
    {
        if (isETHInternal(token)) {
            to.sendETHAndVerify(amount, gasleft());
        } else {
            // Try to transfer the amount requested.
            // If this fails try to transfer the remaining balance in this contract.
            // This is to guard against non-standard token behavior where total supply
            // has changed in unexpected ways.
            if (!token.safeTransfer(to, amount)){
                uint amountPaid = ERC20(token).balanceOf(address(this));
                require(amountPaid < amount, "UNEXPECTED");
                token.safeTransferAndVerify(to, amountPaid);
            }
        }
    }

    function transfer(
        address from,
        address to,
        address token,
        uint    amount
        )
        external
        override
        payable
        onlyExchange
        ifNotZero(amount)
    {
        token.safeTransferFromAndVerify(from, to, amount);
    }

    function isETH(address addr)
        external
        override
        pure
        returns (bool)
    {
        return isETHInternal(addr);
    }

    // -- private --

    function isETHInternal(address addr)
        private
        pure
        returns (bool)
    {
        return addr == address(0);
    }
}

File 41 of 95 : BlockVerifier.sol
pragma solidity ^0.7.0;

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022

import "../../lib/ReentrancyGuard.sol";
import "../../thirdparty/verifiers/BatchVerifier.sol";
import "../../thirdparty/verifiers/Verifier.sol";
import "../iface/ExchangeData.sol";
import "../iface/IBlockVerifier.sol";
import "./VerificationKeys.sol";

/// @title An Implementation of IBlockVerifier.
/// @author Brecht Devos - <[email protected]>
contract BlockVerifier is ReentrancyGuard, IBlockVerifier
{
    struct Circuit
    {
        bool registered;
        bool enabled;
        uint[18] verificationKey;
    }

    mapping (uint8 => mapping (uint16 => mapping (uint8 => Circuit))) public circuits;

    constructor() Claimable() {}

    function verifyProofs(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion,
        uint[] calldata publicInputs,
        uint[] calldata proofs
        )
        external
        override
        view
        returns (bool)
    {
        // First try to find the verification key in the hard coded list
        (uint[14] memory _vk, uint[4] memory _vk_gammaABC, bool found) = VerificationKeys.getKey(
            blockType,
            blockSize,
            blockVersion
        );
        if (!found) {
            Circuit storage circuit = circuits[blockType][blockSize][blockVersion];
            require(circuit.registered == true, "NOT_REGISTERED");
            require(circuit.enabled == true, "NOT_ENABLED");

            // Load the verification key from storage.
            uint[18] storage vk = circuit.verificationKey;
            _vk = [
                vk[0], vk[1], vk[2], vk[3], vk[4], vk[5], vk[6],
                vk[7], vk[8], vk[9], vk[10], vk[11], vk[12], vk[13]
            ];
            _vk_gammaABC = [vk[14], vk[15], vk[16], vk[17]];
        }

        // Verify the proof.
        // Batched proof verification has a fixed overhead which makes it more
        // expensive to verify a single proof compared to the non-batched code
        // This is why we don't use the batched verification code here when only
        // a single proof needs to be verified.
        if (publicInputs.length == 1) {
            return Verifier.Verify(_vk, _vk_gammaABC, proofs, publicInputs);
        } else {
            return BatchVerifier.BatchVerify(
                _vk,
                _vk_gammaABC,
                proofs,
                publicInputs,
                publicInputs.length
            );
        }
    }

    function isCircuitRegistered(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion
        )
        external
        override
        view
        returns (bool)
    {
        return circuits[blockType][blockSize][blockVersion].registered;
    }

    function isCircuitEnabled(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion
        )
        external
        override
        view
        returns (bool)
    {
        return circuits[blockType][blockSize][blockVersion].enabled;
    }

    function getVerificationKey(
        uint8  blockType,
        uint16 blockSize,
        uint8  blockVersion
        )
        public
        view
        returns (uint[18] memory)
    {
        return circuits[blockType][blockSize][blockVersion].verificationKey;
    }
}

File 42 of 95 : BatchVerifier.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://github.com/matter-labs/Groth16BatchVerifier/blob/master/BatchedSnarkVerifier/contracts/BatchVerifier.sol
// Thanks Harry from ETHSNARKS for base code
pragma solidity ^0.7.0;

library BatchVerifier {
    function GroupOrder ()
        public pure returns (uint256)
    {
        return 21888242871839275222246405745257275088548364400416034343698204186575808495617;
    }

    function NegateY( uint256 Y )
        internal pure returns (uint256)
    {
        uint q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
        return q - (Y % q);
    }

    function getProofEntropy(
        uint256[] memory in_proof,
        uint256[] memory proof_inputs,
        uint proofNumber
    )
        internal pure returns (uint256)
    {
        // Truncate the least significant 3 bits from the 256bit entropy so it fits the scalar field
        return uint(
            keccak256(
                abi.encodePacked(
                    in_proof[proofNumber*8 + 0], in_proof[proofNumber*8 + 1], in_proof[proofNumber*8 + 2], in_proof[proofNumber*8 + 3],
                    in_proof[proofNumber*8 + 4], in_proof[proofNumber*8 + 5], in_proof[proofNumber*8 + 6], in_proof[proofNumber*8 + 7],
                    proof_inputs[proofNumber]
                )
            )
        ) >> 3;
    }

    function accumulate(
        uint256[] memory in_proof,
        uint256[] memory proof_inputs, // public inputs, length is num_inputs * num_proofs
        uint256 num_proofs
    ) internal view returns (
        bool success,
        uint256[] memory proofsAandC,
        uint256[] memory inputAccumulators
    ) {
        uint256 q = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
        uint256 numPublicInputs = proof_inputs.length / num_proofs;
        uint256[] memory entropy = new uint256[](num_proofs);
        inputAccumulators = new uint256[](numPublicInputs + 1);

        for (uint256 proofNumber = 0; proofNumber < num_proofs; proofNumber++) {
            if (proofNumber == 0) {
                entropy[proofNumber] = 1;
            } else {
                // entropy[proofNumber] = uint(blockhash(block.number - proofNumber)) % q;
                // Safer entropy:
                entropy[proofNumber] = getProofEntropy(in_proof, proof_inputs, proofNumber);
            }
            require(entropy[proofNumber] != 0, "Entropy should not be zero");
            // here multiplication by 1 is implied
            inputAccumulators[0] = addmod(inputAccumulators[0], entropy[proofNumber], q);
            for (uint256 i = 0; i < numPublicInputs; i++) {
                require(proof_inputs[proofNumber * numPublicInputs + i] < q, "INVALID_INPUT");
                // accumulate the exponent with extra entropy mod q
                inputAccumulators[i+1] = addmod(inputAccumulators[i+1], mulmod(entropy[proofNumber], proof_inputs[proofNumber * numPublicInputs + i], q), q);
            }
            // coefficient for +vk.alpha (mind +) is the same as inputAccumulator[0]
        }

        // inputs for scalar multiplication
        uint256[3] memory mul_input;

        // use scalar multiplications to get proof.A[i] * entropy[i]

        proofsAandC = new uint256[](num_proofs*2 + 2);

        proofsAandC[0] = in_proof[0];
        proofsAandC[1] = in_proof[1];

        for (uint256 proofNumber = 1; proofNumber < num_proofs; proofNumber++) {
            require(entropy[proofNumber] < q, "INVALID_INPUT");
            mul_input[0] = in_proof[proofNumber*8];
            mul_input[1] = in_proof[proofNumber*8 + 1];
            mul_input[2] = entropy[proofNumber];
            assembly {
                // ECMUL, output proofsA[i]
                // success := staticcall(sub(gas, 2000), 7, mul_input, 0x60, add(add(proofsAandC, 0x20), mul(proofNumber, 0x40)), 0x40)
                success := staticcall(sub(gas(), 2000), 7, mul_input, 0x60, mul_input, 0x40)
            }
            if (!success) {
                return (false, proofsAandC, inputAccumulators);
            }
            proofsAandC[proofNumber*2] = mul_input[0];
            proofsAandC[proofNumber*2 + 1] = mul_input[1];
        }

        // use scalar multiplication and addition to get sum(proof.C[i] * entropy[i])

        uint256[4] memory add_input;

        add_input[0] = in_proof[6];
        add_input[1] = in_proof[7];

        for (uint256 proofNumber = 1; proofNumber < num_proofs; proofNumber++) {
            mul_input[0] = in_proof[proofNumber*8 + 6];
            mul_input[1] = in_proof[proofNumber*8 + 7];
            mul_input[2] = entropy[proofNumber];
            assembly {
                // ECMUL, output proofsA
                success := staticcall(sub(gas(), 2000), 7, mul_input, 0x60, add(add_input, 0x40), 0x40)
            }
            if (!success) {
                return (false, proofsAandC, inputAccumulators);
            }

            assembly {
                // ECADD from two elements that are in add_input and output into first two elements of add_input
                success := staticcall(sub(gas(), 2000), 6, add_input, 0x80, add_input, 0x40)
            }
            if (!success) {
                return (false, proofsAandC, inputAccumulators);
            }
        }

        proofsAandC[num_proofs*2] = add_input[0];
        proofsAandC[num_proofs*2 + 1] = add_input[1];
    }

    function prepareBatches(
        uint256[14] memory in_vk,
        uint256[4] memory vk_gammaABC,
        uint256[] memory inputAccumulators
    ) internal view returns (
        bool success,
        uint256[4] memory finalVksAlphaX
    ) {
        // Compute the linear combination vk_x using accumulator
        // First two fields are used as the sum and are initially zero
        uint256[4] memory add_input;
        uint256[3] memory mul_input;

        // Performs a sum(gammaABC[i] * inputAccumulator[i])
        for (uint256 i = 0; i < inputAccumulators.length; i++) {
            mul_input[0] = vk_gammaABC[2*i];
            mul_input[1] = vk_gammaABC[2*i + 1];
            mul_input[2] = inputAccumulators[i];

            assembly {
                // ECMUL, output to the last 2 elements of `add_input`
                success := staticcall(sub(gas(), 2000), 7, mul_input, 0x60, add(add_input, 0x40), 0x40)
            }
            if (!success) {
                return (false, finalVksAlphaX);
            }

            assembly {
                // ECADD from four elements that are in add_input and output into first two elements of add_input
                success := staticcall(sub(gas(), 2000), 6, add_input, 0x80, add_input, 0x40)
            }
            if (!success) {
                return (false, finalVksAlphaX);
            }
        }

        finalVksAlphaX[2] = add_input[0];
        finalVksAlphaX[3] = add_input[1];

        // add one extra memory slot for scalar for multiplication usage
        uint256[3] memory finalVKalpha;
        finalVKalpha[0] = in_vk[0];
        finalVKalpha[1] = in_vk[1];
        finalVKalpha[2] = inputAccumulators[0];

        assembly {
            // ECMUL, output to first 2 elements of finalVKalpha
            success := staticcall(sub(gas(), 2000), 7, finalVKalpha, 0x60, finalVKalpha, 0x40)
        }
        if (!success) {
            return (false, finalVksAlphaX);
        }

        finalVksAlphaX[0] = finalVKalpha[0];
        finalVksAlphaX[1] = finalVKalpha[1];
    }

    // original equation
    // e(proof.A, proof.B)*e(-vk.alpha, vk.beta)*e(-vk_x, vk.gamma)*e(-proof.C, vk.delta) == 1
    // accumulation of inputs
    // gammaABC[0] + sum[ gammaABC[i+1]^proof_inputs[i] ]

    function BatchVerify (
        uint256[14] memory in_vk, // verifying key is always constant number of elements
        uint256[4] memory vk_gammaABC, // variable length, depends on number of inputs
        uint256[] memory in_proof, // proof itself, length is 8 * num_proofs
        uint256[] memory proof_inputs, // public inputs, length is num_inputs * num_proofs
        uint256 num_proofs
    )
    internal
    view
    returns (bool success)
    {
        require(in_proof.length == num_proofs * 8, "Invalid proofs length for a batch");
        require(proof_inputs.length % num_proofs == 0, "Invalid inputs length for a batch");
        require(((vk_gammaABC.length / 2) - 1) == proof_inputs.length / num_proofs, "Invalid verification key");

        // strategy is to accumulate entropy separately for some proof elements
        // (accumulate only for G1, can't in G2) of the pairing equation, as well as input verification key,
        // postpone scalar multiplication as much as possible and check only one equation
        // by using 3 + num_proofs pairings only plus 2*num_proofs + (num_inputs+1) + 1 scalar multiplications compared to naive
        // 4*num_proofs pairings and num_proofs*(num_inputs+1) scalar multiplications

        bool valid;
        uint256[] memory proofsAandC;
        uint256[] memory inputAccumulators;
        (valid, proofsAandC, inputAccumulators) = accumulate(in_proof, proof_inputs, num_proofs);
        if (!valid) {
            return false;
        }

        uint256[4] memory finalVksAlphaX;
        (valid, finalVksAlphaX) = prepareBatches(in_vk, vk_gammaABC, inputAccumulators);
        if (!valid) {
            return false;
        }

        uint256[] memory inputs = new uint256[](6*num_proofs + 18);
        // first num_proofs pairings e(ProofA, ProofB)
        for (uint256 proofNumber = 0; proofNumber < num_proofs; proofNumber++) {
            inputs[proofNumber*6] = proofsAandC[proofNumber*2];
            inputs[proofNumber*6 + 1] = proofsAandC[proofNumber*2 + 1];
            inputs[proofNumber*6 + 2] = in_proof[proofNumber*8 + 2];
            inputs[proofNumber*6 + 3] = in_proof[proofNumber*8 + 3];
            inputs[proofNumber*6 + 4] = in_proof[proofNumber*8 + 4];
            inputs[proofNumber*6 + 5] = in_proof[proofNumber*8 + 5];
        }

        // second pairing e(-finalVKaplha, vk.beta)
        inputs[num_proofs*6] = finalVksAlphaX[0];
        inputs[num_proofs*6 + 1] = NegateY(finalVksAlphaX[1]);
        inputs[num_proofs*6 + 2] = in_vk[2];
        inputs[num_proofs*6 + 3] = in_vk[3];
        inputs[num_proofs*6 + 4] = in_vk[4];
        inputs[num_proofs*6 + 5] = in_vk[5];

        // third pairing e(-finalVKx, vk.gamma)
        inputs[num_proofs*6 + 6] = finalVksAlphaX[2];
        inputs[num_proofs*6 + 7] = NegateY(finalVksAlphaX[3]);
        inputs[num_proofs*6 + 8] = in_vk[6];
        inputs[num_proofs*6 + 9] = in_vk[7];
        inputs[num_proofs*6 + 10] = in_vk[8];
        inputs[num_proofs*6 + 11] = in_vk[9];

        // fourth pairing e(-proof.C, finalVKdelta)
        inputs[num_proofs*6 + 12] = proofsAandC[num_proofs*2];
        inputs[num_proofs*6 + 13] = NegateY(proofsAandC[num_proofs*2 + 1]);
        inputs[num_proofs*6 + 14] = in_vk[10];
        inputs[num_proofs*6 + 15] = in_vk[11];
        inputs[num_proofs*6 + 16] = in_vk[12];
        inputs[num_proofs*6 + 17] = in_vk[13];

        uint256 inputsLength = inputs.length * 32;
        uint[1] memory out;
        require(inputsLength % 192 == 0, "Inputs length should be multiple of 192 bytes");

        assembly {
            success := staticcall(sub(gas(), 2000), 8, add(inputs, 0x20), inputsLength, out, 0x20)
        }
        return success && out[0] == 1;
    }
}

File 43 of 95 : Verifier.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://github.com/HarryR/ethsnarks/blob/master/contracts/Verifier.sol
// this code is taken from https://github.com/JacobEberhardt/ZoKrates
pragma solidity ^0.7.0;

library Verifier
{
    function ScalarField ()
        internal
        pure
        returns (uint256)
    {
        return 21888242871839275222246405745257275088548364400416034343698204186575808495617;
    }

    function NegateY( uint256 Y )
        internal pure returns (uint256)
    {
        uint q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
        return q - (Y % q);
    }


    /*
    * This implements the Solidity equivalent of the following Python code:

        from py_ecc.bn128 import *

        data = # ... arguments to function [in_vk, vk_gammaABC, in_proof, proof_inputs]

        vk = [int(_, 16) for _ in data[0]]
        ic = [FQ(int(_, 16)) for _ in data[1]]
        proof = [int(_, 16) for _ in data[2]]
        inputs = [int(_, 16) for _ in data[3]]

        it = iter(ic)
        ic = [(_, next(it)) for _ in it]
        vk_alpha = [FQ(_) for _ in vk[:2]]
        vk_beta = (FQ2(vk[2:4][::-1]), FQ2(vk[4:6][::-1]))
        vk_gamma = (FQ2(vk[6:8][::-1]), FQ2(vk[8:10][::-1]))
        vk_delta = (FQ2(vk[10:12][::-1]), FQ2(vk[12:14][::-1]))

        assert is_on_curve(vk_alpha, b)
        assert is_on_curve(vk_beta, b2)
        assert is_on_curve(vk_gamma, b2)
        assert is_on_curve(vk_delta, b2)

        proof_A = [FQ(_) for _ in proof[:2]]
        proof_B = (FQ2(proof[2:4][::-1]), FQ2(proof[4:-2][::-1]))
        proof_C = [FQ(_) for _ in proof[-2:]]

        assert is_on_curve(proof_A, b)
        assert is_on_curve(proof_B, b2)
        assert is_on_curve(proof_C, b)

        vk_x = ic[0]
        for i, s in enumerate(inputs):
            vk_x = add(vk_x, multiply(ic[i + 1], s))

        check_1 = pairing(proof_B, proof_A)
        check_2 = pairing(vk_beta, neg(vk_alpha))
        check_3 = pairing(vk_gamma, neg(vk_x))
        check_4 = pairing(vk_delta, neg(proof_C))

        ok = check_1 * check_2 * check_3 * check_4
        assert ok == FQ12.one()
    */
    function Verify(
        uint256[14] memory in_vk,
        uint256[4] memory vk_gammaABC,
        uint256[] memory in_proof,
        uint256[] memory proof_inputs
        )
        internal
        view
        returns (bool)
    {
        uint256 snark_scalar_field = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
        require(((vk_gammaABC.length / 2) - 1) == proof_inputs.length, "INVALID_VALUE");

        // Compute the linear combination vk_x
        uint256[3] memory mul_input;
        uint256[4] memory add_input;
        bool success;
        uint m = 2;

        // First two fields are used as the sum
        add_input[0] = vk_gammaABC[0];
        add_input[1] = vk_gammaABC[1];

        // Performs a sum of gammaABC[0] + sum[ gammaABC[i+1]^proof_inputs[i] ]
        for (uint i = 0; i < proof_inputs.length; i++) {
            require(proof_inputs[i] < snark_scalar_field, "INVALID_INPUT");
            mul_input[0] = vk_gammaABC[m++];
            mul_input[1] = vk_gammaABC[m++];
            mul_input[2] = proof_inputs[i];

            assembly {
                // ECMUL, output to last 2 elements of `add_input`
                success := staticcall(sub(gas(), 2000), 7, mul_input, 0x80, add(add_input, 0x40), 0x60)
            }
            if (!success) {
                return false;
            }

            assembly {
                // ECADD
                success := staticcall(sub(gas(), 2000), 6, add_input, 0xc0, add_input, 0x60)
            }
            if (!success) {
                return false;
            }
        }

        uint[24] memory input = [
            // (proof.A, proof.B)
            in_proof[0], in_proof[1],                           // proof.A   (G1)
            in_proof[2], in_proof[3], in_proof[4], in_proof[5], // proof.B   (G2)

            // (-vk.alpha, vk.beta)
            in_vk[0], NegateY(in_vk[1]),                        // -vk.alpha (G1)
            in_vk[2], in_vk[3], in_vk[4], in_vk[5],             // vk.beta   (G2)

            // (-vk_x, vk.gamma)
            add_input[0], NegateY(add_input[1]),                // -vk_x     (G1)
            in_vk[6], in_vk[7], in_vk[8], in_vk[9],             // vk.gamma  (G2)

            // (-proof.C, vk.delta)
            in_proof[6], NegateY(in_proof[7]),                  // -proof.C  (G1)
            in_vk[10], in_vk[11], in_vk[12], in_vk[13]          // vk.delta  (G2)
        ];

        uint[1] memory out;
        assembly {
            success := staticcall(sub(gas(), 2000), 8, input, 768, out, 0x20)
        }
        return success && out[0] != 0;
    }
}

File 44 of 95 : LoopringV3.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../../lib/AddressUtil.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../iface/IExchangeV3.sol";
import "../iface/ILoopringV3.sol";


/// @title LoopringV3
/// @dev This contract does NOT support proxy.
/// @author Brecht Devos - <[email protected]>
/// @author Daniel Wang  - <[email protected]>
contract LoopringV3 is ILoopringV3, ReentrancyGuard
{
    using AddressUtil       for address payable;
    using MathUint          for uint;
    using ERC20SafeTransfer for address;

    address public immutable override lrcAddress;

    // -- Constructor --
    constructor(
        address _lrcAddress,
        address payable _protocolFeeVault,
        address _blockVerifierAddress
        )
        Claimable()
    {
        require(address(0) != _lrcAddress, "ZERO_ADDRESS");

        lrcAddress = _lrcAddress;
        blockVerifierAddress = _blockVerifierAddress;

        protocolFeeBips = ExchangeData.DEFAULT_PROTOCOL_FEE_BIPS;

        updateSettingsInternal(_protocolFeeVault, 0);
    }

    // == Public Functions ==
    function updateSettings(
        address payable _protocolFeeVault,
        uint    _forcedWithdrawalFee
        )
        external
        override
        nonReentrant
        onlyOwner
    {
        updateSettingsInternal(
            _protocolFeeVault,
            _forcedWithdrawalFee
        );
    }

    function updateProtocolFeeSettings(
        uint16 _protocolFeeBips
        )
        external
        override
        nonReentrant
        onlyOwner
    {
        protocolFeeBips = _protocolFeeBips;

        emit SettingsUpdated(block.timestamp);
    }

    function getExchangeStake(
        address exchangeAddr
        )
        external
        override
        view
        returns (uint)
    {
        return exchangeStake[exchangeAddr];
    }

    function burnExchangeStake(
        uint amount
        )
        external
        override
        nonReentrant
        returns (uint burnedLRC)
    {
        require(amount > 0, "ZERO_VALUE");

        burnedLRC = exchangeStake[msg.sender];

        if (amount < burnedLRC) {
            burnedLRC = amount;
        }
        if (burnedLRC > 0) {
            lrcAddress.safeTransferAndVerify(protocolFeeVault, burnedLRC);
            exchangeStake[msg.sender] = exchangeStake[msg.sender].sub(burnedLRC);
            totalStake = totalStake.sub(burnedLRC);
        }
        emit ExchangeStakeBurned(msg.sender, burnedLRC);
    }

    function depositExchangeStake(
        address exchangeAddr,
        uint    amountLRC
        )
        external
        override
        nonReentrant
        returns (uint stakedLRC)
    {
        require(amountLRC > 0, "ZERO_VALUE");

        lrcAddress.safeTransferFromAndVerify(msg.sender, address(this), amountLRC);

        stakedLRC = exchangeStake[exchangeAddr].add(amountLRC);
        exchangeStake[exchangeAddr] = stakedLRC;
        totalStake = totalStake.add(amountLRC);

        emit ExchangeStakeDeposited(exchangeAddr, amountLRC);
    }

    function withdrawExchangeStake(
        address recipient,
        uint    requestedAmount
        )
        external
        override
        nonReentrant
        returns (uint amountLRC)
    {
        require(requestedAmount > 0, "ZERO_VALUE");

        uint stake = exchangeStake[msg.sender];
        amountLRC = (stake > requestedAmount) ? requestedAmount : stake;

        if (amountLRC > 0) {
            lrcAddress.safeTransferAndVerify(recipient, amountLRC);
            exchangeStake[msg.sender] = exchangeStake[msg.sender].sub(amountLRC);
            totalStake = totalStake.sub(amountLRC);
        }

        emit ExchangeStakeWithdrawn(msg.sender, amountLRC);
    }

    function getProtocolFeeValues()
        external
        override
        view
        returns (
            uint16 feeBips
        )
    {
        return protocolFeeBips;
    }

    // == Internal Functions ==
    function updateSettingsInternal(
        address payable  _protocolFeeVault,
        uint    _forcedWithdrawalFee
        )
        private
    {
        require(address(0) != _protocolFeeVault, "ZERO_ADDRESS");
        require(_forcedWithdrawalFee <= ExchangeData.MAX_FORCED_WITHDRAWAL_FEE, "INVALID_FORCED_WITHDRAWAL_FEE");

        protocolFeeVault = _protocolFeeVault;
        forcedWithdrawalFee = _forcedWithdrawalFee;

        emit SettingsUpdated(block.timestamp);
    }
}

File 45 of 95 : LzDecompressorContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../aux/compression/LzDecompressor.sol";

contract LzDecompressorContract {
    function decompress(
        bytes calldata data
        )
        external
        pure
        returns (bytes memory)
    {
        return LzDecompressor.decompress(data);
    }

    function benchmark(
        bytes calldata data
        )
        external
        pure
        returns (bytes memory)
    {
        return LzDecompressor.decompress(data);
    }
}

File 46 of 95 : LzDecompressor.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title LzDecompressor
/// @author Brecht Devos - <[email protected]>
/// @dev Decompresses data compressed with a LZ77/Snappy like compressor optimized for EVM
///      Currently supports 3 modes:
///      - Copy directly from calldata (needs length)
///      - Fill memory with zeros (needs length)
///      - Copy from previously decompressed memory (needs offset, length)
///      TODO:
///      - better packing of (mode, offset, length)
///      - add mode copying from random location in calldata (faster than memory copies)
///      - add support to copy data from memory using the identity pre-compile
///        (large initital cost but cheaper copying, does not support overlapping memory ranges)
library LzDecompressor
{
    function decompress(
        bytes calldata /*data*/
        )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory uncompressed;
        assembly {
            uncompressed := mload(0x40)
            let ptr := add(uncompressed, 32)
            let dataLength := calldataload(36)
            for { let pos := 0 } lt(pos, dataLength) {} {
                // Read the mode
                pos := add(pos, 1)
                let mode := and(calldataload(add(36, pos)), 0xFF)

                switch mode
                case 0 {
                    // Copy from calldata at the current position
                    pos := add(pos, 2)
                    let length := and(calldataload(add(36, pos)), 0xFFFF)

                    calldatacopy(ptr, add(68, pos), length)
                    pos := add(pos, length)

                    ptr := add(ptr, length)
                }
                case 1 {
                    // Write out zeros
                    pos := add(pos, 2)
                    let length := and(calldataload(add(36, pos)), 0xFFFF)

                    codecopy(ptr, codesize(), length)

                    ptr := add(ptr, length)
                }
                case 2 {
                    // Copy from previously decompressed bytes in memory
                    pos := add(pos, 2)
                    let offset := and(calldataload(add(36, pos)), 0xFFFF)
                    pos := add(pos, 2)
                    let length := and(calldataload(add(36, pos)), 0xFFFF)

                    let src := sub(ptr, offset)
                    let i := 0
                    if lt(offset, 32) {
                        // If the offset is less than 32 we can't begin copying 32 bytes at a time.
                        // We first do some copies to fix this
                        mstore(add(src, offset), mload(src))
                        mstore(add(src, mul(offset, 2)), mload(src))
                        mstore(add(src, mul(offset, 4)), mload(src))
                        mstore(add(src, mul(offset, 8)), mload(src))
                        mstore(add(src, mul(offset, 16)), mload(src))
                        mstore(add(src, mul(offset, 32)), mload(src))

                        // No matter the offset, the first 32 bytes can now be copied
                        // Fix the starting data so we can copy like normal afterwards
                        i := 32
                        src := add(sub(src, 32), mod(32, offset))
                    }
                    // This can copy too many bytes, but that's okay
                    // Needs unrolling for the best performance
                    for { } lt(i, length) { } {
                        mstore(add(ptr, i), mload(add(src, i)))
                        i := add(i, 32)
                        mstore(add(ptr, i), mload(add(src, i)))
                        i := add(i, 32)
                        mstore(add(ptr, i), mload(add(src, i)))
                        i := add(i, 32)
                        mstore(add(ptr, i), mload(add(src, i)))
                        i := add(i, 32)
                    }
                    ptr := add(ptr, length)
                }
                default {
                    revert(0, 0)
                }
            }
            // Store data length
            mstore(uncompressed, sub(sub(ptr, uncompressed), 32))

            // Update free memory pointer
            mstore(0x40, add(ptr, 0x20))
        }
        return uncompressed;
    }
}

File 47 of 95 : DelayedOwnerContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../aux/access/DelayedOwner.sol";
import "./DelayedTargetContract.sol";


/// @title DelayedOwnerContract
/// @author Brecht Devos - <[email protected]>
contract DelayedOwnerContract is DelayedOwner
{
    constructor(
        address delayedTargetAddress,
        bool setDefaultFunctionDelays
        )
        DelayedOwner(delayedTargetAddress, 3 days)
    {
        if (setDefaultFunctionDelays) {
            DelayedTargetContract delayedTarget = DelayedTargetContract(delayedTargetAddress);
            setFunctionDelay(delayedTarget.delayedFunctionPayable.selector, 1 days);
            setFunctionDelay(delayedTarget.delayedFunctionRevert.selector, 2 days);
            setFunctionDelay(delayedTarget.transferOwnership.selector, 3 days);
        }
    }

    function setFunctionDelayExternal(
        address to,
        bytes4  functionSelector,
        uint    delay
        )
        external
    {
        setFunctionDelay(to, functionSelector, delay);
    }
}

File 48 of 95 : DelayedOwner.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../../lib/Claimable.sol";
import "./DelayedTransaction.sol";


/// @title  DelayedOwner
/// @author Brecht Devos - <[email protected]>
contract DelayedOwner is DelayedTransaction, Claimable
{
    address public defaultContract;

    event FunctionDelayUpdate(
        bytes4  functionSelector,
        uint    delay
    );

    constructor(
        address _defaultContract,
        uint    _timeToLive
        )
        DelayedTransaction(_timeToLive)
    {
        require(_defaultContract != address(0), "INVALID_ADDRESS");

        defaultContract = _defaultContract;
    }

    receive()
        external
        // nonReentrant
        payable
    {
        // Don't do anything when receiving ETH
    }

    fallback()
        external
        nonReentrant
        payable
    {
        // Don't do anything if msg.sender isn't the owner
        if (msg.sender != owner) {
            return;
        }
        transactInternal(defaultContract, msg.value, msg.data);
    }

    function isAuthorizedForTransactions(address sender)
        internal
        override
        view
        returns (bool)
    {
        return sender == owner;
    }

    function setFunctionDelay(
        bytes4  functionSelector,
        uint    delay
        )
        internal
    {
        setFunctionDelay(defaultContract, functionSelector, delay);

        emit FunctionDelayUpdate(functionSelector, delay);
    }
}

File 49 of 95 : DelayedTransaction.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../../lib/AddressUtil.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../../thirdparty/BytesUtil.sol";
import "./IDelayedTransaction.sol";


/// @title DelayedOwner
/// @author Brecht Devos - <[email protected]>
/// @dev Base class for an Owner contract where certain functions have
///      a mandatory delay for security purposes.
abstract contract DelayedTransaction is IDelayedTransaction, ReentrancyGuard
{
    using AddressUtil for address payable;
    using BytesUtil   for bytes;
    using MathUint    for uint;

    // Map from address and function to the functions's location+1 in the `delayedFunctions` array.
    mapping (address => mapping (bytes4 => uint)) private delayedFunctionMap;

    // Map from transaction ID to the transaction's location+1 in the `pendingTransactions` array.
    mapping (uint => uint) private pendingTransactionMap;

    // Used to generate a unique identifier for a delayed transaction
    uint private totalNumDelayedTransactions = 0;

    modifier onlyAuthorized
    {
        require(isAuthorizedForTransactions(msg.sender), "UNAUTHORIZED");
        _;
    }

    constructor(
        uint    _timeToLive
        )
    {
        timeToLive = _timeToLive;
    }

    // If the function that is called has no delay the function is called immediately,
    // otherwise the function call is stored on-chain and can be executed later using
    // `executeTransaction` when the necessary time has passed.
    function transact(
        address to,
        bytes   calldata data
        )
        external
        override
        nonReentrant
        payable
        onlyAuthorized
    {
        transactInternal(to, msg.value, data);
    }

    function executeTransaction(
        uint transactionId
        )
        external
        override
        nonReentrant
        onlyAuthorized
    {
        Transaction memory transaction = getTransaction(transactionId);

        // Make sure the delay is respected
        bytes4 functionSelector = transaction.data.toBytes4(0);
        uint delay = getFunctionDelay(transaction.to, functionSelector);
        require(block.timestamp >= transaction.timestamp.add(delay), "TOO_EARLY");
        require(block.timestamp <= transaction.timestamp.add(delay).add(timeToLive), "TOO_LATE");

        // Remove the transaction
        removeTransaction(transaction.id);

        // Exectute the transaction
        (bool success, bytes memory returnData) = exectuteTransaction(transaction);
        if (!success) {
            assembly { revert(add(returnData, 32), mload(returnData)) }
        }

        emit PendingTransactionExecuted(
            transaction.id,
            transaction.timestamp,
            transaction.to,
            transaction.value,
            transaction.data
        );
    }

    function cancelTransaction(
        uint transactionId
        )
        external
        override
        nonReentrant
        onlyAuthorized
    {
        cancelTransactionInternal(transactionId);
    }

    function cancelAllTransactions()
        external
        override
        nonReentrant
        onlyAuthorized
    {
        // First cache all transactions ids of the transactions we will remove
        uint[] memory transactionIds = new uint[](pendingTransactions.length);
        for(uint i = 0; i < pendingTransactions.length; i++) {
            transactionIds[i] = pendingTransactions[i].id;
        }
        // Now remove all delayed transactions
        for(uint i = 0; i < transactionIds.length; i++) {
            cancelTransactionInternal(transactionIds[i]);
        }
    }

    function getFunctionDelay(
        address to,
        bytes4  functionSelector
        )
        public
        override
        view
        returns (uint)
    {
        uint pos = delayedFunctionMap[to][functionSelector];
        if (pos == 0) {
            return 0;
        } else {
            return delayedFunctions[pos - 1].delay;
        }
    }

    function getNumPendingTransactions()
        external
        override
        view
        returns (uint)
    {
        return pendingTransactions.length;
    }

    function getNumDelayedFunctions()
        external
        override
        view
        returns (uint)
    {
        return delayedFunctions.length;
    }

    // == Internal Functions ==

    function transactInternal(
        address to,
        uint    value,
        bytes   memory data
        )
        internal
    {
        Transaction memory transaction = Transaction(
            totalNumDelayedTransactions,
            block.timestamp,
            to,
            value,
            data
        );

        bytes4 functionSelector = transaction.data.toBytes4(0);
        uint delay = getFunctionDelay(transaction.to, functionSelector);
        if (delay == 0) {
            (bool success, bytes memory returnData) = exectuteTransaction(transaction);
            if (!success) {
                assembly { revert(add(returnData, 32), mload(returnData)) }
            }
            emit TransactionExecuted(
                transaction.timestamp,
                transaction.to,
                transaction.value,
                transaction.data
            );
        } else {
            pendingTransactions.push(transaction);
            pendingTransactionMap[transaction.id] = pendingTransactions.length;
            emit TransactionDelayed(
                transaction.id,
                transaction.timestamp,
                transaction.to,
                transaction.value,
                transaction.data,
                delay
            );
            totalNumDelayedTransactions++;
        }
    }

    function setFunctionDelay(
        address to,
        bytes4  functionSelector,
        uint    delay
        )
        internal
    {
        // Check if the function already has a delay
        uint pos = delayedFunctionMap[to][functionSelector];
        if (pos > 0) {
            if (delay > 0) {
                // Just update the delay
                delayedFunctions[pos - 1].delay = delay;
            } else {
                // Remove the delayed function
                uint size = delayedFunctions.length;
                if (pos != size) {
                    DelayedFunction memory lastOne = delayedFunctions[size - 1];
                    delayedFunctions[pos - 1] = lastOne;
                    delayedFunctionMap[lastOne.to][lastOne.functionSelector] = pos;
                }
                delayedFunctions.pop();
                delete delayedFunctionMap[to][functionSelector];
            }
        } else if (delay > 0) {
            // Add the new delayed function
            DelayedFunction memory delayedFunction = DelayedFunction(
                to,
                functionSelector,
                delay
            );
            delayedFunctions.push(delayedFunction);
            delayedFunctionMap[to][functionSelector] = delayedFunctions.length;
        }
    }

    function exectuteTransaction(
        Transaction memory transaction
        )
        internal
        returns (bool success, bytes memory returnData)
    {
        // solium-disable-next-line security/no-call-value
        (success, returnData) = transaction.to.call{value: transaction.value}(transaction.data);
    }

    function cancelTransactionInternal(
        uint transactionId
        )
        internal
    {
        Transaction memory transaction = getTransaction(transactionId);

        // Remove the transaction
        removeTransaction(transaction.id);

        emit TransactionCancelled(
            transaction.id,
            transaction.timestamp,
            transaction.to,
            transaction.value,
            transaction.data
        );

        // Return the transaction value (if there is any)
        uint value = transaction.value;
        if (value > 0) {
            msg.sender.sendETHAndVerify(value, gasleft());
        }
    }

    function getTransaction(
        uint transactionId
        )
        internal
        view
        returns (Transaction storage transaction)
    {
        uint pos = pendingTransactionMap[transactionId];
        require(pos != 0, "TRANSACTION_NOT_FOUND");
        transaction = pendingTransactions[pos - 1];
    }

    function removeTransaction(
        uint transactionId
        )
        internal
    {
        uint pos = pendingTransactionMap[transactionId];
        require(pos != 0, "TRANSACTION_NOT_FOUND");

        uint size = pendingTransactions.length;
        if (pos != size) {
            Transaction memory lastOne = pendingTransactions[size - 1];
            pendingTransactions[pos - 1] = lastOne;
            pendingTransactionMap[lastOne.id] = pos;
        }

        pendingTransactions.pop();
        delete pendingTransactionMap[transactionId];
    }

    function isAuthorizedForTransactions(address sender)
        internal
        virtual
        view
        returns (bool);
}

File 50 of 95 : IDelayedTransaction.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;


/// @title IDelayedTransaction
/// @author Brecht Devos - <[email protected]>
abstract contract IDelayedTransaction
{
    event TransactionDelayed(
        uint    id,
        uint    timestamp,
        address to,
        uint    value,
        bytes   data,
        uint    delay
    );

    event TransactionCancelled(
        uint    id,
        uint    timestamp,
        address to,
        uint    value,
        bytes   data
    );

    event TransactionExecuted(
        uint    timestamp,
        address to,
        uint    value,
        bytes   data
    );

    event PendingTransactionExecuted(
        uint    id,
        uint    timestamp,
        address to,
        uint    value,
        bytes   data
    );

    struct Transaction
    {
        uint    id;
        uint    timestamp;
        address to;
        uint    value;
        bytes   data;
    }

    struct DelayedFunction
    {
        address to;
        bytes4  functionSelector;
        uint    delay;
    }

    // The maximum amount of time (in seconds) a pending transaction can be executed
    // (so the amount of time than can pass after the mandatory function specific delay).
    // If the transaction hasn't been executed before then it can be cancelled so it is removed
    // from the pending transaction list.
    uint public timeToLive;

    // Active list of delayed functions (delay > 0)
    DelayedFunction[] public delayedFunctions;

    // Active list of pending transactions
    Transaction[] public pendingTransactions;

    /// @dev Executes a pending transaction.
    /// @param to The contract address to call
    /// @param data The call data
    function transact(
        address to,
        bytes   calldata data
        )
        external
        virtual
        payable;

    /// @dev Executes a pending transaction.
    /// @param transactionId The id of the pending transaction.
    function executeTransaction(
        uint transactionId
        )
        external
        virtual;

    /// @dev Cancels a pending transaction.
    /// @param transactionId The id of the pending transaction.
    function cancelTransaction(
        uint transactionId
        )
        external
        virtual;

    /// @dev Cancels all pending transactions.
    function cancelAllTransactions()
        external
        virtual;

    /// @dev Gets the delay for the given function
    /// @param functionSelector The function selector.
    /// @return The delay of the function.
    function getFunctionDelay(
        address to,
        bytes4  functionSelector
        )
        public
        virtual
        view
        returns (uint);

    /// @dev Gets the number of pending transactions.
    /// @return The number of pending transactions.
    function getNumPendingTransactions()
        external
        virtual
        view
        returns (uint);

    /// @dev Gets the number of functions that have a delay.
    /// @return The number of delayed functions.
    function getNumDelayedFunctions()
        external
        virtual
        view
        returns (uint);
}

File 51 of 95 : DelayedTargetContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../lib/Claimable.sol";


/// @title DelayedTargetContract
/// @author Brecht Devos - <[email protected]>
contract DelayedTargetContract is Claimable
{
    uint public constant MAGIC_VALUE = 0xFEDCBA987654321;
    uint public value = 7;

    function delayedFunctionPayable(
        uint _value
        )
        external
        payable
        returns (uint)
    {
        value = _value;
        return _value;
    }

    function delayedFunctionRevert(
        uint _value
        )
        external
    {
        require(false, "DELAYED_REVERT");
        value = _value;
    }

    function immediateFunctionPayable(
        uint _value
        )
        external
        payable
    {
        value = _value;
    }

    function immediateFunctionView()
        external
        pure
        returns (uint)
    {
        return MAGIC_VALUE;
    }

    function immediateFunctionRevert(
        uint _value
        )
        external
        payable
    {
        require(false, "IMMEDIATE_REVERT");
        value = _value;
    }
}

File 52 of 95 : DummyToken.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./LRCToken.sol";


/// @author Kongliang Zhong - <[email protected]>
contract DummyToken is LRCToken {
    using SafeMath for uint;

    constructor(
        string memory _name,
        string memory _symbol,
        uint8         _decimals,
        uint          _totalSupply
    ) LRCToken(
        _name,
        _symbol,
        _decimals,
        _totalSupply,
        msg.sender
        )
    {
    }

    function setBalance(
        address _target,
        uint _value
        )
        public
    {
        uint currBalance = balanceOf(_target);
        if (_value < currBalance) {
            totalSupply_ = totalSupply_.sub(currBalance.sub(_value));
        } else {
            totalSupply_ = totalSupply_.add(_value.sub(currBalance));
        }
        balances[_target] = _value;
    }

    function addBalance(
        address _target,
        uint _value
        )
        public
    {
        uint currBalance = balanceOf(_target);
        require(_value + currBalance >= currBalance, "INVALID_VALUE");
        totalSupply_ = totalSupply_.add(_value);
        balances[_target] = currBalance.add(_value);
    }

}

File 53 of 95 : LRCToken.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

/**
 * @title ERC20Basic
 * @dev Simpler version of ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/179
 */
abstract contract ERC20Basic {
    function totalSupply() public view virtual returns (uint);
    function balanceOf(address who) public view virtual returns (uint);
    function transfer(address to, uint value) public virtual returns (bool);
    event Transfer(address indexed from, address indexed to, uint value);
}
/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {
    /**
     * @dev Multiplies two numbers, throws on overflow.
     */
    function mul(uint a, uint b) internal pure returns (uint) {
        if (a == 0) {
            return 0;
        }
        uint c = a * b;
        assert(c / a == b);
        return c;
    }
    /**
     * @dev Integer division of two numbers, truncating the quotient.
     */
    function div(uint a, uint b) internal pure returns (uint) {
        // assert(b > 0); // Solidity automatically throws when dividing by 0
        uint c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold
        return c;
    }
    /**
     * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
     */
    function sub(uint a, uint b) internal pure returns (uint) {
        assert(b <= a);
        return a - b;
    }
    /**
     * @dev Adds two numbers, throws on overflow.
     */
    function add(uint a, uint b) internal pure returns (uint) {
        uint c = a + b;
        assert(c >= a);
        return c;
    }
}
/**
 * @title Basic token
 * @dev Basic version of StandardToken, with no allowances.
 */
contract BasicToken is ERC20Basic {
    using SafeMath for uint;
    mapping(address => uint) balances;
    uint totalSupply_;
    /**
     * @dev total number of tokens in existence
     */
    function totalSupply() public view override virtual returns (uint) {
        return totalSupply_;
    }
    /**
     * @dev transfer token for a specified address
     * @param _to The address to transfer to.
     * @param _value The amount to be transferred.
     */
    function transfer(address _to, uint _value) public override virtual returns (bool) {
        // require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[msg.sender], "TRANSFER_INSUFFICIENT_BALANCE");
        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }
    /**
     * @dev Gets the balance of the specified address.
     * @param _owner The address to query the the balance of.
     * @return balance An uint representing the amount owned by the passed address.
     */
    function balanceOf(address _owner) public view override virtual returns (uint balance) {
        return balances[_owner];
    }
}
/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
abstract contract ERC20 is ERC20Basic {
    function allowance(address owner, address spender) public view virtual returns (uint);
    function transferFrom(address from, address to, uint value) public virtual returns (bool);
    function approve(address spender, uint value) public virtual returns (bool);
    event Approval(address indexed owner, address indexed spender, uint value);
}
/**
 * @title Standard ERC20 token
 *
 * @dev Implementation of the basic standard token.
 * @dev https://github.com/ethereum/EIPs/issues/20
 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is ERC20, BasicToken {
    using SafeMath for uint;
    mapping (address => mapping (address => uint)) internal allowed;
    /**
     * @dev Transfer tokens from one address to another
     * @param _from address The address which you want to send tokens from
     * @param _to address The address which you want to transfer to
     * @param _value uint the amount of tokens to be transferred
     */
    function transferFrom(address _from, address _to, uint _value) public override virtual returns (bool) {
        // require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[_from], "TRANSFERFROM_INSUFFICIENT_BALANCE");
        require(_value <= allowed[_from][msg.sender], "TRANSFERFROM_INSUFFICIENT_ALLOWANCE");
        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        emit Transfer(_from, _to, _value);
        return true;
    }
    /**
     * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
     *
     * Beware that changing an allowance with this method brings the risk that someone may use both the old
     * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
     * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     * @param _spender The address which will spend the funds.
     * @param _value The amount of tokens to be spent.
     */
    function approve(address _spender, uint _value) public override returns (bool) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }
    /**
     * @dev Function to check the amount of tokens that an owner allowed to a spender.
     * @param _owner address The address which owns the funds.
     * @param _spender address The address which will spend the funds.
     * @return A uint specifying the amount of tokens still available for the spender.
     */
    function allowance(address _owner, address _spender) public view override returns (uint) {
        return allowed[_owner][_spender];
    }
    /**
     * @dev Increase the amount of tokens that an owner allowed to a spender.
     *
     * approve should be called when allowed[_spender] == 0. To increment
     * allowed value is better to use this function to avoid 2 calls (and wait until
     * the first transaction is mined)
     * From MonolithDAO Token.sol
     * @param _spender The address which will spend the funds.
     * @param _addedValue The amount of tokens to increase the allowance by.
     */
    function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
        allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }
    /**
     * @dev Decrease the amount of tokens that an owner allowed to a spender.
     *
     * approve should be called when allowed[_spender] == 0. To decrement
     * allowed value is better to use this function to avoid 2 calls (and wait until
     * the first transaction is mined)
     * From MonolithDAO Token.sol
     * @param _spender The address which will spend the funds.
     * @param _subtractedValue The amount of tokens to decrease the allowance by.
     */
    function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
        uint oldValue = allowed[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowed[msg.sender][_spender] = 0;
        } else {
            allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
        }
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }
}

contract LRCToken is StandardToken {
    using SafeMath for uint;

    string     public name = "New Loopring token on ethereum";
    string     public symbol = "LRC";
    uint8      public decimals = 18;

    event Burn(address indexed burner, uint value);

    function burn(uint _value) public returns (bool) {
        require(_value <= balances[msg.sender], "BURN_INSUFFICIENT_BALANCE");

        address burner = msg.sender;
        balances[burner] = balances[burner].sub(_value);
        totalSupply_ = totalSupply_.sub(_value);
        emit Burn(burner, _value);
        emit Transfer(burner, address(0), _value);
        return true;
    }

    function burnFrom(address _owner, uint _value) public returns (bool) {
        require(_owner != address(0), "ZERO_ADDRESS");
        require(_value <= balances[_owner], "BURNFROM_INSUFFICIENT_BALANCE");
        require(_value <= allowed[_owner][msg.sender], "BURNFROM_INSUFFICIENT_ALLOWANCE");

        balances[_owner] = balances[_owner].sub(_value);
        allowed[_owner][msg.sender] = allowed[_owner][msg.sender].sub(_value);
        totalSupply_ = totalSupply_.sub(_value);

        emit Burn(_owner, _value);
        emit Transfer(_owner, address(0), _value);
        return true;
    }

    constructor(
        string memory _name,
        string memory _symbol,
        uint8         _decimals,
        uint          _totalSupply,
        address       _firstHolder
        )
    {
        require(_totalSupply > 0, "INVALID_VALUE");
        require(_firstHolder != address(0), "ZERO_ADDRESS");
        checkSymbolAndName(_symbol,_name);

        name = _name;
        symbol = _symbol;
        decimals = _decimals;
        totalSupply_ = _totalSupply;

        balances[_firstHolder] = totalSupply_;
    }

    // Make sure symbol has 3-8 chars in [A-Za-z._] and name has up to 128 chars.
    function checkSymbolAndName(
        string memory _symbol,
        string memory _name
        )
        internal
        pure
    {
        bytes memory s = bytes(_symbol);
        require(s.length >= 3 && s.length <= 8, "INVALID_SIZE");
        for (uint i = 0; i < s.length; i++) {
            // make sure symbol contains only [A-Za-z._]
            require(
                s[i] == 0x2E || (
                s[i] == 0x5F) || (
                s[i] >= 0x41 && s[i] <= 0x5A) || (
                s[i] >= 0x61 && s[i] <= 0x7A), "INVALID_VALUE");
        }
        bytes memory n = bytes(_name);
        require(n.length >= s.length && n.length <= 128, "INVALID_SIZE");
        for (uint i = 0; i < n.length; i++) {
            require(n[i] >= 0x20 && n[i] <= 0x7E, "INVALID_VALUE");
        }
    }
}

File 54 of 95 : TransferContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../lib/AddressUtil.sol";
import "../lib/ERC20SafeTransfer.sol";


contract TransferContract {

    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using ERC20SafeTransfer for address;

    uint8 public constant TEST_NOTHING = 0;
    uint8 public constant TEST_REQUIRE_FAIL = 1;
    uint8 public constant TEST_EXPENSIVE_TRANSFER = 2;

    uint public testCase = TEST_NOTHING;

    uint[16] private dummyStorageVariables;

    function safeTransferWithGasLimit(
        address token,
        address to,
        uint    value,
        uint    gasLimit
        )
        external
    {
        token.safeTransferWithGasLimitAndVerify(to, value, gasLimit);
    }

    function safeTransferFromWithGasLimit(
        address token,
        address from,
        address to,
        uint    value,
        uint    gasLimit
        )
        external
    {
        token.safeTransferFromWithGasLimitAndVerify(from, to, value, gasLimit);
    }

    function sendETH(
        address to,
        uint    amount,
        uint    gasLimit
        )
        external
    {
        to.sendETHAndVerify(amount, gasLimit);
    }

    function setTestCase(
        uint8 _testCase
        )
        external
    {
        testCase = _testCase;
    }

    receive()
        external
        payable
    {
        if (testCase == TEST_NOTHING) {
            return;
        } else if (testCase == TEST_REQUIRE_FAIL) {
            revert("ETH_FAILURE");
        } else if (testCase == TEST_EXPENSIVE_TRANSFER) {
            // Some expensive operation
            for (uint i = 0; i < 16; i++) {
                dummyStorageVariables[i] = block.number;
            }
        }
    }
}

File 55 of 95 : PoseidonContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../lib/Poseidon.sol";
import "../core/iface/ExchangeData.sol";


contract PoseidonContract {
    function hash_t5f6p52(
        uint t0,
        uint t1,
        uint t2,
        uint t3,
        uint t4
        )
        external
        pure
        returns (uint)
    {
        Poseidon.HashInputs5 memory inputs = Poseidon.HashInputs5(t0, t1, t2, t3, t4);
        return Poseidon.hash_t5f6p52(inputs, ExchangeData.SNARK_SCALAR_FIELD);
    }

    function hash_t6f6p52(
        uint t0,
        uint t1,
        uint t2,
        uint t3,
        uint t4,
        uint t5
        )
        external
        pure
        returns (uint)
    {
        Poseidon.HashInputs6 memory inputs = Poseidon.HashInputs6(t0, t1, t2, t3, t4, t5);
        return Poseidon.hash_t6f6p52(inputs, ExchangeData.SNARK_SCALAR_FIELD);
    }
}

File 56 of 95 : LPERC20.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import '../lib/ERC20.sol';
import '../lib/MathUint.sol';

contract LPERC20 is ERC20 {
    using MathUint for uint;

    string public constant name = 'Loopring AMM';
    string public constant symbol = 'LLT';
    uint8 public constant decimals = 18;
    uint  public _totalSupply;
    mapping(address => uint) public _balanceOf;
    mapping(address => mapping(address => uint)) public _allowance;

    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function totalSupply() public virtual view override returns (uint) {
        return _totalSupply;
    }

    function balanceOf(address owner) public view override virtual returns (uint balance) {
        return _balanceOf[owner];
    }

    function allowance(address owner, address spender) public view override returns (uint) {
        return _allowance[owner][spender];
    }

    function approve(address spender, uint value) public override returns (bool) {
        _approve(msg.sender, spender, value);
        return true;
    }

    function transfer(address to, uint value) public override returns (bool) {
        _transfer(msg.sender, to, value);
        return true;
    }

    function transferFrom(address from, address to, uint value) public override returns (bool) {
        if (_allowance[from][msg.sender] != uint(-1)) {
            _allowance[from][msg.sender] = _allowance[from][msg.sender].sub(value);
        }
        _transfer(from, to, value);
        return true;
    }

    function _mint(address to, uint value) internal {
        _totalSupply = _totalSupply.add(value);
        _balanceOf[to] = _balanceOf[to].add(value);
        emit Transfer(address(0), to, value);
    }

    function _burn(address from, uint value) internal {
        _balanceOf[from] = _balanceOf[from].sub(value);
        _totalSupply = _totalSupply.sub(value);
        emit Transfer(from, address(0), value);
    }

    function _approve(address owner, address spender, uint value) private {
        _allowance[owner][spender] = value;
        emit Approval(owner, spender, value);
    }

    function _transfer(address from, address to, uint value) private {
        _balanceOf[from] = _balanceOf[from].sub(value);
        _balanceOf[to] = _balanceOf[to].add(value);
        emit Transfer(from, to, value);
    }
}

File 57 of 95 : ZeroDecompressorContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../aux/compression/ZeroDecompressor.sol";

contract ZeroDecompressorContract {
    function decompress(
        bytes calldata data
        )
        external
        pure
        returns (bytes memory)
    {
        return ZeroDecompressor.decompress(data, 0);
    }

    function benchmark(
        bytes calldata data
        )
        external
        pure
        returns (bytes memory)
    {
        return ZeroDecompressor.decompress(data, 0);
    }
}

File 58 of 95 : ZeroDecompressor.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title ZeroDecompressor
/// @author Brecht Devos - <[email protected]>
/// @dev Easy decompressor that compresses runs of zeros.
/// The format is very simple. Each entry consists of
/// (uint16 numDataBytes, uint16 numZeroBytes) which will
/// copy `numDataBytes` data bytes from `data` and will
/// add an additional `numZeroBytes` after it.
library ZeroDecompressor
{
    function decompress(
        bytes calldata /*data*/,
        uint  parameterIdx
        )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory uncompressed;
        uint offsetPos = 4 + 32 * parameterIdx;
        assembly {
            uncompressed := mload(0x40)
            let ptr := add(uncompressed, 32)
            let offset := add(4, calldataload(offsetPos))
            let pos := add(offset, 4)
            let dataLength := add(calldataload(offset), pos)
            let tupple := 0
            let numDataBytes := 0
            let numZeroBytes := 0

            for {} lt(pos, dataLength) {} {
                tupple := and(calldataload(pos), 0xFFFFFFFF)
                numDataBytes := shr(16, tupple)
                numZeroBytes := and(tupple, 0xFFFF)
                calldatacopy(ptr, add(32, pos), numDataBytes)
                pos := add(pos, add(4, numDataBytes))
                ptr := add(ptr, add(numDataBytes, numZeroBytes))
            }

            // Store data length
            mstore(uncompressed, sub(sub(ptr, uncompressed), 32))

            // Update free memory pointer
            mstore(0x40, add(ptr, 0x20))
        }
        return uncompressed;
    }
}

File 59 of 95 : TestAccountContract.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../core/iface/IExchangeV3.sol";

import "../lib/AddressUtil.sol";
import "../lib/MathUint.sol";


contract TestAccountContract {

    using AddressUtil       for address payable;
    using MathUint          for uint;

    IExchangeV3 exchange;

    uint[16] private dummyStorageVariables;

    modifier refund()
    {
        // Send surplus to msg.sender
        uint balanceBefore = address(this).balance.sub(msg.value);
        _;
        uint balanceAfter = address(this).balance;
        msg.sender.sendETHAndVerify(balanceAfter.sub(balanceBefore), gasleft());
    }

    constructor(
        address _exchangeAddress
        )
    {
        exchange = IExchangeV3(_exchangeAddress);
    }

    function withdraw(
        address token,
        uint96 amount,
        uint32 accountID
        )
        external
        payable
        refund
    {
        //exchange.withdraw{value: msg.value}(address(this), token, amount, accountID);
    }

    receive()
        external
        payable
    {
        // Some expensive operation
        for (uint i = 0; i < 16; i++) {
            dummyStorageVariables[i] = block.number;
        }
    }
}

File 60 of 95 : INDA.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract INDA is DummyToken {

    constructor() DummyToken(
        "INDIVISIBLE_A",
        "INDA",
        0,
        10 ** 27
    )
    {
    }

}

File 61 of 95 : INDB.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract INDB is DummyToken {

    constructor() DummyToken(
        "INDIVISIBLE_B",
        "INDB",
        0,
        10 ** 27
    )
    {
    }

}

File 62 of 95 : RDN.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract RDN is DummyToken {

    constructor() DummyToken(
        "RDN_TEST",
        "RDN",
        18,
        10 ** 27
    )
    {
    }

}

File 63 of 95 : LRC.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract LRC is DummyToken {

    constructor() DummyToken(
        "LRC_TEST",
        "LRC",
        18,
        10 ** 27
    )
    {
    }

}

File 64 of 95 : GTO.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract GTO is DummyToken {

    constructor() DummyToken(
        "GTO_TEST",
        "GTO",
        18,
        10 ** 27
    )
    {
    }

}

File 65 of 95 : TEST.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";
import "../../core/iface/IExchangeV3.sol";

/// @author Brecht Devos - <[email protected]>
contract TEST is DummyToken {
    using SafeMath for uint;

    // Test cases
    uint8 public constant TEST_NOTHING = 0;
    uint8 public constant TEST_REENTRANCY = 1;
    uint8 public constant TEST_REQUIRE_FAIL = 2;
    uint8 public constant TEST_RETURN_FALSE = 3;
    uint8 public constant TEST_NO_RETURN_VALUE = 4;
    uint8 public constant TEST_INVALID_RETURN_SIZE = 5;
    uint8 public constant TEST_EXPENSIVE_TRANSFER = 6;
    uint8 public constant TEST_DIFFERENT_TRANSFER_AMOUNT = 7;

    uint public testCase = TEST_NOTHING;

    address public exchangeAddress = address(0);

    bytes public reentrancyCalldata;

    uint[16] private dummyStorageVariables;

    constructor() DummyToken(
        "TEST_TEST",
        "TEST",
        18,
        2 ** 128
    )
    {
    }

    function transfer(
        address _to,
        uint _value
        )
        public
        override
        returns (bool)
    {
        if (testCase == TEST_DIFFERENT_TRANSFER_AMOUNT) {
            _value = _value.mul(99) / 100;
        }
        // require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[msg.sender], "INVALID_VALUE");
        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return doTestCase();
    }

    function transferFrom(
        address _from,
        address _to,
        uint _value
        )
        public
        override
        returns (bool)
    {
        if (testCase == TEST_DIFFERENT_TRANSFER_AMOUNT) {
            _value = _value.mul(99) / 100;
        }
        // require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[_from], "INVALID_VALUE");
        require(_value <= allowed[_from][msg.sender], "INVALID_VALUE");
        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        emit Transfer(_from, _to, _value);
        return doTestCase();
    }

    function doTestCase()
        internal
        returns (bool)
    {
        if (testCase == TEST_NOTHING) {
            return true;
        } else if (testCase == TEST_REENTRANCY) {
            // Call the exchange function without ever throwing
            (bool success, ) = exchangeAddress.call(reentrancyCalldata);
            success; // to disable unused local variable warning

            // Copy the 100 bytes containing the revert message
            bytes memory returnData = new bytes(100);
            assembly {
                if eq(returndatasize(), 100) {
                    returndatacopy(add(returnData, 32), 0, 100)
                }
            }

            // Revert reason should match REENTRANCY
            bytes memory reentryMessageData = abi.encodeWithSelector(
                bytes4(keccak256("Error(string)")),
                "REENTRANCY"
            );

            // Throw here when the results are as expected. This way we know the test was correctly executed.
            require(keccak256(reentryMessageData) != keccak256(returnData), "REVERT_MESSAGE_OK");
            return true;
        } else if (testCase == TEST_REQUIRE_FAIL) {
            require(false, "REQUIRE_FAILED");
            return true;
        } else if (testCase == TEST_RETURN_FALSE) {
            return false;
        } else if (testCase == TEST_NO_RETURN_VALUE) {
            assembly {
                return(0, 0)
            }
        } else if (testCase == TEST_INVALID_RETURN_SIZE) {
            assembly {
                return(0, 64)
            }
        } else if (testCase == TEST_EXPENSIVE_TRANSFER) {
            // Some expensive operation
            for (uint i = 0; i < 16; i++) {
                dummyStorageVariables[i] = block.number;
            }
        }
        return true;
    }

    function setTestCase(
        uint8 _testCase
        )
        external
    {
        testCase = _testCase;
    }

    function setExchangeAddress(
        address _exchangeAddress
        )
        external
    {
        exchangeAddress = _exchangeAddress;
    }

    function setCalldata(
        bytes calldata _reentrancyCalldata
        )
        external
    {
        reentrancyCalldata = _reentrancyCalldata;
    }
}

File 66 of 95 : WETH.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract WETH is DummyToken {

    constructor() DummyToken(
        "WETH_TEST",
        "WETH",
        18,
        10 ** 27
    )
    {
    }

}

File 67 of 95 : REP.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../DummyToken.sol";

contract REP is DummyToken {

    constructor() DummyToken(
        "REP_TEST",
        "REP",
        18,
        10 ** 27
    )
    {
    }

}

File 68 of 95 : Migrations.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

contract Migrations
{
    address public owner;
    uint public last_completed_migration;

    modifier restricted()
    {
        if (msg.sender == owner) {
            _;
        }
    }

    constructor()
    {
        owner = msg.sender;
    }

    function setCompleted(uint completed)
        public
        restricted
    {
        last_completed_migration = completed;
    }

    function upgrade(address newAddress)
        public
        restricted
    {
        Migrations upgraded = Migrations(newAddress);
        upgraded.setCompleted(last_completed_migration);
    }
}

File 69 of 95 : AddressSet.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title AddressSet
/// @author Daniel Wang - <[email protected]>
contract AddressSet
{
    struct Set
    {
        address[] addresses;
        mapping (address => uint) positions;
        uint count;
    }
    mapping (bytes32 => Set) private sets;

    function addAddressToSet(
        bytes32 key,
        address addr,
        bool maintainList
        ) internal
    {
        Set storage set = sets[key];
        require(set.positions[addr] == 0, "ALREADY_IN_SET");

        if (maintainList) {
            require(set.addresses.length == set.count, "PREVIOUSLY_NOT_MAINTAILED");
            set.addresses.push(addr);
        } else {
            require(set.addresses.length == 0, "MUST_MAINTAIN");
        }

        set.count += 1;
        set.positions[addr] = set.count;
    }

    function removeAddressFromSet(
        bytes32 key,
        address addr
        )
        internal
    {
        Set storage set = sets[key];
        uint pos = set.positions[addr];
        require(pos != 0, "NOT_IN_SET");

        delete set.positions[addr];
        set.count -= 1;

        if (set.addresses.length > 0) {
            address lastAddr = set.addresses[set.count];
            if (lastAddr != addr) {
                set.addresses[pos - 1] = lastAddr;
                set.positions[lastAddr] = pos;
            }
            set.addresses.pop();
        }
    }

    function removeSet(bytes32 key)
        internal
    {
        delete sets[key];
    }

    function isAddressInSet(
        bytes32 key,
        address addr
        )
        internal
        view
        returns (bool)
    {
        return sets[key].positions[addr] != 0;
    }

    function numAddressesInSet(bytes32 key)
        internal
        view
        returns (uint)
    {
        Set storage set = sets[key];
        return set.count;
    }

    function addressesInSet(bytes32 key)
        internal
        view
        returns (address[] memory)
    {
        Set storage set = sets[key];
        require(set.count == set.addresses.length, "NOT_MAINTAINED");
        return sets[key].addresses;
    }
}

File 70 of 95 : OwnerManagable.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./AddressSet.sol";
import "./Claimable.sol";


contract OwnerManagable is Claimable, AddressSet
{
    bytes32 internal constant MANAGER = keccak256("__MANAGED__");

    event ManagerAdded  (address indexed manager);
    event ManagerRemoved(address indexed manager);

    modifier onlyManager
    {
        require(isManager(msg.sender), "NOT_MANAGER");
        _;
    }

    modifier onlyOwnerOrManager
    {
        require(msg.sender == owner || isManager(msg.sender), "NOT_OWNER_OR_MANAGER");
        _;
    }

    constructor() Claimable() {}

    /// @dev Gets the managers.
    /// @return The list of managers.
    function managers()
        public
        view
        returns (address[] memory)
    {
        return addressesInSet(MANAGER);
    }

    /// @dev Gets the number of managers.
    /// @return The numer of managers.
    function numManagers()
        public
        view
        returns (uint)
    {
        return numAddressesInSet(MANAGER);
    }

    /// @dev Checks if an address is a manger.
    /// @param addr The address to check.
    /// @return True if the address is a manager, False otherwise.
    function isManager(address addr)
        public
        view
        returns (bool)
    {
        return isAddressInSet(MANAGER, addr);
    }

    /// @dev Adds a new manager.
    /// @param manager The new address to add.
    function addManager(address manager)
        public
        onlyOwner
    {
        addManagerInternal(manager);
    }

    /// @dev Removes a manager.
    /// @param manager The manager to remove.
    function removeManager(address manager)
        public
        onlyOwner
    {
        removeAddressFromSet(MANAGER, manager);
        emit ManagerRemoved(manager);
    }

    function addManagerInternal(address manager)
        internal
    {
        addAddressToSet(MANAGER, manager, true);
        emit ManagerAdded(manager);
    }
}

File 71 of 95 : ERC20Token.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./ERC20.sol";
import "./MathUint.sol";


/// @title ERC20 Token Implementation
/// @dev see https://github.com/ethereum/EIPs/issues/20
/// @author Daniel Wang - <[email protected]>
contract ERC20Token is ERC20
{
    using MathUint for uint;

    string  public name;
    string  public symbol;
    uint8   public decimals;
    uint    public totalSupply_;

    mapping (address => uint) balances;
    mapping (address => mapping (address => uint)) internal allowed;

    event Transfer(
        address indexed from,
        address indexed to,
        uint            value
    );

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

    constructor(
        string memory _name,
        string memory _symbol,
        uint8         _decimals,
        uint          _totalSupply,
        address       _firstHolder
        )
    {
        require(_totalSupply > 0, "INVALID_VALUE");
        require(_firstHolder != address(0), "ZERO_ADDRESS");
        checkSymbolAndName(_symbol,_name);

        name = _name;
        symbol = _symbol;
        decimals = _decimals;
        totalSupply_ = _totalSupply;

        balances[_firstHolder] = totalSupply_;
    }

    /**
    * @dev total number of tokens in existence
    */
    function totalSupply()
        public
        override
        view
        returns (uint)
    {
        return totalSupply_;
    }

    /**
    * @dev transfer token for a specified address
    * @param _to The address to transfer to.
    * @param _value The amount to be transferred.
    */
    function transfer(
        address _to,
        uint    _value
        )
        public
        override
        returns (bool)
    {
        require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[msg.sender], "INVALID_VALUE");

        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }

    /**
    * @dev Gets the balance of the specified address.
    * @param _owner The address to query the the balance of.
    * @return balance An uint representing the amount owned by the passed address.
    */
    function balanceOf(
        address _owner
        )
        public
        override
        view
        returns (uint balance)
    {
        return balances[_owner];
    }

    /**
     * @dev Transfer tokens from one address to another
     * @param _from address The address which you want to send tokens from
     * @param _to address The address which you want to transfer to
     * @param _value uint the amount of tokens to be transferred
     */
    function transferFrom(
        address _from,
        address _to,
        uint    _value
        )
        public
        override
        returns (bool)
    {
        require(_to != address(0), "ZERO_ADDRESS");
        require(_value <= balances[_from], "INVALID_VALUE");
        require(_value <= allowed[_from][msg.sender], "INVALID_VALUE");

        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        emit Transfer(_from, _to, _value);
        return true;
    }

    /**
     * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
     *
     * Beware that changing an allowance with this method brings the risk that someone may use both the old
     * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
     * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     * @param _spender The address which will spend the funds.
     * @param _value The amount of tokens to be spent.
     */
    function approve(
        address _spender,
        uint    _value
        )
        public
        override
        returns (bool)
    {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    /**
     * @dev Function to check the amount of tokens that an owner allowed to a spender.
     * @param _owner address The address which owns the funds.
     * @param _spender address The address which will spend the funds.
     * @return A uint specifying the amount of tokens still available for the spender.
     */
    function allowance(
        address _owner,
        address _spender
        )
        public
        override
        view
        returns (uint)
    {
        return allowed[_owner][_spender];
    }

    /**
     * @dev Increase the amount of tokens that an owner allowed to a spender.
     *
     * approve should be called when allowed[_spender] == 0. To increment
     * allowed value is better to use this function to avoid 2 calls (and wait until
     * the first transaction is mined)
     * From MonolithDAO Token.sol
     * @param _spender The address which will spend the funds.
     * @param _addedValue The amount of tokens to increase the allowance by.
     */
    function increaseApproval(
        address _spender,
        uint    _addedValue
        )
        public
        returns (bool)
    {
        allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }

    /**
     * @dev Decrease the amount of tokens that an owner allowed to a spender.
     *
     * approve should be called when allowed[_spender] == 0. To decrement
     * allowed value is better to use this function to avoid 2 calls (and wait until
     * the first transaction is mined)
     * From MonolithDAO Token.sol
     * @param _spender The address which will spend the funds.
     * @param _subtractedValue The amount of tokens to decrease the allowance by.
     */
    function decreaseApproval(
        address _spender,
        uint    _subtractedValue
        )
        public
        returns (bool)
    {
        uint oldValue = allowed[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowed[msg.sender][_spender] = 0;
        } else {
            allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
        }
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }

    // Make sure symbol has 3-8 chars in [A-Za-z._] and name has up to 128 chars.
    function checkSymbolAndName(
        string memory _symbol,
        string memory _name
        )
        internal
        pure
    {
        bytes memory s = bytes(_symbol);
        require(s.length >= 3 && s.length <= 8, "INVALID_SIZE");
        for (uint i = 0; i < s.length; i++) {
            // make sure symbol contains only [A-Za-z._]
            require(
                s[i] == 0x2E || (
                s[i] == 0x5F) || (
                s[i] >= 0x41 && s[i] <= 0x5A) || (
                s[i] >= 0x61 && s[i] <= 0x7A), "INVALID_VALUE");
        }
        bytes memory n = bytes(_name);
        require(n.length >= s.length && n.length <= 128, "INVALID_SIZE");
        for (uint i = 0; i < n.length; i++) {
            require(n[i] >= 0x20 && n[i] <= 0x7E, "INVALID_VALUE");
        }
    }
}

File 72 of 95 : SimpleProxy.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../thirdparty/proxies/Proxy.sol";


/// @title SimpleProxy
/// @author Daniel Wang  - <[email protected]>
contract SimpleProxy is Proxy
{
    bytes32 private constant implementationPosition = keccak256(
        "org.loopring.protocol.simple.proxy"
    );

    constructor(address _implementation) {
        if (_implementation != address(0)) {
            setImplementation(_implementation);
        }
    }

    function setImplementation(address _implementation)
        public
    {
        address _impl = implementation();
        require(_impl == address(0), "INITIALIZED_ALREADY");

        bytes32 position = implementationPosition;
        assembly {sstore(position, _implementation) }
    }

    function implementation()
        public
        override
        view
        returns (address)
    {
        address impl;
        bytes32 position = implementationPosition;
        assembly { impl := sload(position) }
        return impl;
    }
}

File 73 of 95 : ERC2612.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./ERC20.sol";


/// @title ERC2612 Token with permit – 712-signed approvals but with
///        bytes as signature
/// @dev see https://eips.ethereum.org/EIPS/eip-2612
/// @author Daniel Wang - <[email protected]>
abstract contract ERC2612 is ERC20
{
    function nonces(address owner)
        public
        view
        virtual
        returns (uint);

    function permit(
        address        owner,
        address        spender,
        uint256        value,
        uint256        deadline,
        bytes calldata signature
        )
        external
        virtual;
}

File 74 of 95 : BurnableERC20.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./ERC20.sol";


/// @title Burnable ERC20 Token Interface
/// @author Brecht Devos - <[email protected]>
abstract contract BurnableERC20 is ERC20
{
    function burn(
        uint value
        )
        public
        virtual
        returns (bool);

    function burnFrom(
        address from,
        uint value
        )
        public
        virtual
        returns (bool);
}

File 75 of 95 : MathUint96.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title Utility Functions for uint
/// @author Daniel Wang - <[email protected]>
library MathUint96
{
    function add(
        uint96 a,
        uint96 b
        )
        internal
        pure
        returns (uint96 c)
    {
        c = a + b;
        require(c >= a, "ADD_OVERFLOW");
    }

    function sub(
        uint96 a,
        uint96 b
        )
        internal
        pure
        returns (uint96 c)
    {
        require(b <= a, "SUB_UNDERFLOW");
        return a - b;
    }
}

File 76 of 95 : Create2.sol
// SPDX-License-Identifier: UNLICENSED
// Taken from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/970f687f04d20e01138a3e8ccf9278b1d4b3997b/contracts/utils/Create2.sol

pragma solidity ^0.7.0;

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}. Note that
     * a contract cannot be deployed twice using the same salt.
     */
    function deploy(bytes32 salt, bytes memory bytecode) internal returns (address payable) {
        address payable addr;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "CREATE2_FAILED");
        return addr;
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecode`
     * or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes memory bytecode) internal view returns (address) {
        return computeAddress(salt, bytecode, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(bytes32 salt, bytes memory bytecodeHash, address deployer) internal pure returns (address) {
        bytes32 bytecodeHashHash = keccak256(bytecodeHash);
        bytes32 _data = keccak256(
            abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHashHash)
        );
        return address(bytes20(_data << 96));
    }
}

File 77 of 95 : Drainable.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "./AddressUtil.sol";
import "./ERC20.sol";
import "./ERC20SafeTransfer.sol";


/// @title Drainable
/// @author Brecht Devos - <[email protected]>
/// @dev Standard functionality to allow draining funds from a contract.
abstract contract Drainable
{
    using AddressUtil       for address;
    using ERC20SafeTransfer for address;

    event Drained(
        address to,
        address token,
        uint    amount
    );

    function drain(
        address to,
        address token
        )
        public
        returns (uint amount)
    {
        require(canDrain(msg.sender, token), "UNAUTHORIZED");

        if (token == address(0)) {
            amount = address(this).balance;
            to.sendETHAndVerify(amount, gasleft());   // ETH
        } else {
            amount = ERC20(token).balanceOf(address(this));
            token.safeTransferAndVerify(to, amount);  // ERC20 token
        }

        emit Drained(to, token, amount);
    }

    // Needs to return if the address is authorized to call drain.
    function canDrain(address drainer, address token)
        public
        virtual
        view
        returns (bool);
}

File 78 of 95 : LoopringIOExchangeOwner.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../aux/compression/ZeroDecompressor.sol";
import "../../core/iface/IExchangeV3.sol";
import "../../thirdparty/BytesUtil.sol";
import "../../lib/AddressUtil.sol";
import "../../lib/Drainable.sol";
import "../../lib/ERC1271.sol";
import "../../lib/MathUint.sol";
import "../../lib/SignatureUtil.sol";
import "./SelectorBasedAccessManager.sol";
import "./IBlockReceiver.sol";


contract LoopringIOExchangeOwner is SelectorBasedAccessManager, ERC1271, Drainable
{
    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using BytesUtil         for bytes;
    using MathUint          for uint;
    using SignatureUtil     for bytes32;

    bytes4    private constant SUBMITBLOCKS_SELECTOR = IExchangeV3.submitBlocks.selector;
    bool      public  open;

    event SubmitBlocksAccessOpened(bool open);

    struct TxCallback
    {
        uint16 txIdx;
        uint16 numTxs;
        uint16 receiverIdx;
        bytes  data;
    }

    struct BlockCallback
    {
        uint16        blockIdx;
        TxCallback[]  txCallbacks;
    }

    struct CallbackConfig
    {
        BlockCallback[] blockCallbacks;
        address[]       receivers;
    }

    constructor(
        address _exchange
        )
        SelectorBasedAccessManager(_exchange)
    {
    }

    function openAccessToSubmitBlocks(bool _open)
        external
        onlyOwner
    {
        open = _open;
        emit SubmitBlocksAccessOpened(_open);
    }

    function isValidSignature(
        bytes32        signHash,
        bytes   memory signature
        )
        external
        view
        override
        returns (bytes4)
    {
        // Role system used a bit differently here.
        return hasAccessTo(
            signHash.recoverECDSASigner(signature),
            this.isValidSignature.selector
        ) ? ERC1271_MAGICVALUE : bytes4(0);
    }

    function canDrain(address drainer, address /* token */)
        public
        override
        view
        returns (bool)
    {
        return hasAccessTo(drainer, this.drain.selector);
    }

    function submitBlocks(
        bool                     isDataCompressed,
        bytes           calldata data
        )
        external
    {
        require(
            hasAccessTo(msg.sender, SUBMITBLOCKS_SELECTOR) || open,
            "PERMISSION_DENIED"
        );
        bytes memory decompressed = isDataCompressed ?
            ZeroDecompressor.decompress(data, 1):
            data;

        require(
            decompressed.toBytes4(0) == SUBMITBLOCKS_SELECTOR,
            "INVALID_DATA"
        );

        target.fastCallAndVerify(gasleft(), 0, decompressed);
    }
}

File 79 of 95 : SelectorBasedAccessManager.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;

import "../../core/iface/IExchangeV3.sol";
import "../../lib/Claimable.sol";
import "../../thirdparty/BytesUtil.sol";


/// @title  SelectorBasedAccessManager
/// @author Daniel Wang - <[email protected]>
contract SelectorBasedAccessManager is Claimable
{
    using BytesUtil for bytes;

    event PermissionUpdate(
        address indexed user,
        bytes4  indexed selector,
        bool            allowed
    );

    event TargetCalled(
        address target,
        bytes data
    );

    address public immutable target;
    mapping(address => mapping(bytes4 => bool)) public permissions;

    modifier withAccess(bytes4 selector)
    {
        require(hasAccessTo(msg.sender, selector), "PERMISSION_DENIED");
        _;
    }

    constructor(address _target)
    {
        require(_target != address(0), "ZERO_ADDRESS");
        target = _target;
    }

    function grantAccess(
        address user,
        bytes4  selector,
        bool    granted
        )
        external
        onlyOwner
    {
        require(permissions[user][selector] != granted, "INVALID_VALUE");
        permissions[user][selector] = granted;
        emit PermissionUpdate(user, selector, granted);
    }

    receive() payable external {}

    fallback()
        payable
        external
    {
        transact(msg.data);
    }

    function transact(bytes memory data)
        payable
        public
        withAccess(data.toBytes4(0))
    {
        (bool success, bytes memory returnData) = target
            .call{value: msg.value}(data);

        if (!success) {
            assembly { revert(add(returnData, 32), mload(returnData)) }
        }

        emit TargetCalled(target, data);
    }

    function hasAccessTo(address user, bytes4 selector)
        public
        view
        returns (bool)
    {
        return user == owner || permissions[user][selector];
    }
}

File 80 of 95 : IBlockReceiver.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../core/iface/ExchangeData.sol";

/// @title IBlockReceiver
/// @author Brecht Devos - <[email protected]>
abstract contract IBlockReceiver
{
    function beforeBlockSubmission(
        bytes              calldata txsData,
        bytes              calldata callbackData
        )
        external
        virtual;
}

File 81 of 95 : ITokenSeller.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;


/// @title ITokenSeller
/// @dev Use this contract to sell tokenS for as many tokenB.
/// @author Daniel Wang  - <[email protected]>
interface ITokenSeller
{
    /// @dev Sells all tokenS for tokenB
    /// @param tokenS The token or Ether (0x0) to sell.
    /// @param tokenB The token to buy.
    /// @return success True if success, false otherwise.
    function sellToken(
        address tokenS,
        address tokenB
        )
        external
        payable
        returns (bool success);
}

File 82 of 95 : AgentRegistry.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../core/iface/IAgentRegistry.sol";
import "../../lib/AddressSet.sol";
import "../../lib/Claimable.sol";


contract AgentRegistry is IAgentRegistry, AddressSet, Claimable
{
    bytes32 internal constant UNIVERSAL_AGENTS = keccak256("__UNVERSAL_AGENTS__");

    event AgentRegistered(
        address indexed user,
        address indexed agent,
        bool            registered
    );

    event TrustUniversalAgents(
        address indexed user,
        bool            trust
    );

    constructor() Claimable() {}

    function isAgent(
        address user,
        address agent
        )
        external
        override
        view
        returns (bool)
    {
        return isUniversalAgent(agent) || isUserAgent(user, agent);
    }

    function isAgent(
        address[] calldata users,
        address            agent
        )
        external
        override
        view
        returns (bool)
    {
        if (isUniversalAgent(agent)) {
            return true;
        }
        for (uint i = 0; i < users.length; i++) {
            if (!isUserAgent(users[i], agent)) {
                return false;
            }
        }
        return true;
    }

    function registerUniversalAgent(
        address agent,
        bool    toRegister
        )
        external
        onlyOwner
    {
        registerInternal(UNIVERSAL_AGENTS, agent, toRegister);
        emit AgentRegistered(address(0), agent, toRegister);
    }

    function isUniversalAgent(address agent)
        public
        override
        view
        returns (bool)
    {
        return isAddressInSet(UNIVERSAL_AGENTS, agent);
    }

    function registerUserAgent(
        address agent,
        bool    toRegister
        )
        external
    {
        registerInternal(userKey(msg.sender), agent, toRegister);
        emit AgentRegistered(msg.sender, agent, toRegister);
    }

    function isUserAgent(
        address user,
        address agent
        )
        public
        view
        returns (bool)
    {
        return isAddressInSet(userKey(user), agent);
    }

    function registerInternal(
        bytes32 key,
        address agent,
        bool    toRegister
        )
        private
    {
        require(agent != address(0), "ZERO_ADDRESS");
        if (toRegister) {
            addAddressToSet(key, agent, false /* maintanList */);
        } else {
            removeAddressFromSet(key, agent);
        }
    }

    function userKey(address addr)
        private
        pure
        returns (bytes32)
    {
        return keccak256(abi.encodePacked("__AGENT__", addr));
    }
}

File 83 of 95 : ForcedWithdrawalAgent.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../core/iface/IExchangeV3.sol";
import "../../lib/ReentrancyGuard.sol";
import "../../lib/OwnerManagable.sol";
import "../../lib/AddressUtil.sol";
import "../../lib/Drainable.sol";

/// @author Kongliang Zhong - <[email protected]>
contract ForcedWithdrawalAgent is ReentrancyGuard, OwnerManagable, Drainable
{
    using AddressUtil for address;

    function canDrain(address /*drainer*/, address /*token*/)
        public
        override
        view
        returns (bool) {
        return msg.sender == owner || isManager(msg.sender);
    }

    function doForcedWithdrawalFor(
        address exchangeAddress,
        address from,
        address token,
        uint32 accountID
        )
        external
        payable
        nonReentrant
        onlyOwnerOrManager
    {
        IExchangeV3(exchangeAddress).forceWithdraw{value: msg.value}(from, token, accountID);

        if (address(this).balance > 0) {
            drain(msg.sender, address(0));
        }
    }

    receive() external payable { }
}

File 84 of 95 : FastWithdrawalAgent.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../core/iface/IAgentRegistry.sol";
import "../../core/iface/IExchangeV3.sol";
import "../../lib/Claimable.sol";
import "../../lib/EIP712.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../../lib/SignatureUtil.sol";

/// @title Fast withdrawal agent implementation. With the help of liquidity providers (LPs),
///        exchange operators can convert any normal withdrawals into fast withdrawals.
///
///        Fast withdrawals are a way for the owner to provide instant withdrawals for
///        users with the help of a liquidity provider and conditional transfers.
///
///        A fast withdrawal requires the non-trustless cooperation of 2 parties:
///        - A liquidity provider which provides funds to users immediately onchain
///        - The operator which will make sure the user has sufficient funds offchain
///          so that the liquidity provider can be paid back.
///          The operator also needs to process those withdrawals so that the
///          liquidity provider receives its funds back.
///
///        We require the fast withdrawals to be executed by the liquidity provider (as msg.sender)
///        so that the liquidity provider can impose its own rules on how its funds are spent. This will
///        inevitably need to be done in close cooperation with the operator, or by the operator
///        itself using a smart contract where the liquidity provider enforces who, how
///        and even if their funds can be used to facilitate the fast withdrawals.
///
///        The liquidity provider can call `executeFastWithdrawals` to provide users
///        immediately with funds onchain. This allows the security of the funds to be handled
///        by any EOA or smart contract.
///
///        Users that want to make use of this functionality have to
///        authorize this contract as their agent.
///
/// @author Brecht Devos - <[email protected]>
/// @author Kongliang Zhong - <[email protected]>
/// @author Daniel Wang - <[email protected]>
contract FastWithdrawalAgent is ReentrancyGuard, IAgent
{
    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using ERC20SafeTransfer for address;
    using MathUint          for uint;

    event Processed(
        address exchange,
        address from,
        address to,
        address token,
        uint248  amount,
        address provider,
        bool    success
    );

    struct Withdrawal
    {
        address exchange;
        address from;                   // The owner of the account
        address to;                     // The `to` address of the withdrawal
        address token;
        uint248  amount;
        uint32  storageID;
    }

    // This method needs to be called by any liquidity provider
    function executeFastWithdrawals(Withdrawal[] calldata withdrawals)
        external
        nonReentrant
        payable
    {
        // Do all fast withdrawals
        for (uint i = 0; i < withdrawals.length; i++) {
            executeInternal(withdrawals[i]);
        }
        // Return any ETH left into this contract
        // (can happen when more ETH is sent than needed for the fast withdrawals)
        msg.sender.sendETHAndVerify(address(this).balance, gasleft());
    }

    // -- Internal --

    function executeInternal(Withdrawal calldata withdrawal)
        internal
    {
        require(
            withdrawal.exchange != address(0) &&
            withdrawal.from != address(0) &&
            withdrawal.to != address(0) &&
            withdrawal.amount != 0,
            "INVALID_WITHDRAWAL"
        );

        // The liquidity provider always authorizes the fast withdrawal by being the direct caller
        address payable liquidityProvider = msg.sender;

        bool success;
        // Override the destination address of a withdrawal to the address of the liquidity provider
        try IExchangeV3(withdrawal.exchange).setWithdrawalRecipient(
            withdrawal.from,
            withdrawal.to,
            withdrawal.token,
            withdrawal.amount,
            withdrawal.storageID,
            liquidityProvider
        ) {
            // Transfer the tokens immediately to the requested address
            // using funds from the liquidity provider (`msg.sender`).
            transfer(
                liquidityProvider,
                withdrawal.to,
                withdrawal.token,
                withdrawal.amount
            );
            success = true;
        } catch {
            success = false;
        }

        emit Processed(
            withdrawal.exchange,
            withdrawal.from,
            withdrawal.to,
            withdrawal.token,
            withdrawal.amount,
            liquidityProvider,
            success
        );
    }

    function transfer(
        address from,
        address to,
        address token,
        uint    amount
        )
        internal
    {
        if (amount > 0) {
            if (token == address(0)) {
                to.sendETHAndVerify(amount, gasleft()); // ETH
            } else {
                token.safeTransferFromAndVerify(from, to, amount);  // ERC20 token
            }
        }
    }
}

File 85 of 95 : IProtocolFeeVault.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;


/// @title IProtocolFeeVault
/// @dev This smart contract manages the distribution of protocol fees.
///     Tokens other than LRC will be sold by TokenSeller,
///     If no TokenSeller is set, the tokens or Ether will be sent to the owner
///     to sell them for LRC by other means such as using a centralized exchange.
///     For LRC token, 70% of them can be withdrawn to the UserStakingPool contract
///     to reward LRC stakers; 20% of them can be withdrawn to the Loopring DAO,
///     and the remaining 10% can be burned to reduce LRC's total supply.
abstract contract IProtocolFeeVault
{
    uint public constant REWARD_PERCENTAGE      = 70;
    uint public constant DAO_PERDENTAGE         = 20;

    address public userStakingPoolAddress;
    address public tokenSellerAddress;
    address public daoAddress;

    uint claimedReward;
    uint claimedDAOFund;
    uint claimedBurn;

    event LRCClaimed(uint amount);
    event DAOFunded(uint amountDAO, uint amountBurn);
    event TokenSold(address token, uint amount);
    event SettingsUpdated(uint time);

    /// @dev Returns the LRC token address
    /// @return the LRC token address
    function lrcAddress()
        external
        view
        virtual
        returns (address);

    /// @dev Sets depending contract addresses. All these addresses can be zero.
    /// @param _userStakingPoolAddress The address of the user staking pool.
    /// @param _tokenSellerAddress The address of the token seller.
    /// @param _daoAddress The address of the DAO contract.
    function updateSettings(
        address _userStakingPoolAddress,
        address _tokenSellerAddress,
        address _daoAddress
        )
        external
        virtual;

    /// @dev Claims LRC as staking reward to the IUserStakingPool contract.
    ///      Note that this function can only be called by
    ///      the IUserStakingPool contract.
    ///
    /// @param amount The amount of LRC to be claimed.
    function claimStakingReward(uint amount)
        external
        virtual;

    /// @dev Withdraws LRC to DAO and in the meanwhile burn some LRC according to
    ///      the predefined percentages.
    function fundDAO()
        external
        virtual;

    /// @dev Sells a non-LRC token or Ether to LRC. If no TokenSeller is set,
    ///      the tokens or Ether will be sent to the owner.
    /// @param token The token or ether (0x0) to sell.
    /// @param amount THe amout of token/ether to sell.
    function sellTokenForLRC(
        address token,
        uint    amount
        )
        external
        virtual;

    /// @dev Returns some global stats regarding fees.
    /// @return accumulatedFees The accumulated amount of LRC protocol fees.
    /// @return accumulatedBurn The accumulated amount of LRC to burn.
    /// @return accumulatedDAOFund The accumulated amount of LRC as developer pool.
    /// @return accumulatedReward The accumulated amount of LRC as staking reward.
    /// @return remainingFees The remaining amount of LRC protocol fees.
    /// @return remainingBurn The remaining amount of LRC to burn.
    /// @return remainingDAOFund The remaining amount of LRC as developer pool.
    /// @return remainingReward The remaining amount of LRC as staking reward.
    function getProtocolFeeStats()
        external
        virtual
        view
        returns (
            uint accumulatedFees,
            uint accumulatedBurn,
            uint accumulatedDAOFund,
            uint accumulatedReward,
            uint remainingFees,
            uint remainingBurn,
            uint remainingDAOFund,
            uint remainingReward
        );
}

File 86 of 95 : ProtocolFeeVault.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;

import "../../lib/AddressUtil.sol";
import "../../lib/BurnableERC20.sol";
import "../../lib/Claimable.sol";
import "../../lib/ERC20.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../token-sellers/ITokenSeller.sol";
import "./IProtocolFeeVault.sol";


/// @title An Implementation of IProtocolFeeVault.
/// @author Daniel Wang - <[email protected]>
contract ProtocolFeeVault is Claimable, ReentrancyGuard, IProtocolFeeVault
{
    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using ERC20SafeTransfer for address;
    using MathUint          for uint;

    address public immutable override lrcAddress;

    constructor(address _lrcAddress)
        Claimable()
    {
        require(_lrcAddress != address(0), "ZERO_ADDRESS");
        lrcAddress = _lrcAddress;
    }

    receive() external payable { }

    function updateSettings(
        address _userStakingPoolAddress,
        address _tokenSellerAddress,
        address _daoAddress
        )
        external
        override
        nonReentrant
        onlyOwner
    {
        require(
            userStakingPoolAddress != _userStakingPoolAddress ||
            tokenSellerAddress != _tokenSellerAddress ||
            daoAddress != _daoAddress,
            "SAME_ADDRESSES"
        );
        userStakingPoolAddress = _userStakingPoolAddress;
        tokenSellerAddress = _tokenSellerAddress;
        daoAddress = _daoAddress;

        emit SettingsUpdated(block.timestamp);
    }

    function claimStakingReward(
        uint amount
        )
        external
        override
        nonReentrant
    {
        require(amount > 0, "ZERO_VALUE");
        require(msg.sender == userStakingPoolAddress, "UNAUTHORIZED");
        lrcAddress.safeTransferAndVerify(userStakingPoolAddress, amount);
        claimedReward = claimedReward.add(amount);
        emit LRCClaimed(amount);
    }

    function fundDAO()
        external
        override
        nonReentrant
    {
        uint amountDAO;
        uint amountBurn;
        (, , , , , amountBurn, amountDAO, ) = getProtocolFeeStats();

        address recipient = daoAddress == address(0) ? owner : daoAddress;

        if (amountDAO > 0) {
            lrcAddress.safeTransferAndVerify(recipient, amountDAO);
        }

        if (amountBurn > 0) {
            require(BurnableERC20(lrcAddress).burn(amountBurn), "BURN_FAILURE");
        }

        claimedBurn = claimedBurn.add(amountBurn);
        claimedDAOFund = claimedDAOFund.add(amountDAO);

        emit DAOFunded(amountDAO, amountBurn);
    }

    function sellTokenForLRC(
        address token,
        uint    amount
        )
        external
        override
        nonReentrant
    {
        require(amount > 0, "ZERO_AMOUNT");
        require(token != lrcAddress, "PROHIBITED");

        address recipient = tokenSellerAddress == address(0) ? owner : tokenSellerAddress;

        if (token == address(0)) {
            recipient.sendETHAndVerify(amount, gasleft());
        } else {
            token.safeTransferAndVerify(recipient, amount);
        }

        require(
            tokenSellerAddress == address(0) ||
            ITokenSeller(tokenSellerAddress).sellToken(token, lrcAddress),
            "SELL_FAILURE"
        );

        emit TokenSold(token, amount);
    }

    function getProtocolFeeStats()
        public
        override
        view
        returns (
            uint accumulatedFees,
            uint accumulatedBurn,
            uint accumulatedDAOFund,
            uint accumulatedReward,
            uint remainingFees,
            uint remainingBurn,
            uint remainingDAOFund,
            uint remainingReward
        )
    {
        remainingFees = ERC20(lrcAddress).balanceOf(address(this));
        accumulatedFees = remainingFees.add(claimedReward).add(claimedDAOFund).add(claimedBurn);

        accumulatedReward = accumulatedFees.mul(REWARD_PERCENTAGE) / 100;
        accumulatedDAOFund = accumulatedFees.mul(DAO_PERDENTAGE) / 100;
        accumulatedBurn = accumulatedFees.sub(accumulatedReward).sub(accumulatedDAOFund);

        remainingReward = accumulatedReward.sub(claimedReward);
        remainingDAOFund = accumulatedDAOFund.sub(claimedDAOFund);
        remainingBurn = accumulatedBurn.sub(claimedBurn);
    }
}

File 87 of 95 : FastWithdrawalLiquidityProvider.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
// Modified by DeGate DAO, 2022
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../agents/FastWithdrawalAgent.sol";
import "../../lib/OwnerManagable.sol";
import "../../lib/EIP712.sol";
import "../../lib/ERC20.sol";
import "../../lib/ERC20SafeTransfer.sol";
import "../../lib/MathUint.sol";
import "../../lib/ReentrancyGuard.sol";
import "../../lib/SignatureUtil.sol";


/// @title Basic contract storing funds for a liquidity provider.
/// @author Brecht Devos - <[email protected]>
contract FastWithdrawalLiquidityProvider is ReentrancyGuard, OwnerManagable
{
    using AddressUtil       for address;
    using AddressUtil       for address payable;
    using ERC20SafeTransfer for address;
    using MathUint          for uint;
    using SignatureUtil     for bytes32;

    struct FastWithdrawalApproval
    {
        address exchange;
        address from;
        address to;
        address token;
        uint248  amount;
        uint32  storageID;
        uint64  validUntil; // most significant 32 bits as block height, least significant 32 bits as block time
        address signer;
        bytes   signature;  // signer's signature
    }

    bytes32 constant public FASTWITHDRAWAL_APPROVAL_TYPEHASH = keccak256(
        "FastWithdrawalApproval(address exchange,address from,address to,address token,uint248 amount,uint32 storageID,uint64 validUntil)"
    );

    bytes32 public immutable DOMAIN_SEPARATOR;

    FastWithdrawalAgent public immutable agent;

    constructor(FastWithdrawalAgent _agent)
    {
        agent = _agent;
        DOMAIN_SEPARATOR = EIP712.hash(EIP712.Domain("FastWithdrawalLiquidityProvider", "1.0", address(this)));
    }

    // Execute the fast withdrawals.
    // Full approvals are posted onchain so they can be used by anyone to speed up the
    // withdrawal by calling , but the approvals are not validated when done by the
    // owner or one of the managers.
    function execute(FastWithdrawalApproval[] calldata approvals)
        external
        nonReentrant
    {
        // Prepare the data and validate the approvals when necessary
        FastWithdrawalAgent.Withdrawal[] memory withdrawals =
            new FastWithdrawalAgent.Withdrawal[](approvals.length);

        bool skipApprovalCheck = isManager(msg.sender);
        for (uint i = 0; i < approvals.length; i++) {
            require(skipApprovalCheck || isApprovalValid(approvals[i]), "PROHIBITED");
            withdrawals[i] = translate(approvals[i]);
        }

        // Calculate how much ETH we need to send to the agent contract.
        // We could also send the full ETH balance each time, but that'll need
        // an additional transfer to send funds back, which may actually be more efficient.
        uint value = 0;
        for (uint i = 0; i < withdrawals.length; i++) {
            if (withdrawals[i].token == address(0)) {
                value = value.add(withdrawals[i].amount);
            }
        }
        // Execute all the fast withdrawals
        agent.executeFastWithdrawals{value: value}(withdrawals);
    }

    // Allows the LP to transfer funds back out of this contract.
    function drain(
        address to,
        address token,
        uint    amount
        )
        external
        nonReentrant
        onlyOwner
    {
        if (token == address(0)) {
            to.sendETHAndVerify(amount, gasleft()); // ETH
        } else {
            token.safeTransferAndVerify(to, amount);  // ERC20 token
        }
    }

    // Allows the LP to enable the necessary ERC20 approvals
    function approve(
        address token,
        address spender,
        uint    amount
        )
        external
        nonReentrant
        onlyOwner
    {
        require(ERC20(token).approve(spender, amount), "APPROVAL_FAILED");
    }

    function isApprovalValid(
        FastWithdrawalApproval calldata approval
        )
        internal
        view
        returns (bool)
    {
        // Compute the hash
        bytes32 hash = EIP712.hashPacked(
            DOMAIN_SEPARATOR,
            keccak256(
                abi.encodePacked(
                    FASTWITHDRAWAL_APPROVAL_TYPEHASH,
                    approval.exchange,
                    approval.from,
                    approval.to,
                    approval.token,
                    approval.amount,
                    approval.storageID,
                    approval.validUntil
                )
            )
        );

        return hash.verifySignature(approval.signer, approval.signature) &&
            checkValidUntil(approval.validUntil) &&
            isManager(approval.signer);
    }

    receive() payable external {}

    // -- Internal --

    function checkValidUntil(uint64 validUntil)
        internal
        view
        returns (bool)
    {
        return (validUntil & 0xFFFFFFFF) >= block.timestamp ||
            (validUntil >> 32) >= block.number;
    }

    function translate(FastWithdrawalApproval calldata approval)
        internal
        pure
        returns (FastWithdrawalAgent.Withdrawal memory)
    {
        return FastWithdrawalAgent.Withdrawal({
            exchange: approval.exchange,
            from: approval.from,
            to: approval.to,
            token: approval.token,
            amount: approval.amount,
            storageID: approval.storageID
        });
    }
}

File 88 of 95 : MigrationToLoopringExchangeV2.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2017 Loopring Technology Limited.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;


import "../../lib/ReentrancyGuard.sol";
import "../../lib/Drainable.sol";

abstract contract ILoopringV3Partial
{
    function withdrawExchangeStake(
        uint    exchangeId,
        address recipient,
        uint    requestedAmount
        )
        external
        virtual
        returns (uint amount);
}

/// @author Kongliang Zhong - <[email protected]>
/// @dev This contract enables an alternative approach of getting back assets from Loopring Exchange v1.
/// Now you don't have to withdraw using merkle proofs (very expensive);
/// instead, all assets will be distributed on Loopring Exchange v2 - Loopring's new zkRollup implementation.
/// Please activate and unlock your address on https://exchange.loopring.io to claim your assets.
contract MigrationToLoopringExchangeV2 is Drainable
{
    function canDrain(address /*drainer*/, address /*token*/)
        public
        override
        view
        returns (bool) {
        return isMigrationOperator();
    }

    function withdrawExchangeStake(
        address loopringV3,
        uint exchangeId,
        uint amount,
        address recipient
        )
        external
    {
        require(isMigrationOperator(), "INVALID_SENDER");
        ILoopringV3Partial(loopringV3).withdrawExchangeStake(exchangeId, recipient, amount);
    }

    function isMigrationOperator() internal view returns (bool) {
        return msg.sender == 0x4374D3d032B3c96785094ec9f384f07077792768;
    }

}

File 89 of 95 : IChiToken.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.7.0;

import "../../lib/ERC20.sol";


abstract contract IChiToken is ERC20
{
    function free(uint256 value)
    external
    virtual
    returns (uint256);

    function freeUpTo(uint256 value)
    external
    virtual
    returns (uint256);

    function freeFrom(address from, uint256 value)
    external
    virtual
    returns (uint256);

    function freeFromUpTo(address from, uint256 value)
    external
    virtual
    returns (uint256 freed);
}

File 90 of 95 : AggregatorInterface.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;

interface AggregatorInterface {
  function latestAnswer() external view returns (int256);
  function latestTimestamp() external view returns (uint256);
  function latestRound() external view returns (uint256);
  function getAnswer(uint256 roundId) external view returns (int256);
  function getTimestamp(uint256 roundId) external view returns (uint256);

  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
  event NewRound(uint256 indexed roundId, address indexed startedBy);
}

File 91 of 95 : Cloneable.sol
// SPDX-License-Identifier: UNLICENSED
// This code is taken from https://gist.github.com/holiman/069de8d056a531575d2b786df3345665
pragma solidity ^0.7.0;

library Cloneable {
    function clone(address a)
        external
        returns (address)
    {

    /*
    Assembly of the code that we want to use as init-code in the new contract,
    along with stack values:
                    # bottom [ STACK ] top
     PUSH1 00       # [ 0 ]
     DUP1           # [ 0, 0 ]
     PUSH20
     <address>      # [0,0, address]
     DUP1           # [0,0, address ,address]
     EXTCODESIZE    # [0,0, address, size ]
     DUP1           # [0,0, address, size, size]
     SWAP4          # [ size, 0, address, size, 0]
     DUP1           # [ size, 0, address ,size, 0,0]
     SWAP2          # [ size, 0, address, 0, 0, size]
     SWAP3          # [ size, 0, size, 0, 0, address]
     EXTCODECOPY    # [ size, 0]
     RETURN

    The code above weighs in at 33 bytes, which is _just_ above fitting into a uint.
    So a modified version is used, where the initial PUSH1 00 is replaced by `PC`.
    This is one byte smaller, and also a bit cheaper Wbase instead of Wverylow. It only costs 2 gas.

     PC             # [ 0 ]
     DUP1           # [ 0, 0 ]
     PUSH20
     <address>      # [0,0, address]
     DUP1           # [0,0, address ,address]
     EXTCODESIZE    # [0,0, address, size ]
     DUP1           # [0,0, address, size, size]
     SWAP4          # [ size, 0, address, size, 0]
     DUP1           # [ size, 0, address ,size, 0,0]
     SWAP2          # [ size, 0, address, 0, 0, size]
     SWAP3          # [ size, 0, size, 0, 0, address]
     EXTCODECOPY    # [ size, 0]
     RETURN

    The opcodes are:
    58 80 73 <address> 80 3b 80 93 80 91 92 3c F3
    We get <address> in there by OR:ing the upshifted address into the 0-filled space.
      5880730000000000000000000000000000000000000000803b80938091923cF3
     +000000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx000000000000000000
     -----------------------------------------------------------------
      588073xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx00000803b80938091923cF3

    This is simply stored at memory position 0, and create is invoked.
    */
        address retval;
        assembly{
            mstore(0x0, or (0x5880730000000000000000000000000000000000000000803b80938091923cF3 ,mul(a,0x1000000000000000000)))
            retval := create(0,0, 32)
        }
        return retval;
    }
}

File 92 of 95 : IKnowForwarderAddress.sol
// SPDX-License-Identifier:MIT
pragma solidity ^0.7.0;

interface IKnowForwarderAddress {

    /**
     * return the forwarder we trust to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function getTrustedForwarder() external view returns(address);
}

File 93 of 95 : IRelayRecipient.sol
// SPDX-License-Identifier:MIT
pragma solidity ^0.7.0;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {

    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public virtual view returns(bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal virtual view returns (address payable);

    function versionRecipient() external virtual view returns (string memory);
}

File 94 of 95 : BaseRelayRecipient.sol
// SPDX-License-Identifier:MIT
pragma solidity ^0.7.0;

import "./IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {

    /*
     * Forwarder singleton we accept calls from
     */
    address public immutable trustedForwarder;

    constructor(address _forwarder)
    {
        trustedForwarder = _forwarder;
    }

    /*
     * require a function to be called through GSN only
     */
    modifier trustedForwarderOnly() {
        require(msg.sender == address(trustedForwarder), "Function can only be called through the trusted Forwarder");
        _;
    }

    function isTrustedForwarder(address forwarder) public override view returns(bool) {
        return forwarder == trustedForwarder;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal override virtual view returns (address payable ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            return msg.sender;
        }
    }
}

File 95 of 95 : MockContract.sol
// SPDX-License-Identifier: UNLICENSED
/// Borrowed from https://github.com/gnosis/mock-contract
pragma solidity ^0.7.0;

interface MockInterface {
	/**
	 * @dev After calling this method, the mock will return `response` when it is called
	 * with any calldata that is not mocked more specifically below
	 * (e.g. using givenMethodReturn).
	 * @param response ABI encoded response that will be returned if method is invoked
	 */
	function givenAnyReturn(bytes calldata response) external;
	function givenAnyReturnBool(bool response) external;
	function givenAnyReturnUint(uint response) external;
	function givenAnyReturnAddress(address response) external;

	function givenAnyRevert() external;
	function givenAnyRevertWithMessage(string calldata message) external;
	function givenAnyRunOutOfGas() external;

	/**
	 * @dev After calling this method, the mock will return `response` when the given
	 * methodId is called regardless of arguments. If the methodId and arguments
	 * are mocked more specifically (using `givenMethodAndArguments`) the latter
	 * will take precedence.
	 * @param method ABI encoded methodId. It is valid to pass full calldata (including arguments). The mock will extract the methodId from it
	 * @param response ABI encoded response that will be returned if method is invoked
	 */
	function givenMethodReturn(bytes calldata method, bytes calldata response) external;
	function givenMethodReturnBool(bytes calldata method, bool response) external;
	function givenMethodReturnUint(bytes calldata method, uint response) external;
	function givenMethodReturnAddress(bytes calldata method, address response) external;

	function givenMethodRevert(bytes calldata method) external;
	function givenMethodRevertWithMessage(bytes calldata method, string calldata message) external;
	function givenMethodRunOutOfGas(bytes calldata method) external;

	/**
	 * @dev After calling this method, the mock will return `response` when the given
	 * methodId is called with matching arguments. These exact calldataMocks will take
	 * precedence over all other calldataMocks.
	 * @param call ABI encoded calldata (methodId and arguments)
	 * @param response ABI encoded response that will be returned if contract is invoked with calldata
	 */
	function givenCalldataReturn(bytes calldata call, bytes calldata response) external;
	function givenCalldataReturnBool(bytes calldata call, bool response) external;
	function givenCalldataReturnUint(bytes calldata call, uint response) external;
	function givenCalldataReturnAddress(bytes calldata call, address response) external;

	function givenCalldataRevert(bytes calldata call) external;
	function givenCalldataRevertWithMessage(bytes calldata call, string calldata message) external;
	function givenCalldataRunOutOfGas(bytes calldata call) external;

	/**
	 * @dev Returns the number of times anything has been called on this mock since last reset
	 */
	function invocationCount() external returns (uint);

	/**
	 * @dev Returns the number of times the given method has been called on this mock since last reset
	 * @param method ABI encoded methodId. It is valid to pass full calldata (including arguments). The mock will extract the methodId from it
	 */
	function invocationCountForMethod(bytes calldata method) external returns (uint);

	/**
	 * @dev Returns the number of times this mock has been called with the exact calldata since last reset.
	 * @param call ABI encoded calldata (methodId and arguments)
	 */
	function invocationCountForCalldata(bytes calldata call) external returns (uint);

	/**
	 * @dev Resets all mocked methods and invocation counts.
	 */
	 function reset() external;
}

/**
 * Implementation of the MockInterface.
 */
contract MockContract is MockInterface {
	enum MockType { Return, Revert, OutOfGas }

	bytes32 public constant MOCKS_LIST_START = hex"01";
	bytes public constant MOCKS_LIST_END = "0xff";
	bytes32 public constant MOCKS_LIST_END_HASH = keccak256(MOCKS_LIST_END);
	bytes4 public constant SENTINEL_ANY_MOCKS = hex"01";

	// A linked list allows easy iteration and inclusion checks
	mapping(bytes32 => bytes) calldataMocks;
	mapping(bytes => MockType) calldataMockTypes;
	mapping(bytes => bytes) calldataExpectations;
	mapping(bytes => string) calldataRevertMessage;
	mapping(bytes32 => uint) calldataInvocations;

	mapping(bytes4 => bytes4) methodIdMocks;
	mapping(bytes4 => MockType) methodIdMockTypes;
	mapping(bytes4 => bytes) methodIdExpectations;
	mapping(bytes4 => string) methodIdRevertMessages;
	mapping(bytes32 => uint) methodIdInvocations;

	MockType fallbackMockType;
	bytes fallbackExpectation;
	string fallbackRevertMessage;
	uint invocations;
	uint resetCount;

	constructor() {
		calldataMocks[MOCKS_LIST_START] = MOCKS_LIST_END;
		methodIdMocks[SENTINEL_ANY_MOCKS] = SENTINEL_ANY_MOCKS;
	}

	function trackCalldataMock(bytes memory call) private {
		bytes32 callHash = keccak256(call);
		if (calldataMocks[callHash].length == 0) {
			calldataMocks[callHash] = calldataMocks[MOCKS_LIST_START];
			calldataMocks[MOCKS_LIST_START] = call;
		}
	}

	function trackMethodIdMock(bytes4 methodId) private {
		if (methodIdMocks[methodId] == 0x0) {
			methodIdMocks[methodId] = methodIdMocks[SENTINEL_ANY_MOCKS];
			methodIdMocks[SENTINEL_ANY_MOCKS] = methodId;
		}
	}

	function _givenAnyReturn(bytes memory response) internal {
		fallbackMockType = MockType.Return;
		fallbackExpectation = response;
	}

	function givenAnyReturn(bytes calldata response) external override {
		_givenAnyReturn(response);
	}

	function givenAnyReturnBool(bool response) external override {
		uint flag = response ? 1 : 0;
		_givenAnyReturn(uintToBytes(flag));
	}

	function givenAnyReturnUint(uint response) external override {
		_givenAnyReturn(uintToBytes(response));
	}

	function givenAnyReturnAddress(address response) external override {
		_givenAnyReturn(uintToBytes(uint(response)));
	}

	function givenAnyRevert() external override {
		fallbackMockType = MockType.Revert;
		fallbackRevertMessage = "";
	}

	function givenAnyRevertWithMessage(string calldata message) external override {
		fallbackMockType = MockType.Revert;
		fallbackRevertMessage = message;
	}

	function givenAnyRunOutOfGas() external override {
		fallbackMockType = MockType.OutOfGas;
	}

	function _givenCalldataReturn(bytes memory call, bytes memory response) private  {
		calldataMockTypes[call] = MockType.Return;
		calldataExpectations[call] = response;
		trackCalldataMock(call);
	}

	function givenCalldataReturn(bytes calldata call, bytes calldata response) external override {
		_givenCalldataReturn(call, response);
	}

	function givenCalldataReturnBool(bytes calldata call, bool response) external override {
		uint flag = response ? 1 : 0;
		_givenCalldataReturn(call, uintToBytes(flag));
	}

	function givenCalldataReturnUint(bytes calldata call, uint response) external override {
		_givenCalldataReturn(call, uintToBytes(response));
	}

	function givenCalldataReturnAddress(bytes calldata call, address response) external override {
		_givenCalldataReturn(call, uintToBytes(uint(response)));
	}

	function _givenMethodReturn(bytes memory call, bytes memory response) private {
		bytes4 method = bytesToBytes4(call);
		methodIdMockTypes[method] = MockType.Return;
		methodIdExpectations[method] = response;
		trackMethodIdMock(method);
	}

	function givenMethodReturn(bytes calldata call, bytes calldata response) external override {
		_givenMethodReturn(call, response);
	}

	function givenMethodReturnBool(bytes calldata call, bool response) external override {
		uint flag = response ? 1 : 0;
		_givenMethodReturn(call, uintToBytes(flag));
	}

	function givenMethodReturnUint(bytes calldata call, uint response) external override {
		_givenMethodReturn(call, uintToBytes(response));
	}

	function givenMethodReturnAddress(bytes calldata call, address response) external override {
		_givenMethodReturn(call, uintToBytes(uint(response)));
	}

	function givenCalldataRevert(bytes calldata call) external override {
		calldataMockTypes[call] = MockType.Revert;
		calldataRevertMessage[call] = "";
		trackCalldataMock(call);
	}

	function givenMethodRevert(bytes calldata call) external override {
		bytes4 method = bytesToBytes4(call);
		methodIdMockTypes[method] = MockType.Revert;
		trackMethodIdMock(method);
	}

	function givenCalldataRevertWithMessage(bytes calldata call, string calldata message) external override {
		calldataMockTypes[call] = MockType.Revert;
		calldataRevertMessage[call] = message;
		trackCalldataMock(call);
	}

	function givenMethodRevertWithMessage(bytes calldata call, string calldata message) external override {
		bytes4 method = bytesToBytes4(call);
		methodIdMockTypes[method] = MockType.Revert;
		methodIdRevertMessages[method] = message;
		trackMethodIdMock(method);
	}

	function givenCalldataRunOutOfGas(bytes calldata call) external override {
		calldataMockTypes[call] = MockType.OutOfGas;
		trackCalldataMock(call);
	}

	function givenMethodRunOutOfGas(bytes calldata call) external override {
		bytes4 method = bytesToBytes4(call);
		methodIdMockTypes[method] = MockType.OutOfGas;
		trackMethodIdMock(method);
	}

	function invocationCount() external override view returns (uint) {
		return invocations;
	}

	function invocationCountForMethod(bytes calldata call) external view override returns (uint) {
		bytes4 method = bytesToBytes4(call);
		return methodIdInvocations[keccak256(abi.encodePacked(resetCount, method))];
	}

	function invocationCountForCalldata(bytes calldata call) external view override returns (uint) {
		return calldataInvocations[keccak256(abi.encodePacked(resetCount, call))];
	}

	function reset() external override {
		// Reset all exact calldataMocks
		bytes memory nextMock = calldataMocks[MOCKS_LIST_START];
		bytes32 mockHash = keccak256(nextMock);
		// We cannot compary bytes
		while(mockHash != MOCKS_LIST_END_HASH) {
			// Reset all mock maps
			calldataMockTypes[nextMock] = MockType.Return;
			calldataExpectations[nextMock] = hex"";
			calldataRevertMessage[nextMock] = "";
			// Set next mock to remove
			nextMock = calldataMocks[mockHash];
			// Remove from linked list
			calldataMocks[mockHash] = "";
			// Update mock hash
			mockHash = keccak256(nextMock);
		}
		// Clear list
		calldataMocks[MOCKS_LIST_START] = MOCKS_LIST_END;

		// Reset all any calldataMocks
		bytes4 nextAnyMock = methodIdMocks[SENTINEL_ANY_MOCKS];
		while(nextAnyMock != SENTINEL_ANY_MOCKS) {
			bytes4 currentAnyMock = nextAnyMock;
			methodIdMockTypes[currentAnyMock] = MockType.Return;
			methodIdExpectations[currentAnyMock] = hex"";
			methodIdRevertMessages[currentAnyMock] = "";
			nextAnyMock = methodIdMocks[currentAnyMock];
			// Remove from linked list
			methodIdMocks[currentAnyMock] = 0x0;
		}
		// Clear list
		methodIdMocks[SENTINEL_ANY_MOCKS] = SENTINEL_ANY_MOCKS;

		fallbackExpectation = "";
		fallbackMockType = MockType.Return;
		invocations = 0;
		resetCount += 1;
	}

	function useAllGas() private {
		while(true) {
			bool s;
			assembly {
				//expensive call to EC multiply contract
				s := call(sub(gas(), 2000), 6, 0, 0x0, 0xc0, 0x0, 0x60)
			}
		}
	}

	function bytesToBytes4(bytes memory b) private pure returns (bytes4) {
		bytes4 out;
		for (uint i = 0; i < 4; i++) {
			out |= bytes4(b[i] & 0xFF) >> (i * 8);
		}
		return out;
	}

	function uintToBytes(uint256 x) private pure returns (bytes memory b) {
		b = new bytes(32);
		assembly { mstore(add(b, 32), x) }
	}

	function updateInvocationCount(bytes4 methodId, bytes memory originalMsgData) public {
		require(msg.sender == address(this), "Can only be called from the contract itself");
		invocations += 1;
		methodIdInvocations[keccak256(abi.encodePacked(resetCount, methodId))] += 1;
		calldataInvocations[keccak256(abi.encodePacked(resetCount, originalMsgData))] += 1;
	}

	receive()
        external
        payable
    {
        // Don't do anything
    }

	fallback() payable external {
		bytes4 methodId;
		assembly {
			methodId := calldataload(0)
		}

		// First, check exact matching overrides
		if (calldataMockTypes[msg.data] == MockType.Revert) {
			revert(calldataRevertMessage[msg.data]);
		}
		if (calldataMockTypes[msg.data] == MockType.OutOfGas) {
			useAllGas();
		}
		bytes memory result = calldataExpectations[msg.data];

		// Then check method Id overrides
		if (result.length == 0) {
			if (methodIdMockTypes[methodId] == MockType.Revert) {
				revert(methodIdRevertMessages[methodId]);
			}
			if (methodIdMockTypes[methodId] == MockType.OutOfGas) {
				useAllGas();
			}
			result = methodIdExpectations[methodId];
		}

		// Last, use the fallback override
		if (result.length == 0) {
			if (fallbackMockType == MockType.Revert) {
				revert(fallbackRevertMessage);
			}
			if (fallbackMockType == MockType.OutOfGas) {
				useAllGas();
			}
			result = fallbackExpectation;
		}

		// Record invocation as separate call so we don't rollback in case we are called with STATICCALL
		(, bytes memory r) = address(this).call{gas: 100000}(abi.encodeWithSignature("updateInvocationCount(bytes4,bytes)", methodId, msg.data));
		assert(r.length == 0);

		assembly {
			return(add(0x20, result), mload(result))
		}
	}
}

Settings
{
  "metadata": {
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {
    "./contracts/core/impl/libexchange/ExchangeAdmins.sol": {
      "ExchangeAdmins": "0x0a5d144ADF62e18eE222f2D05a2Bf2037ce8EeAe"
    },
    "./contracts/core/impl/libexchange/ExchangeBalances.sol": {
      "ExchangeBalances": "0xF799e5CEF24528b9409502E99f5837ee3446D11d"
    },
    "./contracts/core/impl/libexchange/ExchangeTokens.sol": {
      "ExchangeTokens": "0x2Bf7021a3Aa041e1a8a5082DB720d0202C70A3aE"
    },
    "./contracts/core/impl/libexchange/ExchangeBlocks.sol": {
      "ExchangeBlocks": "0x4AD92EE2019A6A26c9E38caEDd46503BD7f79C10"
    },
    "./contracts/core/impl/libexchange/ExchangeGenesis.sol": {
      "ExchangeGenesis": "0x57f2BAa929EcE41D8B6FDc4c7f7b60B95522AbcB"
    },
    "./contracts/core/impl/libexchange/ExchangeWithdrawals.sol": {
      "ExchangeWithdrawals": "0x9FB27470d766A29Ac126CF99eE103087a4072e33"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"AllowOnchainTransferFrom","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"blockIdx","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"publicDataHash","type":"bytes32"}],"name":"BlockSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"blockVerifier","type":"address"}],"name":"BlockVerifierRefreshed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"depositContract","type":"address"}],"name":"DepositContractUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"freeDepositMax","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"freeDepositRemained","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"freeSlotPerBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositFee","type":"uint256"}],"name":"DepositParamsUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint32","name":"tokenId","type":"uint32"},{"indexed":false,"internalType":"uint248","name":"amount","type":"uint248"}],"name":"DepositRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"exchangeAddress","type":"address"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bytes32","name":"genesisMerkleRoot","type":"bytes32"}],"name":"ExchangeCloned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint32","name":"accountID","type":"uint32"}],"name":"ForcedWithdrawalRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"protocolFeeBips","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"previousProtocolFeeBips","type":"uint16"}],"name":"ProtocolFeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Shutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint32","name":"tokenId","type":"uint32"}],"name":"TokenRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bytes32","name":"transactionHash","type":"bytes32"}],"name":"TransactionApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"owners","type":"address[]"},{"indexed":false,"internalType":"bytes32[]","name":"transactionHashes","type":"bytes32[]"}],"name":"TransactionsApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"WithdrawExchangeFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"category","type":"uint8"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawalCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"category","type":"uint8"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawalFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"WithdrawalModeActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint248","name":"amount","type":"uint248"},{"indexed":false,"internalType":"uint32","name":"storageID","type":"uint32"},{"indexed":false,"internalType":"address","name":"newRecipient","type":"address"}],"name":"WithdrawalRecipientUpdate","type":"event"},{"inputs":[],"name":"allowOnchainTransferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"bytes32","name":"transactionHash","type":"bytes32"}],"name":"approveTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"bytes32[]","name":"transactionHashes","type":"bytes32[]"}],"name":"approveTransactions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnExchangeStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint248","name":"amount","type":"uint248"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint32","name":"accountID","type":"uint32"}],"name":"forceWithdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getAmountWithdrawable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockHeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockIdx","type":"uint256"}],"name":"getBlockInfo","outputs":[{"components":[{"internalType":"uint32","name":"timestamp","type":"uint32"},{"internalType":"bytes28","name":"blockDataHash","type":"bytes28"}],"internalType":"struct ExchangeData.BlockInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConstants","outputs":[{"components":[{"internalType":"uint256","name":"SNARK_SCALAR_FIELD","type":"uint256"},{"internalType":"uint256","name":"MAX_OPEN_FORCED_REQUESTS","type":"uint256"},{"internalType":"uint256","name":"MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE","type":"uint256"},{"internalType":"uint256","name":"TIMESTAMP_HALF_WINDOW_SIZE_IN_SECONDS","type":"uint256"},{"internalType":"uint256","name":"MAX_NUM_ACCOUNTS","type":"uint256"},{"internalType":"uint256","name":"MAX_NUM_TOKENS","type":"uint256"},{"internalType":"uint256","name":"MIN_AGE_PROTOCOL_FEES_UNTIL_UPDATED","type":"uint256"},{"internalType":"uint256","name":"MIN_TIME_IN_SHUTDOWN","type":"uint256"},{"internalType":"uint256","name":"TX_DATA_AVAILABILITY_SIZE","type":"uint256"},{"internalType":"uint256","name":"MAX_AGE_DEPOSIT_UNTIL_WITHDRAWABLE_UPPERBOUND","type":"uint256"},{"internalType":"uint256","name":"MAX_FORCED_WITHDRAWAL_FEE","type":"uint256"},{"internalType":"uint256","name":"DEFAULT_PROTOCOL_FEE_BIPS","type":"uint256"}],"internalType":"struct ExchangeData.Constants","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getDepositBalance","outputs":[{"internalType":"uint248","name":"","type":"uint248"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDepositContract","outputs":[{"internalType":"contract IDepositContract","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExchangeStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFreeDepositRemained","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxAgeDepositUntilWithdrawable","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMerkleAssetRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumAvailableForcedSlots","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"getPendingDepositAmount","outputs":[{"internalType":"uint248","name":"","type":"uint248"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"getProtocolFeeLastWithdrawnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolFeeValues","outputs":[{"internalType":"uint32","name":"syncedAt","type":"uint32"},{"internalType":"uint16","name":"protocolFeeBips","type":"uint16"},{"internalType":"uint16","name":"previousProtocolFeeBips","type":"uint16"},{"internalType":"uint32","name":"executeTimeOfNextProtocolFeeBips","type":"uint32"},{"internalType":"uint16","name":"nextProtocolFeeBips","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"tokenID","type":"uint32"}],"name":"getTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"getTokenID","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getUnconfirmedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint248","name":"amount","type":"uint248"},{"internalType":"uint32","name":"storageID","type":"uint32"}],"name":"getWithdrawalRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_loopring","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_genesisMerkleRoot","type":"bytes32"},{"internalType":"bytes32","name":"_genesisMerkleAssetRoot","type":"bytes32"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"accountID","type":"uint32"},{"internalType":"address","name":"token","type":"address"}],"name":"isForcedWithdrawalPending","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInWithdrawalMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"bytes32","name":"transactionHash","type":"bytes32"}],"name":"isTransactionApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"}],"name":"isUserOrAgent","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"accountID","type":"uint32"},{"internalType":"address","name":"token","type":"address"}],"name":"isWithdrawnInWithdrawalMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"accountID","type":"uint32"},{"internalType":"address","name":"token","type":"address"}],"name":"notifyForcedRequestTooOld","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"onchainTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"registerToken","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setAllowOnchainTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_depositContract","type":"address"}],"name":"setDepositContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"freeDepositMax","type":"uint256"},{"internalType":"uint256","name":"freeDepositRemained","type":"uint256"},{"internalType":"uint256","name":"freeSlotPerBlock","type":"uint256"},{"internalType":"uint256","name":"depositFee","type":"uint256"}],"name":"setDepositParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newValue","type":"uint32"}],"name":"setMaxAgeDepositUntilWithdrawable","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint248","name":"amount","type":"uint248"},{"internalType":"uint32","name":"storageID","type":"uint32"},{"internalType":"address","name":"newRecipient","type":"address"}],"name":"setWithdrawalRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdown","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"state","outputs":[{"internalType":"uint32","name":"maxAgeDepositUntilWithdrawable","type":"uint32"},{"internalType":"bytes32","name":"DOMAIN_SEPARATOR","type":"bytes32"},{"internalType":"contract ILoopringV3","name":"loopring","type":"address"},{"internalType":"contract IBlockVerifier","name":"blockVerifier","type":"address"},{"internalType":"contract IAgentRegistry","name":"agentRegistry","type":"address"},{"internalType":"contract IDepositContract","name":"depositContract","type":"address"},{"components":[{"internalType":"uint256","name":"freeDepositMax","type":"uint256"},{"internalType":"uint256","name":"freeDepositRemained","type":"uint256"},{"internalType":"uint256","name":"lastDepositBlockNum","type":"uint256"},{"internalType":"uint256","name":"freeSlotPerBlock","type":"uint256"},{"internalType":"uint256","name":"depositFee","type":"uint256"}],"internalType":"struct ExchangeData.DepositState","name":"depositState","type":"tuple"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"bytes32","name":"merkleAssetRoot","type":"bytes32"},{"internalType":"uint256","name":"numBlocks","type":"uint256"},{"internalType":"uint32","name":"numPendingForcedTransactions","type":"uint32"},{"components":[{"internalType":"uint32","name":"syncedAt","type":"uint32"},{"internalType":"uint16","name":"protocolFeeBips","type":"uint16"},{"internalType":"uint16","name":"previousProtocolFeeBips","type":"uint16"},{"internalType":"uint32","name":"executeTimeOfNextProtocolFeeBips","type":"uint32"},{"internalType":"uint16","name":"nextProtocolFeeBips","type":"uint16"}],"internalType":"struct ExchangeData.ProtocolFeeData","name":"protocolFeeData","type":"tuple"},{"components":[{"internalType":"uint256","name":"shutdownModeStartTime","type":"uint256"},{"internalType":"uint256","name":"withdrawalModeStartTime","type":"uint256"}],"internalType":"struct ExchangeData.ModeTime","name":"modeTime","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"blockType","type":"uint8"},{"internalType":"uint16","name":"blockSize","type":"uint16"},{"internalType":"uint8","name":"blockVersion","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256[8]","name":"proof","type":"uint256[8]"},{"internalType":"bool","name":"storeBlockInfoOnchain","type":"bool"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"},{"internalType":"bytes","name":"offchainData","type":"bytes"}],"internalType":"struct ExchangeData.Block[]","name":"blocks","type":"tuple[]"}],"name":"submitBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"}],"name":"withdrawExchangeFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"withdrawExchangeStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"withdrawFromApprovedWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"withdrawFromDepositRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint32","name":"accountID","type":"uint32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"pubKeyX","type":"uint256"},{"internalType":"uint256","name":"pubKeyY","type":"uint256"},{"internalType":"uint32","name":"nonce","type":"uint32"}],"internalType":"struct ExchangeData.AccountLeaf","name":"accountLeaf","type":"tuple"},{"components":[{"internalType":"uint32","name":"tokenID","type":"uint32"},{"internalType":"uint248","name":"balance","type":"uint248"}],"internalType":"struct ExchangeData.BalanceLeaf","name":"balanceLeaf","type":"tuple"},{"internalType":"uint256[48]","name":"accountMerkleProof","type":"uint256[48]"},{"internalType":"uint256[48]","name":"balanceMerkleProof","type":"uint256[48]"}],"internalType":"struct ExchangeData.MerkleProof","name":"merkleProof","type":"tuple"}],"name":"withdrawFromMerkleTree","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526022805460ff1916905534801561001a57600080fd5b50600080546001600160a01b031916331790556155408061003c6000396000f3fe60806040526004361061036b5760003560e01c80638a554abe116101c6578063c8e26cae116100f7578063e795799211610095578063f2fde38b1161006f578063f2fde38b14610997578063f698da2514610982578063f732e021146109b7578063fc0e74d1146109cc5761036b565b8063e795799214610942578063ed05ae7814610962578063ed24911d146109825761036b565b8063ce2ec5de116100d1578063ce2ec5de146108cd578063cea69b86146108ed578063d59acd251461090d578063e30c39781461092d5761036b565b8063c8e26cae1461086d578063cd097b4f1461088d578063cdb1b44b146108ad5761036b565b80639a295e7311610164578063ab94276a1161013e578063ab94276a146107e8578063bb141cf4146107fd578063bf86d6901461082a578063c19d93fb1461083f5761036b565b80639a295e7314610791578063a75f8a4e146107b3578063a7bff050146107d35761036b565b806391b11ad4116101a057806391b11ad41461072757806392f54afc1461073c578063960af2d91461075c578063972f75651461077c5761036b565b80638a554abe146106d25780638d2a8888146106f25780638da5cb5b146107125761036b565b80634e71e0c8116102a057806370f30de31161023e5780637907140e116102185780637907140e146106755780637bb96acb146106955780637beefcd4146106aa5780638070f2ca146106bf5761036b565b806370f30de314610620578063715018a61461064057806376cfcff6146106555761036b565b806354fd4d501161027a57806354fd4d50146105a95780636008cd1f146105cb57806363f8071c146105eb57806369b914321461060b5761036b565b80634e71e0c814610547578063532284301461055c578063543d7a191461057c5761036b565b80632c3d356b1161030d5780634597d3ce116102e75780634597d3ce146104e457806347b67d051461050a578063495906571461051d5780634a14cd84146105325761036b565b80632c3d356b146104775780632fa5825f14610497578063438c2a42146104b75761036b565b80630ec2e821116103495780630ec2e821146103f55780631280f724146104155780631de679661461043557806328068da3146104575761036b565b806301b1eb071461037057806309824a80146103925780630c6dd8c9146103c8575b600080fd5b34801561037c57600080fd5b5061039061038b366004614307565b6109e1565b005b34801561039e57600080fd5b506103b26103ad366004613f3c565b610b29565b6040516103bf91906152f1565b60405180910390f35b3480156103d457600080fd5b506103e86103e3366004613f3c565b610c36565b6040516103bf9190614917565b34801561040157600080fd5b50610390610410366004613f3c565b610daf565b34801561042157600080fd5b5061039061043036600461433f565b610f4c565b34801561044157600080fd5b5061044a611016565b6040516103bf919061490c565b34801561046357600080fd5b50610390610472366004614154565b61101f565b34801561048357600080fd5b5061044a61049236600461440c565b611174565b3480156104a357600080fd5b506103e86104b2366004613f74565b6111b4565b3480156104c357600080fd5b506104d76104d2366004613f74565b611223565b6040516103bf91906152aa565b3480156104f057600080fd5b506104f9611292565b6040516103bf9594939291906153a9565b6103906105183660046141e9565b6112de565b34801561052957600080fd5b506103e86113ef565b34801561053e57600080fd5b506103b26113f5565b34801561055357600080fd5b50610390611401565b34801561056857600080fd5b506103906105773660046142c7565b6114e8565b34801561058857600080fd5b5061059c6105973660046143d4565b611606565b6040516103bf919061468b565b3480156105b557600080fd5b506105be6116ac565b6040516103bf9190614959565b3480156105d757600080fd5b5061044a6105e6366004614233565b6116e3565b3480156105f757600080fd5b506103b2610606366004613f3c565b61171b565b34801561061757600080fd5b506103e8611728565b34801561062c57600080fd5b5061039061063b36600461440c565b611739565b34801561064c57600080fd5b506103906118af565b34801561066157600080fd5b506103906106703660046141a4565b61196f565b34801561068157600080fd5b506103906106903660046140d3565b611b36565b3480156106a157600080fd5b506103e8611db6565b3480156106b657600080fd5b506103e8611dbc565b6103906106cd366004613fac565b611dc2565b3480156106de57600080fd5b5061044a6106ed366004613f3c565b611e9a565b3480156106fe57600080fd5b5061039061070d366004613f74565b611f85565b34801561071e57600080fd5b5061059c612019565b34801561073357600080fd5b5061044a612035565b34801561074857600080fd5b5061044a61075736600461440c565b612041565b34801561076857600080fd5b506103b26107773660046143d4565b6120a2565b34801561078857600080fd5b50610390612189565b34801561079d57600080fd5b506107a6612331565b6040516103bf9190614eb1565b3480156107bf57600080fd5b506103906107ce366004613f74565b6123d1565b3480156107df57600080fd5b506103e8612600565b3480156107f457600080fd5b5061059c612606565b34801561080957600080fd5b5061081d610818366004614373565b612622565b6040516103bf9190614e72565b34801561083657600080fd5b5061044a612682565b34801561084b57600080fd5b5061085461268e565b6040516103bf9d9c9b9a99989796959493929190615302565b34801561087957600080fd5b506103e8610888366004613f3c565b612799565b34801561089957600080fd5b506103906108a836600461425e565b6127c1565b3480156108b957600080fd5b506103906108c836600461425e565b612859565b3480156108d957600080fd5b506103e86108e8366004613f3c565b612aaf565b3480156108f957600080fd5b5061059c610908366004614063565b612be6565b34801561091957600080fd5b50610390610928366004614233565b612c79565b34801561093957600080fd5b5061059c612d95565b34801561094e57600080fd5b5061039061095d3660046143a3565b612db1565b34801561096e57600080fd5b506104d761097d366004613f3c565b612e84565b34801561098e57600080fd5b506103e8612ecf565b3480156109a357600080fd5b506103906109b2366004613f3c565b612ed5565b3480156109c357600080fd5b506103e8612fe3565b3480156109d857600080fd5b5061044a61308a565b60025415610a24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60405180910390fd5b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314610a7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60225460ff1615158115151415610abd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614aed565b602280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f17d24aa44406852bec8b62a0f7e5aa1becf54dc52cfe7d6976325584cb51fc5b90610b1990839061490c565b60405180910390a1506000600255565b6000600254600014610b67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556000546040517f5ac78334000000000000000000000000000000000000000000000000000000008152732bf7021a3aa041e1a8a5082db720d0202c70a3ae91635ac7833491610bdb91600391879173ffffffffffffffffffffffffffffffffffffffff16331490600401614fb9565b60206040518083038186803b158015610bf357600080fd5b505af4158015610c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b91906143f0565b600060025592915050565b600080610c446003846131e7565b9050600063ffffffff8216610cba5763ffffffff808316600090815260146020526040902054600854610cb39273ffffffffffffffffffffffffffffffffffffffff90911631917effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169061327416565b9050610da8565b63ffffffff8216600090815260146020526040908190205460085491517f70a08231000000000000000000000000000000000000000000000000000000008152610da5927effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169173ffffffffffffffffffffffffffffffffffffffff808916926370a0823192610d4f92169060040161468b565b60206040518083038186803b158015610d6757600080fd5b505afa158015610d7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9f919061438b565b90613274565b90505b9392505050565b60025415610de9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314610e3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff8116610e8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b60085473ffffffffffffffffffffffffffffffffffffffff1615610edc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ab6565b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790556040517f88d7f6699f4edd4606a19dfeb74ff4531bd8941e1a059fd431ddff444f7b035f90610b1990839061468b565b60025415610f86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517fcae3c781000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063cae3c78190610fde9060039085906004016151e8565b60006040518083038186803b158015610ff657600080fd5b505af415801561100a573d6000803e3d6000fd5b50506000600255505050565b60225460ff1681565b60025415611059576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558361106881611e9a565b61109e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60225460ff166110da576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b5b565b6008546040517ff18d03cc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063f18d03cc9061113690889088908890889060040161473f565b600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b5050600060025550505050505050565b6000806111826003846131e7565b63ffffffff808616600090815260176020908152604080832093909416825291909152205460ff169150505b92915050565b6000806111c26003846131e7565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260186020908152604080832063ffffffff909416835292905220547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505092915050565b6000806112316003846131e7565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601a6020908152604080832063ffffffff909416835292905220547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505092915050565b601e5463ffffffff8082169261ffff64010000000084048116936601000000000000810482169368010000000000000000820416926c0100000000000000000000000090910490911690565b60025415611318576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558261132781611e9a565b61135d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f997f0d5f000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063997f0d5f906113b490600390889088908890600401614f81565b60006040518083038186803b1580156113cc57600080fd5b505af41580156113e0573d6000803e3d6000fd5b50506000600255505050505050565b600e5490565b60035463ffffffff1690565b60015473ffffffffffffffffffffffffffffffffffffffff163314611452576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff93841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60025415611522576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314611578576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f5ee5495b000000000000000000000000000000000000000000000000000000008152734ad92ee2019a6a26c9e38caedd46503bd7f79c1090635ee5495b906115cd9060039086908690600401615059565b60006040518083038186803b1580156115e557600080fd5b505af41580156115f9573d6000803e3d6000fd5b5050600060025550505050565b6040517fcb25fdbe000000000000000000000000000000000000000000000000000000008152600090732bf7021a3aa041e1a8a5082db720d0202c70a3ae9063cb25fdbe9061165c906003908690600401615296565b60206040518083038186803b15801561167457600080fd5b505af4158015611688573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190613f58565b60408051808201909152600581527f302e312e30000000000000000000000000000000000000000000000000000000602082015290565b73ffffffffffffffffffffffffffffffffffffffff919091166000908152601b60209081526040808320938352929052205460ff1690565b60006111ae6003836131e7565b600061173460036132b6565b905090565b60025415611773576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560006117856003836131e7565b63ffffffff848116600090815260196020908152604080832093851683529290522080549192509074010000000000000000000000000000000000000000900467ffffffffffffffff16611805576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d13565b805467ffffffffffffffff74010000000000000000000000000000000000000000909104166213c68001421015611868576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d13565b4260208190556040517f5b8f5ce93a49fc6eab534327f9c77fd2966e16278d6135cc0d99e6b6450c79639161189c91614917565b60405180910390a1505060006002555050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611900576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b600254156119a9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560055473ffffffffffffffffffffffffffffffffffffffff161580156119d45750600e54155b611a0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b9061496c565b73ffffffffffffffffffffffffffffffffffffffff8316611a57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85161790556040805160a08101909152600f606082019081527f4465476174652050726f746f636f6c0000000000000000000000000000000000608083015281527357f2baa929ece41d8b6fdc4c7f7b60b95522abcb90630f903da490600390879086908690611b169060208101611b086116ac565b8152306020909101526132c8565b6040518663ffffffff1660e01b81526004016113b4959493929190614fe7565b60025415611b70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025585611b7f81611e9a565b611bb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff8216611c02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614dde565b6000611c0f6003876131e7565b73ffffffffffffffffffffffffffffffffffffffff8981166000908152601c602090815260408083208c85168452825280832063ffffffff80871685529083528184207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8c1685528352818420908a1684529091529020549192501615611cc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d4a565b73ffffffffffffffffffffffffffffffffffffffff8881166000908152601c602090815260408083208b85168452825280832063ffffffff86811685529083528184207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b168552835281842090891684529091529081902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001692861692909217909155517fbf71661a97663230b12613d9e77a7d73cd25efa46a80a34836ee240f02c5641390611d9f908a908a908a908a908a908a906146d3565b60405180910390a150506000600255505050505050565b60115490565b600a5490565b60025415611dfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025585611e0b81611e9a565b611e41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b611e8c8787878787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506003979695949392505061333f9050565b505060006002555050505050565b600073ffffffffffffffffffffffffffffffffffffffff82163314806111ae575060075473ffffffffffffffffffffffffffffffffffffffff16158015906111ae57506007546040517f4ebf59d200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690634ebf59d290611f3590859033906004016146ac565b60206040518083038186803b158015611f4d57600080fd5b505afa158015611f61573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190614323565b60025415611fbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517f95d75555000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e33906395d75555906115cd9060039086908690600401614f55565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60006117346003613964565b60008061204f6003846131e7565b63ffffffff808616600090815260196020908152604080832093909416825291909152205467ffffffffffffffff7401000000000000000000000000000000000000000090910416151591505092915050565b60006002546000146120e0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612136576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f1854b85c000000000000000000000000000000000000000000000000000000008152730a5d144adf62e18ee222f2d05a2bf2037ce8eeae90631854b85c90610bdb906003908690600401615296565b600254156121c3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556121d26003613964565b1561232a576005546040517f883515c100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883515c19061222e90309060040161468b565b60206040518083038186803b15801561224657600080fd5b505afa15801561225a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227e919061438b565b6005546040517fc51c820800000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063c51c8208906122d5908490600401614917565b602060405180830381600087803b1580156122ef57600080fd5b505af1158015612303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612327919061438b565b50505b6000600255565b612339613e5b565b5060408051610180810182527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018152620f424060208201526213c68091810182905262093a80606082018190526401000000006080830181905260a083015260c082015262278d0060e082015260536101008201526101208101919091526703782dace9d90000610140820152601261016082015290565b6002541561240b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612461576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff81166124ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149a3565b73ffffffffffffffffffffffffffffffffffffffff82166124f457476124ed815a73ffffffffffffffffffffffffffffffffffffffff8516919061396d565b50506125be565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8416906370a082319061254990309060040161468b565b60206040518083038186803b15801561256157600080fd5b505afa158015612575573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612599919061438b565b90506125bc73ffffffffffffffffffffffffffffffffffffffff841683836139c9565b505b7faa34b6f2263f4f4931586178b8e2d225effbfae46a95b5c56c6c641a8a21f62982826040516125ef9291906146ac565b60405180910390a150506000600255565b600f5490565b60085473ffffffffffffffffffffffffffffffffffffffff1690565b61262a613ebc565b5060009081526010602090815260409182902082518084019093525463ffffffff811683526401000000009004811b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000169082015290565b600061173460036139da565b6003546004546005546006546007546008546040805160a080820183526009548252600a54602080840191909152600b5483850152600c54606080850191909152600d54608080860191909152600e54600f54601154601d5489519788018a52601e5463ffffffff8181168a5261ffff640100000000830481168b8b01526601000000000000830481168b8e01526801000000000000000083048216988b01989098526c01000000000000000000000000909104909616948801949094528851808a01909952601f5489528554958901959095529c83169c73ffffffffffffffffffffffffffffffffffffffff9b8c169b9a8b169a998a16999890981697959690959491909216918d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526021602052604090205490565b600254156127fb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517ff460cca9000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063f460cca9906113b4906003908890889088908890600401615020565b60025415612893576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558281146128d1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614dde565b6007546040517f2eac95f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690632eac95f19061292b9087908790339060040161486c565b60206040518083038186803b15801561294357600080fd5b505afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190614323565b6129b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60005b83811015612a79576001601b60008787858181106129ce57fe5b90506020020160208101906129e39190613f3c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858585818110612a2b57fe5b6020908102929092013583525081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790556001016129b4565b507fe548a963a45d48f7887098ee1903d1291c4bef5b33e4fa75fced37e24b3a20da8484848460405161189c94939291906148a6565b6000600254600014612aed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612b43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517ff93234a2000000000000000000000000000000000000000000000000000000008152730a5d144adf62e18ee222f2d05a2bf2037ce8eeae9063f93234a290612b96906003908690600401614f31565b60206040518083038186803b158015612bae57600080fd5b505af4158015612bc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b919061438b565b600080612bf46003866131e7565b73ffffffffffffffffffffffffffffffffffffffff8089166000908152601c602090815260408083208b85168452825280832063ffffffff958616845282528083207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a1684528252808320948816835293905291909120541691505095945050505050565b60025415612cb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025581612cc281611e9a565b612cf8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601b602090815260408083208584529091529081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f7115b98931e7aca6d0aa11d10fe28877316a661a44c4bfc93c76b19dbbf5b10790612d839085908590614846565b60405180910390a15050600060025550565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60025415612deb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612e41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b612e4f6003858585856139e3565b7fd5ed9d44b4e70b483ebc5cb0f4b40468805a9cb2f9249d0201d77ef64d6368828484848460405161189c94939291906152d6565b600080612e926003846131e7565b63ffffffff166000908152601460205260409020547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169392505050565b60045490565b60005473ffffffffffffffffffffffffffffffffffffffff163314612f26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff811615801590612f66575060005473ffffffffffffffffffffffffffffffffffffffff828116911614155b612f9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149a3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6005546040517f883515c100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883515c19061303a90309060040161468b565b60206040518083038186803b15801561305257600080fd5b505afa158015613066573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611734919061438b565b60006002546000146130c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff16331461311e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6131286003613964565b1561315f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c00565b61316960036139da565b156131a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c37565b42601f8190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a916131d491614917565b60405180910390a1506001600060025590565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260128301602052604090205463ffffffff168061324c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c6e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b6000828211156132b0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b92565b50900390565b601a015463ffffffff16620f42400390565b6000804690507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f836000015180519060200120846020015180519060200120838660400151604051602001613321959493929190614920565b60405160208183030381529060405280519060200120915050919050565b73ffffffffffffffffffffffffffffffffffffffff841661338c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16146133f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149da565b6000806133fe8886613a00565b91509150806134af576040517f5ac78334000000000000000000000000000000000000000000000000000000008152732bf7021a3aa041e1a8a5082db720d0202c70a3ae90635ac783349061345c908b908990600090600401614fb9565b60206040518083038186803b15801561347457600080fd5b505af4158015613488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ac91906143f0565b91505b63ffffffff82161580156134e257507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8416155b1561351f57341561351f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a7f565b600061352a89613a6c565b1561356e5750600a8801546040517f12197207b0a54de931fdf21dc8066c293dc29b9dd4875c6b64a36c6a36ff904090613565908390614917565b60405180910390a15b803410156135a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614cdc565b60058901546040517f5e1da861000000000000000000000000000000000000000000000000000000008152348390039160009173ffffffffffffffffffffffffffffffffffffffff90911690635e1da861908490613610908e908d908d908d906004016147dc565b6020604051808303818588803b15801561362957600080fd5b505af115801561363d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906136629190614357565b905061366c613ebc565b5073ffffffffffffffffffffffffffffffffffffffff8916600090815260178c016020908152604080832063ffffffff808a168552908352928190208151808301909252547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168082524267ffffffffffffffff1692820192909252916136f591908490613afc16565b81600001907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681525050808c60170160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008863ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a8154817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02191690837effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050506138b0828d60110160008963ffffffff1663ffffffff16815260200190815260200160002060009054906101000a90047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16613afc90919063ffffffff16565b63ffffffff8716600090815260118e0160205260409081902080547fff00000000000000000000000000000000000000000000000000000000000000167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9390931692909217909155517f5cc43c6b47c350258362c540eb61d09c2060eaa8b760707b2892d08a01f6e9c39061394e908d908d908d908b908890614776565b60405180910390a1505050505050505050505050565b601d0154151590565b600061399073ffffffffffffffffffffffffffffffffffffffff85168484613b5d565b905080610da8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b24565b6139d58383835a613c04565b505050565b601c0154151590565b600685019390935560078401919091556009830155600a90910155565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260128301602052604081205463ffffffff169081613a3f57506000905080613a65565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160015b9250929050565b6009810154600882015460009182918291613aa291613a979190613a91904390613274565b90613c4c565b600786015490613c9a565b6006850154909150811115613ab8575060068301545b8015613ae5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01613aea565b600191505b60078401554360088401559050919050565b8181017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80841690821610156111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ca5565b600082613b6c57506001610da8565b6000613b8d8573ffffffffffffffffffffffffffffffffffffffff16613cd7565b90508073ffffffffffffffffffffffffffffffffffffffff16848490604051613bb590613cd7565b600060405180830381858888f193505050503d8060008114613bf3576040519150601f19603f3d011682016040523d82523d6000602084013e613bf8565b606091505b50909695505050505050565b613c1084848484613cda565b613c46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b24565b50505050565b818102821580613c64575081838281613c6157fe5b04145b6111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614da7565b818101828110156111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ca5565b90565b6000613ce585613e1a565b613d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614e15565b606063a9059cbb60e01b8585604051602401613d38929190614846565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008673ffffffffffffffffffffffffffffffffffffffff168483604051613dbf919061466f565b60006040518083038160008787f1925050503d8060008114613dfd576040519150601f19603f3d011682016040523d82523d6000602084013e613e02565b606091505b50509050613e0f81613e20565b979650505050505050565b3b151590565b60008115613e57573d8015613e405760208114613e495760009250613e55565b60019250613e55565b60206000803e60005192505b505b5090565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b80356111ae81615498565b60008083601f840112613eef578182fd5b50813567ffffffffffffffff811115613f06578182fd5b6020830191508360208083028501011115613a6557600080fd5b80356111ae816154f8565b803560ff811681146111ae57600080fd5b600060208284031215613f4d578081fd5b8135610da881615498565b600060208284031215613f69578081fd5b8151610da881615498565b60008060408385031215613f86578081fd5b8235613f9181615498565b91506020830135613fa181615498565b809150509250929050565b60008060008060008060a08789031215613fc4578182fd5b8635613fcf81615498565b95506020870135613fdf81615498565b94506040870135613fef81615498565b93506060870135613fff816154cb565b9250608087013567ffffffffffffffff8082111561401b578384fd5b818901915089601f83011261402e578384fd5b81358181111561403c578485fd5b8a602082850101111561404d578485fd5b6020830194508093505050509295509295509295565b600080600080600060a0868803121561407a578081fd5b853561408581615498565b9450602086013561409581615498565b935060408601356140a581615498565b925060608601356140b5816154cb565b915060808601356140c5816154f8565b809150509295509295909350565b60008060008060008060c087890312156140eb578182fd5b86356140f681615498565b9550602087013561410681615498565b9450604087013561411681615498565b93506060870135614126816154cb565b92506080870135614136816154f8565b915060a087013561414681615498565b809150509295509295509295565b60008060008060808587031215614169578182fd5b843561417481615498565b9350602085013561418481615498565b9250604085013561419481615498565b9396929550929360600135925050565b600080600080608085870312156141b9578182fd5b84356141c481615498565b935060208501356141d481615498565b93969395505050506040820135916060013590565b6000806000606084860312156141fd578081fd5b833561420881615498565b9250602084013561421881615498565b91506040840135614228816154f8565b809150509250925092565b60008060408385031215614245578182fd5b823561425081615498565b946020939093013593505050565b60008060008060408587031215614273578182fd5b843567ffffffffffffffff8082111561428a578384fd5b61429688838901613ede565b909650945060208701359150808211156142ae578384fd5b506142bb87828801613ede565b95989497509550505050565b600080602083850312156142d9578182fd5b823567ffffffffffffffff8111156142ef578283fd5b6142fb85828601613ede565b90969095509350505050565b600060208284031215614318578081fd5b8135610da8816154bd565b600060208284031215614334578081fd5b8151610da8816154bd565b6000610ce08284031215614351578081fd5b50919050565b600060208284031215614368578081fd5b8151610da8816154cb565b600060208284031215614384578081fd5b5035919050565b60006020828403121561439c578081fd5b5051919050565b600080600080608085870312156143b8578182fd5b5050823594602084013594506040840135936060013592509050565b6000602082840312156143e5578081fd5b8135610da8816154f8565b600060208284031215614401578081fd5b8151610da8816154f8565b6000806040838503121561441e578182fd5b8235613f91816154f8565b60008284526020808501945082825b8581101561447357813561444b81615498565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614438565b509495945050505050565b60008284526020808501945082825b858110156144735781356144a081615498565b73ffffffffffffffffffffffffffffffffffffffff168752958201959082019060010161448d565b61060080828437600081840152505050565b61010080828437600081840152505050565b15159052565b600082845282826020860137806020848601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011685010190509392505050565b6000815180845261455281602086016020860161546c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b803561458f816154f8565b63ffffffff16825260208101356145a5816154cb565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166020840152505050565b80518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b80518252602090810151910152565b63ffffffff808251168352602082015161ffff80821660208601528060408501511660408601528260608501511660608601528060808501511660808601525050505050565b61ffff169052565b63ffffffff169052565b60ff169052565b6000825161468181846020870161546c565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292851660408501527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91909116606084015263ffffffff16608083015290911660a082015260c00190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b73ffffffffffffffffffffffffffffffffffffffff9586168152938516602085015291909316604083015263ffffffff90921660608201527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909116608082015260a00190565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841660408301526080606083015261483c608083018461453a565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b600060408252614880604083018587614429565b905073ffffffffffffffffffffffffffffffffffffffff83166020830152949350505050565b6000604082526148ba604083018688614429565b82810360208401528381527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8411156148f1578182fd5b60208402808660208401370160200190815295945050505050565b901515815260200190565b90815260200190565b94855260208501939093526040840191909152606083015273ffffffffffffffffffffffffffffffffffffffff16608082015260a00190565b600060208252610da8602083018461453a565b6020808252600b908201527f494e495449414c495a4544000000000000000000000000000000000000000000604082015260600190565b6020808252600f908201527f494e56414c49445f414444524553530000000000000000000000000000000000604082015260600190565b60208082526014908201527f494e56414c49445f4445504f5349545f46524f4d000000000000000000000000604082015260600190565b6020808252600a908201527f5245454e5452414e435900000000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f554e415554484f52495a45440000000000000000000000000000000000000000604082015260600190565b60208082526013908201527f494e56414c49445f4554485f4445504f53495400000000000000000000000000604082015260600190565b6020808252600b908201527f414c52454144595f534554000000000000000000000000000000000000000000604082015260600190565b6020808252600a908201527f53414d455f56414c554500000000000000000000000000000000000000000000604082015260600190565b60208082526010908201527f5452414e534645525f4641494c55524500000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e4f545f414c4c4f574544000000000000000000000000000000000000000000604082015260600190565b6020808252600d908201527f5355425f554e444552464c4f5700000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f5a45524f5f414444524553530000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f494e56414c49445f4d4f44450000000000000000000000000000000000000000604082015260600190565b60208082526010908201527f414c52454144595f53485554444f574e00000000000000000000000000000000604082015260600190565b6020808252600f908201527f544f4b454e5f4e4f545f464f554e440000000000000000000000000000000000604082015260600190565b6020808252600c908201527f4144445f4f564552464c4f570000000000000000000000000000000000000000604082015260600190565b60208082526018908201527f494e53554646494349454e545f4445504f5349545f4645450000000000000000604082015260600190565b60208082526016908201527f5749544844524157414c5f4e4f545f544f4f5f4f4c4400000000000000000000604082015260600190565b60208082526021908201527f43414e4e4f545f4f564552524944455f524543495049454e545f41444452455360408201527f5300000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252600c908201527f4d554c5f4f564552464c4f570000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f494e56414c49445f444154410000000000000000000000000000000000000000604082015260600190565b60208082526027908201527f4552433230536166655472616e736665723a2063616c6c20746f206e6f6e2d6360408201527f6f6e747261637400000000000000000000000000000000000000000000000000606082015260800190565b815163ffffffff1681526020918201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000169181019190915260400190565b815181526020808301519082015260408083015190820152606080830151908201526080808301519082015260a0808301519082015260c0808301519082015260e0808301519082015261010080830151908201526101208083015190820152610140808301519082015261016091820151918101919091526101800190565b91825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b93845273ffffffffffffffffffffffffffffffffffffffff92831660208501529116604083015263ffffffff16606082015260800190565b92835273ffffffffffffffffffffffffffffffffffffffff9190911660208301521515604082015260600190565b94855273ffffffffffffffffffffffffffffffffffffffff93909316602085015260408401919091526060830152608082015260a00190565b60008682526060602083015261503a60608301868861447e565b828103604084015261504d81858761447e565b98975050505050505050565b83815260406020808301829052828201849052600091906060908185018682028601830188865b898110156151d8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa089840301845281357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe218c36030181126150e0578889fd5b8b016101e086820160ff6150f48285613f2b565b168652615101818461544a565b905061510f88870182614656565b5061511c8983018361545d565b6151288a870182614668565b50615135888301836153e7565b828a88015261514783880182846144f2565b92505050608061515b8187018285016144da565b5061018061516b818401846153da565b615177828801826144ec565b50506101a0615188818401846153e7565b8784038389015261519a8482846144f2565b93505050506101c06151ae818401846153e7565b9350868303828801526151c28385836144f2565b9789019796505050928601925050600101615080565b50909a9950505050505050505050565b828152610d00810182356151fb816154f8565b63ffffffff81166020840152506040830173ffffffffffffffffffffffffffffffffffffffff61522e8260208701613ed3565b16604084015280356060840152506060830135608083015260a083016152578160808601613f20565b61526460a085018261465e565b5061527260c0840182614584565b50615284610100830160e085016144c8565b610da861070083016106e085016144c8565b91825263ffffffff16602082015260400190565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91909116815260200190565b93845260208401929092526040830152606082015260800190565b63ffffffff91909116815260200190565b63ffffffff8e168152602081018d905273ffffffffffffffffffffffffffffffffffffffff8c811660408301528b811660608301528a81166080830152891660a08201526102c0810161535860c083018a6145d1565b8761016083015286610180830152856101a083015261537b6101c083018661465e565b6153896101e0830185614610565b615397610280830184614601565b9e9d5050505050505050505050505050565b63ffffffff958616815261ffff94851660208201529284166040840152931660608201529116608082015260a00190565b60008235610da8816154bd565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261541b578283fd5b830160208101925035905067ffffffffffffffff81111561543b57600080fd5b803603831315613a6557600080fd5b6000823561ffff81168114610da8578182fd5b6000610da86020840184613f2b565b60005b8381101561548757818101518382015260200161546f565b83811115613c465750506000910152565b73ffffffffffffffffffffffffffffffffffffffff811681146154ba57600080fd5b50565b80151581146154ba57600080fd5b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146154ba57600080fd5b63ffffffff811681146154ba57600080fdfea2646970667358221220ef2ae624677c8106d2ff439b7093d388a10413c0c426ed7a90b110b3e3154abb64736f6c63430007000033

Deployed Bytecode

0x60806040526004361061036b5760003560e01c80638a554abe116101c6578063c8e26cae116100f7578063e795799211610095578063f2fde38b1161006f578063f2fde38b14610997578063f698da2514610982578063f732e021146109b7578063fc0e74d1146109cc5761036b565b8063e795799214610942578063ed05ae7814610962578063ed24911d146109825761036b565b8063ce2ec5de116100d1578063ce2ec5de146108cd578063cea69b86146108ed578063d59acd251461090d578063e30c39781461092d5761036b565b8063c8e26cae1461086d578063cd097b4f1461088d578063cdb1b44b146108ad5761036b565b80639a295e7311610164578063ab94276a1161013e578063ab94276a146107e8578063bb141cf4146107fd578063bf86d6901461082a578063c19d93fb1461083f5761036b565b80639a295e7314610791578063a75f8a4e146107b3578063a7bff050146107d35761036b565b806391b11ad4116101a057806391b11ad41461072757806392f54afc1461073c578063960af2d91461075c578063972f75651461077c5761036b565b80638a554abe146106d25780638d2a8888146106f25780638da5cb5b146107125761036b565b80634e71e0c8116102a057806370f30de31161023e5780637907140e116102185780637907140e146106755780637bb96acb146106955780637beefcd4146106aa5780638070f2ca146106bf5761036b565b806370f30de314610620578063715018a61461064057806376cfcff6146106555761036b565b806354fd4d501161027a57806354fd4d50146105a95780636008cd1f146105cb57806363f8071c146105eb57806369b914321461060b5761036b565b80634e71e0c814610547578063532284301461055c578063543d7a191461057c5761036b565b80632c3d356b1161030d5780634597d3ce116102e75780634597d3ce146104e457806347b67d051461050a578063495906571461051d5780634a14cd84146105325761036b565b80632c3d356b146104775780632fa5825f14610497578063438c2a42146104b75761036b565b80630ec2e821116103495780630ec2e821146103f55780631280f724146104155780631de679661461043557806328068da3146104575761036b565b806301b1eb071461037057806309824a80146103925780630c6dd8c9146103c8575b600080fd5b34801561037c57600080fd5b5061039061038b366004614307565b6109e1565b005b34801561039e57600080fd5b506103b26103ad366004613f3c565b610b29565b6040516103bf91906152f1565b60405180910390f35b3480156103d457600080fd5b506103e86103e3366004613f3c565b610c36565b6040516103bf9190614917565b34801561040157600080fd5b50610390610410366004613f3c565b610daf565b34801561042157600080fd5b5061039061043036600461433f565b610f4c565b34801561044157600080fd5b5061044a611016565b6040516103bf919061490c565b34801561046357600080fd5b50610390610472366004614154565b61101f565b34801561048357600080fd5b5061044a61049236600461440c565b611174565b3480156104a357600080fd5b506103e86104b2366004613f74565b6111b4565b3480156104c357600080fd5b506104d76104d2366004613f74565b611223565b6040516103bf91906152aa565b3480156104f057600080fd5b506104f9611292565b6040516103bf9594939291906153a9565b6103906105183660046141e9565b6112de565b34801561052957600080fd5b506103e86113ef565b34801561053e57600080fd5b506103b26113f5565b34801561055357600080fd5b50610390611401565b34801561056857600080fd5b506103906105773660046142c7565b6114e8565b34801561058857600080fd5b5061059c6105973660046143d4565b611606565b6040516103bf919061468b565b3480156105b557600080fd5b506105be6116ac565b6040516103bf9190614959565b3480156105d757600080fd5b5061044a6105e6366004614233565b6116e3565b3480156105f757600080fd5b506103b2610606366004613f3c565b61171b565b34801561061757600080fd5b506103e8611728565b34801561062c57600080fd5b5061039061063b36600461440c565b611739565b34801561064c57600080fd5b506103906118af565b34801561066157600080fd5b506103906106703660046141a4565b61196f565b34801561068157600080fd5b506103906106903660046140d3565b611b36565b3480156106a157600080fd5b506103e8611db6565b3480156106b657600080fd5b506103e8611dbc565b6103906106cd366004613fac565b611dc2565b3480156106de57600080fd5b5061044a6106ed366004613f3c565b611e9a565b3480156106fe57600080fd5b5061039061070d366004613f74565b611f85565b34801561071e57600080fd5b5061059c612019565b34801561073357600080fd5b5061044a612035565b34801561074857600080fd5b5061044a61075736600461440c565b612041565b34801561076857600080fd5b506103b26107773660046143d4565b6120a2565b34801561078857600080fd5b50610390612189565b34801561079d57600080fd5b506107a6612331565b6040516103bf9190614eb1565b3480156107bf57600080fd5b506103906107ce366004613f74565b6123d1565b3480156107df57600080fd5b506103e8612600565b3480156107f457600080fd5b5061059c612606565b34801561080957600080fd5b5061081d610818366004614373565b612622565b6040516103bf9190614e72565b34801561083657600080fd5b5061044a612682565b34801561084b57600080fd5b5061085461268e565b6040516103bf9d9c9b9a99989796959493929190615302565b34801561087957600080fd5b506103e8610888366004613f3c565b612799565b34801561089957600080fd5b506103906108a836600461425e565b6127c1565b3480156108b957600080fd5b506103906108c836600461425e565b612859565b3480156108d957600080fd5b506103e86108e8366004613f3c565b612aaf565b3480156108f957600080fd5b5061059c610908366004614063565b612be6565b34801561091957600080fd5b50610390610928366004614233565b612c79565b34801561093957600080fd5b5061059c612d95565b34801561094e57600080fd5b5061039061095d3660046143a3565b612db1565b34801561096e57600080fd5b506104d761097d366004613f3c565b612e84565b34801561098e57600080fd5b506103e8612ecf565b3480156109a357600080fd5b506103906109b2366004613f3c565b612ed5565b3480156109c357600080fd5b506103e8612fe3565b3480156109d857600080fd5b5061044a61308a565b60025415610a24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60405180910390fd5b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314610a7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60225460ff1615158115151415610abd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614aed565b602280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215151790556040517f17d24aa44406852bec8b62a0f7e5aa1becf54dc52cfe7d6976325584cb51fc5b90610b1990839061490c565b60405180910390a1506000600255565b6000600254600014610b67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556000546040517f5ac78334000000000000000000000000000000000000000000000000000000008152732bf7021a3aa041e1a8a5082db720d0202c70a3ae91635ac7833491610bdb91600391879173ffffffffffffffffffffffffffffffffffffffff16331490600401614fb9565b60206040518083038186803b158015610bf357600080fd5b505af4158015610c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b91906143f0565b600060025592915050565b600080610c446003846131e7565b9050600063ffffffff8216610cba5763ffffffff808316600090815260146020526040902054600854610cb39273ffffffffffffffffffffffffffffffffffffffff90911631917effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169061327416565b9050610da8565b63ffffffff8216600090815260146020526040908190205460085491517f70a08231000000000000000000000000000000000000000000000000000000008152610da5927effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092169173ffffffffffffffffffffffffffffffffffffffff808916926370a0823192610d4f92169060040161468b565b60206040518083038186803b158015610d6757600080fd5b505afa158015610d7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9f919061438b565b90613274565b90505b9392505050565b60025415610de9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314610e3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff8116610e8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b60085473ffffffffffffffffffffffffffffffffffffffff1615610edc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ab6565b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790556040517f88d7f6699f4edd4606a19dfeb74ff4531bd8941e1a059fd431ddff444f7b035f90610b1990839061468b565b60025415610f86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517fcae3c781000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063cae3c78190610fde9060039085906004016151e8565b60006040518083038186803b158015610ff657600080fd5b505af415801561100a573d6000803e3d6000fd5b50506000600255505050565b60225460ff1681565b60025415611059576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558361106881611e9a565b61109e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60225460ff166110da576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b5b565b6008546040517ff18d03cc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063f18d03cc9061113690889088908890889060040161473f565b600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b5050600060025550505050505050565b6000806111826003846131e7565b63ffffffff808616600090815260176020908152604080832093909416825291909152205460ff169150505b92915050565b6000806111c26003846131e7565b73ffffffffffffffffffffffffffffffffffffffff8516600090815260186020908152604080832063ffffffff909416835292905220547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505092915050565b6000806112316003846131e7565b73ffffffffffffffffffffffffffffffffffffffff85166000908152601a6020908152604080832063ffffffff909416835292905220547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505092915050565b601e5463ffffffff8082169261ffff64010000000084048116936601000000000000810482169368010000000000000000820416926c0100000000000000000000000090910490911690565b60025415611318576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558261132781611e9a565b61135d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f997f0d5f000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063997f0d5f906113b490600390889088908890600401614f81565b60006040518083038186803b1580156113cc57600080fd5b505af41580156113e0573d6000803e3d6000fd5b50506000600255505050505050565b600e5490565b60035463ffffffff1690565b60015473ffffffffffffffffffffffffffffffffffffffff163314611452576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff93841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60025415611522576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314611578576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f5ee5495b000000000000000000000000000000000000000000000000000000008152734ad92ee2019a6a26c9e38caedd46503bd7f79c1090635ee5495b906115cd9060039086908690600401615059565b60006040518083038186803b1580156115e557600080fd5b505af41580156115f9573d6000803e3d6000fd5b5050600060025550505050565b6040517fcb25fdbe000000000000000000000000000000000000000000000000000000008152600090732bf7021a3aa041e1a8a5082db720d0202c70a3ae9063cb25fdbe9061165c906003908690600401615296565b60206040518083038186803b15801561167457600080fd5b505af4158015611688573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190613f58565b60408051808201909152600581527f302e312e30000000000000000000000000000000000000000000000000000000602082015290565b73ffffffffffffffffffffffffffffffffffffffff919091166000908152601b60209081526040808320938352929052205460ff1690565b60006111ae6003836131e7565b600061173460036132b6565b905090565b60025415611773576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560006117856003836131e7565b63ffffffff848116600090815260196020908152604080832093851683529290522080549192509074010000000000000000000000000000000000000000900467ffffffffffffffff16611805576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d13565b805467ffffffffffffffff74010000000000000000000000000000000000000000909104166213c68001421015611868576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d13565b4260208190556040517f5b8f5ce93a49fc6eab534327f9c77fd2966e16278d6135cc0d99e6b6450c79639161189c91614917565b60405180910390a1505060006002555050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611900576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b600254156119a9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560055473ffffffffffffffffffffffffffffffffffffffff161580156119d45750600e54155b611a0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b9061496c565b73ffffffffffffffffffffffffffffffffffffffff8316611a57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85161790556040805160a08101909152600f606082019081527f4465476174652050726f746f636f6c0000000000000000000000000000000000608083015281527357f2baa929ece41d8b6fdc4c7f7b60b95522abcb90630f903da490600390879086908690611b169060208101611b086116ac565b8152306020909101526132c8565b6040518663ffffffff1660e01b81526004016113b4959493929190614fe7565b60025415611b70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025585611b7f81611e9a565b611bb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff8216611c02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614dde565b6000611c0f6003876131e7565b73ffffffffffffffffffffffffffffffffffffffff8981166000908152601c602090815260408083208c85168452825280832063ffffffff80871685529083528184207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8c1685528352818420908a1684529091529020549192501615611cc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614d4a565b73ffffffffffffffffffffffffffffffffffffffff8881166000908152601c602090815260408083208b85168452825280832063ffffffff86811685529083528184207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b168552835281842090891684529091529081902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001692861692909217909155517fbf71661a97663230b12613d9e77a7d73cd25efa46a80a34836ee240f02c5641390611d9f908a908a908a908a908a908a906146d3565b60405180910390a150506000600255505050505050565b60115490565b600a5490565b60025415611dfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025585611e0b81611e9a565b611e41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b611e8c8787878787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506003979695949392505061333f9050565b505060006002555050505050565b600073ffffffffffffffffffffffffffffffffffffffff82163314806111ae575060075473ffffffffffffffffffffffffffffffffffffffff16158015906111ae57506007546040517f4ebf59d200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690634ebf59d290611f3590859033906004016146ac565b60206040518083038186803b158015611f4d57600080fd5b505afa158015611f61573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190614323565b60025415611fbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517f95d75555000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e33906395d75555906115cd9060039086908690600401614f55565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60006117346003613964565b60008061204f6003846131e7565b63ffffffff808616600090815260196020908152604080832093909416825291909152205467ffffffffffffffff7401000000000000000000000000000000000000000090910416151591505092915050565b60006002546000146120e0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612136576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517f1854b85c000000000000000000000000000000000000000000000000000000008152730a5d144adf62e18ee222f2d05a2bf2037ce8eeae90631854b85c90610bdb906003908690600401615296565b600254156121c3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556121d26003613964565b1561232a576005546040517f883515c100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883515c19061222e90309060040161468b565b60206040518083038186803b15801561224657600080fd5b505afa15801561225a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227e919061438b565b6005546040517fc51c820800000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063c51c8208906122d5908490600401614917565b602060405180830381600087803b1580156122ef57600080fd5b505af1158015612303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612327919061438b565b50505b6000600255565b612339613e5b565b5060408051610180810182527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000018152620f424060208201526213c68091810182905262093a80606082018190526401000000006080830181905260a083015260c082015262278d0060e082015260536101008201526101208101919091526703782dace9d90000610140820152601261016082015290565b6002541561240b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612461576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff81166124ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149a3565b73ffffffffffffffffffffffffffffffffffffffff82166124f457476124ed815a73ffffffffffffffffffffffffffffffffffffffff8516919061396d565b50506125be565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8416906370a082319061254990309060040161468b565b60206040518083038186803b15801561256157600080fd5b505afa158015612575573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612599919061438b565b90506125bc73ffffffffffffffffffffffffffffffffffffffff841683836139c9565b505b7faa34b6f2263f4f4931586178b8e2d225effbfae46a95b5c56c6c641a8a21f62982826040516125ef9291906146ac565b60405180910390a150506000600255565b600f5490565b60085473ffffffffffffffffffffffffffffffffffffffff1690565b61262a613ebc565b5060009081526010602090815260409182902082518084019093525463ffffffff811683526401000000009004811b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000169082015290565b600061173460036139da565b6003546004546005546006546007546008546040805160a080820183526009548252600a54602080840191909152600b5483850152600c54606080850191909152600d54608080860191909152600e54600f54601154601d5489519788018a52601e5463ffffffff8181168a5261ffff640100000000830481168b8b01526601000000000000830481168b8e01526801000000000000000083048216988b01989098526c01000000000000000000000000909104909616948801949094528851808a01909952601f5489528554958901959095529c83169c73ffffffffffffffffffffffffffffffffffffffff9b8c169b9a8b169a998a16999890981697959690959491909216918d565b73ffffffffffffffffffffffffffffffffffffffff1660009081526021602052604090205490565b600254156127fb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002556040517ff460cca9000000000000000000000000000000000000000000000000000000008152739fb27470d766a29ac126cf99ee103087a4072e339063f460cca9906113b4906003908890889088908890600401615020565b60025415612893576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b60016002558281146128d1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614dde565b6007546040517f2eac95f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690632eac95f19061292b9087908790339060040161486c565b60206040518083038186803b15801561294357600080fd5b505afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190614323565b6129b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b60005b83811015612a79576001601b60008787858181106129ce57fe5b90506020020160208101906129e39190613f3c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858585818110612a2b57fe5b6020908102929092013583525081019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790556001016129b4565b507fe548a963a45d48f7887098ee1903d1291c4bef5b33e4fa75fced37e24b3a20da8484848460405161189c94939291906148a6565b6000600254600014612aed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612b43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6040517ff93234a2000000000000000000000000000000000000000000000000000000008152730a5d144adf62e18ee222f2d05a2bf2037ce8eeae9063f93234a290612b96906003908690600401614f31565b60206040518083038186803b158015612bae57600080fd5b505af4158015612bc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b919061438b565b600080612bf46003866131e7565b73ffffffffffffffffffffffffffffffffffffffff8089166000908152601c602090815260408083208b85168452825280832063ffffffff958616845282528083207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8a1684528252808320948816835293905291909120541691505095945050505050565b60025415612cb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025581612cc281611e9a565b612cf8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601b602090815260408083208584529091529081902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f7115b98931e7aca6d0aa11d10fe28877316a661a44c4bfc93c76b19dbbf5b10790612d839085908590614846565b60405180910390a15050600060025550565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60025415612deb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff163314612e41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b612e4f6003858585856139e3565b7fd5ed9d44b4e70b483ebc5cb0f4b40468805a9cb2f9249d0201d77ef64d6368828484848460405161189c94939291906152d6565b600080612e926003846131e7565b63ffffffff166000908152601460205260409020547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169392505050565b60045490565b60005473ffffffffffffffffffffffffffffffffffffffff163314612f26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b73ffffffffffffffffffffffffffffffffffffffff811615801590612f66575060005473ffffffffffffffffffffffffffffffffffffffff828116911614155b612f9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149a3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6005546040517f883515c100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff169063883515c19061303a90309060040161468b565b60206040518083038186803b15801561305257600080fd5b505afa158015613066573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611734919061438b565b60006002546000146130c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a11565b600160025560005473ffffffffffffffffffffffffffffffffffffffff16331461311e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a48565b6131286003613964565b1561315f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c00565b61316960036139da565b156131a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c37565b42601f8190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a916131d491614917565b60405180910390a1506001600060025590565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260128301602052604090205463ffffffff168061324c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614c6e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b6000828211156132b0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b92565b50900390565b601a015463ffffffff16620f42400390565b6000804690507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f836000015180519060200120846020015180519060200120838660400151604051602001613321959493929190614920565b60405160208183030381529060405280519060200120915050919050565b73ffffffffffffffffffffffffffffffffffffffff841661338c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614bc9565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16146133f1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b906149da565b6000806133fe8886613a00565b91509150806134af576040517f5ac78334000000000000000000000000000000000000000000000000000000008152732bf7021a3aa041e1a8a5082db720d0202c70a3ae90635ac783349061345c908b908990600090600401614fb9565b60206040518083038186803b15801561347457600080fd5b505af4158015613488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ac91906143f0565b91505b63ffffffff82161580156134e257507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8416155b1561351f57341561351f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614a7f565b600061352a89613a6c565b1561356e5750600a8801546040517f12197207b0a54de931fdf21dc8066c293dc29b9dd4875c6b64a36c6a36ff904090613565908390614917565b60405180910390a15b803410156135a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614cdc565b60058901546040517f5e1da861000000000000000000000000000000000000000000000000000000008152348390039160009173ffffffffffffffffffffffffffffffffffffffff90911690635e1da861908490613610908e908d908d908d906004016147dc565b6020604051808303818588803b15801561362957600080fd5b505af115801561363d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906136629190614357565b905061366c613ebc565b5073ffffffffffffffffffffffffffffffffffffffff8916600090815260178c016020908152604080832063ffffffff808a168552908352928190208151808301909252547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168082524267ffffffffffffffff1692820192909252916136f591908490613afc16565b81600001907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681525050808c60170160008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008863ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a8154817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02191690837effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050506138b0828d60110160008963ffffffff1663ffffffff16815260200190815260200160002060009054906101000a90047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16613afc90919063ffffffff16565b63ffffffff8716600090815260118e0160205260409081902080547fff00000000000000000000000000000000000000000000000000000000000000167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9390931692909217909155517f5cc43c6b47c350258362c540eb61d09c2060eaa8b760707b2892d08a01f6e9c39061394e908d908d908d908b908890614776565b60405180910390a1505050505050505050505050565b601d0154151590565b600061399073ffffffffffffffffffffffffffffffffffffffff85168484613b5d565b905080610da8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b24565b6139d58383835a613c04565b505050565b601c0154151590565b600685019390935560078401919091556009830155600a90910155565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260128301602052604081205463ffffffff169081613a3f57506000905080613a65565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160015b9250929050565b6009810154600882015460009182918291613aa291613a979190613a91904390613274565b90613c4c565b600786015490613c9a565b6006850154909150811115613ab8575060068301545b8015613ae5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01613aea565b600191505b60078401554360088401559050919050565b8181017effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80841690821610156111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ca5565b600082613b6c57506001610da8565b6000613b8d8573ffffffffffffffffffffffffffffffffffffffff16613cd7565b90508073ffffffffffffffffffffffffffffffffffffffff16848490604051613bb590613cd7565b600060405180830381858888f193505050503d8060008114613bf3576040519150601f19603f3d011682016040523d82523d6000602084013e613bf8565b606091505b50909695505050505050565b613c1084848484613cda565b613c46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614b24565b50505050565b818102821580613c64575081838281613c6157fe5b04145b6111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614da7565b818101828110156111ae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614ca5565b90565b6000613ce585613e1a565b613d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1b90614e15565b606063a9059cbb60e01b8585604051602401613d38929190614846565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050905060008673ffffffffffffffffffffffffffffffffffffffff168483604051613dbf919061466f565b60006040518083038160008787f1925050503d8060008114613dfd576040519150601f19603f3d011682016040523d82523d6000602084013e613e02565b606091505b50509050613e0f81613e20565b979650505050505050565b3b151590565b60008115613e57573d8015613e405760208114613e495760009250613e55565b60019250613e55565b60206000803e60005192505b505b5090565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604080518082019091526000808252602082015290565b80356111ae81615498565b60008083601f840112613eef578182fd5b50813567ffffffffffffffff811115613f06578182fd5b6020830191508360208083028501011115613a6557600080fd5b80356111ae816154f8565b803560ff811681146111ae57600080fd5b600060208284031215613f4d578081fd5b8135610da881615498565b600060208284031215613f69578081fd5b8151610da881615498565b60008060408385031215613f86578081fd5b8235613f9181615498565b91506020830135613fa181615498565b809150509250929050565b60008060008060008060a08789031215613fc4578182fd5b8635613fcf81615498565b95506020870135613fdf81615498565b94506040870135613fef81615498565b93506060870135613fff816154cb565b9250608087013567ffffffffffffffff8082111561401b578384fd5b818901915089601f83011261402e578384fd5b81358181111561403c578485fd5b8a602082850101111561404d578485fd5b6020830194508093505050509295509295509295565b600080600080600060a0868803121561407a578081fd5b853561408581615498565b9450602086013561409581615498565b935060408601356140a581615498565b925060608601356140b5816154cb565b915060808601356140c5816154f8565b809150509295509295909350565b60008060008060008060c087890312156140eb578182fd5b86356140f681615498565b9550602087013561410681615498565b9450604087013561411681615498565b93506060870135614126816154cb565b92506080870135614136816154f8565b915060a087013561414681615498565b809150509295509295509295565b60008060008060808587031215614169578182fd5b843561417481615498565b9350602085013561418481615498565b9250604085013561419481615498565b9396929550929360600135925050565b600080600080608085870312156141b9578182fd5b84356141c481615498565b935060208501356141d481615498565b93969395505050506040820135916060013590565b6000806000606084860312156141fd578081fd5b833561420881615498565b9250602084013561421881615498565b91506040840135614228816154f8565b809150509250925092565b60008060408385031215614245578182fd5b823561425081615498565b946020939093013593505050565b60008060008060408587031215614273578182fd5b843567ffffffffffffffff8082111561428a578384fd5b61429688838901613ede565b909650945060208701359150808211156142ae578384fd5b506142bb87828801613ede565b95989497509550505050565b600080602083850312156142d9578182fd5b823567ffffffffffffffff8111156142ef578283fd5b6142fb85828601613ede565b90969095509350505050565b600060208284031215614318578081fd5b8135610da8816154bd565b600060208284031215614334578081fd5b8151610da8816154bd565b6000610ce08284031215614351578081fd5b50919050565b600060208284031215614368578081fd5b8151610da8816154cb565b600060208284031215614384578081fd5b5035919050565b60006020828403121561439c578081fd5b5051919050565b600080600080608085870312156143b8578182fd5b5050823594602084013594506040840135936060013592509050565b6000602082840312156143e5578081fd5b8135610da8816154f8565b600060208284031215614401578081fd5b8151610da8816154f8565b6000806040838503121561441e578182fd5b8235613f91816154f8565b60008284526020808501945082825b8581101561447357813561444b81615498565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614438565b509495945050505050565b60008284526020808501945082825b858110156144735781356144a081615498565b73ffffffffffffffffffffffffffffffffffffffff168752958201959082019060010161448d565b61060080828437600081840152505050565b61010080828437600081840152505050565b15159052565b600082845282826020860137806020848601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011685010190509392505050565b6000815180845261455281602086016020860161546c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b803561458f816154f8565b63ffffffff16825260208101356145a5816154cb565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166020840152505050565b80518252602081015160208301526040810151604083015260608101516060830152608081015160808301525050565b80518252602090810151910152565b63ffffffff808251168352602082015161ffff80821660208601528060408501511660408601528260608501511660608601528060808501511660808601525050505050565b61ffff169052565b63ffffffff169052565b60ff169052565b6000825161468181846020870161546c565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9687168152948616602086015292851660408501527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91909116606084015263ffffffff16608083015290911660a082015260c00190565b73ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152606081019190915260800190565b73ffffffffffffffffffffffffffffffffffffffff9586168152938516602085015291909316604083015263ffffffff90921660608201527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909116608082015260a00190565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841660408301526080606083015261483c608083018461453a565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b600060408252614880604083018587614429565b905073ffffffffffffffffffffffffffffffffffffffff83166020830152949350505050565b6000604082526148ba604083018688614429565b82810360208401528381527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8411156148f1578182fd5b60208402808660208401370160200190815295945050505050565b901515815260200190565b90815260200190565b94855260208501939093526040840191909152606083015273ffffffffffffffffffffffffffffffffffffffff16608082015260a00190565b600060208252610da8602083018461453a565b6020808252600b908201527f494e495449414c495a4544000000000000000000000000000000000000000000604082015260600190565b6020808252600f908201527f494e56414c49445f414444524553530000000000000000000000000000000000604082015260600190565b60208082526014908201527f494e56414c49445f4445504f5349545f46524f4d000000000000000000000000604082015260600190565b6020808252600a908201527f5245454e5452414e435900000000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f554e415554484f52495a45440000000000000000000000000000000000000000604082015260600190565b60208082526013908201527f494e56414c49445f4554485f4445504f53495400000000000000000000000000604082015260600190565b6020808252600b908201527f414c52454144595f534554000000000000000000000000000000000000000000604082015260600190565b6020808252600a908201527f53414d455f56414c554500000000000000000000000000000000000000000000604082015260600190565b60208082526010908201527f5452414e534645525f4641494c55524500000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e4f545f414c4c4f574544000000000000000000000000000000000000000000604082015260600190565b6020808252600d908201527f5355425f554e444552464c4f5700000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f5a45524f5f414444524553530000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f494e56414c49445f4d4f44450000000000000000000000000000000000000000604082015260600190565b60208082526010908201527f414c52454144595f53485554444f574e00000000000000000000000000000000604082015260600190565b6020808252600f908201527f544f4b454e5f4e4f545f464f554e440000000000000000000000000000000000604082015260600190565b6020808252600c908201527f4144445f4f564552464c4f570000000000000000000000000000000000000000604082015260600190565b60208082526018908201527f494e53554646494349454e545f4445504f5349545f4645450000000000000000604082015260600190565b60208082526016908201527f5749544844524157414c5f4e4f545f544f4f5f4f4c4400000000000000000000604082015260600190565b60208082526021908201527f43414e4e4f545f4f564552524944455f524543495049454e545f41444452455360408201527f5300000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252600c908201527f4d554c5f4f564552464c4f570000000000000000000000000000000000000000604082015260600190565b6020808252600c908201527f494e56414c49445f444154410000000000000000000000000000000000000000604082015260600190565b60208082526027908201527f4552433230536166655472616e736665723a2063616c6c20746f206e6f6e2d6360408201527f6f6e747261637400000000000000000000000000000000000000000000000000606082015260800190565b815163ffffffff1681526020918201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000169181019190915260400190565b815181526020808301519082015260408083015190820152606080830151908201526080808301519082015260a0808301519082015260c0808301519082015260e0808301519082015261010080830151908201526101208083015190820152610140808301519082015261016091820151918101919091526101800190565b91825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b93845273ffffffffffffffffffffffffffffffffffffffff92831660208501529116604083015263ffffffff16606082015260800190565b92835273ffffffffffffffffffffffffffffffffffffffff9190911660208301521515604082015260600190565b94855273ffffffffffffffffffffffffffffffffffffffff93909316602085015260408401919091526060830152608082015260a00190565b60008682526060602083015261503a60608301868861447e565b828103604084015261504d81858761447e565b98975050505050505050565b83815260406020808301829052828201849052600091906060908185018682028601830188865b898110156151d8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa089840301845281357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe218c36030181126150e0578889fd5b8b016101e086820160ff6150f48285613f2b565b168652615101818461544a565b905061510f88870182614656565b5061511c8983018361545d565b6151288a870182614668565b50615135888301836153e7565b828a88015261514783880182846144f2565b92505050608061515b8187018285016144da565b5061018061516b818401846153da565b615177828801826144ec565b50506101a0615188818401846153e7565b8784038389015261519a8482846144f2565b93505050506101c06151ae818401846153e7565b9350868303828801526151c28385836144f2565b9789019796505050928601925050600101615080565b50909a9950505050505050505050565b828152610d00810182356151fb816154f8565b63ffffffff81166020840152506040830173ffffffffffffffffffffffffffffffffffffffff61522e8260208701613ed3565b16604084015280356060840152506060830135608083015260a083016152578160808601613f20565b61526460a085018261465e565b5061527260c0840182614584565b50615284610100830160e085016144c8565b610da861070083016106e085016144c8565b91825263ffffffff16602082015260400190565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91909116815260200190565b93845260208401929092526040830152606082015260800190565b63ffffffff91909116815260200190565b63ffffffff8e168152602081018d905273ffffffffffffffffffffffffffffffffffffffff8c811660408301528b811660608301528a81166080830152891660a08201526102c0810161535860c083018a6145d1565b8761016083015286610180830152856101a083015261537b6101c083018661465e565b6153896101e0830185614610565b615397610280830184614601565b9e9d5050505050505050505050505050565b63ffffffff958616815261ffff94851660208201529284166040840152931660608201529116608082015260a00190565b60008235610da8816154bd565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261541b578283fd5b830160208101925035905067ffffffffffffffff81111561543b57600080fd5b803603831315613a6557600080fd5b6000823561ffff81168114610da8578182fd5b6000610da86020840184613f2b565b60005b8381101561548757818101518382015260200161546f565b83811115613c465750506000910152565b73ffffffffffffffffffffffffffffffffffffffff811681146154ba57600080fd5b50565b80151581146154ba57600080fd5b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811681146154ba57600080fd5b63ffffffff811681146154ba57600080fdfea2646970667358221220ef2ae624677c8106d2ff439b7093d388a10413c0c426ed7a90b110b3e3154abb64736f6c63430007000033

Deployed Bytecode Sourcemap

1135:17042:25:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16921:271;;;;;;;;;;-1:-1:-1;16921:271:25;;;;;:::i;:::-;;:::i;:::-;;6387:225;;;;;;;;;;-1:-1:-1;6387:225:25;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;17198:561;;;;;;;;;;-1:-1:-1;17198:561:25;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;3124:444::-;;;;;;;;;;-1:-1:-1;3124:444:25;;;;;:::i;:::-;;:::i;10516:214::-;;;;;;;;;;-1:-1:-1;10516:214:25;;;;;:::i;:::-;;:::i;1811:44::-;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;13744:351::-;;;;;;;;;;-1:-1:-1;13744:351:25;;;;;:::i;:::-;;:::i;10736:294::-;;;;;;;;;;-1:-1:-1;10736:294:25;;;;;:::i;:::-;;:::i;11578:273::-;;;;;;;;;;-1:-1:-1;11578:273:25;;;;;:::i;:::-;;:::i;9520:296::-;;;;;;;;;;-1:-1:-1;9520:296:25;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;16227:688::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;9848:274::-;;;;;;:::i;:::-;;:::i;8128:142::-;;;;;;;;;;;;;:::i;15633:181::-;;;;;;;;;;;;;:::i;1066:198:44:-;;;;;;;;;;;;;:::i;8787:180:25:-;;;;;;;;;;-1:-1:-1;8787:180:25;;;;;:::i;:::-;;:::i;6814:190::-;;;;;;;;;;-1:-1:-1;6814:190:25;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;2272:114::-;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;14956:233::-;;;;;;;;;;-1:-1:-1;14956:233:25;;;;;:::i;:::-;;:::i;6618:190::-;;;;;;;;;;-1:-1:-1;6618:190:25;;;;;:::i;:::-;;:::i;8973:170::-;;;;;;;;;;;;;:::i;11857:784::-;;;;;;;;;;-1:-1:-1;11857:784:25;;;;;:::i;:::-;;:::i;1287:155:57:-;;;;;;;;;;;;;:::i;2559:559:25:-;;;;;;;;;;-1:-1:-1;2559:559:25;;;;;:::i;:::-;;:::i;12647:712::-;;;;;;;;;;-1:-1:-1;12647:712:25;;;;;:::i;:::-;;:::i;8454:139::-;;;;;;;;;;;;;:::i;17765:172::-;;;;;;;;;;;;;:::i;9172:342::-;;;;;;:::i;:::-;;:::i;4848:261::-;;;;;;;;;;-1:-1:-1;4848:261:25;;;;;:::i;:::-;;:::i;11036:246::-;;;;;;;;;;-1:-1:-1;11036:246:25;;;;;:::i;:::-;;:::i;383:20:57:-;;;;;;;;;;;;;:::i;6062:154:25:-;;;;;;;;;;;;;:::i;10128:308::-;;;;;;;;;;-1:-1:-1;10128:308:25;;;;;:::i;:::-;;:::i;15374:253::-;;;;;;;;;;-1:-1:-1;15374:253:25;;;;;:::i;:::-;;:::i;7677:425::-;;;;;;;;;;;;;:::i;5138:900::-;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;3741:585::-;;;;;;;;;;-1:-1:-1;3741:585:25;;;;;:::i;:::-;;:::i;8296:152::-;;;;;;;;;;;;;:::i;3574:161::-;;;;;;;;;;;;;:::i;8599:182::-;;;;;;;;;;-1:-1:-1;8599:182:25;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;6222:138::-;;;;;;;;;;;;;:::i;1774:31::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;:::i;7444:227::-;;;;;;;;;;-1:-1:-1;7444:227:25;;;;;:::i;:::-;;:::i;11288:284::-;;;;;;;;;;-1:-1:-1;11288:284:25;;;;;:::i;:::-;;:::i;14413:537::-;;;;;;;;;;-1:-1:-1;14413:537:25;;;;;:::i;:::-;;:::i;7208:230::-;;;;;;;;;;-1:-1:-1;7208:230:25;;;;;:::i;:::-;;:::i;13365:373::-;;;;;;;;;;-1:-1:-1;13365:373:25;;;;;:::i;:::-;;:::i;14101:306::-;;;;;;;;;;-1:-1:-1;14101:306:25;;;;;:::i;:::-;;:::i;388:27:44:-;;;;;;;;;;;;;:::i;4332:510:25:-;;;;;;;;;;-1:-1:-1;4332:510:25;;;;;:::i;:::-;;:::i;17943:231::-;;;;;;;;;;-1:-1:-1;17943:231:25;;;;;:::i;:::-;;:::i;15195:153::-;;;;;;;;;;;;;:::i;751:238:44:-;;;;;;;;;;-1:-1:-1;751:238:44;;;;;:::i;:::-;;:::i;7030:172:25:-;;;;;;;;;;;;;:::i;15820:401::-;;;;;;;;;;;;;:::i;16921:271::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;;;;;;;;;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;17048:24:25::2;::::0;::::2;;:33;;::::0;::::2;;;;17040:56;;;;;;;;;;;;:::i;:::-;17106:24;:32:::0;;;::::2;::::0;::::2;;;::::0;;17154:31:::2;::::0;::::2;::::0;::::2;::::0;17106:32;;17154:31:::2;:::i;:::-;;;;;;;;-1:-1:-1::0;956:1:60;942:11;:15;16921:271:25:o;6387:225::-;6522:6;764:11:60;;779:1;764:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;6599:5:25::1;::::0;6551:54:::1;::::0;;;;:19:::1;::::0;::::1;::::0;:54:::1;::::0;:5:::1;::::0;6571:12;;6599:5:::1;;6585:10;:19;::::0;6551:54:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;956:1:60::0;942:11;:15;6544:61:25;6387:225;-1:-1:-1;;6387:225:25:o;17198:561::-;17307:7;;17347:23;:5;17364;17347:16;:23::i;:::-;17330:40;-1:-1:-1;17381:26:25;17426:12;;;17422:296;;17518:38;;;;;;;;:29;:38;;;;;;17483:21;;17475:82;;17483:21;;;;17475:38;;17518;;;17475:42;:82;:::i;:::-;17454:103;;17422:296;;;17668:38;;;;;;;:29;:38;;;;;;;;17640:21;;17609:54;;;;;:98;;17668:38;;;;;17609:22;;;;;;;:54;;17640:21;;17609:54;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:58;;:98::i;:::-;17588:119;;17422:296;17734:18;17198:561;-1:-1:-1;;;17198:561:25:o;3124:444::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;3273:30:25::2;::::0;::::2;3265:55;;;;;;;;;;;;:::i;:::-;3378:21:::0;;:44:::2;:21;:44:::0;3370:68:::2;;;;;;;;;;;;:::i;:::-;3448:21:::0;:58;;;::::2;;::::0;::::2;;::::0;;3522:39:::2;::::0;::::2;::::0;::::2;::::0;3448:58;;3522:39:::2;:::i;10516:214::-:0;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;10682:41:25::1;::::0;;;;:28:::1;::::0;::::1;::::0;:41:::1;::::0;:5:::1;::::0;10711:11;;10682:41:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;10516:214:25:o;1811:44::-;;;;;;:::o;13744:351::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;13955:4:25;2127:19:::1;13955:4:::0;2127:13:::1;:19::i;:::-;2119:44;;;;;;;;;;;;:::i;:::-;13983:24:::2;::::0;::::2;;13975:48;;;;;;;;;;;;:::i;:::-;14033:21:::0;;:55:::2;::::0;;;;:21:::2;::::0;;::::2;::::0;:30:::2;::::0;:55:::2;::::0;14064:4;;14070:2;;14074:5;;14081:6;;14033:55:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;;;;;13744:351:25:o;10736:294::-;10897:4;;10934:23;:5;10951;10934:16;:23::i;:::-;10974:40;;;;;;;;:29;:40;;;;;;;;:49;;;;;;;;;;;;;;;-1:-1:-1;;10736:294:25;;;;;:::o;11578:273::-;11728:4;;11765:23;:5;11782;11765:16;:23::i;:::-;11805:30;;;;;;;:24;:30;;;;;;;;:39;;;;;;;;;;;;;;-1:-1:-1;;11578:273:25;;;;:::o;9520:296::-;9679:7;;9719:30;:5;9736:12;9719:16;:30::i;:::-;9766:27;;;;;;;:21;:27;;;;;;;;:36;;;;;;;;;;:43;;;;-1:-1:-1;;9520:296:25;;;;:::o;16227:688::-;16560:21;:30;;;;;;16618:37;;;;;;;16691:45;;;;;;16781:54;;;;;16867:41;;;;;;;;16227:688::o;9848:274::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;10052:4:25;2127:19:::1;10052:4:::0;2127:13:::1;:19::i;:::-;2119:44;;;;;;;;;;;;:::i;:::-;10072:43:::2;::::0;;;;:19:::2;::::0;::::2;::::0;:43:::2;::::0;:5:::2;::::0;10092:4;;10098:5;;10105:9;;10072:43:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;;;;9848:274:25:o;8128:142::-;8247:16;;8128:142;:::o;15633:181::-;15771:5;:36;;;15633:181;:::o;1066:198:44:-;565:12;;;;551:10;:26;543:51;;;;;;;;;;;;:::i;:::-;1179:12:::1;::::0;::::1;1172:5:::0;;1151:41:::1;::::0;1179:12:::1;::::0;;::::1;::::0;1172:5;;::::1;::::0;1151:41:::1;::::0;::::1;1210:12;::::0;;::::1;1202:20:::0;;;;;::::1;1210:12;::::0;::::1;1202:20;::::0;;;1232:25:::1;::::0;;1066:198::o;8787:180:25:-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;8934:26:25::2;::::0;;;;:18:::2;::::0;::::2;::::0;:26:::2;::::0;:5:::2;::::0;8953:6;;;;8934:26:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;;8787:180:25:o;6814:190::-;6967:30;;;;;6937:7;;6967:21;;;;:30;;:5;;6989:7;;6967:30;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;2272:114::-;2365:14;;;;;;;;;;;;;;;;;2272:114;:::o;14956:233::-;15143:22;;;;;15116:4;15143:22;;;:16;:22;;;;;;;;:39;;;;;;;;;;;14956:233::o;6618:190::-;6742:6;6771:30;:5;6788:12;6771:16;:30::i;8973:170::-;9075:4;9102:34;:5;:32;:34::i;:::-;9095:41;;8973:170;:::o;11857:784::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;12021:14:25::1;12038:23;:5;12055::::0;12038:16:::1;:23::i;:::-;12122:41;::::0;;::::1;12071:48;12122:41:::0;;;:30;:41:::1;::::0;;;;;;;:50;;::::1;::::0;;;;;;12190:20;;12122:50;;-1:-1:-1;12122:50:25;12190:20;;::::1;;;12182:60;;;;;;;;;;;;:::i;:::-;12350:20:::0;;::::1;::::0;;;::::1;;3693:7:17;12350:78:25;12331:15;:97;;12323:132;;;;;;;;;;;;:::i;:::-;12540:15;12499:38:::0;:56;;;12571:63:::1;::::0;::::1;::::0;::::1;::::0;::::1;:::i;:::-;;;;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;11857:784:25:o;1287:155:57:-;812:5;;;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;1404:1:::1;1389:5:::0;;1368:39:::1;::::0;::::1;1389:5:::0;;::::1;::::0;1368:39:::1;::::0;1404:1;;1368:39:::1;1433:1;1417:18:::0;;;::::1;::::0;;1287:155::o;2559:559:25:-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;1938:14:25;;1930:37:::1;1938:14;1930:37:::0;:71;::::1;;;-1:-1:-1::0;1971:16:25;;:30;1930:71:::1;1909:129;;;;;;;;;;;;:::i;:::-;2824:20:::2;::::0;::::2;2816:45;;;;;;;;;;;;:::i;:::-;2871:5;:14:::0;;;::::2;;::::0;::::2;;::::0;;3042:58:::2;::::0;;;;;;;;::::2;;::::0;::::2;::::0;;;::::2;::::0;;;;;;2896:28:::2;::::0;::::2;::::0;:5:::2;::::0;2938:9;;2961:18;;2993:23;;3030:71:::2;::::0;3042:58:::2;::::0;::::2;3075:9;:7;:9::i;:::-;3042:58:::0;;3094:4:::2;3042:58;::::0;;::::2;::::0;3030:11:::2;:71::i;:::-;2896:215;;;;;;;;;;;;;;;;;;;:::i;12647:712::-:0;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;12919:4:25;2127:19:::1;12919:4:::0;2127:13:::1;:19::i;:::-;2119:44;;;;;;;;;;;;:::i;:::-;12947:26:::2;::::0;::::2;12939:51;;;;;;;;;;;;:::i;:::-;13000:14;13017:23;:5;13034::::0;13017:16:::2;:23::i;:::-;13058:77;:31:::0;;::::2;13133:1;13058:31:::0;;;:25;:31:::2;::::0;;;;;;;:35;;::::2;::::0;;;;;;;:44:::2;::::0;;::::2;::::0;;;;;;;;:52:::2;::::0;::::2;::::0;;;;;;;:63;;::::2;::::0;;;;;;;;13000:40;;-1:-1:-1;13058:63:25::2;:77:::0;13050:123:::2;;;;;;;;;;;;:::i;:::-;13183:31;::::0;;::::2;;::::0;;;:25;:31:::2;::::0;;;;;;;:35;;::::2;::::0;;;;;;;:44:::2;::::0;;::::2;::::0;;;;;;;;:52:::2;::::0;::::2;::::0;;;;;;;:63;;::::2;::::0;;;;;;;;;:78;;;::::2;::::0;;::::2;::::0;;;::::2;::::0;;;13277:75;::::2;::::0;::::2;::::0;13183:31;;:35;;13313:5;;13183:52;;:63;;:78;;13277:75:::2;:::i;:::-;;;;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;;;;12647:712:25:o;8454:139::-;8571:15;;8454:139;:::o;17765:172::-;17892:38;;17765:172;:::o;9172:342::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;9431:4:25;2127:19:::1;9431:4:::0;2127:13:::1;:19::i;:::-;2119:44;;;;;;;;;;;;:::i;:::-;9451:56:::2;9465:4;9471:2;9475:12;9489:6;9497:9;;9451:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::2;::::0;;;;-1:-1:-1;9451:5:25::2;::::0;:56;;;;;-1:-1:-1;;9451:13:25::2;:56:::0;-1:-1:-1;9451:56:25:i:2;:::-;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;;;;;9172:342:25:o;4848:261::-;4930:4;4958:18;;;4966:10;4958:18;;:144;;-1:-1:-1;4992:19:25;;:49;:19;:49;;;;:110;;-1:-1:-1;5057:19:25;;:45;;;;;:19;;;;;:27;;:45;;5085:4;;5091:10;;5057:19;:45;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;11036:246::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;11196:79:25::1;::::0;;;;:32:::1;::::0;::::1;::::0;:79:::1;::::0;:5:::1;::::0;11242:4;;11260:5;;11196:79:::1;;;:::i;383:20:57:-:0;;;;;;:::o;6062:154:25:-;6156:4;6183:26;:5;:24;:26::i;10128:308::-;10287:4;;10324:23;:5;10341;10324:16;:23::i;:::-;10364:41;;;;;;;;:30;:41;;;;;;;;:50;;;;;;;;;;;:60;;;;;;;:65;;;-1:-1:-1;;10128:308:25;;;;:::o;15374:253::-;15542:6;764:11:60;;779:1;764:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;15571:49:25::2;::::0;;;;:39:::2;::::0;::::2;::::0;:49:::2;::::0;:5:::2;::::0;15611:8;;15571:49:::2;;;:::i;7677:425::-:0;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;7876:26:25::1;:5;:24;:26::i;:::-;7872:224;;;7986:14:::0;;:46:::1;::::0;;;;7973:10:::1;::::0;7986:14:::1;;::::0;:31:::1;::::0;:46:::1;::::0;8026:4:::1;::::0;7986:46:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8046:14:::0;;:39:::1;::::0;;;;7973:59;;-1:-1:-1;8046:14:25::1;;::::0;:32:::1;::::0;:39:::1;::::0;7973:59;;8046:39:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;7872:224;;956:1:60::0;942:11;:15;7677:425:25:o;5138:900::-;5225:29;;:::i;:::-;-1:-1:-1;5277:754:25;;;;;;;;3482:77:17;5277:754:25;;3614:7:17;5277:754:25;;;;3693:7:17;5277:754:25;;;;;;3767:6:17;5277:754:25;;;;;;3877:31:17;5277:754:25;;;;;;;;;;;;;;4299:7:17;5277:754:25;;;;4676:2:17;5277:754:25;;;;;;;;;;;4861:10:17;5277:754:25;;;;4929:2:17;5277:754:25;;;;5138:900;:::o;3741:585::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;3926:23:25::2;::::0;::::2;3918:51;;;;;;;;;;;;:::i;:::-;3984:19;::::0;::::2;3980:286;;4033:21;4068:45;4033:21:::0;4103:9:::2;4068:26;::::0;::::2;::::0;:45;:26:::2;:45::i;:::-;;3980:286;;;;4158:37;::::0;;;;4144:11:::2;::::0;4158:22:::2;::::0;::::2;::::0;::::2;::::0;:37:::2;::::0;4189:4:::2;::::0;4158:37:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;4144:51:::0;-1:-1:-1;4209:46:25::2;:27;::::0;::::2;4237:9:::0;4144:51;4209:27:::2;:46::i;:::-;3980:286;;4281:38;4302:5;4309:9;4281:38;;;;;;;:::i;:::-;;;;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;3741:585:25:o;8296:152::-;8420:21;;8296:152;:::o;3574:161::-;3707:21;;;;3574:161;:::o;8599:182::-;8700:29;;:::i;:::-;-1:-1:-1;8752:22:25;;;;:12;:22;;;;;;;;;8745:29;;;;;;;;;;;;;;;;;;;;;;;;;;8599:182::o;6222:138::-;6308:4;6335:18;:5;:16;:18::i;1774:31::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;7444:227::-;7616:48;;7589:4;7616:48;;;:34;:48;;;;;;;7444:227::o;11288:284::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;11478:87:25::1;::::0;;;;:37:::1;::::0;::::1;::::0;:87:::1;::::0;:5:::1;::::0;11529:6;;;;11549;;;;11478:87:::1;;;:::i;14413:537::-:0;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;14610:41:25;;::::1;14602:66;;;;;;;;;;;;:::i;:::-;14686:19:::0;;:47:::1;::::0;;;;:19:::1;::::0;;::::1;::::0;:27:::1;::::0;:47:::1;::::0;14714:6;;;;14722:10:::1;::::0;14686:19:::1;:47;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;14678:72;;;;;;;;;;;;:::i;:::-;14765:6;14760:122;14777:17:::0;;::::1;14760:122;;;14867:4;14815:16:::0;:27:::1;14832:6:::0;;14839:1;14832:9;;::::1;;;;;;;;;;;;;;;;;;:::i;:::-;14815:27;;;;;;;;;;;;;;;:49;14843:17;;14861:1;14843:20;;;;;;;;::::0;;::::1;::::0;;;::::1;;14815:49:::0;;-1:-1:-1;14815:49:25;::::1;::::0;;;;;;-1:-1:-1;14815:49:25;:56;;;::::1;::::0;::::1;;::::0;;;::::1;::::0;;-1:-1:-1;14796:3:25::1;14760:122;;;;14896:47;14917:6;;14925:17;;14896:47;;;;;;;;;:::i;7208:230::-:0;7366:4;764:11:60;;779:1;764:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;7393:38:25::2;::::0;;;;:27:::2;::::0;::::2;::::0;:38:::2;::::0;:5:::2;::::0;7421:9;;7393:38:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;13365:373::-:0;13588:7;;13628:23;:5;13645;13628:16;:23::i;:::-;13668:31;;;;;;;;:25;:31;;;;;;;;:35;;;;;;;;;;:44;;;;;;;;;;;:52;;;;;;;;;;:63;;;;;;;;;;;;;;;-1:-1:-1;;13365:373:25;;;;;;;:::o;14101:306::-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;14277:4:25;2127:19:::1;14277:4:::0;2127:13:::1;:19::i;:::-;2119:44;;;;;;;;;;;;:::i;:::-;14297:22:::2;::::0;::::2;;::::0;;;:16;:22:::2;::::0;;;;;;;:39;;;;;;;;;;:46;;;::::2;14339:4;14297:46;::::0;;14358:42;::::2;::::0;::::2;::::0;14314:4;;14320:15;;14358:42:::2;:::i;:::-;;;;;;;;-1:-1:-1::0;;956:1:60;942:11;:15;-1:-1:-1;14101:306:25:o;388:27:44:-;;;;;;:::o;4332:510:25:-;764:11:60;;:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;4586:147:25::2;:5;4622:14:::0;4650:19;4683:16;4713:10;4586:22:::2;:147::i;:::-;4749:86;4769:14;4785:19;4806:16;4824:10;4749:86;;;;;;;;;:::i;17943:231::-:0;18048:7;;18088:23;:5;18105;18088:16;:23::i;:::-;18129:38;;;;;;:29;:38;;;;;;;;;17943:231;-1:-1:-1;;;17943:231:25:o;15195:153::-;15319:22;;15195:153;:::o;751:238:44:-;812:5:57;;;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;886:22:44::1;::::0;::::1;::::0;;::::1;::::0;:43:::1;;-1:-1:-1::0;924:5:44::1;::::0;::::1;912:17:::0;;::::1;924:5:::0;::::1;912:17;;886:43;878:71;;;;;;;;;;;;:::i;:::-;959:12;:23:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;751:238::o;7030:172:25:-;7149:14;;:46;;;;;7122:4;;7149:14;;;:31;;:46;;7189:4;;7149:46;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;15820:401::-;15930:12;764:11:60;;779:1;764:16;756:39;;;;;;;;;;;;:::i;:::-;863:1;849:11;:15;812:5:57::1;::::0;::::1;;798:10;:19;790:44;;;;;;;;;;;;:::i;:::-;15967:26:25::2;:5;:24;:26::i;:::-;15966:27;15958:52;;;;;;;;;;;;:::i;:::-;16029:18;:5;:16;:18::i;:::-;16028:19;16020:48;;;;;;;;;;;;:::i;:::-;16117:15;16078:14:::0;:54;;;16147:46:::2;::::0;::::2;::::0;::::2;::::0;::::2;:::i;:::-;;;;;;;;-1:-1:-1::0;16210:4:25::2;956:1:60::0;942:11;:15;15820:401:25;:::o;2634:319:35:-;2835:30;;;2795:14;2835:30;;;:16;;;:30;;;;;;;;2883:12;2875:40;;;;;;;;;;;;:::i;:::-;2935:11;;;2634:319;-1:-1:-1;;2634:319:35:o;452:183:54:-;554:4;587:1;582;:6;;574:32;;;;;;;;;;;;:::i;:::-;-1:-1:-1;623:5:54;;;452:183::o;988:235:33:-;1186:30;;;;;3614:7:17;1146:70:33;;988:235::o;501:449:47:-;584:7;607:13;653:9;641:21;;327:109;788:6;:11;;;772:29;;;;;;835:6;:14;;;819:32;;;;;;869:8;895:6;:24;;;704:229;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;681:262;;;;;;674:269;;;501:449;;;:::o;987:2271:31:-;1269:16;;;1261:41;;;;;;;;;;;;:::i;:::-;1328:2;1320:10;;:4;:10;;;1312:43;;;;;;;;;;;;:::i;:::-;1706:14;;1741:27;:1;1755:12;1741:13;:27::i;:::-;1705:63;;;;1782:10;1778:87;;1818:36;;;;;:15;;;;:36;;:1;;1834:12;;1848:5;;1818:36;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1808:46;;1778:87;1879:12;;;;:27;;;;-1:-1:-1;1895:11:31;;;;1879:27;1875:104;;;1930:9;:14;1922:46;;;;;;;;;;;;:::i;:::-;2069:21;2108:23;2129:1;2108:20;:23::i;:::-;2104:139;;;-1:-1:-1;2163:25:31;;;;2207;;;;;;2163;;2207;:::i;:::-;;;;;;;;2104:139;2306:13;2293:9;:26;;2285:63;;;;;;;;;;;;:::i;:::-;2498:17;;;;:149;;;;;2388:9;:25;;;;2359:26;;2498:17;;;;;:25;;2388;;2498:149;;2564:4;;2582:12;;2608:6;;2628:9;;2498:149;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2472:175;;2757:36;;:::i;:::-;-1:-1:-1;2796:21:31;;;;;;;:17;;;:21;;;;;;;;:30;;;;;;;;;;;;;2757:69;;;;;;;;;;;;;;2864:15;2757:69;2836:44;2757:69;;;2836:44;;;;2757:69;2908:36;;2757:69;2928:15;;2908:19;:36;:::i;:::-;2890:8;:15;;:54;;;;;;;;;;;2987:8;2954:1;:17;;:21;2972:2;2954:21;;;;;;;;;;;;;;;:30;2976:7;2954:30;;;;;;;;;;;;;;;:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3044:55;3083:15;3044:1;:25;;:34;3070:7;3044:34;;;;;;;;;;;;;;;;;;;;;;;;;:38;;;;:55;;;;:::i;:::-;3007:34;;;;;;;:25;;;:34;;;;;;;:92;;;;;;;;;;;;;;;;3115:136;;;;;3145:4;;3163:2;;3179:12;;3007:34;;3226:15;;3115:136;:::i;:::-;;;;;;;;987:2271;;;;;;;;;;;;:::o;557:219:33:-;731:34;;;:38;;;557:219::o;1772:259:42:-;1912:12;1950:28;:10;;;1961:6;1969:8;1950:10;:28::i;:::-;1940:38;;1996:7;1988:36;;;;;;;;;;;;:::i;691:265:50:-;829:120;876:5;895:2;911:5;930:9;829:33;:120::i;:::-;691:265;;;:::o;782:200:33:-;939:10;;:32;:36;;;782:200::o;3264:447:31:-;3484:14;;;:46;;;;3540:34;;;:56;;;;3606:31;;;:50;3666:25;;;;:38;3264:447::o;2959:372:35:-;3173:30;;;3121:14;3173:30;;;:16;;;:30;;;;;;;;;3216:12;3213:59;;-1:-1:-1;3252:1:35;;-1:-1:-1;3252:1:35;3244:17;;3213:59;-1:-1:-1;3291:11:35;;3301:1;2959:372;;;;;;:::o;3717:913:31:-;4140:31;;;;4099:34;;;;3810:4;;;;;;4029:153;;4081:91;;4140:31;4082:52;;:12;;:16;:52::i;:::-;4081:58;;:91::i;:::-;4029:34;;;;;:38;:153::i;:::-;4227:14;;;:29;3999:183;;-1:-1:-1;4205:51:31;;4201:133;;;-1:-1:-1;4294:14:31;;;:29;4201:133;4348:23;;4344:126;;4387:24;;4344:126;;;4455:4;4442:17;;4344:126;4480:34;;;:56;4583:12;4546:34;;;:49;4613:10;-1:-1:-1;3717:913:31;;;:::o;206:190:55:-;343:5;;;366:6;;;;;;;;;358:31;;;;;;;;;;;;:::i;1240:381:42:-;1371:12;1403:11;1399:53;;-1:-1:-1;1437:4:42;1430:11;;1399:53;1461:25;1489:14;:2;:12;;;:14::i;:::-;1461:42;;1566:9;:14;;1588:6;1601:8;1566:48;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1552:62:42;;1240:381;-1:-1:-1;;;;;;1240:381:42:o;1245:298:50:-;1442:52;1467:5;1474:2;1478:5;1485:8;1442:24;:52::i;:::-;1421:115;;;;;;;;;;;;:::i;:::-;1245:298;;;;:::o;251:195:54:-;379:5;;;402:6;;;:20;;;421:1;416;412;:5;;;;;;:10;402:20;394:45;;;;;;;;;;;;:::i;641:181::-;769:5;;;792:6;;;;784:31;;;;;;;;;;;;:::i;937:156:42:-;1081:4;937:156::o;1549:859:50:-;1719:4;2029:17;2040:5;2029:10;:17::i;:::-;2021:69;;;;;;;;;;;;:::i;:::-;2172:21;2239:10;2232:18;;2264:2;2280:5;2196:99;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2172:123;;2306:12;2324:5;:10;;2340:8;2350;2324:35;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2305:54;;;2376:25;2393:7;2376:16;:25::i;:::-;2369:32;1549:859;-1:-1:-1;;;;;;;1549:859:50:o;308:377::-;624:20;670:8;;;308:377::o;4395:1098::-;4500:4;4818:7;4814:649;;;4875:16;5028:59;;;;5202:2;5197:112;;;;5420:1;5409:12;;4868:571;;5028:59;5068:1;5057:12;;5028:59;;5197:112;5248:2;5245:1;5242;5227:24;5289:1;5283:8;5272:19;;4868:571;;4850:603;-1:-1:-1;5479:7:50;4395:1098::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;:::o;5:130::-;72:20;;97:33;72:20;97:33;:::i;301:352::-;;;431:3;424:4;416:6;412:17;408:27;398:2;;-1:-1;;439:12;398:2;-1:-1;469:20;;509:18;498:30;;495:2;;;-1:-1;;531:12;495:2;575:4;567:6;563:17;551:29;;626:3;575:4;;610:6;606:17;567:6;592:32;;589:41;586:2;;;643:1;;633:12;3123:128;3189:20;;3214:32;3189:20;3214:32;:::i;3397:126::-;3462:20;;74581:4;74570:16;;77673:33;;77663:2;;77720:1;;77710:12;3530:241;;3634:2;3622:9;3613:7;3609:23;3605:32;3602:2;;;-1:-1;;3640:12;3602:2;85:6;72:20;97:33;124:5;97:33;:::i;3778:263::-;;3893:2;3881:9;3872:7;3868:23;3864:32;3861:2;;;-1:-1;;3899:12;3861:2;226:6;220:13;238:33;265:5;238:33;:::i;4048:366::-;;;4169:2;4157:9;4148:7;4144:23;4140:32;4137:2;;;-1:-1;;4175:12;4137:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;4227:63;-1:-1;4327:2;4366:22;;72:20;97:33;72:20;97:33;:::i;:::-;4335:63;;;;4131:283;;;;;:::o;4421:867::-;;;;;;;4612:3;4600:9;4591:7;4587:23;4583:33;4580:2;;;-1:-1;;4619:12;4580:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;4671:63;-1:-1;4771:2;4810:22;;72:20;97:33;72:20;97:33;:::i;:::-;4779:63;-1:-1;4879:2;4918:22;;72:20;97:33;72:20;97:33;:::i;:::-;4887:63;-1:-1;4987:2;5026:22;;2634:20;2659:33;2634:20;2659:33;:::i;:::-;4995:63;-1:-1;5123:3;5108:19;;5095:33;5148:18;5137:30;;;5134:2;;;-1:-1;;5170:12;5134:2;5255:6;5244:9;5240:22;;;1991:3;1984:4;1976:6;1972:17;1968:27;1958:2;;-1:-1;;1999:12;1958:2;2042:6;2029:20;5148:18;2061:6;2058:30;2055:2;;;-1:-1;;2091:12;2055:2;2186:3;4771:2;2166:17;2127:6;2152:32;;2149:41;2146:2;;;-1:-1;;2193:12;2146:2;4771;2127:6;2123:17;5190:82;;;;;;;;4574:714;;;;;;;;:::o;5295:741::-;;;;;;5466:3;5454:9;5445:7;5441:23;5437:33;5434:2;;;-1:-1;;5473:12;5434:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;5525:63;-1:-1;5625:2;5664:22;;72:20;97:33;72:20;97:33;:::i;:::-;5633:63;-1:-1;5733:2;5772:22;;72:20;97:33;72:20;97:33;:::i;:::-;5741:63;-1:-1;5841:2;5880:22;;2634:20;2659:33;2634:20;2659:33;:::i;:::-;5849:63;-1:-1;5949:3;5988:22;;3189:20;3214:32;3189:20;3214:32;:::i;:::-;5958:62;;;;5428:608;;;;;;;;:::o;6043:867::-;;;;;;;6231:3;6219:9;6210:7;6206:23;6202:33;6199:2;;;-1:-1;;6238:12;6199:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;6290:63;-1:-1;6390:2;6429:22;;72:20;97:33;72:20;97:33;:::i;:::-;6398:63;-1:-1;6498:2;6537:22;;72:20;97:33;72:20;97:33;:::i;:::-;6506:63;-1:-1;6606:2;6645:22;;2634:20;2659:33;2634:20;2659:33;:::i;:::-;6614:63;-1:-1;6714:3;6753:22;;3189:20;3214:32;3189:20;3214:32;:::i;:::-;6723:62;-1:-1;6822:3;6862:22;;72:20;97:33;72:20;97:33;:::i;:::-;6831:63;;;;6193:717;;;;;;;;:::o;6917:617::-;;;;;7072:3;7060:9;7051:7;7047:23;7043:33;7040:2;;;-1:-1;;7079:12;7040:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7131:63;-1:-1;7231:2;7270:22;;72:20;97:33;72:20;97:33;:::i;:::-;7239:63;-1:-1;7339:2;7378:22;;72:20;97:33;72:20;97:33;:::i;:::-;7034:500;;;;-1:-1;7347:63;;7447:2;7486:22;2912:20;;-1:-1;;7034:500::o;7541:617::-;;;;;7696:3;7684:9;7675:7;7671:23;7667:33;7664:2;;;-1:-1;;7703:12;7664:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;7755:63;-1:-1;7855:2;7894:22;;72:20;97:33;72:20;97:33;:::i;:::-;7658:500;;7863:63;;-1:-1;;;;7963:2;8002:22;;1793:20;;8071:2;8110:22;1793:20;;7658:500::o;8165:489::-;;;;8302:2;8290:9;8281:7;8277:23;8273:32;8270:2;;;-1:-1;;8308:12;8270:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8360:63;-1:-1;8460:2;8499:22;;72:20;97:33;72:20;97:33;:::i;:::-;8468:63;-1:-1;8568:2;8606:22;;3189:20;3214:32;3189:20;3214:32;:::i;:::-;8576:62;;;;8264:390;;;;;:::o;8661:366::-;;;8782:2;8770:9;8761:7;8757:23;8753:32;8750:2;;;-1:-1;;8788:12;8750:2;85:6;72:20;97:33;124:5;97:33;:::i;:::-;8840:63;8940:2;8979:22;;;;1793:20;;-1:-1;;;8744:283::o;9034:678::-;;;;;9225:2;9213:9;9204:7;9200:23;9196:32;9193:2;;;-1:-1;;9231:12;9193:2;9289:17;9276:31;9327:18;;9319:6;9316:30;9313:2;;;-1:-1;;9349:12;9313:2;9387:80;9459:7;9450:6;9439:9;9435:22;9387:80;:::i;:::-;9369:98;;-1:-1;9369:98;-1:-1;9532:2;9517:18;;9504:32;;-1:-1;9545:30;;;9542:2;;;-1:-1;;9578:12;9542:2;;9616:80;9688:7;9679:6;9668:9;9664:22;9616:80;:::i;:::-;9187:525;;;;-1:-1;9598:98;-1:-1;;;;9187:525::o;10404:447::-;;;10568:2;10556:9;10547:7;10543:23;10539:32;10536:2;;;-1:-1;;10574:12;10536:2;10632:17;10619:31;10670:18;10662:6;10659:30;10656:2;;;-1:-1;;10692:12;10656:2;10730:105;10827:7;10818:6;10807:9;10803:22;10730:105;:::i;:::-;10712:123;;;;-1:-1;10530:321;-1:-1;;;;10530:321::o;10858:235::-;;10959:2;10947:9;10938:7;10934:23;10930:32;10927:2;;;-1:-1;;10965:12;10927:2;1537:6;1524:20;1549:30;1573:5;1549:30;:::i;11100:257::-;;11212:2;11200:9;11191:7;11187:23;11183:32;11180:2;;;-1:-1;;11218:12;11180:2;1672:6;1666:13;1684:30;1708:5;1684:30;:::i;11364:305::-;;11499:4;11487:9;11478:7;11474:23;11470:34;11467:2;;;-1:-1;;11507:12;11467:2;-1:-1;11559:94;11461:208;-1:-1;11461:208::o;11676:263::-;;11791:2;11779:9;11770:7;11766:23;11762:32;11759:2;;;-1:-1;;11797:12;11759:2;2788:6;2782:13;2800:33;2827:5;2800:33;:::i;11946:241::-;;12050:2;12038:9;12029:7;12025:23;12021:32;12018:2;;;-1:-1;;12056:12;12018:2;-1:-1;2912:20;;12012:175;-1:-1;12012:175::o;12194:263::-;;12309:2;12297:9;12288:7;12284:23;12280:32;12277:2;;;-1:-1;;12315:12;12277:2;-1:-1;3060:13;;12271:186;-1:-1;12271:186::o;12464:617::-;;;;;12619:3;12607:9;12598:7;12594:23;12590:33;12587:2;;;-1:-1;;12626:12;12587:2;-1:-1;;2912:20;;;12778:2;12817:22;;2912:20;;-1:-1;12886:2;12925:22;;2912:20;;12994:2;13033:22;2912:20;;-1:-1;12581:500;-1:-1;12581:500::o;13088:239::-;;13191:2;13179:9;13170:7;13166:23;13162:32;13159:2;;;-1:-1;;13197:12;13159:2;3202:6;3189:20;3214:32;3240:5;3214:32;:::i;13334:261::-;;13448:2;13436:9;13427:7;13423:23;13419:32;13416:2;;;-1:-1;;13454:12;13416:2;3341:6;3335:13;3353:32;3379:5;3353:32;:::i;13602:364::-;;;13722:2;13710:9;13701:7;13697:23;13693:32;13690:2;;;-1:-1;;13728:12;13690:2;3202:6;3189:20;3214:32;3240:5;3214:32;:::i;15283:665::-;;70040:6;70035:3;70028:19;70077:4;;70072:3;70068:14;15430:93;;15608:21;-1:-1;15635:291;15660:6;15657:1;15654:13;15635:291;;;85:6;72:20;97:33;124:5;97:33;:::i;:::-;74131:42;74120:54;14837:37;;14127:14;;;;71462:12;;;;15682:1;15675:9;15635:291;;;-1:-1;15932:10;;15417:531;-1:-1;;;;;15417:531::o;15987:689::-;;70040:6;70035:3;70028:19;70077:4;;70072:3;70068:14;16142:101;;16328:21;-1:-1;16355:299;16380:6;16377:1;16374:13;16355:299;;;85:6;72:20;97:33;124:5;97:33;:::i;:::-;74131:42;74120:54;14837:37;;14127:14;;;;71462:12;;;;16402:1;16395:9;16355:299;;18341:169;18497:6;;76299:3;76294;76281:30;76360:1;18497:6;76346:3;76342:16;76335:27;;18454:56;;:::o;18551:167::-;18705:6;;76299:3;76294;76281:30;76360:1;18705:6;76346:3;76342:16;76335:27;;18662:56;;:::o;18726:104::-;73710:13;73703:21;18791:34;;18785:45::o;19446:293::-;;70040:6;70035:3;70028:19;76304:6;76299:3;70077:4;70072:3;70068:14;76281:30;-1:-1;70077:4;76351:6;70072:3;76342:16;;76335:27;70077:4;76737:7;76741:2;19725:6;76721:14;76717:28;70072:3;19694:39;;19687:46;;19544:195;;;;;:::o;19747:343::-;;19889:5;69480:12;70040:6;70035:3;70028:19;19982:52;20027:6;70077:4;70072:3;70068:14;70077:4;20008:5;20004:16;19982:52;:::i;:::-;76741:2;76721:14;76737:7;76717:28;20046:39;;;;70077:4;20046:39;;19837:253;-1:-1;;19837:253::o;30343:557::-;3202:6;3189:20;3214:32;3240:5;3214:32;:::i;:::-;74487:10;74476:22;41397:36;;73404:2;73395:12;;2634:20;2659:33;2634:20;2659:33;:::i;:::-;74259:64;40853:5;74248:76;73404:2;30868:3;30864:14;40823:37;;30467:433;;:::o;36166:1006::-;36401:16;36395:23;19253:3;19246:37;36581:4;36574:5;36570:16;36564:23;36581:4;36645:3;36641:14;19246:37;36750:4;36743:5;36739:16;36733:23;36750:4;36814:3;36810:14;19246:37;36916:4;36909:5;36905:16;36899:23;36916:4;36980:3;36976:14;19246:37;37076:4;37069:5;37065:16;37059:23;37076:4;37140:3;37136:14;19246:37;36292:880;;:::o;38650:514::-;38878:23;;19246:37;;39068:4;39057:16;;;39051:23;39128:14;;19246:37;38768:396::o;39252:1021::-;74487:10;;39487:16;39481:23;74476:22;41404:3;41397:36;39661:4;39654:5;39650:16;39644:23;74039:6;;40501:5;74028:18;39661:4;39723:3;39719:14;40472:36;74039:6;39832:4;39825:5;39821:16;39815:23;74028:18;39832:4;39894:3;39890:14;40472:36;74487:10;40012:4;40005:5;40001:16;39995:23;74476:22;40012:4;40074:3;40070:14;41397:36;74039:6;40179:4;40172:5;40168:16;40162:23;74028:18;40179:4;40241:3;40237:14;40472:36;;;;39384:889;;:::o;40413:100::-;74039:6;74028:18;40472:36;;40466:47::o;41338:100::-;74487:10;74476:22;41397:36;;41391:47::o;41802:105::-;74581:4;74570:16;41867:35;;41861:46::o;41914:271::-;;20257:5;69480:12;20368:52;20413:6;20408:3;20401:4;20394:5;20390:16;20368:52;:::i;:::-;20432:16;;;;;42048:137;-1:-1;;42048:137::o;42578:222::-;74131:42;74120:54;;;;14837:37;;42705:2;42690:18;;42676:124::o;42807:333::-;74131:42;74120:54;;;14837:37;;74120:54;;43126:2;43111:18;;14837:37;42962:2;42947:18;;42933:207::o;43503:776::-;74131:42;74120:54;;;14837:37;;74120:54;;;43933:2;43918:18;;14837:37;74120:54;;;44016:2;44001:18;;14837:37;74259:64;74248:76;;;;44099:2;44084:18;;40823:37;74487:10;74476:22;44180:3;44165:19;;41397:36;74120:54;;;44264:3;44249:19;;14837:37;43768:3;43753:19;;43739:540::o;44286:556::-;74131:42;74120:54;;;14837:37;;74120:54;;;44662:2;44647:18;;14837:37;74120:54;;44745:2;44730:18;;14837:37;44828:2;44813:18;;19246:37;;;;44497:3;44482:19;;44468:374::o;44849:664::-;74131:42;74120:54;;;14837:37;;74120:54;;;45251:2;45236:18;;14837:37;74120:54;;;;45334:2;45319:18;;14837:37;74487:10;74476:22;;;45415:2;45400:18;;41397:36;74259:64;74248:76;;;45498:3;45483:19;;40823:37;45086:3;45071:19;;45057:456::o;45520:640::-;;74131:42;;73626:5;74120:54;14844:3;14837:37;74131:42;73626:5;74120:54;45914:2;45903:9;45899:18;14837:37;;74259:64;40853:5;74248:76;45997:2;45986:9;45982:18;40823:37;45749:3;46034:2;46023:9;46019:18;46012:48;46074:76;45749:3;45738:9;45734:19;46136:6;46074:76;:::i;:::-;46066:84;45720:440;-1:-1;;;;;;45720:440::o;46167:333::-;74131:42;74120:54;;;;14837:37;;46486:2;46471:18;;19246:37;46322:2;46307:18;;46293:207::o;46847:517::-;;47070:2;47091:17;47084:47;47145:118;47070:2;47059:9;47055:18;47249:6;47241;47145:118;:::i;:::-;47137:126;;74131:42;73626:5;74120:54;47350:2;47339:9;47335:18;14706:58;47041:323;;;;;;:::o;47371:669::-;;47646:2;47667:17;47660:47;47721:118;47646:2;47635:9;47631:18;47825:6;47817;47721:118;:::i;:::-;47887:9;47881:4;47877:20;47872:2;47861:9;47857:18;47850:48;70040:6;70035:3;70028:19;16974:66;16966:6;16963:78;16960:2;;;-1:-1;;17044:12;16960:2;47872;17079:6;17075:17;76304:6;76299:3;47872:2;70072:3;70068:14;76281:30;76342:16;47872:2;76342:16;76335:27;;;76342:16;47617:423;-1:-1;;;;;47617:423::o;48047:210::-;73710:13;;73703:21;18791:34;;48168:2;48153:18;;48139:118::o;48264:222::-;19246:37;;;48391:2;48376:18;;48362:124::o;48493:668::-;19246:37;;;48897:2;48882:18;;19246:37;;;;48980:2;48965:18;;19246:37;;;;49063:2;49048:18;;19246:37;74131:42;74120:54;49146:3;49131:19;;14837:37;48732:3;48717:19;;48703:458::o;49447:310::-;;49594:2;49615:17;49608:47;49669:78;49594:2;49583:9;49579:18;49733:6;49669:78;:::i;49764:416::-;49964:2;49978:47;;;21753:2;49949:18;;;70028:19;21789:13;70068:14;;;21769:34;21822:12;;;49935:245::o;50187:416::-;50387:2;50401:47;;;22073:2;50372:18;;;70028:19;22109:17;70068:14;;;22089:38;22146:12;;;50358:245::o;50610:416::-;50810:2;50824:47;;;22397:2;50795:18;;;70028:19;22433:22;70068:14;;;22413:43;22475:12;;;50781:245::o;51033:416::-;51233:2;51247:47;;;22726:2;51218:18;;;70028:19;22762:12;70068:14;;;22742:33;22794:12;;;51204:245::o;51456:416::-;51656:2;51670:47;;;23045:2;51641:18;;;70028:19;23081:14;70068;;;23061:35;23115:12;;;51627:245::o;51879:416::-;52079:2;52093:47;;;23366:2;52064:18;;;70028:19;23402:21;70068:14;;;23382:42;23443:12;;;52050:245::o;52302:416::-;52502:2;52516:47;;;23694:2;52487:18;;;70028:19;23730:13;70068:14;;;23710:34;23763:12;;;52473:245::o;52725:416::-;52925:2;52939:47;;;24014:2;52910:18;;;70028:19;24050:12;70068:14;;;24030:33;24082:12;;;52896:245::o;53148:416::-;53348:2;53362:47;;;24333:2;53333:18;;;70028:19;24369:18;70068:14;;;24349:39;24407:12;;;53319:245::o;53571:416::-;53771:2;53785:47;;;24658:2;53756:18;;;70028:19;24694:13;70068:14;;;24674:34;24727:12;;;53742:245::o;53994:416::-;54194:2;54208:47;;;24978:2;54179:18;;;70028:19;25014:15;70068:14;;;24994:36;25049:12;;;54165:245::o;54417:416::-;54617:2;54631:47;;;25300:2;54602:18;;;70028:19;25336:14;70068;;;25316:35;25370:12;;;54588:245::o;54840:416::-;55040:2;55054:47;;;25621:2;55025:18;;;70028:19;25657:14;70068;;;25637:35;25691:12;;;55011:245::o;55263:416::-;55463:2;55477:47;;;25942:2;55448:18;;;70028:19;25978:18;70068:14;;;25958:39;26016:12;;;55434:245::o;55686:416::-;55886:2;55900:47;;;26267:2;55871:18;;;70028:19;26303:17;70068:14;;;26283:38;26340:12;;;55857:245::o;56109:416::-;56309:2;56323:47;;;26591:2;56294:18;;;70028:19;26627:14;70068;;;26607:35;26661:12;;;56280:245::o;56532:416::-;56732:2;56746:47;;;26912:2;56717:18;;;70028:19;26948:26;70068:14;;;26928:47;26994:12;;;56703:245::o;56955:416::-;57155:2;57169:47;;;27245:2;57140:18;;;70028:19;27281:24;70068:14;;;27261:45;27325:12;;;57126:245::o;57378:416::-;57578:2;57592:47;;;27881:2;57563:18;;;70028:19;27917:34;70068:14;;;27897:55;27986:3;27972:12;;;27965:25;28009:12;;;57549:245::o;57801:416::-;58001:2;58015:47;;;28260:2;57986:18;;;70028:19;28296:14;70068;;;28276:35;28330:12;;;57972:245::o;58224:416::-;58424:2;58438:47;;;28581:2;58409:18;;;70028:19;28617:14;70068;;;28597:35;28651:12;;;58395:245::o;58647:416::-;58847:2;58861:47;;;28902:2;58832:18;;;70028:19;28938:34;70068:14;;;28918:55;29007:9;28993:12;;;28986:31;29036:12;;;58818:245::o;59070:330::-;31194:23;;74487:10;74476:22;41397:36;;31372:4;31361:16;;;31355:23;73809:66;73798:78;31432:14;;;19126:37;;;;59251:2;59236:18;;59222:178::o;59407:331::-;33997:23;;19246:37;;34188:4;34177:16;;;34171:23;34248:14;;;19246:37;34380:4;34369:16;;;34363:23;34440:14;;;19246:37;34567:4;34556:16;;;34550:23;34627:14;;;19246:37;34733:4;34722:16;;;34716:23;34793:14;;;19246:37;34897:4;34886:16;;;34880:23;34957:14;;;19246:37;35082:4;35071:16;;;35065:23;35142:14;;;19246:37;35252:4;35241:16;;;35235:23;35312:14;;;19246:37;35427:6;35416:18;;;35410:25;35489:16;;;19246:37;35626:6;35615:18;;;35609:25;35688:16;;;19246:37;35805:6;35794:18;;;35788:25;35867:16;;;19246:37;35984:6;35973:18;;;35967:25;36046:16;;;19246:37;;;;59588:3;59573:19;;59559:179::o;59745:405::-;19246:37;;;74131:42;74120:54;60136:2;60121:18;;14837:37;59932:2;59917:18;;59903:247::o;60157:524::-;19246:37;;;74131:42;74120:54;;;60576:2;60561:18;;14837:37;74120:54;60667:2;60652:18;;14837:37;60372:2;60357:18;;60343:338::o;60688:640::-;19246:37;;;74131:42;74120:54;;;61134:2;61119:18;;14837:37;74120:54;;61225:2;61210:18;;14837:37;74487:10;74476:22;61314:2;61299:18;;41397:36;60929:3;60914:19;;60900:428::o;61335:512::-;19246:37;;;74131:42;74120:54;;;;61748:2;61733:18;;14837:37;73710:13;73703:21;61833:2;61818:18;;18791:34;61544:2;61529:18;;61515:332::o;61854:764::-;19246:37;;;74131:42;74120:54;;;;62330:2;62315:18;;14837:37;62421:2;62406:18;;19246:37;;;;62512:2;62497:18;;19246:37;62603:3;62588:19;;19246:37;62125:3;62110:19;;62096:522::o;62625:860::-;;19276:5;19253:3;19246:37;62960:2;63110;63099:9;63095:18;63088:48;63150:126;62960:2;62949:9;62945:18;63262:6;63254;63150:126;:::i;:::-;63324:9;63318:4;63314:20;63309:2;63298:9;63294:18;63287:48;63349:126;63470:4;63461:6;63453;63349:126;:::i;:::-;63341:134;62931:554;-1:-1;;;;;;;;62931:554::o;63492:669::-;19246:37;;;63787:2;63937;63922:18;;;63915:48;;;63772:18;;;70028:19;;;63492:669;;63787:2;70068:14;;;;;17637:17;;;17628:27;;;;17765:21;63492:669;17792:467;17817:6;17814:1;17811:13;17792:467;;;17869:20;63776:9;17873:4;17869:20;;17864:3;17857:33;72733:3;72720:17;72777:50;72801:8;72785:14;72781:29;72777:50;72757:18;72753:75;72743:2;;-1:-1;;72832:12;72743:2;72861:33;;31683:6;73519:12;;;74581:4;73495:37;73519:12;72861:33;73495:37;:::i;:::-;74570:16;41874:3;41867:35;31944:49;31976:16;31969:5;31944:49;:::i;:::-;31924:69;;31999;63937:2;32057:3;32053:14;32039:12;31999:69;:::i;:::-;;32138:48;63787:2;32173:5;32169:16;32162:5;32138:48;:::i;:::-;32192:67;63787:2;32248:3;32244:14;32230:12;32192:67;:::i;:::-;;32335:61;70068:14;32383:5;32379:16;32372:5;32335:61;:::i;:::-;31683:6;70068:14;32420:3;32416:14;32409:38;32462:95;31683:6;31678:3;31674:16;32538:12;32524;32462:95;:::i;:::-;32454:103;;;;32695:4;32707:119;32695:4;32815:3;32811:14;32695:4;32688:5;32684:16;32707:119;:::i;:::-;;32946:6;32905:49;32946:6;32939:5;32935:18;32928:5;32905:49;:::i;:::-;32960:67;32946:6;33014:3;33010:16;32996:12;32960:67;:::i;:::-;;;33167:6;33112:63;33167:6;33160:5;33156:18;33149:5;33112:63;:::i;:::-;33223:3;33217:4;33213:14;33167:6;33199:3;33195:16;33188:40;33243:95;33333:4;33319:12;33305;33243:95;:::i;:::-;33235:103;;;;;33483:6;33428:63;33483:6;33476:5;33472:18;33465:5;33428:63;:::i;:::-;33394:97;;33539:3;33533:4;33529:14;33483:6;33515:3;33511:16;33504:40;33559:95;33649:4;33635:12;33621;33559:95;:::i;:::-;18238:14;;;;17992:128;-1:-1;;;69741:14;;;;-1:-1;;17839:1;17832:9;17792:467;;;-1:-1;63969:182;;63758:403;-1:-1;;;;;;;;;;63758:403::o;64168:527::-;19246:37;;;64415:4;64400:20;;3189;;3214:32;3189:20;3214:32;:::i;:::-;74487:10;41426:5;74476:22;64681:2;64670:9;64666:18;41397:36;;71462:12;29389:16;71462:12;74131:42;71436:39;71462:12;64681:2;29389:16;73395:12;71436:39;:::i;:::-;74120:54;71462:12;64670:9;29656:14;14837:37;2925:6;2912:20;29848:14;64670:9;29848:14;19246:37;;29848:14;29965:5;29961:16;2912:20;30040:14;64670:9;30040:14;19246:37;73395:12;30154:5;73395:12;73370:38;73395:12;30040:14;30154:5;30150:16;73370:38;:::i;:::-;30173:69;73395:12;64670:9;30227:14;30213:12;30173:69;:::i;:::-;;37862:131;37978:14;64670:9;37978:14;37964:12;37862:131;:::i;:::-;;38151:121;38257:14;64670:9;38257:14;38139:4;38132:5;38128:16;38151:121;:::i;:::-;38432:123;38538:16;64670:9;38538:16;38418:6;38411:5;38407:18;38432:123;:::i;64702:401::-;19246:37;;;74487:10;74476:22;65089:2;65074:18;;41397:36;64887:2;64872:18;;64858:245::o;65110:222::-;74259:64;74248:76;;;;40823:37;;65237:2;65222:18;;65208:124::o;65568:556::-;19246:37;;;65944:2;65929:18;;19246:37;;;;66027:2;66012:18;;19246:37;66110:2;66095:18;;19246:37;65779:3;65764:19;;65750:374::o;66131:218::-;74487:10;74476:22;;;;41397:36;;66256:2;66241:18;;66227:122::o;66356:2100::-;74487:10;74476:22;;41397:36;;67250:2;67235:18;;19246:37;;;74131:42;74120:54;;;67353:2;67338:18;;20554:73;74120:54;;;67459:2;67444:18;;14837:37;74120:54;;;67565:3;67550:19;;14837:37;74120:54;;67674:3;67659:19;;14837:37;67087:3;67072:19;;67690:133;67818:3;67803:19;;67794:6;67690:133;:::i;:::-;19276:5;67902:3;67891:9;67887:19;19246:37;19276:5;67986:3;67975:9;67971:19;19246:37;19276:5;68070:3;68059:9;68055:19;19246:37;68086:72;68153:3;68142:9;68138:19;68128:7;68086:72;:::i;:::-;68169:140;68304:3;68293:9;68289:19;68279:7;68169:140;:::i;:::-;68320:126;68441:3;68430:9;68426:19;68416:7;68320:126;:::i;:::-;67058:1398;;;;;;;;;;;;;;;;:::o;68463:648::-;74487:10;74476:22;;;41397:36;;74039:6;74028:18;;;68853:2;68838:18;;40472:36;74028:18;;;68934:2;68919:18;;40472:36;74476:22;;69015:2;69000:18;;41397:36;74028:18;;69096:3;69081:19;;40472:36;68692:3;68677:19;;68663:448::o;71725:113::-;;1537:6;1524:20;1549:30;1573:5;1549:30;:::i;71847:501::-;;;71971:3;71958:17;72015:48;72039:8;72023:14;72019:29;72015:48;71995:18;71991:73;71981:2;;-1:-1;;72068:12;71981:2;72097:33;;72054:4;72186:16;;;-1:-1;72152:19;;-1:-1;72222:18;72211:30;;72208:2;;;72254:1;;72244:12;72208:2;72301:17;72023:14;72281:38;72271:8;72267:53;72264:2;;;72333:1;;72323:12;72915:117;;2511:6;2498:20;74039:6;77209:5;74028:18;77185:5;77182:34;77172:2;;-1:-1;;77220:12;73423:115;;73495:37;73528:2;73523:3;73519:12;73514:3;73495:37;:::i;76377:268::-;76442:1;76449:101;76463:6;76460:1;76457:13;76449:101;;;76530:11;;;76524:18;76511:11;;;76504:39;76485:2;76478:10;76449:101;;;76565:6;76562:1;76559:13;76556:2;;;-1:-1;;76442:1;76612:16;;76605:27;76426:219::o;76758:117::-;74131:42;76845:5;74120:54;76820:5;76817:35;76807:2;;76866:1;;76856:12;76807:2;76801:74;:::o;76882:111::-;76963:5;73710:13;73703:21;76941:5;76938:32;76928:2;;76984:1;;76974:12;77246:117;74259:64;77333:5;74248:76;77308:5;77305:35;77295:2;;77354:1;;77344:12;77494:115;74487:10;77579:5;74476:22;77555:5;77552:34;77542:2;;77600:1;;77590:12

Swarm Source

ipfs://ef2ae624677c8106d2ff439b7093d388a10413c0c426ed7a90b110b3e3154abb

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.